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!