正如你所看到的图像(excel文件),我想在Octave中使用该公式来获得所需的结果。我也上传了八度码图片和工作区图片。在工作区中,存储变量的结果/值应该与excel(存储列)中的值相同。我怀疑在代码中使用的最后一部分(如果带有i-1的语句似乎是错误的话)。如何将excel公式转换为八度?
有人可以帮我弄明白吗?让我知道是否需要进一步澄清。我也是张贴我的代码如下太:
BM_max = 1236;
virtual_feed_max = 64;
operation = dlmread ('2020Operation.csv');
BM = ones (size (operation, 1), 1);
for i=1:size(operation,1)
if operation(i,1)==1
BM(i,1)=BM_max;
else
BM(i,1)=0;
end
end
virtual_feed = ones(size(operation,1),1);
virtual_feed(:,1) = 64;
storage = ones(size(BM,1),1);
c = ones(size(BM,1),1);
for i=1:size(BM,1)
c=(BM(:,1)-virtual_feed(:,1));
end
for i=1:size(BM,1)
if ((i=1)&& c)<0
storage(:,1)=0;
elseif ((i=1)&& c)>0
storage(:,1)=c;
else
# Issue is below (Taking the value from subsequent row is the problem)
if (c+(storage(i-1,1)))<0
storage(:,1)=0;
elseif (c+(storage(i-1,1)))>0
storage(:,1)=(c+(storage(i-1,1)));
end
end
end
我看到的只是一个断开的链接到一个图像。请将您的代码添加为文本,格式正确,而不是图片。 – beaker
我也包含了代码。寻找你的建议 – Mayil
首先,'((i = 1)&& c)<0'似乎是错的,也许你的意思是'((i == 1)&& c <0)'?如果您将代码格式化为[代码块](http://stackoverflow.com/help/formatting),那也会更好。 – beaker