explain x=trial_03(:,3); in matlab

The line x=trial_03(:,3); in MATLAB assigns the values in the third column of the matrix variable trial_03 to the variable x.

The : operator selects all the rows of the matrix while the 3 specifies the third column.

So, x will now be a column vector containing all the elements from the third column of the matrix trial_03.

Here's an example:

main.m
trial_03 = [1,2,3; 4,5,6; 7,8,9];
x = trial_03(:,3);

% Output:
% trial_03 =
%      1     2     3
%      4     5     6
%      7     8     9
% 
% x =
%      3
%      6
%      9
176 chars
14 lines

related categories

gistlibby LogSnag