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:
Equation - how to solve it

Subject: Equation - how to solve it

From: news.neostrada.pl

Date: 23 Jan, 2009 18:01:49

Message: 1 of 2

Sorry for my language mistakes - It's not my mother language.

I try to write script which find roots of this equation
f(H)=Q-(and there is http://en.wikipedia.org/wiki/Manning_formula)
using http://en.wikipedia.org/wiki/Secant_method

So I input Q and other constants and I want find H.
Unfortunately, it's result in COMPLEX numbers.
What's wrong?


====================
function [h]=glebokosc_norm(Q,s,n,B,M,H)
R=((B*H+M*(H.^2))./(B+2.*H.*((1+(M.^2)).^(1./2)))).^(2./3);
A=B.*H+M.*(H.^(1./2));
Q_oblicz=(s.^0.5).*A.*R./n;
h=Q-Q_oblicz;
===================
Q=input('Podaj wydatek Q= ');
s=input('Podaj spadek linii energii s= ');
M=input('Podaj nachylenie skarp M= ');
B=input('Podaj szeroko

Subject: Equation - how to solve it

From: Roger Stafford

Date: 23 Jan, 2009 20:34:02

Message: 2 of 2

"news.neostrada.pl" <guru59622cfr34ff@hotmail.com> wrote in message <gld0td$3oh$1@atlantis.news.neostrada.pl>...
> Sorry for my language mistakes - It's not my mother language.
>
> I try to write script which find roots of this equation
> f(H)=Q-(and there is http://en.wikipedia.org/wiki/Manning_formula)
> using http://en.wikipedia.org/wiki/Secant_method
>
> So I input Q and other constants and I want find H.
> Unfortunately, it's result in COMPLEX numbers.
> What's wrong?
>
> ====================
> function [h]=glebokosc_norm(Q,s,n,B,M,H)
> R=((B*H+M*(H.^2))./(B+2.*H.*((1+(M.^2)).^(1./2)))).^(2./3);
> A=B.*H+M.*(H.^(1./2));
> Q_oblicz=(s.^0.5).*A.*R./n;
> h=Q-Q_oblicz;
> ===================
> Q=input('Podaj wydatek Q= ');
> s=input('Podaj spadek linii energii s= ');
> M=input('Podaj nachylenie skarp M= ');
> B=input('Podaj szeroko

  You are getting complex values because somewhere you are taking either the 1/2 power or the 2/3 power of a negative number. Better check each stage of your computation to find out where this is occurring.

Roger Stafford

Tags for this Thread

No tags are associated with 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