Jump to content

Matlab Help, URGENT


kerja

Recommended Posts

In the exam at the moment ?!? The forum rules say something like "we do not do your homework for you". While not strictly speaking, in the sense of that message that naturally means "we will not help you cheat in an exam".

Link to comment
Share on other sites

well, I've just stuck on the question.

I've done something like that:

 

clear all




dt= 0.01;                      
t_max=10;                      

i_max=ceil(t_max/dt)+1;       

y=zeros(1,i_max);           
x=zeros(1,i_max);           

y(1)= 0;                     
x(1)= 1;                    

k=0;

t=[0.0:dt:(i_max-1)*dt];    


for i=1:i_max-1              

  k1=-x(i)^2+20;
  l1=y(i);

  k2=-x(i)^2+dt*l1/2-k+20;
  l2=y(i)+dt*k1/2;

  k3=-x(i)^2+dt*l2/2-k+20;
  l3=y(i)+dt*k2/2;

  k4=-x(i)^2+dt*l3-k+20;
  l4=y(i)+dt*k3;

  y(i+1)=y(i)+(dt/6)*(k1+2*k2+2*k3+k4); 
  x(i+1)=x(i)+(dt/6)*(l1+2*l2+2*l3+l4); 

end
figure(2)
plot(t,x,'b','LineWidth',1),xlabel('t / s'),ylabel('x / m') 


but think that's wrong

 

btw, the exam is opensource based.

Link to comment
Share on other sites

btw, the exam is opensource based.

 

I doubt that means asking others to answer for you.

 

In any case, now that the exam is over - we are not in the habit of answering homework (or EXAM!) questions for you. If you want homework assistance, there's a special sub-forum for that purpose, where we can review your attempts and help you understand the subject.

 

Good luck.

 

~moo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.