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:
how to find the point of rectangular coordinate

Subject: how to find the point of rectangular coordinate

From: Constantine Ong

Date: 22 Oct, 2010 14:43:04

Message: 1 of 5

hi, could anyone help me figure out the point on a rectangular coordinate if i know only the value of y.....below are the codes and the pattern of the graph, what i need to find is the point when there is -3db

clc
clear

M=1800;
k=2*pi;
theta=linspace(0,2*pi,M+1);
N=2
beta=pi/4
d=1/4;
Y=k.*d.*cos(theta)+beta;

E= cos(theta);
AF= sin((N.*Y)./2)./(N.*sin(Y./2));
Pat=abs(E.*AF);
AFdb=10.*log10(Pat);

plot(theta.*180./pi,AFdb);
axis([0 360 -60 0])
xlabel('theta 0 to 2pi');
ylabel('Gain of the radiation pattern in dB');
grid on;

I am a new user to matlab and thank you very muc for those who are willing to help.....thanks....

Subject: how to find the point of rectangular coordinate

From: Miroslav Balda

Date: 22 Oct, 2010 15:32:04

Message: 2 of 5

"Constantine Ong" <syin_88@hotmail.com> wrote in message <i9s7to$3ql$1@fred.mathworks.com>...
> hi, could anyone help me figure out the point on a rectangular coordinate if i know only the value of y.....below are the codes and the pattern of the graph, what i need to find is the point when there is -3db

Hi Constantine,

Try this

I = find(AGdb<=3, 1) % I is the index of the first value of AGdb less or equal 3db.

Mira

Subject: how to find the point of rectangular coordinate

From: John

Date: 22 Oct, 2010 19:31:04

Message: 3 of 5

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <i9sapk$cnl$1@fred.mathworks.com>...
> "Constantine Ong" <syin_88@hotmail.com> wrote in message <i9s7to$3ql$1@fred.mathworks.com>...
> > hi, could anyone help me figure out the point on a rectangular coordinate if i know only the value of y.....below are the codes and the pattern of the graph, what i need to find is the point when there is -3db
>
> Hi Constantine,
>
> Try this
>
> I = find(AGdb<=3, 1) % I is the index of the first value of AGdb less or equal 3db.
>
> Mira

Hello Constantine,

Here are a couple of things:

First with your code I noticed that you are using the '.' operator on every multiplication operation. This is only need when you are multiply two vectors or matricies together that have the same dimensions and the multiplication should be element wise, otherwise it isnt needed, here is an example:

suppose we have the vector A = [ 1 2 3 4 5] and the vector B = [2 2 2 2 3]

A.*B produces:
ans =

     2 4 6 8 15

the elements are multiplied be eachother directly, if we were to have just

A*B MATLAB attempts matrix multiplication producing the following error:
??? Error using ==> mtimes
Inner matrix dimensions must agree.

For a lot of your computation you are doing a vector or a matric multiplied by a scalar, such as:

A*5
ans =

     5 10 15 20 25

you notice that the '.' operator is not needed, anyway back to your problem, what mira gave you will find the first index of data where that y value of the data point is less than -3 db which is 1. I assume this isnt exactly what you are looking for, i am going to take a small leap here and assume you are trying to find the data points where the y data equal -3 db (or as close to that as possible), I did the following:

 thresh = .0104; % Chosen after a few tries
A = AFdb( AFdb <= -3+thresh & AFdb >= -3 - thresh);
[C IA IB] = intersect(AFdb, A);
>> IA

IA =

         601 1201

Subject: how to find the point of rectangular coordinate

From: Constantine Ong

Date: 23 Oct, 2010 03:16:03

Message: 4 of 5

"John " <jrazzano@usc.edu> wrote in message <i9sopo$t2d$1@fred.mathworks.com>...
> "Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <i9sapk$cnl$1@fred.mathworks.com>...
> > "Constantine Ong" <syin_88@hotmail.com> wrote in message <i9s7to$3ql$1@fred.mathworks.com>...
> > > hi, could anyone help me figure out the point on a rectangular coordinate if i know only the value of y.....below are the codes and the pattern of the graph, what i need to find is the point when there is -3db
> >
> > Hi Constantine,
> >
> > Try this
> >
> > I = find(AGdb<=3, 1) % I is the index of the first value of AGdb less or equal 3db.
> >
> > Mira
>
> Hello Constantine,
>
> Here are a couple of things:
>
> First with your code I noticed that you are using the '.' operator on every multiplication operation. This is only need when you are multiply two vectors or matricies together that have the same dimensions and the multiplication should be element wise, otherwise it isnt needed, here is an example:
>
> suppose we have the vector A = [ 1 2 3 4 5] and the vector B = [2 2 2 2 3]
>
> A.*B produces:
> ans =
>
> 2 4 6 8 15
>
> the elements are multiplied be eachother directly, if we were to have just
>
> A*B MATLAB attempts matrix multiplication producing the following error:
> ??? Error using ==> mtimes
> Inner matrix dimensions must agree.
>
> For a lot of your computation you are doing a vector or a matric multiplied by a scalar, such as:
>
> A*5
> ans =
>
> 5 10 15 20 25
>
> you notice that the '.' operator is not needed, anyway back to your problem, what mira gave you will find the first index of data where that y value of the data point is less than -3 db which is 1. I assume this isnt exactly what you are looking for, i am going to take a small leap here and assume you are trying to find the data points where the y data equal -3 db (or as close to that as possible), I did the following:
>
> thresh = .0104; % Chosen after a few tries
> A = AFdb( AFdb <= -3+thresh & AFdb >= -3 - thresh);
> [C IA IB] = intersect(AFdb, A);
> >> IA
>
> IA =
>
> 601 1201

Thanks John and Mira for helping me, ^^
hi John, I am sorry to bother u again...but can i ask wat is C, IA and IB?
and the answer 601 and 1201 means?? I am a beginner in matlab and hope that you can explain a little bit to me thanks a lot.....

Subject: how to find the point of rectangular coordinate

From: Constantine Ong

Date: 24 Oct, 2010 01:39:05

Message: 5 of 5

Hi John.....I still have 1 more question to ask you......
from the code u given, if I change my N=10, and beta=0.6, the IA shows this:
'Empty matrix: 1-by-0'
I don't know what is the IA for, could you please explain to me, thanks.....appreciate your help......

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