Unable to perform assignment because the left and right sides have a different number of elements.
1 次查看(过去 30 天)
显示 更早的评论
I`m new in this, but im trying to solve a problem with euler`s method and appears this as an error.
C= 100;
D= 0.1;
b= 0.15;
m= 0.05;
g= 9.81;
vo=0;
yo=0;
% Euler's Method
% Initial conditions and setup
h = 0.001; % step size
x = 0.001:h:5; % the range of x
y = zeros(size(x)); % allocate the result y
y(1) = 0; % the initial y value
n = numel(y); % the number of y values
% The loop to solve the DE
for i=1:n-1
f = C*(dt/m)*(D-yo)-(g*dt)+(vo*(1-(b*dt)/m))
y(i+1) = y(i) + h * f;
end
plot(x,y); grid on
COMMAND WINDOW
Unable to perform assignment because the left and right sides have a different number of elements.
Error in EulerMethod (line 20)
y(i+1) = y(i) + h * f;
2 个评论
KSSV
2020-10-19
Show us the wholde code....you will not get such error, when you run the give code.....
You have to define dt.....once you define dt..code runs smooth.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Argument Definitions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!