Matrix problem with pattern in rows and columns

9 visualizaciones (últimos 30 días)
Daabir Momin
Daabir Momin el 16 de Feb. de 2022
Respondida: Benjamin Thompson el 16 de Feb. de 2022
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.

Respuestas (1)

Benjamin Thompson
Benjamin Thompson el 16 de Feb. de 2022
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.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by