Yesterday Matlab tutorial classes began. We learned the basics of solving differential equations and integral functions. Solving differential and integral function with matlab quite difficult at the very beginning but I try it independently.
Some .m files which are written by me. Do not evaluate me‼‼‼ this is only a beginning……..
x = 0:0.1:10;
y= length(x);
for I=1:y;
m(I)= [x(end-I)];
end
m;
Second Problem
Solving integral from 0 to 1 ,ydx where y=x
x = linspace(0,1,10);
h = 0.01;
a=0;
b=1;
n= (a-b)/h;
y(1)=1;
x(1)=0;
for I = 1:n;
x(I+1)= x(I)+h;
y(I+1)= y(I)+ h*x(I);
end
[x,y]
plot(x,y);
This .m file did not run, it gives a error message
Are there any MATLAB experts? Help me via comments
3 comments:
I'm not a matlab expert, but don't mind looking at your problem, if you still haven't solved it.
I think your code got corrupted when you posted it. Is it one file or two? Where does each file start / end, and what's with the "?
Thank you rt,
I make it correct.
There was only a small mistake..
It should be
n= (b-a)/h;
not
n= (a-b)/h;
When u use it as n= (a-b)/h; it will give minus value to n and loop will assign minus values to array index..Ask, if u have any more questions..
x = linspace(0,1,10);
h = 0.01;
a=0;
b=1;
n= (b-a)/h;
y(1)=1;
x(1)=0;
for I = 1:n;
x(I+1)= x(I)+h;
y(I+1)= y(I)+ h*x(I);
end
[x,y]
plot(x,y);
Post a Comment