Matlab - Resolver sistema con N ecuaciones

 
Vista:

Resolver sistema con N ecuaciones

Publicado por Pablo (8 intervenciones) el 09/04/2012 17:23:40
Hola.

Tengo un script que me genera N ecuaciones, y necesito resolver el sistema de esas N ecuaciones, pero no se como hacerlo sin tener que escribir una a una cada ecuacion obtenida.

Este es mi script:

>> Ecuaciones
Introduzca el nº de pisos de rectificación ---> 6
Introduzca el nº de pisos de agotamiento ---> 5
Introduzca el tipo de condensador, total(T) o parcial(P) ---> T

REC =

'L/V=(y1-y2)/(x0-x1)'
'L/V=(y2-y3)/(x1-x2)'
'L/V=(y3-y4)/(x2-x3)'
'L/V=(y4-y5)/(x3-x4)'
'L/V=(y5-y6)/(x4-x5)'
'L/V=(y6-y7a)/(x5-x6)'


AGO =

'l/v=(y7-y8)/(x6a-x7)'
'l/v=(y8-y9)/(x7-x8)'
'l/v=(y9-y10)/(x8-x9)'
'l/v=(y10-y11)/(x9-x10)'
'l/v=(y11-yw)/(x10-x11)'


ALI =

'x6a=(L*x6+q*F*xf)/l'
'y7a=(v*y7+(1-q)*F*xf)/V'


EQUI =

'yw=a*xw/(1+xw*(a-1))'
'y1=a*x1/(1+x1*(a-1))'
'y2=a*x2/(1+x2*(a-1))'
'y3=a*x3/(1+x3*(a-1))'
'y4=a*x4/(1+x4*(a-1))'
'y5=a*x5/(1+x5*(a-1))'
'y6=a*x6/(1+x6*(a-1))'
'y7=a*x7/(1+x7*(a-1))'
'y8=a*x8/(1+x8*(a-1))'
'y9=a*x9/(1+x9*(a-1))'
'y10=a*x10/(1+x10*(a-1))'
'y11=a*x11/(1+x11*(a-1))'


CAL =

'xw=(l*x11-v*yw)/W'

A estas ecuaciones añado los valores de F, xf, q, L, V, l, v, d y W .

Con todo esto usando solve me resuelve el sistema, pero no se como hacerlo para no tener que introducir a mano las ecuaciones.

Si alguien tiene alguna idea lo agradeceria.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Resolver sistema con N ecuaciones

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 09/04/2012 19:55:57
Hola Pablo.
Deberias poner tu codigo script para que te pueda ayudarte con mas eficaz, solo viendo tus ejecucion de tu código, es dificil darte una respuesta precisa.

Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
programador en matlab
Servicios de programacion matla
[email protected]

http://matlabcaballero.blogspot.com/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Resolver sistema con N ecuaciones

Publicado por Pablo (8 intervenciones) el 10/04/2012 10:49:18
Realmente hay un script para matriz de las que salen arriba. Como seria muy largo pongo solo uno, pero el resto funcionan igual.

Este es el script:

EQ={'yw=a*xw/(1+xw*(a-1))';'y1=a*x1/(1+x1*(a-1))';'y2=a*x2/(1+x2*(a-1))';'y3=a*x3/(1+x3*(a-1))';'y4=a*x4/(1+x4*(a-1))';
'y5=a*x5/(1+x5*(a-1))';'y6=a*x6/(1+x6*(a-1))';'y7=a*x7/(1+x7*(a-1))';'y8=a*x8/(1+x8*(a-1))';'y9=a*x9/(1+x9*(a-1))';'y10=a*x10/(1+x10*(a-1))';
'y11=a*x11/(1+x11*(a-1))';'y12=a*x12/(1+x12*(a-1))';'y13=a*x13/(1+x13*(a-1))';'y14=a*x14/(1+x14*(a-1))';'y15=a*x15/(1+x15*(a-1))';'y16=a*x16/(1+x16*(a-1))';
'y17=a*x17/(1+x17*(a-1))';'y18=a*x18/(1+x18*(a-1))';'y19=a*x19/(1+x19*(a-1))';'y20=a*x20/(1+x20*(a-1))';'y21=a*x21/(1+x21*(a-1))';'y22=a*x22/(1+x22*(a-1))';'y23=a*x23/(1+x4*(a-1))'};

EQUI=EQ(1:N+1)

Como ves, lo unico que hago es crear una matriz con las ecuaciones para N=23 (en este caso, aunque podria ser mas) y coger las que me interesan para la N dada.

El problema como dije arriba es que una vez escogidas todas las ecuaciones, no se como meterlas en la funcion solve para que las resuelva.

Gracias por vuestro tiempo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Resolver sistema con N ecuaciones

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 10/04/2012 18:59:52
Hola Pablo.
Con la informacional que me haz dado, solo puedo ayudarte a hasta este punto.
Me hablas de solve, para utilizar necesitas saber, cuales son tus varibles dependientes y cuales son tus variables independientes. Con la informacion que brindas no puedo deducir tales variables.
Asi como yo me doy un tiempo para contestar a las personas sus preguntas, bueno me gustaria tambien que pusieras toda la informacion de toda las ecuaciones, asi de esta manera poder ver los posibles errores del script que haz hecho y arreglarlo y utlilizar la funcion solve.



1
2
3
4
5
6
N=23;
EQ={'yw=a*xw/(1+xw*(a-1))' };
for i=1:N
    EQ=[EQ;{['y',num2str(i),'=a*x',num2str(i),'/(1+x',num2str(i),'*(a-1))']}];
end
EQ


eL codigo anterior hace los mismo que tu haz hecho, pero en forma comprimida y N puede tomar cualquier valor natural positivo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
EJECUCION
EQ =
 
    'yw=a*xw/(1+xw*(a-1))'
    'y1=a*x1/(1+x1*(a-1))'
    'y2=a*x2/(1+x2*(a-1))'
    'y3=a*x3/(1+x3*(a-1))'
    'y4=a*x4/(1+x4*(a-1))'
    'y5=a*x5/(1+x5*(a-1))'
    'y6=a*x6/(1+x6*(a-1))'
    'y7=a*x7/(1+x7*(a-1))'
    'y8=a*x8/(1+x8*(a-1))'
    'y9=a*x9/(1+x9*(a-1))'
    'y10=a*x10/(1+x10*(a-1))'
    'y11=a*x11/(1+x11*(a-1))'
    'y12=a*x12/(1+x12*(a-1))'
    'y13=a*x13/(1+x13*(a-1))'
    'y14=a*x14/(1+x14*(a-1))'
    'y15=a*x15/(1+x15*(a-1))'
    'y16=a*x16/(1+x16*(a-1))'
    'y17=a*x17/(1+x17*(a-1))'
    'y18=a*x18/(1+x18*(a-1))'
    'y19=a*x19/(1+x19*(a-1))'
    'y20=a*x20/(1+x20*(a-1))'
    'y21=a*x21/(1+x21*(a-1))'
    'y22=a*x22/(1+x22*(a-1))'
    'y23=a*x23/(1+x23*(a-1))'




Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
programador en matlab
Servicios de programacion matla
[email protected]

http://matlabcaballero.blogspot.com/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Resolver sistema con N ecuaciones

Publicado por Pablo (8 intervenciones) el 11/04/2012 11:38:17
Hola, gracias por la respuesta.

Veamos, no puse todo el script porque pense que seria mejor simplificar un poco el problema.
Este seria el script completo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
N=input('Introduzca el valor de N ---> ');
M=input('Introduzca el valor de M ---> ');
 
ECr1={'L/V=(y1-y2)/(x0-x1)';'L/V=(y2-y3)/(x1-x2)';'L/V=(y3-y4)/(x2-x3)';'L/V=(y4-y5)/(x3-x4)';'L/V=(y5-y6)/(x4-x5)';'L/V=(y6-y7)/(x5-x6)'
    'L/V=(y7-y8)/(x6-x7)';'L/V=(y8-y9)/(x7-x8)';'L/V=(y9-y10)/(x8-x9)';'L/V=(y10-y11)/(x9-x10)';'L/V=(y11-y12)/(x10-x11)';'L/V=(y12-y13)/(x11-x12)'
    'L/V=(y13-y14)/(x12-x13)';'L/V=(y14-y15)/(x13-x14)';'L/V=(y15-y16)/(x14-x15)';'L/V=(y16-y17)/(x15-x16)';'L/V=(y17-y18)/(x16-x17)';'L/V=(y18-y19)/(x17-x18)'
    'L/V=(y19-y20)/(x18-x19)';'L/V=(y20-y21)/(x19-x20)';'L/V=(y21-y22)/(x20-x21)';'L/V=(y22-y23)/(x21-x22)';'L/V=(y23-y24)/(x22-x23)';'L/V=(y24-y25)/(x23-x24)'};
 
ECr2={'L/V=(y1-y2a)/(x0-x1)';'L/V=(y2-y3a)/(x1-x2)';'L/V=(y3-y4a)/(x2-x3)';'L/V=(y4-y5a)/(x3-x4)';'L/V=(y5-y6a)/(x4-x5)';'L/V=(y6-y7a)/(x5-x6)'
    'L/V=(y7-y8a)/(x6-x7)';'L/V=(y8-y9a)/(x7-x8)';'L/V=(y9-y10a)/(x8-x9)';'L/V=(y10-y11a)/(x9-x10)';'L/V=(y11-y12a)/(x10-x11)';'L/V=(y12-y13a)/(x11-x12)'
    'L/V=(y13-y14a)/(x12-x13)';'L/V=(y14-y15a)/(x13-x14)';'L/V=(y15-y16a)/(x14-x15)';'L/V=(y16-y17a)/(x15-x16)';'L/V=(y17-y18a)/(x16-x17)';'L/V=(y18-y19a)/(x17-x18)'
    'L/V=(y19-y20a)/(x18-x19)';'L/V=(y20-y21a)/(x19-x20)';'L/V=(y21-y22a)/(x20-x21)';'L/V=(y22-y23a)/(x21-x22)';'L/V=(y23-y24a)/(x22-x23)';'L/V=(y24-y25a)/(x23-x24)'};
 
ECa1={'l/v=(y1-y2)/(x0-x1)';'l/v=(y2-y3)/(x1-x2)';'l/v=(y3-y4)/(x2-x3)';'l/v=(y4-y5)/(x3-x4)';'l/v=(y5-y6)/(x4-x5)';'l/v=(y6-y7)/(x5-x6)'
    'l/v=(y7-y8)/(x6-x7)';'l/v=(y8-y9)/(x7-x8)';'l/v=(y9-y10)/(x8-x9)';'l/v=(y10-y11)/(x9-x10)';'l/v=(y11-y12)/(x10-x11)';'l/v=(y12-y13)/(x11-x12)'
    'l/v=(y13-y14)/(x12-x13)';'l/v=(y14-y15)/(x13-x14)';'l/v=(y15-y16)/(x14-x15)';'l/v=(y16-y17)/(x15-x16)';'l/v=(y17-y18)/(x16-x17)';'l/v=(y18-y19)/(x17-x18)'
    'l/v=(y19-y20)/(x18-x19)';'l/v=(y20-y21)/(x19-x20)';'l/v=(y21-y22)/(x20-x21)';'l/v=(y22-y23)/(x21-x22)';'l/v=(y23-y24)/(x22-x23)';'l/v=(y24-y25)/(x23-x24)'};
 
ECa2={'l/v=(y1-y2)/(x0a-x1)';'l/v=(y2-y3)/(x1a-x2)';'l/v=(y3-y4)/(x2a-x3)';'l/v=(y4-y5)/(x3a-x4)';'l/v=(y5-y6)/(x4a-x5)';'l/v=(y6-y7)/(x5a-x6)'
    'l/v=(y7-y8)/(x6a-x7)';'l/v=(y8-y9)/(x7a-x8)';'l/v=(y9-y10)/(x8a-x9)';'l/v=(y10-y11)/(x9a-x10)';'l/v=(y11-y12)/(x10a-x11)';'l/v=(y12-y13)/(x11a-x12)'
    'l/v=(y13-y14)/(x12a-x13)';'l/v=(y14-y15)/(x13a-x14)';'l/v=(y15-y16)/(x14a-x15)';'l/v=(y16-y17)/(x15a-x16)';'l/v=(y17-y18)/(x16a-x17)';'l/v=(y18-y19)/(x17a-x18)'
    'l/v=(y19-y20)/(x18a-x19)';'l/v=(y20-y21)/(x19a-x20)';'l/v=(y21-y22)/(x20a-x21)';'l/v=(y22-y23)/(x21a-x22)';'l/v=(y23-y24)/(x22a-x23)';'l/v=(y24-y25)/(x23a-x24)'};
 
ECa3={'l/v=(y1-yw)/(x0-x1)';'l/v=(y2-yw)/(x1-x2)';'l/v=(y3-yw)/(x2-x3)';'l/v=(y4-yw)/(x3-x4)';'l/v=(y5-yw)/(x4-x5)';'l/v=(y6-yw)/(x5-x6)'
    'l/v=(y7-yw)/(x6-x7)';'l/v=(y8-yw)/(x7-x8)';'l/v=(y9-yw)/(x8-x9)';'l/v=(y10-yw)/(x9-x10)';'l/v=(y11-yw)/(x10-x11)';'l/v=(y12-yw)/(x11-x12)'
    'l/v=(y13-yw)/(x12-x13)';'l/v=(y14-yw)/(x13-x14)';'l/v=(y15-yw)/(x14-x15)';'l/v=(y16-yw)/(x15-x16)';'l/v=(y17-yw)/(x16-x17)';'l/v=(y18-yw)/(x17-x18)'
    'l/v=(y19-yw)/(x18-x19)';'l/v=(y20-yw)/(x19-x20)';'l/v=(y21-yw)/(x20-x21)';'l/v=(y22-yw)/(x21-x22)';'l/v=(y23-yw)/(x22-x23)';'l/v=(y24-yw)/(x23-x24)'};
 
REC1=ECr1(1:N-1);
REC2=ECr2(N);
REC=[REC1;REC2]
AGO1=ECa1(N+2:M+N-1);
AGO2=ECa2(N+1);
AGO3=ECa3(M+N);
AGO=[AGO2;AGO1;AGO3]
 
ECal1={'x1a=(L*x1+q*F*xf)/l';'x2a=(L*x2+q*F*xf)/l';'x3a=(L*x3+q*F*xf)/l';'x4a=(L*x4+q*F*xf)/l';'x5a=(L*x5+q*F*xf)/l';'x6a=(L*x6+q*F*xf)/l';
    'x7a=(L*x7+q*F*xf)/l';'x8a=(L*x8+q*F*xf)/l';'x9a=(L*x9+q*F*xf)/l';'x10a=(L*x10+q*F*xf)/l';'x11a=(L*x11+q*F*xf)/l';'x12a=(L*x12+q*F*xf)/l';
    'x13a=(L*x13+q*F*xf)/l';'x14a=(L*x14+q*F*xf)/l';'x15a=(L*x15+q*F*xf)/l';'x16a=(L*x16+q*F*xf)/l';'x17a=(L*x17+q*F*xf)/l';'x18a=(L*x18+q*F*xf)/l';
    'x19a=(L*x19+q*F*xf)/l';'x20a=(L*x20+q*F*xf)/l';'x21a=(L*x21+q*F*xf)/l';'x22a=(L*x22+q*F*xf)/l';'x23a=(L*x23+q*F*xf)/l';'x24a=(L*x24+q*F*xf)/l'};
 
ECal2={'y1a=(v*y1+(1-q)*F*xf)/V';'y2a=(v*y2+(1-q)*F*xf)/V';'y3a=(v*y3+(1-q)*F*xf)/V';'y4a=(v*y4+(1-q)*F*xf)/V';'y5a=(v*y5+(1-q)*F*xf)/V';'y6a=(v*y6+(1-q)*F*xf)/V';
    'y7a=(v*y7+(1-q)*F*xf)/V';'y8a=(v*y8+(1-q)*F*xf)/V';'y9a=(v*y9+(1-q)*F*xf)/V';'y10a=(v*y10+(1-q)*F*xf)/V';'y11a=(v*y11+(1-q)*F*xf)/V';'y12a=(v*y12+(1-q)*F*xf)/V';
    'y13a=(v*y13+(1-q)*F*xf)/V';'y14a=(v*y14+(1-q)*F*xf)/V';'y15a=(v*y15+(1-q)*F*xf)/V';'y16a=(v*y16+(1-q)*F*xf)/V';'y17a=(v*y17+(1-q)*F*xf)/V';'y18a=(v*y18+(1-q)*F*xf)/V';
    'y19a=(v*y19+(1-q)*F*xf)/V';'y20a=(v*y20+(1-q)*F*xf)/V';'y21a=(v*y21+(1-q)*F*xf)/V';'y22a=(v*y22+(1-q)*F*xf)/V';'y23a=(v*y23+(1-q)*F*xf)/V';'y24a=(v*y24+(1-q)*F*xf)/V'};
 
ALI1=ECal1(N);
ALI2=ECal2(N+1);
 
ALI=[ALI1;ALI2]
 
EQ={'yw=a*xw/(1+xw*(a-1))';'y1=a*x1/(1+x1*(a-1))';'y2=a*x2/(1+x2*(a-1))';'y3=a*x3/(1+x3*(a-1))';'y4=a*x4/(1+x4*(a-1))';
'y5=a*x5/(1+x5*(a-1))';'y6=a*x6/(1+x6*(a-1))';'y7=a*x7/(1+x7*(a-1))';'y8=a*x8/(1+x8*(a-1))';'y9=a*x9/(1+x9*(a-1))';'y10=a*x10/(1+x10*(a-1))';
'y11=a*x11/(1+x11*(a-1))';'y12=a*x12/(1+x12*(a-1))';'y13=a*x13/(1+x13*(a-1))';'y14=a*x14/(1+x14*(a-1))';'y15=a*x15/(1+x15*(a-1))';'y16=a*x16/(1+x16*(a-1))';
'y17=a*x17/(1+x17*(a-1))';'y18=a*x18/(1+x18*(a-1))';'y19=a*x19/(1+x19*(a-1))';'y20=a*x20/(1+x20*(a-1))';'y21=a*x21/(1+x21*(a-1))';'y22=a*x22/(1+x22*(a-1))';'y23=a*x23/(1+x4*(a-1))'};
 
EQUI=EQ(1:N+M+1)
 
ECcal={'xw=(l*x1-v*yw)/W';'xw=(l*x2-v*yw)/W';'xw=(l*x3-v*yw)/W';'xw=(l*x4-v*yw)/W';'xw=(l*x5-v*yw)/W';'xw=(l*x6-v*yw)/W';
    'xw=(l*x7-v*yw)/W';'xw=(l*x8-v*yw)/W';'xw=(l*x9-v*yw)/W';'xw=(l*x10-v*yw)/W';'xw=(l*x11-v*yw)/W';'xw=(l*x12-v*yw)/W';
    'xw=(l*x13-v*yw)/W';'xw=(l*x14-v*yw)/W';'xw=(l*x15-v*yw)/W';'xw=(l*x16-v*yw)/W';'xw=(l*x17-v*yw)/W';'xw=(l*x18-v*yw)/W';
    'xw=(l*x19-v*yw)/W';'xw=(l*x20-v*yw)/W';'xw=(l*x21-v*yw)/W';'xw=(l*x22-v*yw)/W';'xw=(l*x23-v*yw)/W';'xw=(l*x24-v*yw)/W'};
 
CAL=ECcal(N+M)
 
CON={'d*xd+L*x0=V*y1';'xd=x0'}


La idea es crear otro script que tome las ecuaciones generadas, y los siguientes datos: F, xf, q, L, V, l, v, d, W y a.

Las incognitas serían: x1, x2,....xN+M, y1, y2,....yN+M, xw, yw, xd, x0, xNa, y(N+1)a

Mi problema es que para resolver el sistema, primero creo las ecuaciones y luego tengo que ir metiendo una a una todas las ecuaciones en la funcion solve, asi:

SOL=solve(eq1,eq2,.....,'F=30','xf=0.8',....)

La pregunta es si hay alguna forma de introducir en la funcion solve todas las ecuaciones y los valores de las variables sin tener que teclearlas.

De nuevo gracias por su tiempo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Resolver sistema con N ecuaciones

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 11/04/2012 15:21:53
Hola Pablo
La respuesta es, si se puede introducir a la funcion solve.
Hay dos formas. Creando un bucle de tus ecuaciones y la otra forma es importando las funciones desde un archivo de texto.
Si deseas mayor información, puedes comunicarte via online, opcion audio para mayor informacion, ya que con la información hasta el momento haz brindado tengo varios dudas. Para hacer un codigo a tu pregunta. Mi objetivo es hacer un codigo a tu pregunta, por eso motivo necesito todo la informacion posible.



Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
programador en matlab
Servicios de programacion matla
[email protected]

http://matlabcaballero.blogspot.com/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Resolver sistema con N ecuaciones

Publicado por Pablo (8 intervenciones) el 12/04/2012 17:47:40
Hola.

Primero de todo gracias por tu interes.

No entiendo como crear un bucle, ¿podrías poner algun ejemplo sencillo para ver si lo entiendo?

En cuanto a más información, tampoco se ha que te refieres es un sistema de ecuaciones que depende de los valores de N y M, simplemente esta limitado con ecuaciones predefinidas hasta N+M=23, si funcionara quiza lo ampliara para más rango.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

resolver un sistema de ecuaciones con n incongnitas

Publicado por gibson (1 intervención) el 08/01/2014 03:59:01
xfavor como hago en matlab un un sistema de ecuaciones con n incongnitas
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar