均匀地添加两个不同尺寸的阵列,而无需混乱累积总和。

14 views (last 30 days)
我有2个阵列。
a = [0 1 2 3 4 5 6。。。。n]%尺寸2402 x 1,假设在这种情况下n数为58
b = [18]百分比1x1
C = [A+B的累积输出]预期结果从0开始,结束时为76 @ 2402 *1
现在
A是从0开始消耗的能量总和,在2402秒内以58 kWh结束。
B是在2402秒内消耗的总辅助能量。请注意,B不是累积能量。它只是1 x 1数组中的数字。
我要做的是将B添加到A均值,以使结果C可以是从0开始到76结束的累积结果。
I tried a lot of logics but nothing worked for me.
请指导我朝着正确的方向来达到这一结果。

接受的答案

Akira Agata
Akira Agata 2019年10月24日
基于问题,C应该是从0开始的累积结果。因此,应该是:
c = a + linspace(0,b,长度(a));
2条评论
Shahab Khan
Shahab Khan 2019年10月24日
编辑:Shahab Khan 2019年10月24日
Ok I managed to do it myself in this maner.
First I tried to understand linespace function. When I understood how it works. I write this code to acheive the above goal.
a = [0 1 2 3 4。。。。n];%尺寸2402 x 1
b = [18];
d = linspace(0,b,长度(a));
e = d';
c = a + e;%尺寸2402 x 1
Thanks for the help.

登录发表评论。

s manbetx 845


Release

R2019a

社区寻宝

在Matlab Central中找到宝藏,发现社区如何为您提供帮助!

Start Hunting!