0
我在經歷多個循環時遇到了上述錯誤。我真的不知道該怎麼解釋這個問題,但我會盡我所能Matlab:單元格內容分配給非單元陣列對象
代碼:
function this = tempaddfilt(this,varargin)
fc = linspace(1,200,(200/0.5));
main = struct('seg_err',{},'sig_err',{},'filt_err',{},'fc',{});
for a = 1:length(fc) % fc
q = 0;
w = 0
for i = 1:length(this.segments) % total number signal
for k = 1:length(this.segments{i}) % total number of segments
filt_sig = eval(this.segments{i}(k).signal,this.segments{i}(k).signal(1)); % apply filter to the ith singal and kth segemnt
filt_sig = filt_sig';
main{i}(k).seg_err(a) = std(filt_sig-this.segments{i}(k).ref); % calculate the standard divitation of the filtered signal and previously calculated signal.
q = q+main{i}(k).seg_err(a); add all the error of the segments for the same FC
end
main{i}(1).sig_err(a) = q; % assign the sum of all error of the all segemnts of the same signal
w = w+main{i}(1).sig_err(a); % add all the error of the signals
end
main.filt_err = w; % assign the sum of all error of the all signals
end
this.error_norm = [this.error_norm ;main];
end
end
基本上我有3個迴路,第一環是FC,第2循環用於信號,第三循環用於信號的segemnts。程序工作正常時,FC = 1
但是當fc是2,我得到以下錯誤:
Cell contents assignment to a non-cell array object.
在該行:
main{i}(k).seg_err(a) = std(filt_sig-this.segments{i}(k).ref);
那就是當i =1
,k=1
,a = 2
錯誤是說你是試圖將單元格的內容分配到數組中,如A = Cell(1,:);你可以試試'std(cell2double(filt_sig-this.segments {i}(k).ref))'看看會發生什麼。 – GameOfThrows
@GameOfThrows,我沒有找到任何叫做cell2double的東西。 – user5603723
@CaptainFuture,我做了調試,我停止了該行的程序並在命令窗口中調用了該值。在兩個實例上它都會返回一個值。 – user5603723