Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Math Resources > Mathematics Software Discussion
Reply
 
Thread Tools Display Modes
  #1  
Old July 6th, 2009, 01:25 AM
Newbie
 
Join Date: Jul 2009
Location: malaysia
Posts: 3
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
anizatie is on a distinguished road
Send a message via Yahoo to anizatie
Default i don't know where is it wrong

plz help me, im newbie in matlab.. ive tried so many ways to make sure it is correct but then still cannot work out..

i hv to do some iteration, and plot as well (save the answer in other place since the answer quite long)

function a = lukis(a0,s,n)


lamda = 1.0*(10e-6);
m = 2;
a(1) = a0;

for i = 1:n
a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m

if(a(i+1)>1)
break;
end
end
plot(a(i+1))

hold on

save('lukis', 'a(i+1)')

to run in c/w : lukis(1.0*10e-10,0.5,1000)

thanks.
Reply With Quote
Advertisement
 
  #2  
Old July 6th, 2009, 01:45 AM
CaptainBlack's Avatar
Grand Panjandrum
 
Join Date: Nov 2005
Location: South of England
Posts: 11,379
Country:
Thanks: 667
Thanked 3,619 Times in 2,916 Posts
CaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond repute
Default

Quote:
Originally Posted by anizatie View Post
plz help me, im newbie in matlab.. ive tried so many ways to make sure it is correct but then still cannot work out..

i hv to do some iteration, and plot as well (save the answer in other place since the answer quite long)

function a = lukis(a0,s,n)


lamda = 1.0*(10e-6);
m = 2;
a(1) = a0;

for i = 1:n
a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m

if(a(i+1)>1)
break;
end
end
plot(a(i+1))

hold on

save('lukis', 'a(i+1)')

to run in c/w : lukis(1.0*10e-10,0.5,1000)

thanks.
Code:
function a = lukis(a0,s,n)
 
lamda = 1.0*(10e-6);
m = 2;
a=zeros(1,n);
a(1) = a0;
 
for i = 1:n-1
  a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m
 
  if(a(i+1)>1)
    break;
  end
end
 
plot(a(i+1))
 
hold on
 
save('lukis', 'a')
CB
Reply With Quote
  #3  
Old July 6th, 2009, 02:03 AM
Newbie
 
Join Date: Jul 2009
Location: malaysia
Posts: 3
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
anizatie is on a distinguished road
Send a message via Yahoo to anizatie
Default

Quote:
Originally Posted by CaptainBlack View Post
Code:
function a = lukis(a0,s,n)
 
lamda = 1.0*(10e-6);
m = 2;
a=zeros(1,n);
a(1) = a0;
 
for i = 1:n-1
  a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m
 
  if(a(i+1)>1)
    break;
  end
end
 
plot(a(i+1))
 
hold on
 
save('lukis', 'a')
CB

thanks for your reply. its helping me a lot but when the value of a(i+1)>1, the operation still go on, the iterations should stop when a(i+1) reach 1.

by looking at the program, it seem notin wrong there.. hope u can help me.. thanks.
Reply With Quote
  #4  
Old July 8th, 2009, 12:34 AM
Newbie
 
Join Date: Jul 2009
Location: malaysia
Posts: 3
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
anizatie is on a distinguished road
Send a message via Yahoo to anizatie
Default

i have found another way to solve this problem... thank you.
Reply With Quote
Reply

Tags
matlab problem

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 01:54 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.