Subscripted assignment dimension mismatch
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!