about separating the variable.

1 visualización (últimos 30 días)
Ejay Kasai
Ejay Kasai el 13 de Sept. de 2011
i have x = 0 and 2. is there a way to separate those numbers using x1=0 and x2=2 ? i'll use this using programming in matlab.

Respuesta aceptada

Wayne King
Wayne King el 13 de Sept. de 2011
Yes, you can also store them in a vector
x = [0 2];
% or as a column vector
x =[0;2];
and then access them by their indices:
x(1)
x(2)
  6 comentarios
Ejay Kasai
Ejay Kasai el 13 de Sept. de 2011
ok so, this is the program
poly1=input('First polynomial function: ','s');
poly2=input('Second polynomial function: ','s');
syms y;
z1=solve(poly1,'y');
z2=solve(poly2,'y');
xi=solve(z1-z2);
yi(1)=eval(subs(z1,xi(1)));
yi(2)=eval(subs(z1,xi(2)));
ezplot(poly1)
hold all
ezplot(poly2)
plot(xi,yi,'o')
what if the user input poly1: y=x^2 and ply2: y=2*x then xi will be 0 and 2. and i want to separate those two number of xi to x1=0 and x2=2 automatically if the program finds the two x's.
Ejay Kasai
Ejay Kasai el 13 de Sept. de 2011
i got it. Thank you very much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by