How to run an array on a vector-function?
显示 更早的评论
Hello, I simplified my problem with the following example. I want to calculate 4 solutions of my function by using the values in a,b,c row-wise. e.g. the first solution should be with a=1,b=2,c=4, the second a=4,b=4,c=3, the third a=7;b=6;c=2; the fourth a=9,b=3,c=1. I tried several options like arrayfun and rowfun but was always unsuccessful. I am sorry if the title might be misleading... Thanks for any suggestions
a=[1;4;7;9]
b=[2;4;6;3]
c=[4;3;2;1]
x=(1:1:100)'
function= a*x + b*x + c*x;
1 个评论
Adam
2018-6-14
What is the answer you are looking for exactly?
a*x + b*x + c*x
simplifies to
( a + b + c )*x
which is very easy to do, either with bsxfun or implicit expansion, depending on your Matlab version e.g.
x * ( a + b + c )';
in R2018a
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!