Effacer les filtres
Effacer les filtres

Unable to perform assignment because the left and right sides have a different number of elements.

1 vue (au cours des 30 derniers jours)
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 commentaires
VBBV
VBBV le 19 Oct 2020
Modifié(e) : VBBV le 19 Oct 2020
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 le 19 Oct 2020
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Argument Definitions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by