My Code is;
Ave3ON = zeros(size(S));
Ave5ON = zeros(size(S));
Ave7ON = zeros(size(S));
AvethdON = zeros(size(S));
Ave3OFF = zeros(size(S));
Ave5OFF = zeros(size(S));
Ave7OFF = zeros(size(S));
AvethdOFF = zeros(size(S));
for i=1:length(S)
M3=([S(i).HV3]);
M5=([S(i).HV5]);
M7=([S(i).HV7]);
Mthd = ([S(i).thd]);
Ave3ON(i)=mean(M3(90000-S(i).date*1667:90000));
Ave5ON(i)=mean(M5(90000-S(i).date*1667:90000));
Ave7ON(i)=mean(M7(90000-S(i).date*1667:90000));
AvethdON(i)=mean(Mthd(90000-S(i).date*1667:90000));
Ave3OFF(i)=mean(M3(110000:110000+S(i).date*1667));
Ave5OFF(i)=mean(M5(110000:110000+S(i).date*1667));
Ave7OFF(i)=mean(M7(110000:110000+S(i).date*1667));
AvethdOFF(i)=mean(thd(110000:110000+S(i).date*1667));
end
Error Message is;
Error using computeperiodogram>validateinputs (line 196)
The input must be either a vector or two-dimensional matrix.
Error in computeperiodogram (line 61)
[x1,~,y,is2sig,win1] = validateinputs(x,win,nfft);
Error in periodogram (line 215)
[Sxx,w2,RSxx,wc] =
computeperiodogram(x,win,nfft,esttype,Fs,options);
Error in thd>timeTHD (line 126)
[Pxx, F] = periodogram(x,w,n,fs,'psd');
Error in thd (line 89)
[r, harmPow, harmFreq] = timeTHD(plotType, harmType,
varargin{:});
Error in Untitled2 (line 28)
AvethdOFF(i)=mean(thd(110000:110000+S(i).date*1667));
Struct S =
480×1 struct array with fields:
name
date
HV3
HV5
HV7
thd

 채택된 답변

Walter Roberson
Walter Roberson 2020년 10월 14일

0 개 추천

Ave3ON(i)=mean(M3(90000-S(i).date*1667:90000));
Ave5ON(i)=mean(M5(90000-S(i).date*1667:90000));
Ave7ON(i)=mean(M7(90000-S(i).date*1667:90000));
AvethdON(i)=mean(Mthd(90000-S(i).date*1667:90000));
Okay, parallel indices into 4 different arrays. Makes sense.
Ave3OFF(i)=mean(M3(110000:110000+S(i).date*1667));
Ave5OFF(i)=mean(M5(110000:110000+S(i).date*1667));
Ave7OFF(i)=mean(M7(110000:110000+S(i).date*1667));
Okay, parallel indices into 3 of the 4 different arrays from above. That's odd, I wonder why the 4th array isn't being used?
AvethdOFF(i)=mean(thd(110000:110000+S(i).date*1667))
The destination location parallels the block of 4 above, and the code structure parallels the three lines above it, but why have you suddenly switched from indexing an array named Mthd, to instead requesting the calculation of Total Harmonic Distortion (thd) ?

댓글 수: 1

FG
FG 2020년 10월 14일
Thank you Walter.. It wad just a mistyping and it's solved : )

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2020a

태그

질문:

FG
2020년 10월 14일

댓글:

FG
2020년 10월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by