Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Trouble replacing one matrix values with vector values.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Good Morning,
I have a simple problem again, if anybody has any thoughts.
I keep getting an error in this bit of code but I've looked to see that the matrix and vectors are the same size, so i'm stuck as to how to get around it.
for i = 1:183
Day2(Day2(:,i) == 1) = D([1,i])
end In an assignment A(:) = B, the number of elements in A and B must be the same.
This is the error, but Day2 is 7 x 183 double and D is 1 x 183 double. I have tried to just pass one row of Day2 through at a time. When I can get it to run without the error I get returned back Day2 but it has not had any modifications the values from D I want to fit in have not been.
Any help or advice would be appreciated. I've been reading over all the indexing information but perhaps I'm missing what I should be looking at.
Thank you very much for any time, help and advice!
0 Kommentare
Antworten (1)
Walter Roberson
am 13 Okt. 2015
D([1,i]) refers to two locations. D(1,i) refer to a single location
5 Kommentare
Stephen23
am 13 Okt. 2015
What are you actually wanting to do? If you explain the goal of this then we can show you how it can be done neatly and efficiently. Loops are probably not an efficient solution.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!