multiplication table in matlab
46 次查看(过去 30 天)
显示 更早的评论
I want to make the multiplication table using matlab ?
2 个评论
leela krishna
2019-6-30
the output is the multiplication table of any number
clc;
clear all;
n=input('Enter an integer:');
i=1;
while(i<=10)
fprintf('%d*%d=%d \n',n,i,n*i);
i=i+1;
end
采纳的回答
Azzi Abdelmalek
2013-3-1
编辑:Azzi Abdelmalek
2013-3-1
x=(1:9)'
a=repmat(x,1,9)
b=a'
c=bsxfun(@times,x,x')
out=arrayfun(@(x,y,z) [num2str(x) 'x' num2str(y) '=' num2str(z)],a,b,c,'un',0)
3 个评论
Azzi Abdelmalek
2013-3-10
编辑:Azzi Abdelmalek
2013-3-10
Look at this example:
a=[2 4 8]
%I want to do some operation to each number of a
out(1)=a(1)*100+cos(a(1))
out(2)=a(2)*100+cos(a(2))
out(3)=a(3)*100+cos(a(3))
%This can be done with arrayfun
out=arrayfun(@(x) x*100+cos(x),a)
更多回答(4 个)
Teja Muppirala
2013-5-23
N = 10
(1:N)'*(1:N)
2 个评论
Morganne Durham
2018-1-22
To make a matrix for a times table, you need to use a period before the *
(1:N)'.*(1:N)
Matt J
2013-3-1
As an example, This will generate a times table for integers 1...10
bsxfun(@times, (1:10).',1:10)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!