Hi pf(adsbygoogle = window.adsbygoogle || []).push({});

I have a question that I have not been able to find. The below function accepts outside scalar inputs but not vectors. The code is below.

Also, ## a, b, delta,FA,Hi,vHnew,iv## are all scalars defined outside the function. The vector I would like to add as an input is ##x##, which I've commented below what it could be. However, even if I add this to the function line and ##fa, fb##, and ##fc##, along with the ##fx## function at the end, I still receive "Error Not enough input arguments." Please help me so this function can operate on ##x## when it is defined outside the function.

Any help is greatly appreciated!

Code (Text):

function c = mshvol(a, b, delta,FA,Hi,vHnew,iv)

fa = f(a,FA,Hi,vHnew,iv);

fb = f(b,FA,Hi,vHnew,iv);

while ( abs(b - a) > 2*delta )

c = (b + a)/2;

fc = f(c,FA,Hi,vHnew,iv);

if sign(fc) ~= sign(fb)

a = c; fa = fc;

else

b = c; fb = fc;

end% end if

end

function fx = f(zbulk,FA,Hi,vHnew,iv)

dx=.001;

% x=0:dx:5;

y=25-x.^2;

diff = abs(x-zbulk);

[~, idx] = min(diff); %index of closest value

z=y(idx:end);

fx = zbulk*15+trapz(z)*dx-70; %% Volume balance

return;

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

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

# MatLab function question

Loading...

Similar Threads - MatLab function question | Date |
---|---|

Working with Edge function in MATLAB | Mar 7, 2017 |

Matlab Does MatLab have this kind of function? | Jan 15, 2017 |

Matlab error matrix function | Apr 25, 2016 |

Matlab Plotting a 3d function | Apr 1, 2016 |

MATLAB transfer function question: Fundamentals | Dec 17, 2009 |

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