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
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 CenterFile Exchange에서 Behavior and Psychophysics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by