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?

采纳的回答

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.

更多回答(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