How to Multiply value in adjacent cell by cell above, Autofil formula in Matlab?
2 次查看(过去 30 天)
显示 更早的评论
Hello, there must be an easy way to do this!
i have an excel file, that has been imported to matlab,
what i would like to do is perform a calculation the same way i would do in excel (and autofill down). what i would like is to multiply the answer in the cell above by the adjacent cell to get a final answer ... and do this for all rows
For instance my excel file below
StartVar = 5
A B C ANS
1 2 -1 (Startvar * -1)
2 2 +2 (above var * 2)
3 3 -2 (above var * -2)
4 3 -4 (above var * -4)
etc
for instance the ANS column will now be
-5
-10
+20
-80
..
0 个评论
采纳的回答
Matt Kindig
2013-8-5
编辑:Matt Kindig
2013-8-5
There is no generic "autofill" command. For the example you've given, the following logic would work:
StartVar = 5;
multipliers = [-1 2 -2 -4];
ANS = StartVar*cumprod(multipliers)';
There are of course other ways to do the same thing. Incidentally, since the multipliers are not changing by a regular increment, I'm not sure how you would use the autofill in Excel to do this either.
0 个评论
更多回答(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!