Operator '*' is not supported for operands of type 'struct'.

14 次查看(过去 30 天)
I want execute my Phasorcode by calling values of my PV and DG set SImulation. Hence I have logged data and saved it as .mat file. In following code you can observe code load that file (let me also know if this is the correct way of using values through .mat file)
% %This program is for samples from ATP simulation
clear all;
f0=50; % System freq=50,
T0=.02; % Time period=0.02 sec=20 msec
ts=2E-5; % ATP time step= 2E-5, so 1000 samples per cycle
N=round(T0/ts); % samples per cycle.
%% Take current and voltage samples by .mat files from both ends of the line
If=load('out.mat');
Vf=load('out.mat');
Ir=load('out.mat');
Vr=load('out.mat');
Nt = length(If);
Ical =[If Ir Vf Vr]; %signal without noise
jj=1;
for jj=1:4
Ifor1c(jj,1)=(2/N)*Ical(1,jj);
Ifor1s(jj,1)=0;
Ifor1m(jj,1)=(2/N)*abs(Ical(1,jj));
end
jj=1;
for jj=1:4
for t= 2:Nt
if(t<=N)
Ifor1c(jj,t) =Ifor1c(jj,t-1)+(2/N)*Ical(t,jj)*cos((t-1)*2*pi/(N));
Ifor1s(jj,t)= Ifor1s(jj,t-1)+(2/N)*Ical(t,jj)*sin((t-1)*2*pi/(N));
else
Ifor1c(jj,t)=Ifor1c(jj,t-1)+(2/N)*(Ical(t,jj)-Ical(t-N,jj))*cos((t-(N+1))*2*pi/(N));
Ifor1s(jj,t)=Ifor1s(jj,t-1)+(2/N)*(Ical(t,jj)-Ical(t-N,jj))*sin((t-(N+1))*2*pi/(N));
end
%% magnitude and angle calculation at each sample
Ifor1m(jj,t)= sqrt(Ifor1c(jj,t)^2+Ifor1s(jj,t)^2);
phi_Ifor1(jj,t)= atan2(-Ifor1c(jj,t),Ifor1s(jj,t));
end
end
%% complex phasor at each sample
I_s = Ifor1c(1,:)-j*Ifor1s(1,:);
I_r=Ifor1c(2,:)-j*Ifor1s(2,:);
V_fa=Ifor1c(3,:)-j*Ifor1s(3,:);
V_ra=Ifor1c(4,:)-j*Ifor1s(4,:);
In 24th line- Ifor1c(jj,1)=(2/N)*Ical(1,jj);- it shows error Operator '*' is not supported for operands of type 'struct'.

回答(1 个)

Rik
Rik 2021-6-1
You are using an output for the load function (which you should), but that means Matlab will load the data to a struct. I'm guessing you mean this instead:
S=load('out.mat');
[If,Vf,Ir,Vr]=deal(S.If,S.Vf,S.Ir,S.Vr);

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by