Unable to perform assignment because the left and right sides have a different number of elements -- variables do have same number
1 次查看(过去 30 天)
显示 更早的评论
I am trying to make a for loop loop through data, detrend it, then output it is a variable so that i can plot them. For some reason i am getting the error of 'Unable to perform assignment because the left and right sides have a different number of elements' when the variables do have same dimensions. Does anyone have any ideas?
subj = {'HCA1','HCA2','HCA3'}; %HCPsubj list
%% loading paths and such
D = '/Users/ll/Documents/data_analysis/HCP/seventy/';
%% indexing and putting all seventy graphs into one
a = zeros(478,1); %pre-allocate a vector to store results
for k = 1:length(subj)
name = subj{k};
c = load(fullfile(D,name,'ts','lcortex_run01regPA.txt'));
v = load(fullfile(D,name,'ts','ventricle_run01regPA.txt'));
%s = load(fullfile(D,name,'ts','spinal_run01regPA.txt'));
% c_ts = l
% v_ts = v
%
%% detrend ventricle and cortex
d_v_ts = detrend(v) %detrended time series of ventricle
d_c_ts = detrend(c) %detrended time series of cortex
for n=1:numel(a)
ventricle_data = d_v_ts; %do something with that data
a(n)=ventricle_data; %store it in the vector
end
end
1 个评论
Walter Roberson
2019-12-30
You load() a file. The result in v is almost certainly a vector or 2D array. detrend() applied to that would be the same size. You then loop 478 times, each time copying the entire vector or array into ventricle_data, and trying to store that entire vector or array into the single numeric location a(n) .
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Electrophysiology 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!