MATLAB: How do i use the for loop for multiplication table

for loopfprintfmultiplication table

hi, i have tried to write the multiplication table for two, like this % multiplication table clc N = 1,2,3,4,5,6,7,8,9,10; for i = 1:N; fi=2*N; end but somehow it's not working. i don't want to use the fprintf command. please help i am new to MATLAB Thank You in advance

Best Answer

% multiplication table
clc
N = 1:10 ;
fi = zeros(size(N)) ;
for i = 1:length(N);
fi(i)=2*N(i);
end
table1 = [N' fi']
% With out loop
N = 1:10 ;
fi = 2*N ;
table2 = [N' fi']