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:
ploting in db

Subject: ploting in db

From: Yousef

Date: 19 Mar, 2013 15:58:10

Message: 1 of 9

Hi Guys,

Can anybody help me to change my y-axis to (db) logarithmic scale..
part of my code looks like:


c=sqrt(abs(data(:,2)).^2 + abs(data(:,3)).^2);
b=data(:,1);
tmp=folderContents(i,:);
plot(b,c,'red');

BUT: I do not want to choose some commands like semilogy, loglog ...etc
Tanks in advance for your help.......

Subject: ploting in db

From: Steven_Lord

Date: 19 Mar, 2013 17:05:24

Message: 2 of 9



"Yousef " <yayatoure@hotmail.com> wrote in message
news:kia1ui$9hl$1@newscl01ah.mathworks.com...
> Hi Guys,
>
> Can anybody help me to change my y-axis to (db) logarithmic scale..
> part of my code looks like:
>
>
> c=sqrt(abs(data(:,2)).^2 + abs(data(:,3)).^2);
> b=data(:,1);
> tmp=folderContents(i,:);
> plot(b,c,'red');
> BUT: I do not want to choose some commands like semilogy, loglog ...etc
> Tanks in advance for your help.......

SET the YScale property of your axes to 'log' and it will change to
logarithmic scale.

http://www.mathworks.com/help/matlab/ref/axes_props.html#XScale

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: ploting in db

From: dpb

Date: 19 Mar, 2013 18:21:39

Message: 3 of 9

On 3/19/2013 12:05 PM, Steven_Lord wrote:
>
>
> "Yousef " <yayatoure@hotmail.com> wrote in message
> news:kia1ui$9hl$1@newscl01ah.mathworks.com...
>> Hi Guys,
>>
>> Can anybody help me to change my y-axis to (db) logarithmic scale..
>> part of my code looks like:
>>
>>
>> c=sqrt(abs(data(:,2)).^2 + abs(data(:,3)).^2);
...

Steven answered the axis question, I'll simply note that the above can
be written more succinctly as

c=abs(complex(data(:,2),data(:,3)));

The abs() in your expression are purely superfluous since squaring a
value makes it positive.

--

Subject: ploting in db

From: TideMan

Date: 19 Mar, 2013 18:54:22

Message: 4 of 9

On Wednesday, March 20, 2013 4:58:10 AM UTC+13, Yousef wrote:
> Hi Guys,
>
>
>
> Can anybody help me to change my y-axis to (db) logarithmic scale..
>
> part of my code looks like:
>
>
>
>
>
> c=sqrt(abs(data(:,2)).^2 + abs(data(:,3)).^2);
>
> b=data(:,1);
>
> tmp=folderContents(i,:);
>
> plot(b,c,'red');
>
>
>
> BUT: I do not want to choose some commands like semilogy, loglog ...etc
>
> Tanks in advance for your help.......

To plot db on the y-axis, it should be:
plot(b,10*log10(c),'r')

Subject: ploting in db

From: Steven_Lord

Date: 19 Mar, 2013 21:25:44

Message: 5 of 9



"dpb" <none@non.net> wrote in message news:kiaaa6$s4e$1@speranza.aioe.org...
> On 3/19/2013 12:05 PM, Steven_Lord wrote:
>>
>>
>> "Yousef " <yayatoure@hotmail.com> wrote in message
>> news:kia1ui$9hl$1@newscl01ah.mathworks.com...
>>> Hi Guys,
>>>
>>> Can anybody help me to change my y-axis to (db) logarithmic scale..
>>> part of my code looks like:
>>>
>>>
>>> c=sqrt(abs(data(:,2)).^2 + abs(data(:,3)).^2);
> ...
>
> Steven answered the axis question,

Yes, I did focus on that piece and didn't look at the code.

> I'll simply note that the above can be written more succinctly as
>
> c=abs(complex(data(:,2),data(:,3)));
>
> The abs() in your expression are purely superfluous since squaring a value
> makes it positive.

Even more succinctly, you can probably just replace this with a call to
HYPOT.

http://www.mathworks.com/help/matlab/ref/hypot.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: ploting in db

From: dpb

Date: 19 Mar, 2013 22:49:39

Message: 6 of 9

On 3/19/2013 4:25 PM, Steven_Lord wrote:
>
>
> "dpb" <none@non.net> wrote in message
> news:kiaaa6$s4e$1@speranza.aioe.org...
>> On 3/19/2013 12:05 PM, Steven_Lord wrote:
>>>
>>>
>>> "Yousef " <yayatoure@hotmail.com> wrote in message
>>> news:kia1ui$9hl$1@newscl01ah.mathworks.com...
>>>> Hi Guys,
>>>>
>>>> Can anybody help me to change my y-axis to (db) logarithmic scale..
>>>> part of my code looks like:
>>>>
>>>>
>>>> c=sqrt(abs(data(:,2)).^2 + abs(data(:,3)).^2);
>> ...
>>
>> Steven answered the axis question,
>
> Yes, I did focus on that piece and didn't look at the code.
>
>> I'll simply note that the above can be written more succinctly as
>>
>> c=abs(complex(data(:,2),data(:,3)));
>>
>> The abs() in your expression are purely superfluous since squaring a
>> value makes it positive.
>
> Even more succinctly, you can probably just replace this with a call to
> HYPOT.
>
> http://www.mathworks.com/help/matlab/ref/hypot.html

If have recent-enough version, yes...

 >> help hypot

hypot.m not found.

 >>

I've not yet learned all the new functions and generally don't use the
gratis new release owing to it overwhelming my old machine, unfortunately...

--

Subject: ploting in db

From: anyone

Date: 19 Mar, 2013 23:55:10

Message: 7 of 9

On Tue, 19 Mar 2013 17:49:39 -0500, dpb wrote:

> On 3/19/2013 4:25 PM, Steven_Lord wrote:
>>
>>
>> "dpb" <none@non.net> wrote in message
>> news:kiaaa6$s4e$1@speranza.aioe.org...
>>> On 3/19/2013 12:05 PM, Steven_Lord wrote:
>>>>
>>>>
>>>> "Yousef " <yayatoure@hotmail.com> wrote in message
>>>> news:kia1ui$9hl$1@newscl01ah.mathworks.com...
>>>>> Hi Guys,
>>>>>
>>>>> Can anybody help me to change my y-axis to (db) logarithmic scale..
>>>>> part of my code looks like:
>>>>>
>>>>>
>>>>> c=sqrt(abs(data(:,2)).^2 + abs(data(:,3)).^2);
>>> ...
>>>
>>> Steven answered the axis question,
>>
>> Yes, I did focus on that piece and didn't look at the code.
>>
>>> I'll simply note that the above can be written more succinctly as
>>>
>>> c=abs(complex(data(:,2),data(:,3)));
>>>
>>> The abs() in your expression are purely superfluous since squaring a
>>> value makes it positive.
>>
>> Even more succinctly, you can probably just replace this with a call to
>> HYPOT.
>>
>> http://www.mathworks.com/help/matlab/ref/hypot.html
>
> If have recent-enough version, yes...
>
> >> help hypot
>
> hypot.m not found.
>
>
> >>
> I've not yet learned all the new functions and generally don't use the
> gratis new release owing to it overwhelming my old machine,
> unfortunately...

R2012b, it seems:
built-in (D:\Program Files\MATLAB\R2012b\toolbox\matlab\elfun\@single\hypot) % single method

Subject: ploting in db

From: Steven_Lord

Date: 20 Mar, 2013 14:03:24

Message: 8 of 9



"anyone" <jaup@h/WSWLG{nR1qHe> wrote in message
news:5148fade$0$63616$c3e8da3$14a0410e@news.astraweb.com...
> On Tue, 19 Mar 2013 17:49:39 -0500, dpb wrote:
>
>> On 3/19/2013 4:25 PM, Steven_Lord wrote:

*snip*

>>> Even more succinctly, you can probably just replace this with a call to
>>> HYPOT.
>>>
>>> http://www.mathworks.com/help/matlab/ref/hypot.html
>>
>> If have recent-enough version, yes...
>>
>> >> help hypot
>>
>> hypot.m not found.
>>
>> >>
>> I've not yet learned all the new functions and generally don't use the
>> gratis new release owing to it overwhelming my old machine,
>> unfortunately...
>
> R2012b, it seems:
> built-in (D:\Program
> Files\MATLAB\R2012b\toolbox\matlab\elfun\@single\hypot) % single method

HYPOT was introduced in release R14SP3 back in September 2005. See the
Mathematics section of that release's Release Notes.

http://www.mathworks.com/help/matlab/release-notes.html#R14SP3

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: ploting in db

From: anyone

Date: 21 Mar, 2013 03:44:09

Message: 9 of 9

On Wed, 20 Mar 2013 10:03:24 -0400, Steven_Lord wrote:

> "anyone" <jaup@h/WSWLG{nR1³qHe> wrote in message
> news:5148fade$0$63616$c3e8da3$14a0410e@news.astraweb.com...
>> On Tue, 19 Mar 2013 17:49:39 -0500, dpb wrote:
>>
>>> On 3/19/2013 4:25 PM, Steven_Lord wrote:
>
> *snip*
[...]
>> R2012b, it seems:
>> built-in (D:\Program
>> Files\MATLAB\R2012b\toolbox\matlab\elfun\@single\hypot) % single
>> method
>
> HYPOT was introduced in release R14SP3 back in September 2005. See the
> Mathematics section of that release's Release Notes.
>
> http://www.mathworks.com/help/matlab/release-notes.html#R14SP3

i have one copy of R2012a still around, and found it there, later, as well. i don't keep any of the older stuff.

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