我不太确定你想达到什么目的。也许你能帮我理解你的代码?
你的问题是你不知道如何在 python 中重写你的方程(在 MATLAB 中给出),或者你没有成功绘制方程?实际上,无法绘制给出的片段。
for i=24
f=sum(X)*(i)
end
(1) This is like writing :
i=24
f=sum(X()*(i)
You will get a scalar value. The result in both cases will be f = 41040
.
(2) If you want to receive a vector you can just multiply both values:
n=0:24
f=sum(X)*n
This will return the vector f = [ 0 1710 3420 ... ]
.
X(t)
, which is in your case is 1710. Then you multiply it 24 times, but always assign it to the same variable (the previous value will get overwritten).vpa(sum(f))
I assume you expect a vector (2), not a scalar. I have explained it above. 我已经重写了你的代码,所以这对我来说很有意义。如果我绘制这个,我会收到一个斜坡。
clc;
clear all;
X=10:10:180
n=0:24
f=sum(X)*n
vpa(sum(f)) % What’s the purpose?
plot(n,f)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句