Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How to save data
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi; I have two data sets
A=[0 6 7 0 3 9 6 8 2 0 3 5];
B=[104 76 54 98 100 23 10 670 123 56 93 90];
when I see 0 in A, I should put its concurrent value from B to a cell till previous 0. for example when I see second 0 in A I should put 765498 in a cell. I need a code to do it. thanks
1 Kommentar
Antworten (1)
Image Analyst
am 11 Dez. 2015
What does "to a cell till previous 0" mean? Also, the first 0 in A is at index 1 and the value of B at index 1 is 104, not 765498 so I don't know how your example works.
A=[0 6 7 0 3 9 6 8 2 0 3 5];
B=[104 76 54 98 100 23 10 670 123 56 93 90];
indexesToReplace = (A==0);
A(indexesToReplace) = B(indexesToReplace)
It's replacing 0's in A with the value of B at the same index. Is that what you want???
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!