Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
René Dienemann
il 1 Mar 2020
Risposto: Walter Roberson
il 1 Mar 2020
Hello, I want to extract different profiles along the x-axis from gridded data, by using a for loop. But, I get this error (Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.), and I don´t know why?
This is my code:
an_names = {'1-1','1-2','1-3','2-1','5-1'}; % Names of profiles
yp = [20.91,27.16,12.16,37.66,7.91]; % y coordinates of these profile
for k=1:numel(yp)
magpr(k,:) = sens2g(round(nvec,2)==yp(k),:); % sens2g are gridded data of magnetic measurements and nvec is the y vector of my field
end
xvec = evec; % x vector of my field
figure (1) % plotting these extracted data
plot(xvec,magpr)
legend(an_names)
Thanks for the help!
Best regards
0 Commenti
Risposta accettata
Walter Roberson
il 1 Mar 2020
round(nvec,2)==yp(k) is matching more than one element at some point so you are getting a 2d array that you are trying to store into a vector location.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements 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!