How to "concatenate" an array by merging the elements?
5 次查看(过去 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!