what am i doing wrong here? Invalid expresssion!
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I am trying to loop over the code below.
co_ordinates = 102 x 1 double
Indices = 17 x 1 double
code to extract the single value is
XY = co_ordinates (indices(1)+1:indices(2)-1,1)
how can I perform the loop over above line ?
So far I tried!
for i =1:length(co_ordinates)
XY(i) = coordinates(i) (indices(1)(i)+1:indices(2)(i)-1,1(i))
end
but I am getting an error: Invalid expression in the line
1 commentaire
Réponses (1)
Image Analyst
le 19 Nov 2020
Modifié(e) : Image Analyst
le 19 Nov 2020
You have extra things in () after the variable names. Get rid of those. And you mispelled co_ordinates inside the loop. Try this:
for k = 1 : length(co_ordinates)
XY(k) = co_ordinates(indices(k)+1 : indices(k)-1, k)
end
but indices(k)+1 : indices(k)-1 will be null unless the indices are negative values since you're going from a high value to a low value. Maybe you wanted
for k = 1 : length(co_ordinates)
XY(k) = co_ordinates(indices(k)-1 : indices(k)+1, k)
end
But that would give a range of values for the first index, and you can't stuff a vector into the single element of XY. It's hard to know you really want/need without you actually describing more what "Extract the single value" means to you.
2 commentaires
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!