how to fprintf element in matrix using array without using loops

9 visualizaciones (últimos 30 días)
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))

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 2 de Dic. de 2020
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(:).'])

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by