clear allm=input ('please input a 4 by matrix'); w=input (' do you want to display a row, column or a single element of the matrix?, for a row type 1, for a element type 2 and for column type 3'); if w==1 dumb=input ('what row do you want displayed?'); if dumb==1 disp (['your chosen row is ' num2str(m(1,:))]) elseif dumb==2; disp (['your chosen row is ' num2str(m(2,:))]) elseif dumb==3; disp (['your chosen row is ' num2str(m(3,:))]) elseif dumb==4 disp (['your chosen row is' num2str(m(4,:))]) end; elseif w==3 stupid=input ('what column do you want displayed?'); if stupid==1 %for some reason this doesnt really work :S
disp (['your chosen column is ' num2str(m(:,1))]) elseif stupid==2; disp (['your chosen column is ' num2str(m(:,2))]) elseif stupid==3; disp (['your chosen column is ' num2str(m(:,3))]) elseif stupid==4; disp (['your chosen column is ' num2str(m(:,4))]) end;elseif w==2 re=input ('what row do you want selected '); rc=input ('what column do you want selected '); disp ([' Your chosen value based on your rows and columns is ' num2str(m(re,rc))]) end;
MATLAB: Horzcat error when trying to display an entire column from a 4 by 4 matrix
beginnererrorhorzcatMATLABmatrix
Best Answer