필터 지우기
필터 지우기

Subscripted assignment dimension mismatch

조회 수: 1 (최근 30일)
Fadzli
Fadzli 2017년 2월 7일
댓글: Fadzli 2017년 2월 8일
Hi, this is my code;
[r]=length(matrice_polar);
[www]=29;
matrice_cartesian=zeros(r,www);
temperature=zeros(r,www);
clear www
for i=1:r
matrice_cartesian(i,2:25)=[matrice_polar(i,1:24)];
distance_x(i,1)=(x_new-matrice_cartesian(i,2))^2;
distance_y(i,1)=(y_new-matrice_cartesian(i,3))^2;
distance_z(i,1)=(z_new-matrice_cartesian(i,4))^2;
total_distance(i,1)=(distance_x(i,1)+distance_y(i,1)+distance_z(i,1))^(1/2);
temperature(i,1)=matrice_cartesian(i,10);
end
for i=1:r
Delta_x(i,1)=(x_new-matrice_cartesian(i,2));
Delta_y(i,1)=(y_new-matrice_cartesian(i,3));
Delta_z(i,1)=(z_new-matrice_cartesian(i,4));
Delta_temperature(i,1)=(temperature-matrice_cartesian(i,10));
end
I get the error "Subscripted assignment dimension mismatch" at the last line:
Delta_temperature(i,1)=(temperature-matrice_cartesian(i,10));
Anyone can help me, why it is happen?

채택된 답변

Roger Stafford
Roger Stafford 2017년 2월 7일
편집: Roger Stafford 2017년 2월 7일
’temperature' is an array, not a scalar, and when the scalar 'matrice_cartesian(i,10)' is subtracted from it, it remains an array. However, you are trying to place it in a single element of 'Delta_temperature' and it doesn’t fit. You need to rethink what it is you are trying to accomplish.
  댓글 수: 1
Fadzli
Fadzli 2017년 2월 8일
Thank you sir, I think I got the point...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by