Error: "Dot indexing is not supported for variables of this type.'' Class structure.

2 次查看(过去 30 天)
Hello everyone! I´m coding a program to design a turbine from several input data. I use a class variable for this purpose. One of the properties ("trapecio") is another class variable. When I run the code it shows me an error saying "Dot indexing is not supported for variables of this type".
One day the code runned perfectly, but the following day it did not.
Any help will be apreciated, thanks in advance!
Here it´s the code:
classdef diseno
properties
m=0
n=0
T0_e=0
p0_e=0
h0_e=0
s0_e=0
p_s=0
wi=0;
P_int=0
P_ef=0
eta_tt=0
eta_te=0
T_s=0
T_ss=0
h_ss=0
h_s=0
s_s=0
c_s=0
Cp=0
gamma=0
trapecio=trapecio(0,0,0,0,0,0)
bidimensional=false
supersonico=false
end
methods
function d=diseno(m,T0_e,p0_e,p_s,n,PSI,PHI,GR,Cp,gamma,i_r,i_e)
if(m>0 && T0_e>0 && p0_e>0 && p_s>0 && n>0 && PSI>0 && PHI>0)
d.m=m;
d.n=n;
d.T0_e=T0_e;
d.p0_e=p0_e;
d.h0_e=Cp*T0_e;
d.s0_e=Cp*log(T0_e);
d.p_s=p_s;
d.Cp=Cp;
d.gamma=gamma;
eta_te_prime=0; d.eta_te=0.7; iteracion_eta=0;
d.wi=d.eta_te*d.Cp*d.T0_e*(1-(d.p_s/d.p0_e)^((d.gamma-1)/d.gamma));
while(abs(eta_te_prime-d.eta_te)>0.00001 && iteracion_eta<100)
eta_te_prime=d.eta_te;
d.trapecio=trapecio(d,PSI,PHI,GR,i_r,i_e);
d.eta_te=d.wi/(d.wi+d.trapecio.zeta_e*d.trapecio.c1^2/2+d.trapecio.zeta_r*d.trapecio.w2^2/2+d.trapecio.c2^2/2+d.trapecio.Y_4r);
iteracion_eta=iteracion_eta+1;
end
d.wi=d.eta_te*d.Cp*d.T0_e*(1-(d.p_s/d.p0_e)^((d.gamma-1)/gamma));
d.trapecio=trapecio(PSI,PHI,GR,d,i_r,i_e);
d.eta_te=d.wi/(d.wi+d.trapecio.zeta_e*d.trapecio.c1^2/2+d.trapecio.zeta_r*d.trapecio.w2^2/2+d.trapecio.c2^2/2);
d.eta_tt=d.wi/(d.wi+d.trapecio.zeta_e*d.trapecio.c1^2/2+d.trapecio.zeta_r*d.trapecio.w2^2/2);
d.P_int=d.m*d.wi;
d.P_ef=d.P_int*0.95;
end
end
end
end
classdef trapecio
properties % Se va a suponer H/l(e)=1.5 y H/l(r)=1
c1=0
w1=0
c2=0
w2=0
ca=0
u=0
delta_cu=0
cu1=0
cu2=0
wu1=0
wu2=0
a1=0
a2=0
b1=0
b2=0
a1_prime=0
a2_prime=0
b1_prime=0
b2_prime=0
i_e=0
i_r=0
am=0
bm=0
epsilon_e=0
epsilon_r=0
delta_e=0
delta_r=0
calado_e=0
calado_r=0
sigma_e=0
sigma_r=0
theta_e=0
theta_r=0
Dm=0
H0=0
H1=0
H2=0
l_e=0
l_r=0
ze=0
zr=0
zeta_e=0
zeta_r=0
Y_e=0
Y_r=0
Y_4r=0
end
methods
function t=trapecio(d,PSI,PHI,GR,i_r,i_e)
t.u=sqrt(d.wi/PSI);
t.ca=t.u*PHI;
t.delta_cu=t.u*PSI;
t.a2=atan((1-GR)/PHI+0.5*PSI/PHI);
t.a1=atan((1-GR)/PHI-0.5*PSI/PHI);
t.b2=atan(GR/PHI+0.5*PSI/PHI);
t.b1=atan(GR/PHI-0.5*PSI/PHI);
t.c1=t.ca/cos(t.a1);
t.c2=t.ca/cos(t.a2);
t.w1=t.ca/cos(t.b1);
t.w2=t.ca/cos(t.b2);
t.cu2=t.c2*sin(t.a2);
t.cu1=t.c1*sin(t.a1);
t.wu2=t.w2*sin(t.b2);
t.wu1=t.w1*sin(t.b1);
t.i_e=i_e;
t.i_r=i_r;
t.a2_prime=t.a2-t.i_e*pi/180;
t.b1_prime=t.b1-t.i_r*pi/180;
t.am=abs(atan((tan(t.a1)-tan(t.a2))/2));
t.bm=abs(atan((tan(t.b1)-tan(t.b2))/2));
t.epsilon_e=abs(t.a1+t.a2);
t.epsilon_r=abs(t.b1+t.b2);
%Regla de Carter y Criterio de Zweifel
t.delta_e=0; t.delta_r=0; error_E=1; error_R=1; iteracion_delta=0;
while((error_E>0.00001 || error_R>0.00001) && iteracion_delta<100)
delta_E_prime=t.delta_e;
delta_R_prime=t.delta_r;
t.a1_prime=t.a1+delta_E_prime;
t.b2_prime=t.b2+delta_R_prime;
t.calado_e=abs(t.a1_prime-t.a2_prime)/2;
t.calado_r=abs(t.b1_prime-t.b2_prime)/2;
t.sigma_e=2*(cos(t.a1)^2)*(tan(t.a1)+tan(t.a2))/(0.8*cos(t.calado_e));
t.sigma_r=2*(cos(t.b2)^2)*(tan(t.b2)+tan(t.b1))/(0.8*cos(t.calado_r));
t.theta_e=t.a2_prime+t.a1_prime;
t.theta_r=t.b2_prime+t.b1_prime;
t.delta_e=0.19*t.theta_e/t.sigma_e;
t.delta_r=0.19*t.theta_r/t.sigma_r;
error_E=abs(t.delta_e-delta_E_prime);
error_R=abs(t.delta_r-delta_R_prime);
iteracion_delta=iteracion_delta+1;
end
t.Dm=t.u/(pi*d.n/60);
T0=d.T0_e-t.c2^2/(2*d.Cp);
P0=d.p0_e*(T0/d.T0_e)^(d.gamma/(d.gamma-1));
rho0=P0/(287*T0);
t.H0=d.m/(pi*t.Dm*t.ca*rho0);
T1=d.T0_e-t.c1^2/(2*d.Cp);
%-----------PÉRDIDAS ESTATOR----------------
zeta_pe=0.025*(1+(t.epsilon_e*2/pi)^2);
zeta_se=zeta_pe*3.2*t.l_e*cos(t.calado_e)*2/(t.H0+t.H1);
t.zeta_e=zeta_se+zeta_pe;
t.Y_e=t.zeta_e*t.c1^2/2;
%---------------------
T1s=T1-t.Y_e/d.Cp;
P1=d.p0_e*(T1s/d.T0_e)^(d.gamma/(d.gamma-1));
rho1=P1/(287*T1);
t.H1=d.m/(pi*t.Dm*t.ca*rho1);
t.l_e=(t.H0+t.H1)/3;
t.ze=(pi*t.Dm)/(t.l_e/t.sigma_e);
T2=d.T0_e-t.c2^2/2-d.eta_te*d.T0_e*(1-(d.p_s/d.p0_e)^((d.gamma-1)/d.gamma));
rho2=d.p_s/(287*T2);
t.H2=d.m/(pi*t.Dm*t.ca*rho2);
t.l_r=(t.H2+t.H1)/3;
t.zr=(pi*t.Dm)/(t.l_r/t.sigma_r);
%----------PÉRDIDAS ROTOR---------------------
zeta_pr=0.025*(1+(t.epsilon_r*2/pi)^2);
zeta_sr=zeta_pr*3.2*t.l_r*cos(t.calado_e)*2/(t.H2+t.H1);
zeta_ir=0.5*0.5e-3*2/(t.H2+t.H1)*(2*(tan(t.b2)-tan(t.b1))/t.sigma_r)^2*cos(t.b2)^2/cos(t.bm)^3;
t.zeta_r=zeta_pr+zeta_sr+zeta_ir;
t.Y_r=t.zeta_r*t.w2^2/2;
t.Y_4r=0.0095*rho1*(d.n*2*pi/60)^3*t.Dm^5/d.m;
end
end
end

回答(1 个)

Satwik
Satwik 2023-7-17
编辑:Satwik 2023-7-17
Hi Daniel,
I understand that you have made a class diseno with multiple properties including another class trapecio but when you execute the main class diseno it gives out an error.
This behaviour is happening because in the trapecio constructor
t.u=sqrt(d.wi/PSI); % first line of trapecio constructor
you are trying to access a property wi inside input argument d using dot notation, but inside diseno when you are invoking trapecio in the properties block you are just passing 0 in place of d as an input argument.
trapecio=trapecio(0,0,0,0,0,0) % in the properties block of class diseno
which does not have a 'wi' property to be accessed, that is where the code is throwing an error.
There are many instances in your code where you are accessing some properties of d.
To fix this pass an object in place of d with all the required properties when invoking a trapecio object.
After making the changes make sure to run
clear classes
to update the classes and then execute your code.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Analog Devices ADALM1000 Support from Data Acquisition Toolbox 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by