필터 지우기
필터 지우기

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
VBBV
VBBV 2020년 10월 19일
편집: VBBV 2020년 10월 19일
Without declaring dt , how did the program complete for loop. ?
i dont get any errors in command window after initalizing dt. see the figure attached
KSSV
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 CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by