Filter löschen
Filter löschen

Why do i get the error: Array indices must be positive integers or logical values?

1 Ansicht (letzte 30 Tage)
Hi, ive been trying to plot 3 sets of data on the same graph plot and i keep getting this error message :Array indices must be positive integers or logical values in my for loop
  1 Kommentar
Stephen23
Stephen23 am 10 Dez. 2021
Bearbeitet: Stephen23 am 10 Dez. 2021
Original question by Sebastion Sunny retrieved from Google Cache:
Why do i get the error: Array indices must be positive integers or logical values?
Hi, ive been trying to plot 3 sets of data on the same graph plot and i keep getting this error message :Array indices must be positive integers or logical values in my for loop
WindSpeeds = linspace(0,30,300);%m/s
deltaT = 0.01;
time = 0:deltaT:300;
%preallocation
rotorTorque = zeros(length(WindSpeeds),1); %Nm
turbinePower = zeros(length(WindSpeeds),1);
generatorTorque = zeros(length(WindSpeeds),1);
omegaRotor = zeros(length(WindSpeeds),1);
%eulers method
for i = 2:length(time)
omegaRotor(i) = omegaRotor(i-1) + deltaT((windTurbineRotorModel(WindSpeeds,Ct,D,Vcutout,Vrated,Vcutin))-(k*omegaRotor(i-1).^2)/j);
end
this is the code ive written at the moment
Thank you

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Voss
Voss am 5 Dez. 2021
This expression in the loop:
deltaT((windTurbineRotorModel(WindSpeeds,Ct,D,Vcutout,Vrated,Vcutin))-(k*omegaRotor(i-1).^2)/j)
says to get the elements of deltaT with index (or indices) equal to the value of:
(windTurbineRotorModel(WindSpeeds,Ct,D,Vcutout,Vrated,Vcutin))-(k*omegaRotor(i-1).^2)/j
I don't know what the value of that expression is because most of those variables are undefined, but given that deltaT is a scalar variable, I would guess that indexing it like that is not what you mean to be doing.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by