Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

1 次查看(过去 30 天)
ew = [-1 0 0 3]; % [<begin pre> <end pre> <begin post> <end post>]
for abc = 1:size(ew,2)
[~, ix(abc)] = min(abs(tw-ew(abc)));
end
clearvars window table_rat table_sex table_trial table_licklat table_numlicks table_pks table_locs table_drug
row = 1;
for abc = animalnumber
for xyz = 1:data(abc).ntrain
wind = data(abc).trainOn(xyz):data(abc).trainOn(xyz)+ix(4);
if isempty(find(data(abc).locs>wind(1) & data(abc).locs<wind(end)))
else
table_rat(row,1) = {data(abc).animal};
table_sex(row,1) = {data(abc).sex};
table_drug(row,1) = str2num(data(abc).conditions(1));
table_trial(row,1) = xyz;
table_licklat(row,1) = data(abc).licklat(xyz);
table_numlicks(row,1) = data(abc).numolicks(xyz);
table_pks(row,1) = max(data(abc).pks(data(abc).locs>wind(1) & data(abc).locs<wind(end)));
table_locs(row,1) = data(abc).locs(data(abc).pks==table_pks(row,1));
table_pkfreq(row,1) = numel(data(abc).pks(data(abc).locs>wind(1) & data(abc).locs<wind(end)))/(size(wind,2)/fsg1);
row = row + 1;
end
end
end
vars = {'rat','sex','drug','trial','licklat','numlicks','locs','pkmag','pkfreq'};
table_pkmagtrial = table(table_rat,...
table_sex,...
table_drug,...
table_trial,...
table_licklat,...
table_numlicks,...
table_locs,...
table_pks,...
table_pkfreq,...
'VariableNames',vars);
writetable(table_pkmagtrial,'pkmagtrial3s.csv','Delimiter',',')
clearvars table_rat table_drug table_trial table_locs table_pks
  1 个评论
Jan
Jan 2019-6-24
You forgot to ask a question and to post a copy of the complete error msssage. Please format your code properly in addition.
Do not waste the time with clearvars, because it is rarely useful.

请先登录,再进行评论。

回答(0 个)

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by