Author Topic: My m file does not print graph [ Solved ]  (Read 1389 times)

0 Members and 1 Guest are viewing this topic.

Offline abrarbaigTopic starter

  • Contributor
  • Posts: 30
  • Country: sa
My m file does not print graph [ Solved ]
« on: March 03, 2018, 04:49:57 pm »
Hello. I am having errors when I run this m file. I get the following this error:Error using plot Vectors must be the same length. I get empty graph
Error in ini (line 67)
plot(tab_lambda,Ct,'linewidth',1.5)

Code: [Select]
% DFIG Parameters Rotor parameters reffered to the stator side
f = 50;                        %Stator frequency(Hz)
Ps = 2e6;                      % Rated stator power(W)
n = 1500;                      %Rated rotational speed (Rev/Min)
Vs = 690;                       % Rated stator voltage(V)
Is = 1740;                      % rated stator current (A)
Tem = 12732;                    %Rated torqu (N.m)
p = 2;                          % Pole pair
u = 1/3;                        %stator/rotor turns ratio
Vr = 2070;                      %Rated rotor voltage reffered to stator
max = 1/3;                      % Maximum slip
Vr_stator = (Vr*max)*u;         % Rated rotor voltage referred to stator
Rs = 2.4e-3;                    % Stator resistance (ohm)
Lsi = 0.067e-3;                 %Leakage inductance(rotor & stator)
Lm = 2.5e-3;                    %Magnetic Induction
Rr = 2.9e-3;                    % rotor resistance (ohm)
Ls = Lm + Lsi;                  % Stator inductance
Lr = Lm + Lsi;                  %Rotor inductance
Vbus = Vr_stator*sqrt(2);       %Dc dc bus voltage referred to stator
sigma = 1 - Lm^2/(Ls*Lr);
Fs = Vs*sqrt(2/3)/(2*pi*f);     % stator flux (approx)
J = 127/2;                        % inertia
D = 1e-3;                       %damping
fsw = 4e3;                      % swtitching frequency
Ts = 1/fsw/50;                  % sample time (sec)
% PI regulators
tau_i =(sigma*Lr)/Rr;
tau_n = 0.05;
wmi = 100*(1/tau_i);
wmn = 1/tau_n;
kp_id =(2*wmi*sigma*Lr)-Rr;
kp_iq = kp_id;
ki_id = (wmi^2)*Lr*sigma;
ki_iq = ki_id;
kp_n = (2*wmn*J)/p;
ki_n = (wmn^2*J)/p;
% three blades wind turbine model
N = 100; % gera box ratio
Radio = 42; % Radio
ro = 1.225; % Air density

% Cp and Ct curves
beta = 0;   % pitch angle
ind2 = 2;
for lambda = (0.1:0.01:11.8)
    lambdai(ind2)=(1./((1./(lambda - 0.02.*beta)+(0.003./(beta^3+1)))));
    Cp(ind2) = 0.73.*(151./lambdai(ind2) - 0.58.*beta - 0.002.*beta^2.14 - 13.2).*(exp(-18.4./lambdai(ind2)));
    Ct(ind2)=Cp(ind2)/lambda;
    ind2 =ind2 + 1;
end
tab_lambda = (0.1:0.01:11.8);
%kopt for MPPT
Cp_max = 0.44;
lambda_opt = 7.2;
Kopt = ((0.5*ro*pi*(Radio^5)*Cp_max)/(lambda_opt^3));

% Power curve in function of wind speed
P = 1.0e6 *[0,0,0,0,0,0,0,0.0472,0.1097,0.1815,0.2568,0.3418,...
    0.4437,0.5642,0.7046,0.8667,1.0518,1.2616,1.4976,1.7613,2.0534,...
    2.3513,2.4024,2.4024,2.4024,2.4024,2.4024,2.4024];
V = [0.0000,0.5556,1.1111,1.6667,2.2222,2.7778,3.3333,3.8889,4.4444,...
    5.0000,5.5556,6.1111,6.6667,7.2222,7.7778,8.3333,8.8889,9.4444,...
    10.0000,10.5556,11.1111,11.6667,12.2222,12.7778,13.3333,13.8889,...
    14.4444,15.0000];
figure
subplot(1,2,1)
plot(tab_lambda,Ct,'linewidth',1.5)
xlabel('lambda','fontsize',14)
ylabel('Ct','fontsize',14)
subplot(1,2,2)
plot(V,P,'linewidth',1.5)
grid
xlabel('Wind Speed (m/s)','fontsize',14)
ylabel('Power (W)','fontsize',14)
« Last Edit: March 04, 2018, 10:55:05 am by abrarbaig »
 

Offline jmsigler

  • Regular Contributor
  • *
  • Posts: 57
  • Country: us
Re: My m file does not print graph
« Reply #1 on: March 03, 2018, 05:04:40 pm »
You start ind2 at 2 and it makes your Ct array 1 longer than tab_lambada. Either start Ind2 at 1 if that is possible, or add an extra .01 to your tab_lambada vector to make it 1 longer.
 
The following users thanked this post: abrarbaig

Offline Neganur

  • Supporter
  • ****
  • Posts: 1138
  • Country: fi
Re: My m file does not print graph
« Reply #2 on: March 03, 2018, 05:12:27 pm »
>> size(Ct)
ans =
           1        1172

>> size(tab_lambda)
ans =
           1        1171


There's your problem
 

Offline abrarbaigTopic starter

  • Contributor
  • Posts: 30
  • Country: sa
Re: My m file does not print graph
« Reply #3 on: March 03, 2018, 05:25:00 pm »
Yes I have realized. Can you tell me where in the formula I am making  mistake?
 

Offline abraxa

  • Frequent Contributor
  • **
  • Posts: 377
  • Country: de
  • Sigrok associate
Re: My m file does not print graph
« Reply #4 on: March 03, 2018, 05:34:07 pm »
Yes I have realized. Can you tell me where in the formula I am making  mistake?

Am I assuming correctly that this is some kind of engineering coursework that you have neither written nor understood and you want us to fix it for you so that you can submit the coursework and get the points for it?
 

Offline m_t

  • Contributor
  • Posts: 11
  • Country: de
    • GitHub
Re: My m file does not print graph
« Reply #5 on: March 03, 2018, 05:34:22 pm »
Yes I have realized. Can you tell me where in the formula I am making  mistake?

Change line 44 to
Code: [Select]
ind2 = 1;
 

Offline abrarbaigTopic starter

  • Contributor
  • Posts: 30
  • Country: sa
Re: My m file does not print graph
« Reply #6 on: March 03, 2018, 05:56:04 pm »
You are correct. It is model of a Wind Turbine.
 

Offline abrarbaigTopic starter

  • Contributor
  • Posts: 30
  • Country: sa
Re: My m file does not print graph
« Reply #7 on: March 03, 2018, 06:03:22 pm »
Thanks. It is fixed now. I have changed line 67 to be:
plot(lambdai,Ct,'linewidth',1.5)
Now both plots are printed.
 

Offline Neganur

  • Supporter
  • ****
  • Posts: 1138
  • Country: fi
Re: My m file does not print graph
« Reply #8 on: March 03, 2018, 06:22:39 pm »
I don't think that is correct. "lambdai" is just an index used in the calculation. lambda still needs to get plotted over its range from 0.1 to 11.8 not 1 to 1172
your x-axis will be wrong in the lambda-plot

Edit:
I meant, check if your intention is to plot Ct(lambdai) or Ct(tab_lambda)  those two lambda arrays are not the same

« Last Edit: March 03, 2018, 06:30:50 pm by Neganur »
 

Offline abrarbaigTopic starter

  • Contributor
  • Posts: 30
  • Country: sa
Re: My m file does not print graph
« Reply #9 on: March 03, 2018, 06:28:04 pm »
Lambda range is in fact from 0.1 o 11.8 1172 are the iterations.
 

Offline Neganur

  • Supporter
  • ****
  • Posts: 1138
  • Country: fi
Re: My m file does not print graph
« Reply #10 on: March 03, 2018, 06:32:58 pm »
I meant, check if your intention is to plot Ct(lambdai) or Ct(tab_lambda)  those two lambda arrays are not the same
 attached screenshot of array content
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf