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 help

Subject: solve help

From: ZACHARY HULL

Date: 22 Jun, 2013 17:54:11

Message: 1 of 5

Good day all,

I am working a problem that requires me to use the 'solve' function of matlab.

The script below is what I solving for:

t = linspace(0,pi,200);
ft = exp(sin(t));
%plot(t,ft)
ft_max = max(ft);
t_max = max(t);
tf = asin(log(ft_max));
display(['The extremum is located at (',num2str(tf),',',num2str(ft_max),') and it is a maximum.'])

ans =
The extremum is located at (1.5629,2.7182) and it is a maximum.

This is solving the problem without the use of the solve function.
____________________________________________________________
However, when I attempt to use 'solve' (required for the problem) the equation ft below for variable t, this is my result:

(script)
syms t
t = linspace(0,pi,200);
ft = exp(sin(t));
tf = solve(ft,t)

result =
Error using message
In 'symbolic:solve:errmsg1', parameter {1} must be a scalar.
Error in solve>processString (line 354)
      error(message('symbolic:solve:errmsg1', v))
Error in solve>getEqns (line 284)
      eqns = processString(eqns, v, vc);
Error in solve (line 160)
[eqns,vars,options] = getEqns(varargin{:});

Any help you all can provide would be appreciated! Thanks!

Subject: solve help

From: Nasser M. Abbasi

Date: 22 Jun, 2013 20:09:33

Message: 2 of 5

On 6/22/2013 12:54 PM, ZACHARY HULL wrote:

> (script)
> syms t
> t = linspace(0,pi,200);
> ft = exp(sin(t));
> tf = solve(ft,t)
>
> result =
> Error using message
> In 'symbolic:solve:errmsg1', parameter {1} must be a scalar.
> Error in solve>processString (line 354)

> Any help you all can provide would be appreciated! Thanks!
>

I have no idea at all really what is it you are trying to do,

In what you wrote, ft is just a list of numbers. So you are
asking solve to do this solve(list_of_numbers==0,t).

But if you are trying to find solution to exp(x)==0
then there is no solution.

What value of 't' you think will make exp(sin(t)) zero?
sin(t) is between -1 and +1. So, just plot exp() between these
2 values and you'll see it is not zero.

You have to go to -infinity and beyond to have any luck of
making exp() in the limit go to zero.

--Nasser

Subject: solve help

From: ZACHARY HULL

Date: 23 Jun, 2013 00:01:19

Message: 3 of 5

"Nasser M. Abbasi" wrote in message <kq50a0$i4h$1@speranza.aioe.org>...
> On 6/22/2013 12:54 PM, ZACHARY HULL wrote:
>
> > (script)
> > syms t
> > t = linspace(0,pi,200);
> > ft = exp(sin(t));
> > tf = solve(ft,t)
> >
> > result =
> > Error using message
> > In 'symbolic:solve:errmsg1', parameter {1} must be a scalar.
> > Error in solve>processString (line 354)
>
> > Any help you all can provide would be appreciated! Thanks!
> >
>
> I have no idea at all really what is it you are trying to do,
>
> In what you wrote, ft is just a list of numbers. So you are
> asking solve to do this solve(list_of_numbers==0,t).
>
> But if you are trying to find solution to exp(x)==0
> then there is no solution.
>
> What value of 't' you think will make exp(sin(t)) zero?
> sin(t) is between -1 and +1. So, just plot exp() between these
> 2 values and you'll see it is not zero.
>
> You have to go to -infinity and beyond to have any luck of
> making exp() in the limit go to zero.
>
> --Nasser

I am using the solve function to solve the equation ft for t

clc, clear;
syms t ft
ft = exp(sin(t));
solve(ft,t)

However, the result of this ^^^ is as follows:

Warning: Explicit solution could not be found.
> In solve at 179
ans =
[ empty sym ]

I don't want to solve the equation for a value, but a variable. I want the equation t with respect to ft. Is this any clearer now?

Subject: solve help

From: Nasser M. Abbasi

Date: 23 Jun, 2013 00:53:44

Message: 4 of 5


>>
>> What value of 't' you think will make exp(sin(t)) zero?
>> sin(t) is between -1 and +1. So, just plot exp() between these
>> 2 values and you'll see it is not zero.
>>
>> You have to go to -infinity and beyond to have any luck of
>> making exp() in the limit go to zero.
>>
>> --Nasser


>
> I am using the solve function to solve the equation ft for t
>
> clc, clear;
> syms t ft
> ft = exp(sin(t));
> solve(ft,t)
>
> However, the result of this ^^^ is as follows:
>
> Warning: Explicit solution could not be found.
>> In solve at 179
> ans =
> [ empty sym ]
>
> I don't want to solve the equation for a value, but a variable.
>I want the equation t with respect to ft. Is this any clearer now?
>

Thank you so much, yes, much more clear now.

But the answer is still the same I am afraid. Please re-read what
I wrote earlier.

There is no solution to exp(sin(t))=0, in other words, there is
no 't' which will make exp(sin(t)) zero.

Did you try to plot exp(x) for x=-1..1 ? did you see exp(x)
cross the x-axis anywhere? It does not. So there is no solution,
it is never zero.

--Nasser

Subject: solve help

From: Steven_Lord

Date: 24 Jun, 2013 14:59:10

Message: 5 of 5



"ZACHARY HULL" <grasshopper5@hotmail.com> wrote in message
news:kq4oc3$jg3$1@newscl01ah.mathworks.com...
> Good day all,
>
> I am working a problem that requires me to use the 'solve' function of
> matlab.
>
> The script below is what I solving for:
>
> t = linspace(0,pi,200);
> ft = exp(sin(t));
> %plot(t,ft)
> ft_max = max(ft);
> t_max = max(t);
> tf = asin(log(ft_max));
> display(['The extremum is located at (',num2str(tf),',',num2str(ft_max),')
> and it is a maximum.'])
>
> ans = The extremum is located at (1.5629,2.7182) and it is a maximum.
>
> This is solving the problem without the use of the solve function.
> ____________________________________________________________
> However, when I attempt to use 'solve' (required for the problem) the
> equation ft below for variable t, this is my result:
>
> (script)
> syms t
> t = linspace(0,pi,200);

This assignment to t makes it numeric again. It is no longer symbolic after
this line. That means:

> ft = exp(sin(t));

ft is also numeric, and this:

> tf = solve(ft,t)

attempts to solve for the solution of a vector of numbers with the
independent variable also a vector of numbers.

But even if you removed the line where you assigned LINSPACE into t, it
wouldn't work. Your equation has no real solution. For real finite z, exp(z)
is always positive. Well, in double precision it can underflow. But you
can't generate a value that would cause exp(z) to underflow when z is
computed as sin(t) unless t is complex.

--
Steve Lord
slord@mathworks.com
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