Info

此问题已关闭。 请重新打开它进行编辑或回答。

A question about generating a matrix

1 次查看(过去 30 天)
Yuxing Zhang
Yuxing Zhang 2018-10-11
关闭: MATLAB Answer Bot 2021-8-20
If I want to have a matirx which follows the change of n, says when n=2, A=[0 1] when n=3,A=[0 0 1], n=5, A=[0 0 0 0 1]. How can I achieve this goal using code? Thank you.

回答(1 个)

Bruno Luong
Bruno Luong 2018-10-11
clear A
A(n) = 1
  2 个评论
Yuxing Zhang
Yuxing Zhang 2018-10-11
Thank you very much, can I ask for what if I want to generate A=[o;o;1]?
Bruno Luong
Bruno Luong 2018-10-11
编辑:Bruno Luong 2018-10-11
Presumably you want "0" and not "o", add the following
A=A(:)
or
clear A
A(n,1) = 1

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by