Input Function of (x,y) For Loop Error
Show older comments
i'm trying to input function of x,y
dy = input ('dy/dx = ','s');
dy = @(x,y) dy;
and also try
dy = input ('dy/dx = ','s');
dy = inline(dy);
then make a for loop to calculate y(2) based on the value of y(1) and dy(1) ===> which a function x,y
for o = 1 : 1 : n
y(o+1) = y(o) + delx * dy(x(o),y(o));
dy(o+1) = feval(dy,x,y);
end
here I want to use the just calculated y(2) to calculate the value of dy(2) and when run that code give me that error
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in Final (line 500)
y(o+1) = y(o) + delx * dy(x(o),y(o));
===================================================
update:
thank you (@Walter Roberson)
this help in convert the string to function
still there that error
Not enough input arguments.
when enter the for loop
for o = 1 : 1 : n
y(o+1) = y(o) + delx * dy(x(o),y(o));
dy(x(o+1),y(o+1)) = feval(dy(o),x(o),y(o));
end
and when made it
for o = 1 : 1 : n
y(o+1) = y(o) + delx * dy(x(o),y(o));
dy(o+1) = feval(dy,x,y);
end
the error is
Matrix dimensions must agree.
Error in Final>@(x,y)x-y
Error in Final (line 500)
dy(o+1) = feval(dy,x,y);
Accepted Answer
More Answers (0)
Categories
Find more on Function Creation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!