Grateful for any help
x = [ 23 34 15 19]
actually i want the result to be a 4 by 2
23 0
34 0
15 0
19 0
Need to transpose x first. But unfortuantely I can't get the results.
My codes
new_A=zeros(size(x,1));

回答 (2 件)

the cyclist
the cyclist 2019 年 9 月 20 日
編集済み: the cyclist 2019 年 9 月 20 日

0 投票

output = [x' zeros(4,1)];
You can generalize this a bit by using the numel function to determine and use the size of x to get the number of zeros, rather than hard-coding the number 4.
output = [x' zeros(numel(x),1)];
Kevin Phung
Kevin Phung 2019 年 9 月 20 日
編集済み: Kevin Phung 2019 年 9 月 20 日

0 投票

x = [23;34;15;19];
new_x = [x zeros(size(x))]

カテゴリ

ヘルプ センター および File ExchangeMultidimensional Arrays についてさらに検索

質問済み:

2019 年 9 月 20 日

編集済み:

2019 年 9 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by