Fixing MATLAB Loop Error in TSR Calculation for VAWT

  • Context: MATLAB 
  • Thread starter Thread starter Thusithatck
  • Start date Start date
  • Tags Tags
    Errors Loop Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
Thusithatck
Messages
11
Reaction score
0
I'm trying to write a MATLAB code but I get an error message which I'm not sure why. The code is follows as,

%%%%% Code %%%%%

for i = 1:1:v;
for j = 1:0.1:a

TSR(i,j)=wR/i;

end
end

%%%%% Code %%%%%

Here 'a' is taken as 90 degrees, which represents blade path of a vertical axis wind turbine and 'v' is taken as the velocity (m/s) of air and wR (omega) is taken as 5 which is the angular speed of the wind turbine. What I'm trying to estimate is the the Tip Speed Ratio of a vertical axis wind turbine at different blade path angle which corresponds to different speeds. The equation is given below which calculates the Tip Speed Ratio.

TSR = (wR/v) = [wind turbine angular speed / speed of wind]

The error message that I'm getting is given below.

? Attempted to access TSR(1.1,1); index must be a positive integer or logical.

Error in ==> Experiment at 57
TSR(i,j)=wR/i;


Could some one give any suggestions to correct my calculations.
 
Physics news on Phys.org
Thusithatck said:
I'm trying to write a MATLAB code but I get an error message which I'm not sure why. The code is follows as,

%%%%% Code %%%%%

for i = 1:1:v;
for j = 1:0.1:a

TSR(i,j)=wR/i;

end
end

%%%%% Code %%%%%

Here 'a' is taken as 90 degrees, which represents blade path of a vertical axis wind turbine and 'v' is taken as the velocity (m/s) of air and wR (omega) is taken as 5 which is the angular speed of the wind turbine. What I'm trying to estimate is the the Tip Speed Ratio of a vertical axis wind turbine at different blade path angle which corresponds to different speeds. The equation is given below which calculates the Tip Speed Ratio.

TSR = (wR/v) = [wind turbine angular speed / speed of wind]

The error message that I'm getting is given below.

? Attempted to access TSR(1.1,1); index must be a positive integer or logical.

Error in ==> Experiment at 57
TSR(i,j)=wR/i;


Could some one give any suggestions to correct my calculations.

I believe it's because you're attempting an index an array with a non-integer; by incrementing j in steps of 0.1, you're trying call out a 1.1'th element in TSR (i.e. the elements must be numbered 1, 2, 3, ...)
 
Is TSR a previously defined matrix? If you're trying to store elements, as it's already been stated you must use a positive integer.

It doesn't look like you are using j in your program.