How to "concatenate" an array by merging the elements?
9 ビュー (過去 30 日間)
古いコメントを表示
Let's say that I have an array
x = [3,0,0]
Is it possible to somehow manipulate this so that I can output a result of y=300? I am wondering if I can "concatenate" this array such that it outputs a combination of the entire row as a single element or numerical value. So for example if I had
x = [1,0,0 ; 2,0,0 ; 3,0,0]
I would want something that would allow me to output
ans = [100 ; 200 ; 300]
Any help and suggestions are appreciated.
0 件のコメント
回答 (2 件)
madhan ravi
2018 年 10 月 5 日
x = [1,0,0 ; 2,0,0 ; 3,0,0]
x1 = x(1,:)
x2 = x(2,:)
x3 = x(3,:)
x1=str2num(strcat(num2str(x1(1)),num2str(x1(2)),num2str(x1(3))))
x2=str2num(strcat(num2str(x2(1)),num2str(x2(2)),num2str(x2(3))))
x3=str2num(strcat(num2str(x3(1)),num2str(x3(2)),num2str(x3(3))))
X=[x1;x2;x3]
Would work for any numbers
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!