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!