Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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 commentaire
Stephen23
Stephen23 le 23 Déc 2021
Modifié(e) : Stephen23 le 23 Déc 2021
"Any pointers appreciated"
What is your question? It is not clear what you want help with.

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 23 Déc 2021
Modifié(e) : Stephen23 le 23 Déc 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.')
  1 commentaire
Andrew Rutter
Andrew Rutter le 23 Déc 2021
Many thanks Stephen for this rapid response - i had never come across toeplitz before! I'll give it a go.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by