Insert 0s in a column matrix with an if function
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Hi, I want to insert 0s in a matrix where an entry is missing. For example: Say I've got matrices T1=[1;2;4;6;9;10] and B=[1;1;1;1;1;1] and another matrix T2=1:10. Values in B correspond to values in T1 so I want that every time that there is a missing value it inserts a zero. Finally B would be, B=[1;1;0;1;0;1;0;0;1;1] (zeroes where T1 was missing a value. Thank you
0 件のコメント
回答 (1 件)
Jos (10584)
2018 年 2 月 27 日
Something along these lines?
T1 = [1;2;4;6;9;10]
B = [1;1;1;1;1;1]
T2 = 1:10
A(T2) = 0
A(T1) = B
2 件のコメント
Ricardo Higinio Picon Alvaro
2018 年 2 月 27 日
Jos (10584)
2018 年 2 月 27 日
That was already clear. If you want to have it into B, do:
B = A
et voila!
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!