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.

回答(2 个)

KSSV
KSSV 2018-10-5
x = [1,0,0 ; 2,0,0 ; 3,0,0] ;
N = [100 10 1] ;
p = sum(x.*N,2)

madhan ravi
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

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by