MATLAB Fixing MATLAB Loop Error in TSR Calculation for VAWT

AI Thread Summary
The MATLAB code aims to calculate the Tip Speed Ratio (TSR) of a vertical axis wind turbine at varying blade path angles and wind speeds. The user encounters an error indicating that they are trying to access an index in the TSR array using a non-integer value. The issue arises because the loop for 'j' increments by 0.1, leading to non-integer indices like 1.1. To resolve this, 'j' should be defined to iterate over integer values, or the TSR array should be appropriately sized to accommodate the intended indexing. Additionally, there is a suggestion that 'j' is not utilized in the calculations, which may indicate a need to revise the logic of the code to ensure it functions as intended.
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.
 

Similar threads

Replies
4
Views
1K
Replies
4
Views
2K
Replies
6
Views
5K
Replies
1
Views
8K
Replies
6
Views
4K
Replies
12
Views
4K
Replies
4
Views
7K
Back
Top