Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
solve ( )

Subject: solve ( )

From: Abhishek

Date: 20 Jul, 2010 10:37:03

Message: 1 of 4

hi
this is the file from which i am reading the data
12,'z','x','o','p','q','r','s','t','u','v','w','T','A*p+B*u','y*p+D*q+E*r+F*s','G*q+H*r+I*t','J*q+K*s+L*x','M*r+N*o+O*t+2*x*P','2*x*Q+R*o+S1*s+P*t+U*T+V*z','W*o+N*t+X*T+R*2*x+Y*v','d*w+e*v+f*u','g*u+h*p+i*w+j*v','k*v+l*o+m*w+n*u','Z*T+2*x*a+b*z+c*o'

using
fid=fopen('/sim/TLV1117LV_DS/x0138322/scripts/userinput.m');
while(1)
    tline1 =fgetl(fid);
   
  %if (tline1 == -1), break, end
    if isempty(tline1), break, end
    
     TL1 =sym(tline1);
end
  eq1=TL1(14);
eq2=TL1(15);
eq3=TL1(16);
eq4=TL1(17);
eq5=TL1(18);
eq6=TL1(19);
eq7=TL1(20);
eq8=TL1(21);
eq9=TL1(22);
eq10=TL1(23);
eq11=TL1(24);S=solve(eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,TL1(3),TL1(4),TL1(5),TL1(6),TL1(7),TL1(8),TL1(9),TL1(10),TL1(11),TL1(12),TL1(13));
it run succesfully but i want the value of each varible
for which i did
S.TL1(8)
which gives error as
??? Access to an object's fields is only permitted within its methods.

Please tell me a way to get value of each varible from solve

Thank you in advance

Subject: solve ( )

From: Abhishek

Date: 20 Jul, 2010 11:13:04

Message: 2 of 4

"Abhishek " <abhi14jan@yahoo.com> wrote in message <i23u8f$f5l$1@fred.mathworks.com>...
> hi
> this is the file from which i am reading the data
> 12,'z','x','o','p','q','r','s','t','u','v','w','T','A*p+B*u','y*p+D*q+E*r+F*s','G*q+H*r+I*t','J*q+K*s+L*x','M*r+N*o+O*t+2*x*P','2*x*Q+R*o+S1*s+P*t+U*T+V*z','W*o+N*t+X*T+R*2*x+Y*v','d*w+e*v+f*u','g*u+h*p+i*w+j*v','k*v+l*o+m*w+n*u','Z*T+2*x*a+b*z+c*o'
>
> using
> fid=fopen('/sim/TLV1117LV_DS/x0138322/scripts/userinput.m');
> while(1)
> tline1 =fgetl(fid);
>
> %if (tline1 == -1), break, end
> if isempty(tline1), break, end
>
> TL1 =sym(tline1);
> end
> eq1=TL1(14);
> eq2=TL1(15);
> eq3=TL1(16);
> eq4=TL1(17);
> eq5=TL1(18);
> eq6=TL1(19);
> eq7=TL1(20);
> eq8=TL1(21);
> eq9=TL1(22);
> eq10=TL1(23);
> eq11=TL1(24);S=solve(eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,TL1(3),TL1(4),TL1(5),TL1(6),TL1(7),TL1(8),TL1(9),TL1(10),TL1(11),TL1(12),TL1(13));
> it run succesfully but i want the value of each varible
> for which i did
> S.TL1(8)
> which gives error as
> ??? Access to an object's fields is only permitted within its methods.
>
> Please tell me a way to get value of each varible from solve
>
> Thank you in advance
tell the solution please;;;;;

Subject: solve ( )

From: Sean

Date: 20 Jul, 2010 12:37:04

Message: 3 of 4

"Abhishek " <abhi14jan@yahoo.com> wrote in message \
> tell the solution please;;;;;

You didn't get a reply in 36 minutes and are throwing a tantrum? I'm sorry, but I don't think that makes you a top priority for other newsreaders.

Subject: solve ( )

From: Steven_Lord

Date: 20 Jul, 2010 13:18:36

Message: 4 of 4



"Abhishek " <abhi14jan@yahoo.com> wrote in message
news:i23u8f$f5l$1@fred.mathworks.com...
> hi this is the file from which i am reading the data
> 12,'z','x','o','p','q','r','s','t','u','v','w','T','A*p+B*u','y*p+D*q+E*r+F*s','G*q+H*r+I*t','J*q+K*s+L*x','M*r+N*o+O*t+2*x*P','2*x*Q+R*o+S1*s+P*t+U*T+V*z','W*o+N*t+X*T+R*2*x+Y*v','d*w+e*v+f*u','g*u+h*p+i*w+j*v','k*v+l*o+m*w+n*u','Z*T+2*x*a+b*z+c*o'
>
> using
> fid=fopen('/sim/TLV1117LV_DS/x0138322/scripts/userinput.m');

Instead of writing a file that you then need to read using FOPEN, FGETL,
etc. why not simply write a script file you can _execute_ to define your
expressions? The contents would be something like:


syms z x o p q r s t u v w T
eq = cell(1, 11);
eq{1} = someSymbolicExpression1;
eq{2} = someSymbolicExpression2;
% etc.

variablesToSolveFor = {z, x, o, p, q, r, s, t, u, v, w}
solution = solve(eq{:}, variablesToSolveFor{:});


To extract a particular variable, convert the symbolic variable from
variablesToSolveFor into the char array containing its name using the CHAR
method, then use dynamic field names.

solution.(char(variablesToSolveFor{4})) % Returns solution.p

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us