How to run an array on a vector-function?
Show older comments
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 Comment
Adam
on 14 Jun 2018
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
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!