How to solve an equation with the variable on both RHS and LHS?
9 views (last 30 days)
Show older comments
Khanak Saxena
on 4 Sep 2020
Commented: Khanak Saxena
on 4 Sep 2020
I have an equation with 2 variables, however, one variable is present on both the LHS and the RHS, on the RHS it is raised to a fractional power usually between 0 and 1, here, it is raised to 0.615.
I would like one variable as an equation of the other. I have tried to plot it, by saving values in seperate vectors, but since both vectors are of different sizes, the plot is unsuccessful.
I am trying to code this particular, equation where only Gf_bar and w_bar are variables, everything else is a constant. Ideally, I would like an equation of Gf_bar in terms of w_bar. I tried to plot Gf_bar against w_bar and fit a curve to obtain the equation.
As is seen, clearly, Gfbar and wbar are vectors but of different lengths. I would like to know how to solve this.
4 Comments
Alan Stevens
on 4 Sep 2020
Edited: Alan Stevens
on 4 Sep 2020
There is almost certainly no symbolic solution here. You don't need a symbolic solution to find values of Gbar for various values of wbar. See below.
Accepted Answer
Alan Stevens
on 4 Sep 2020
Like this for example (obviously, you will need to replace my arbitrary data with your actual data):
OF = 2.4;
wbar = linspace(0,1,100);
n = 0.615;
G0 = 0.1;
Gbar = zeros(1,numel(wbar));
for k = 1:numel(wbar)
Gbar(k)= fzero(@Gbarfn,G0,[],wbar(k),OF,n);
end
plot(wbar,Gbar), grid
xlabel('wbar'),ylabel('Gbar')
function F = Gbarfn(G,wbar,OF,n)
c1 = 1/(OF + 1)^n;
c2 = 4 + 2*pi*wbar;
c3 = 1 + 4*wbar +pi*wbar.^2;
c4 = 1./(1 + 4*wbar + 4*wbar.^2);
F = c1*( OF*c4 - G ).^n*c2./c3 - G;
end
3 Comments
Alan Stevens
on 4 Sep 2020
G0 is simply an initial guess for Gbar, required by fzero. Each time fzero is called it needs an initial guess for the parameter it is solving for. I've used the same initial guess for each Gbar, though that isn't essential.
The [] is a placeholder in case one wants to specify any non default options (like a tighter tolerance for example). See fzero documentation for details.
More Answers (0)
See Also
Categories
Find more on Argument Definitions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!