How can I call one of the outputs of a function in another script and plot it?

1 view (last 30 days)
Hi.
I have a function:
----------------------------
function F = tethsolve3(p,H,L);
x0=[2;2];
g=9.82;
mu=0.0141*g;
% [x,fval]=fsolve(@Teth3,x0);
[x,fval] = fsolve(@(x) Teth3(x, p, H, L), x0);
Th2Radian=atan(sinh((x(1)+p)*mu/x(2)));
T2=x(2)/cos(Th2Radian)
end
-------------------------------
I need to plot one of the outputs of the function in another script for different inputs, as follows:
------------------- L=108;
H=100;
g=9.82;
mu=0.0141*g;
for p=0.01:1:10;);
tethsolve3(p,H,L);
T2=T2
p=p
plot(p,T2)
hold on
grid on
end -------------------------------
But there is an error. I guess it's because T2 is not really an output. Do I need to use a function handle???!
Please advise.
Thanks a lot.
  1 Comment
dpb
dpb on 29 Oct 2013
No, you need to return back to the caller any outputs from your function(s) that you need to have for further use--functions, otherwise, are pretty much useless for computations.
You wrote
function F = tethsolve3(p,H,L);
but F isn't ever defined so the end result of calling tethsolve3 is--well, nothing.

Sign in to comment.

Answers (0)

Categories

Find more on Symbolic Math Toolbox 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!