Matrix problem with pattern in rows and columns
Ältere Kommentare anzeigen
So I want a matrix that looks like this:
[a^1, (a+1)^2, (a+2)^3....;(a+2)^1, (a+3)^2,(a+4)^3....;(a+4)^1, (a+5)^2,(a+6)^3....;(a+6)^1, (a+7)^2,(a+8)^3...]
all the way to the power of 15 for each row (15 rows) and 5 columns with this pattern. Also, I cannot type out the exact numbers explicitly. I tried looking for resources but wasn't able to find something to help me with this. Help would be really appreciated thank you in advance.
Antworten (1)
Benjamin Thompson
am 16 Feb. 2022
0 Stimmen
The brute force way is:
a = 2;
M = zeros(15,5);
M(1, 1) = a;
M(1, 2) = (a+1)^2;
M(1,3) = and so on...
M(2, 1) = (a+2)^3;
and so on...
You can also square just the second column of a matrix if you wish using this command:
M(:,2) = M(:,2).^2
And if you construct a 15x5 matrix with the integers you would like to add to a:
N = 1:(15*5);
N = reshape(N,15,5)
Then you can add a to all elements of that matrix like this:
M = ones(15,5)*a + N
I cannot fully understand pattern of the contents of the 15x5 matrix to complete all of it. Hopefully these examples are helpful.
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!