I'm newish to MATLAB and want to automate populating a matrix A rather than manually create...
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Andrew Rutter
am 23 Dez. 2021
Kommentiert: Andrew Rutter
am 23 Dez. 2021
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 Kommentar
Akzeptierte Antwort
Stephen23
am 23 Dez. 2021
Bearbeitet: Stephen23
am 23 Dez. 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)
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.')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!