Error Message during execution

3 次查看(过去 30 天)
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by