dannyt
dannyt

Reputation: 11

Column vector in MATLAB

I am very new to MATLAB and I was wondering if anyone can suggest how to construct a Nx1 column vector with all the entries being 0, except for the last entry which is 1. I tried playing with the following commands with no luck

A=zeros(N,1)
B=ones(N,1)
C=horzcat(A,B)
Cvector=C(:)

Upvotes: 0

Views: 84

Answers (1)

GrapefruitIsAwesome
GrapefruitIsAwesome

Reputation: 488

Cvector = zeros(N, 1);
Cvector(end) = 1;

Upvotes: 2

Related Questions