Parametric system solve -> parametric plot

View: New views
2 Messages — Rating Filter:   Alert me  

Parametric system solve -> parametric plot

by Bertone :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello to everybody,
I'm a physicist and an Octave-proud newbie, I need technical help to solve a simple problem.

I've got a parametric nonlinear system of 2 eqns in 2 unknowns plus a parameter, t:

f(x,y,t) = 0  AND g(x,y,t) = 0

well,

I could solve it point-by-point by setting manually a value for t and obtaining a point (x(t),y(t)), then following the instructions contained in the User Manual.

What should I tell Octave to draw a plot of the curve x(t), y(t) which is implicitly defined by the system above?

Thank you all!

Mario Alberto

Re: Parametric system solve -> parametric plot

by Ivan Sutoris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bertone wrote:
Hello to everybody,
I'm a physicist and an Octave-proud newbie, I need technical help to solve a simple problem.

I've got a parametric nonlinear system of 2 eqns in 2 unknowns plus a parameter, t:

f(x,y,t) = 0  AND g(x,y,t) = 0

well,

I could solve it point-by-point by setting manually a value for t and obtaining a point (x(t),y(t)), then following the instructions contained in the User Manual.

What should I tell Octave to draw a plot of the curve x(t), y(t) which is implicitly defined by the system above?

Thank you all!

Mario Alberto
Hi

if you have already solved your system for various values of t and have the results in vector x and y, you can just use plot(x,y). Assuming you have functions f and g already defined, it could look like this (not tested):

t = 0:0.01:1; % or whatever you need
x = zeros(length(t), 1);
y = zeros(length(t), 1);
for i=1:length(t)
    solfun = @(X) [f(X(1), X(2), t(i)); g(X(1), X(2), t(i))];
    X0 = [1; 1];
    X = fsolve(solfun, X0);
    x(i) = X(1);
    y(i) = X(2);
end
plot(x,y)

BTW, I did not receive your email through regular mailing list (just noticed it on Nabble), so there may have been some problem with your email passing through.

Regards
Ivan Sutoris