Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write cos squared of angle phi ?

Status
Not open for further replies.

mujee

Member level 1
Member level 1
Joined
Feb 11, 2007
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,585
hey guys
i have some syntax problem in this statement

d=sqrt((x(1:length(x))-r*sin(phi))^2 + r^2 *cos^2(phi))

it gives me error on cos^2(phi)...can anyone tell me how to write cos squared of angle phi
 

Re: syntax problem

mujee said:
hey guys
i have some syntax problem in this statement

d=sqrt((x(1:length(x))-r*sin(phi))^2 + r^2 *cos^2(phi))

it gives me error on cos^2(phi)...can anyone tell me how to write cos squared of angle phi

what language is this ?
 

Re: syntax problem

matlab
 

Re: syntax problem

mujee said:
hey guys
i have some syntax problem in this statement

d=sqrt((x(1:length(x))-r*sin(phi))^2 + r^2 *cos^2(phi))

it gives me error on cos^2(phi)...can anyone tell me how to write cos squared of angle phi

try this :

d=sqrt( ( ( (x*(1:length(x))) - (r*sin(phi)) )^2 ) + ( (r^2) * (cos^2(phi)) ) )
 

    mujee

    Points: 2
    Helpful Answer Positive Rating
syntax problem

Hi mujee, try replacing cos^2(phi) with cos(phi)^2
 

    mujee

    Points: 2
    Helpful Answer Positive Rating
Re: syntax problem

tried both of the options, still same prob
 

syntax problem

Hi

The right command is cos(phi)^2 or (cos(phih))^2.

your problems may be somewhere else

Sal
 

    mujee

    Points: 2
    Helpful Answer Positive Rating
syntax problem

Can you show us a complete example that demonstrates the problem? We need to see how you've defined the variables. Maybe you need to use an element-wise operator such as cos(x).^2
 

    mujee

    Points: 2
    Helpful Answer Positive Rating
Re: syntax problem

yeah now i figured out the other problem
i was squaring array with ^2 instead of .^2
thank you guys for your help in correcting my syntax cos(phi)^2 was the correct way of doing it
have hit 'helped me' tab for all of you

Added after 6 minutes:

actually that x was an array...i was using wrong operator for that..i needed to use element wise operation and that i just figured out.
with cos i didnt know how to use squared cos ..thanks echo and sal for helping me out
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top