Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

A question about generating a matrix

1 vue (au cours des 30 derniers jours)
Yuxing Zhang
Yuxing Zhang le 11 Oct 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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.

Réponses (1)

Bruno Luong
Bruno Luong le 11 Oct 2018
clear A
A(n) = 1
  2 commentaires
Yuxing Zhang
Yuxing Zhang le 11 Oct 2018
Thank you very much, can I ask for what if I want to generate A=[o;o;1]?
Bruno Luong
Bruno Luong le 11 Oct 2018
Modifié(e) : Bruno Luong le 11 Oct 2018
Presumably you want "0" and not "o", add the following
A=A(:)
or
clear A
A(n,1) = 1

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by