You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Creat 1000 different matrix
1 view (last 30 days)
Show older comments
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.
Accepted Answer
Steven Lord
on 25 Sep 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 Comments
Deepesh Kumar Gupta
on 26 Sep 2021
Okay Steven, instead of C1, C2.. C1000 you can take C(1), C(2).. C(1000).and please help in this code
Deepesh Kumar Gupta
on 26 Sep 2021
I have to print all 1000 matrix in command window.
Thank you in advance
Deepesh Kumar Gupta
on 26 Sep 2021
Edited: Walter Roberson
on 26 Sep 2021
c=0.01;
d=.013;
m=1000;
ri=c+(d-c).*rand(m,1);
h=315;
K=44.5;
Bi=(h*ri) /K;
for k=1:1000
C=zeros(12,1)
for i=1:12
C(i,:)=Bi(k)
end
end
Deepesh Kumar Gupta
on 26 Sep 2021
I am getting only one (12, 1) matrix, i have to print such 1000 matrix
Stephen23
on 26 Sep 2021
c = 0.01;
d = 0.013;
m = 1000;
ri = c+(d-c).*rand(1,m);
h = 315;
K = 44.5;
Bi = (h*ri)./K
Bi = 1×1000
0.0757 0.0807 0.0876 0.0810 0.0781 0.0866 0.0910 0.0856 0.0741 0.0887 0.0910 0.0854 0.0813 0.0713 0.0860 0.0914 0.0905 0.0809 0.0748 0.0788 0.0893 0.0723 0.0761 0.0732 0.0807 0.0917 0.0891 0.0755 0.0741 0.0764
C = num2cell(repmat(Bi,12,1),1)
C = 1×1000 cell array
Columns 1 through 588
{12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double}
Columns 589 through 1000
{12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double} {12×1 double}
C{1} % Checking the first cell
ans = 12×1
0.0757
0.0757
0.0757
0.0757
0.0757
0.0757
0.0757
0.0757
0.0757
0.0757
Deepesh Kumar Gupta
on 26 Sep 2021
I am still not able to print C{1} of order (12,1) , can u please be in more details
Steven Lord
on 26 Sep 2021
A = {magic(4), ones(2, 3, 4), @sin} % A sample cell array
A = 1×3 cell array
{4×4 double} {2×3×4 double} {@sin}
celldisp(A) % Display all elements of the cell array
A{1} =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
A{2} =
(:,:,1) =
1 1 1
1 1 1
(:,:,2) =
1 1 1
1 1 1
(:,:,3) =
1 1 1
1 1 1
(:,:,4) =
1 1 1
1 1 1
A{3} =
@sin
Deepesh Kumar Gupta
on 1 Oct 2021
I have 1000 Rs matrix of order(1,12) and 1000 values Bi .I want to create 1000 A matrix of order (12,12). How can I create A matrix .
% 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
Stephen23
on 1 Oct 2021
Edited: Stephen23
on 1 Oct 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:
- assign the matrices to a cell arraz, much like you are already doing for Rs, or
- 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
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)