how to solve "Subscripted assignment dimension mismatch"?

time_roi = [0 30];
intind_p = find(t >= 0 & t <=30);
H_roi = squeeze(newdcAvg(intind_p,1,:,:));
peak_h=squeeze(max(H_roi,[],1));
t_roi=t(intind_p);
for i=1:size(peak_h,1);
for j=1:size(peak_h,2);
t_ind = squeeze(H_roi(:,i,j));
peak = peak_h(i,j);
position= find(t_ind == peak_h(i,j));
p_latency(i,j)=[t_roi(position)];
end
end
I guess "p_latency(i,j)=[t_roi(position)];"might be wrong,but i dont know how to change it.

7 件のコメント

per isakson
per isakson 2022 年 6 月 10 日
especially
  • 3) Show what you have ...
  • 5) Provide standalone code ...
Wenbo
Wenbo 2022 年 6 月 10 日
Thank you. the codes below are where i get "Subscripted assignment dimension mismatch“ , and if i imput just numbers, it can run smoothly. So i guess "p_latency(i,j)=[t_roi(position)]" might need modification, and i seek for the help here.
for i=1:size(peak_h,1);
for j=1:size(peak_h,2);
t_ind = squeeze(H_roi(:,i,j));
peak = peak_h(i,j);
position= find(t_ind == peak_h(i,j));
p_latency(i,j)=[t_roi(position)];
end
end
per isakson
per isakson 2022 年 6 月 10 日
Most likely the value of [t_roi(position)] is not a scalar. Since I cannot run the code, I cannot say for sure. Put a break-point at the line and inspect the value of [t_roi(position)]
Wenbo
Wenbo 2022 年 6 月 10 日
Thank you! Here, t_roi(position) is a number.
KSSV
KSSV 2022 年 6 月 10 日
Show us all the variables and full code, so that we can help you.
per isakson
per isakson 2022 年 6 月 10 日
"a number" that shouldn't cause this error. I don't understand.
Jeffrey Clark
Jeffrey Clark 2022 年 6 月 11 日
It may be that position= find(t_ind == peak_h(i,j)) finds more than one, which wouldn't be compatible with p_latency(i,j)=[t_roi(position)]. In fact why do you have brackets in this line?

サインインしてコメントする。

回答 (0 件)

カテゴリ

質問済み:

2022 年 6 月 10 日

コメント済み:

2022 年 6 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by