I'm newish to MATLAB and want to automate populating a matrix A rather than manually create...
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephen23
2021-12-23
编辑:Stephen23
2021-12-23
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.')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!