MATLAB Answers

How would i store data into a vector

112 views (last 30 days)
What i want to do is create a vector with only 1's that has a varying size depending on how i want it to be, since i know dynamically creating variables is not good i thought about creating a matrix of zeroes and storing the values i want in it, how would i do that? Also if there is another way of doing it please help.


Sign in to comment.

Accepted Answer

David Fletcher
David Fletcher on 16 Apr 2018
Edited: David Fletcher on 16 Apr 2018
%Create 1x10 row vector filled with zeros
%Create 1x10 column vector filled with ones
colVector(5)=10 %Store the value 10 in the fifth element of colVector
rowVector(2)=22 %Store the value 22 in the second element of rowVector

  1 Comment

Feliciano Döring
Feliciano Döring on 16 Apr 2018
Perfect, thanks! I didn't know you could use 'ones' likes 'zeroes'

Sign in to comment.

More Answers (0)

Sign in to answer this question.