Borrar filtros
Borrar filtros

I'm newish to MATLAB and want to automate populating a matrix A rather than manually create...

1 visualización (últimos 30 días)
My columns represent years, and the rows the demand profile TM (versus a peak demand) for products each year. I could launch 1 2 or 3 products per year.
The demand profile starts slow, builds to a peak and tails to zero 20 years after launch
TM = [0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1 0.0]
The typical demand profile looks like this, and is the same for each product TM(1:N):
TM1 = [0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1 0.0....]
If products launched/yr = 1 then the second product curve would look like
TM2 = [0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1 0.0....];
If products lanched/yr = 2 then the second product curve would look like TM1, and the third like TM2
TM2 = [0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1 0.0];
and
TM3 = [0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1 0.0....];
So I might end up with something like this for one product a year and four products...
A=
[0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1 0.0;
0.0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1;
0.0 0.0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2;
0.0 0.0 0.0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4];
Any pointers appreciated, Thank you.
  1 comentario
Stephen23
Stephen23 el 23 de Dic. de 2021
Editada: Stephen23 el 23 de Dic. de 2021
"Any pointers appreciated"
What is your question? It is not clear what you want help with.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 23 de Dic. de 2021
Editada: Stephen23 el 23 de Dic. de 2021
TM = [0.1,0.1,0.1,0.1,0.1,0.2,0.3,0.4,0.6,0.8,1.0,1.0,1.0,1.0,1.0,0.8,0.6,0.4,0.2,0.1,0.0];
N = 4;
M = toeplitz([TM(1),zeros(1,N-1)],TM)
M = 4×21
0.1000 0.1000 0.1000 0.1000 0.1000 0.2000 0.3000 0.4000 0.6000 0.8000 1.0000 1.0000 1.0000 1.0000 1.0000 0.8000 0.6000 0.4000 0.2000 0.1000 0 0 0.1000 0.1000 0.1000 0.1000 0.1000 0.2000 0.3000 0.4000 0.6000 0.8000 1.0000 1.0000 1.0000 1.0000 1.0000 0.8000 0.6000 0.4000 0.2000 0.1000 0 0 0.1000 0.1000 0.1000 0.1000 0.1000 0.2000 0.3000 0.4000 0.6000 0.8000 1.0000 1.0000 1.0000 1.0000 1.0000 0.8000 0.6000 0.4000 0.2000 0 0 0 0.1000 0.1000 0.1000 0.1000 0.1000 0.2000 0.3000 0.4000 0.6000 0.8000 1.0000 1.0000 1.0000 1.0000 1.0000 0.8000 0.6000 0.4000
plot(M.')
Compared to your requested output:
A = [0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1 0.0;
0.0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2 0.1;
0.0 0.0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4 0.2;
0.0 0.0 0.0 0.1 0.1 0.1 0.1 0.1 0.2 0.3 0.4 0.6 0.8 1.0 1.0 1.0 1.0 1.0 0.8 0.6 0.4];
plot(A.')

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by