Borrar filtros
Borrar filtros

Creat 1000 different matrix

1 visualización (últimos 30 días)
Deepesh Kumar Gupta
Deepesh Kumar Gupta el 25 de Sept. de 2021
Comentada: Deepesh Kumar Gupta el 2 de Oct. de 2021
I have 1000 different values of Bi, I want to creat 1000 different C matrix of order (12, 1) , where Each element of (12, 1) , ist matrix contains ist value of Bi and each element of (12, 1) ,2nd matrix contains 2 nd value of Bi. and so on. And each different 1000 matrix will print in Command windows and it's name like C1, C2, C3... C1000.

Respuesta aceptada

Steven Lord
Steven Lord el 25 de Sept. de 2021
Can you define variables with numbered names like C1, C2, C3, ... ? Yes.
Should you do this? Generally we recommend against it. See that page for alternatives you should use instead.
  13 comentarios
Stephen23
Stephen23 el 1 de Oct. de 2021
Editada: Stephen23 el 1 de Oct. de 2021
@Deepesh Kumar Gupta: please format your code properly. Badly formatted code discourages people from helping you.
% matrix calculation for i=1:1000 A=zeros(12,12);
for k=1:12
for j=1:12
if j==1
A(k,j)=1./(Rs{i}(k))+Bi(i).*log(Rs{i}(k));
else
A(k,j)=((j-1)*((Rs{i}(k)).^(j-1)+(Rs{i}(k)).^(1-j))./Rs{i}(k)+Bi(i)*((Rs{i}(k)).^(j-1)-(Rs{i}(k)).^(1-j)))* cos((j-1).*g(k));
end
end
end
end
If this code works and you need to repeat it 1000 times, then you can simply nest it inside another loop and either:
  1. assign the matrices to a cell arraz, much like you are already doing for Rs, or
  2. assign the matrices to one ND array.
Give it a try, e.g. cell array (just like Rs):
N = 1000;
C = cell(1,N);
for ii = 1:N
.. your code
C{ii} = your matrix
end
Deepesh Kumar Gupta
Deepesh Kumar Gupta el 2 de Oct. de 2021
Thank you very much @Stephen .this code works

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting 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