Creat a matrix using 2 while loops?
Show older comments
Hello,
I need to be able to create f amount of arrays with n number of cells. where i is the location inn the array:
n = 10000;
i =1;
f = 9;
arrays:
T_8 = [1 2 3 4 5 6 7 8 9];
P_8 = [1 2 3 4 5 6 7 8 9];
S_8 = [1 2 3 4 5 6 7 8 9];
T_8 = repelem(1,n);
T_9 = repelem(1,n);
T_10 = repelem(1,n);
while i - 1 ~= n;
while f<= 11
T_(f)(i) = 1*T_8(i);
P_(f)(i) = 2*T_8(i);
S_(f)(i) = 3*T_8(i);
f = f+1;
end
i = i+1;
end
disp("Output: " + T_(9));
disp("Output: " + T_(10));
disp("Output: " + T_(11));
OUTPUT:
T_9 = [ 1 2 3 4 5 6 7 8 9];
P_9 = [2 4 6 8 10 12 14 16];
S_10 = [3 6 9 12 15 18 21];
...
T_10 = [----------]
P_10 = [---------];
S_10 = [---------];
....
T_11 = [--------];
etc.
F needs to be inside i as I have a single set of functions I dont want to copy and past into my code and edit to fit the variable each time. I want the code to build the variable for me and put it through the function.
Is this possible?
Kindes Regards.
Answers (1)
m = 10 ;
n = 11 ;
x = 1:m ;
y = 1:n ;
A = y'*x ;
iwant = num2cell(A,2)
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!