copying arrays from one variable to another .
124 ビュー (過去 30 日間)
古いコメントを表示
i have 2 variables, a=[22 23 43 0 0 0 0], now i need to copy array ' a ' to ' b ' from 1st element to 3rd element. how can it be done?? i tried b=a(3); , b=a(:,3), all these copies only that corresponding element.
0 件のコメント
採用された回答
Geoff Hayes
2015 年 4 月 5 日
Pradeep - if you want to copy the first three elements of a into b, then just do
a = [22 23 43 0 0 0 0];
b = a(:,1:3);
In the above, since a is a row vector, we want to copy the first three elements (columns) of a. Try it and see what happens!
2 件のコメント
Kelsey Romine
2017 年 9 月 12 日
What if I need the first two elements and the fourth and fifth elements?
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!