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
Click For Summary
SUMMARY

The forum discussion addresses a MATLAB coding error encountered while calculating the Tip Speed Ratio (TSR) for a vertical axis wind turbine (VAWT). The error message indicates an attempt to access a non-integer index in the TSR matrix due to the loop increment of j by 0.1. The variables involved include wR (angular speed set to 5), v (air velocity in m/s), and a (blade path angle set to 90 degrees). The solution involves ensuring that the indices used for the TSR matrix are positive integers, as MATLAB requires.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Knowledge of vertical axis wind turbine (VAWT) mechanics
  • Familiarity with the concept of Tip Speed Ratio (TSR)
  • Basic understanding of matrix indexing in MATLAB
NEXT STEPS
  • Review MATLAB matrix indexing rules to avoid non-integer access errors
  • Learn how to define and initialize matrices in MATLAB
  • Explore MATLAB's for-loop structure and its implications on indexing
  • Investigate the calculation of Tip Speed Ratio in wind turbine design
USEFUL FOR

Engineers, MATLAB programmers, and researchers involved in wind turbine design and performance analysis will benefit from this discussion.

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 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 41 ·
2
Replies
41
Views
10K
  • · Replies 1 ·
Replies
1
Views
4K