how to save solution from a solve?

racing01's picture

I have this problem

I have to solve something like this

for i to 17 do

solucion[i] := solve({item3[i], item4[i]}, {x, y})

end do

and I obtain in the answer for example

solucion[1] =             {x=2,y=3}

solucion[2] =             {x=3,y=4}

and I would like to create a vector containing all the values for x and all the values for y like x[1]=2  x[2]=3 and so on

How can I do it. and How can I export that to an excel or a text file???

 

Thanks!

edgar's picture

there are many ways

> solucion[1] := {x=2,y=3};
> solucion[2] := {x=3,y=4};
> solucion[3] := {x=2,y=0};
solucion[1] := {x = 2, y = 3}
solucion[2] := {x = 3, y = 4}
solucion[3] := {x = 2, y = 0}
> for i from 1 to 3 do
> x[i] := subs(solucion[i],x);
> y[i] := subs(solucion[i],y);
> end do;
x[1] := 2
y[1] := 3
x[2] := 3
y[2] := 4
x[3] := 2
y[3] := 0
> x[2];
3

lemelinm's picture

To export your file

 Here is how to expor to a file

 

> with(LinearAlgebra);
> for i to 3 do
 v[i] := <(x[i], y[i])>;
 vt[i] := Transpose(v[i]);
end do:
> M := <vt[1], vt[2], vt[3]>

                                      [2  3]
                                      [    ]
                                 M := [3  4]
                                      [    ]
                                      [2  0]

> ExportMatrix("D:/Data/Data6/My_Filea.txt", M, format = rectangular);
> fclose("D:/Data/Data6/My_Filea.txt");
> restart;
> M := ImportMatrix("D:/Data/Data6/My_Filea.txt", format = rectangular);

                                      [2  3]
                                      [    ]
                                 M := [3  4]
                                      [    ]
                                      [2  0]

 

Hope it help.

racing01's picture

THANK YOU

THank you very much, I could do it!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}