http://nl.mathworks.com/matlabcentral/newsreader/view_thread/296426
MATLAB Central Newsreader  How to solve for system of equation with set of known variables?
Feed for thread: How to solve for system of equation with set of known variables?
enus
©19942017 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://nl.mathworks.com/images/membrane_icon.gif

Mon, 15 Nov 2010 00:47:03 +0000
How to solve for system of equation with set of known variables?
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/296426#796112
Michal Kolaj
Hello all, I am a selftaught programmer and I am having a problem with the following:<br>
<br>
So I need to solve for 2 variables, I have 2 equations. Easy enough... but:<br>
<br>
In each of the 2 equations i have another 2 variables which I know and have a large list of. I need some sort of code to solve the system of equations for the two unknown variables for the entire list of known variables (like a loop statement)<br>
<br>
my equations:<br>
<br>
RH=sqrt(4*z^2+1)2*z;<br>
RV=1/sqrt(4*z^2+1);<br>
VD=c*(1RV)<br>
HD=c*(1RH) <br>
<br>
I have vectors for both VD and HD (my known variables)<br>
<br>
How do i cycle through solutions for z,c for each pair of VD HD ?<br>
<br>
I can solve for any specific VD,HD pair using the solve function or fsolve but I do not know how to include a loop statement in this in order to solve for the full list of VD and HD vectors.<br>
<br>
Any help would be appreciated.<br>


Mon, 15 Nov 2010 01:06:03 +0000
Re: How to solve for system of equation with set of known variables?
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/296426#796115
Michal Kolaj
Solved:<br>
<br>
function F = conductivity(H,V)<br>
syms c z <br>
f1=((1/(4*(z^2)+1)^(1/2)))((Vc)/(c));<br>
f2=(((4*(z^2)+1)^(1/2))(2*z))((Hc)/(c));<br>
F=solve(f1,f2);<br>
end<br>
<br>
then:<br>
<br>
for n=1:71<br>
p(n)=conductivity(H(n),V(n))<br>
end<br>
<br>
Sorry if I wasted anyones time.

Mon, 15 Nov 2010 01:38:03 +0000
Re: How to solve for system of equation with set of known variables?
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/296426#796121
Roger Stafford
"Michal Kolaj" <toomanybullets@hotmail.com> wrote in message <ibpvu7$iot$1@fred.mathworks.com>...<br>
> Hello all, I am a selftaught programmer and I am having a problem with the following:<br>
> <br>
> So I need to solve for 2 variables, I have 2 equations. Easy enough... but:<br>
> <br>
> In each of the 2 equations i have another 2 variables which I know and have a large list of. I need some sort of code to solve the system of equations for the two unknown variables for the entire list of known variables (like a loop statement)<br>
> <br>
> my equations:<br>
> <br>
> RH=sqrt(4*z^2+1)2*z;<br>
> RV=1/sqrt(4*z^2+1);<br>
> VD=c*(1RV)<br>
> HD=c*(1RH) <br>
> <br>
> I have vectors for both VD and HD (my known variables)<br>
> <br>
> How do i cycle through solutions for z,c for each pair of VD HD ?<br>
> <br>
> I can solve for any specific VD,HD pair using the solve function or fsolve but I do not know how to include a loop statement in this in order to solve for the full list of VD and HD vectors.<br>
> <br>
> Any help would be appreciated.<br>
> <br>
        <br>
I don't think you need to use a forloop. If you take the ratio VD/HD, this leads after some manipulation to a quadratic equation in z (after discarding the z = 0 root) which has two roots that have explicit solution expressions in terms of the above ratio. You could evaluate this as a vectorized solution for a list of VD and HD vectors. The value c can easily be obtained from this.<br>
<br>
Roger Stafford