Borrar filtros
Borrar filtros

Subscripted assignment dimension mismatch

1 visualización (últimos 30 días)
Fadzli
Fadzli el 7 de Feb. de 2017
Comentada: Fadzli el 8 de Feb. de 2017
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?

Respuesta aceptada

Roger Stafford
Roger Stafford el 7 de Feb. de 2017
Editada: Roger Stafford el 7 de Feb. de 2017
’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.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by