how to fprintf element in matrix using array without using loops
9 次查看(过去 30 天)
显示 更早的评论
A=randi([-5,5],2,2)
B=randi([-10,10],3,4)
K=kron(A,B);
a=1:6
a2=1:8
fprintf('K(%.0f,%.0f) is %.1f\n',a,a2,K(a,a2))
0 个评论
采纳的回答
Ameer Hamza
2020-12-2
Like this
A=randi([-5,5],2,2);
B=randi([-10,10],3,4);
K=kron(A,B);
a=1:6;
a2=1:8;
[ag,a2g] = ndgrid(a,a2);
fprintf('K(%.0f,%.0f) is %.1f\n',[ag(:).'; a2g(:).'; K(:).'])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!