Subscripted assignment dimension mismatch
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Roger Stafford
il 7 Feb 2017
Modificato: Roger Stafford
il 7 Feb 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!