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

1 回表示 (過去 30 日間)
Sebastian Sunny
Sebastian Sunny 2021 年 12 月 5 日
編集済み: Stephen23 2021 年 12 月 10 日
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 件のコメント
Stephen23
Stephen23 2021 年 12 月 10 日
編集済み: Stephen23 2021 年 12 月 10 日
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

サインインしてコメントする。

採用された回答

Voss
Voss 2021 年 12 月 5 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by