I need some help with the quad() function in MATLAB. I've simplified my issue to make the following code (and thus my problem) easier to understand.(adsbygoogle = window.adsbygoogle || []).push({});

function testint

clc;

%%% Formula

x = 0:0.001:pi;

x = [zeros(1,40) x zeros(1,40)];

y = sin(x);

Result = quad(@work, min(x), max(x))

end

function [a b c q y s] = work(x)

a = log(x);

b = cos(x);

c = 5.*x;

q = 2.^x;

y = sin(x);

s = 2./x;

end

The value of "Result" always gives me the first output of work(x) (i.e., a). I need "Result" to give me the value of y (the 5th output of work(x)). How can I manipulate the function handle and/or call to work(x) to get this? Also, I am using work(x) in other locations, so I cannot manipulate the inputs / outputs (or even the order... such as, if I move y to the beginning (i.e., function [y a b c q s] = work(x) ... end) it works perfectly).

Thanks for any suggestions!

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB quad function

Loading...

Similar Threads - MATLAB quad function | Date |
---|---|

Matlab Coding angular spectrum of waves in a fluid | Yesterday at 7:30 AM |

How to program this in Matlab | Feb 28, 2018 |

Matlab Making a short test for self-adjointness | Feb 23, 2018 |

MATLAB quad and difficulty with vector input | Nov 22, 2010 |

**Physics Forums - The Fusion of Science and Community**