how to write a column vector in matlab

In MATLAB, a column vector can be created by enclosing a list of values within square brackets [] and separating them with semicolons (;) or by using the transpose operator (') after a row vector.

main.m
% Creating column vector with semicolons
v1 = [1; 2; 3; 4; 5];

% Creating column vector with transpose operator
v2 = [1 2 3 4 5]';

% Displaying column vectors
disp(v1);
disp(v2);
181 chars
10 lines

Output:

main.m
1
2
3
4
5

1
2
3
4
5
21 chars
12 lines

related categories

gistlibby LogSnag