value from graph

3 views (last 30 days)
nitya ...
nitya ... on 24 Mar 2011
theta= 0:.1:360
theta=deg2rad(theta)
w=B*d.*cos(theta)
AF=1/N*(sin(N*(w./2))./sin(w./2))
plot((theta),AF)
here i need the value of theta at at a poin of AF
i wrote that x(y(0.7)) in command window but it gives
"Empty matrix: 1-by-0"
how can i get the value of theta at y=0.7

Answers (1)

Matt Fig
Matt Fig on 24 Mar 2011
I am surprised you didn't get an error, indexing into y like that. What is y anyway, you don't define it. All I see is theta, w, and AF. And what are B,d and N? Also, why no semi-colons?
.
.
EDIT
I don't know why you would do that when you can just do this:
x = theta;
y = AF;
but anyway...
[mn,I] = min(abs(.7-y));
x(I)
Note that you are using a cyclical function, so there might be more than one value of y 'equal' to .7. If you want to get them all, use:
tol = 1e-6; % decide how close is close enough.
I = abs(.7-y)<tol
x(I)
  5 Comments
Matt Fig
Matt Fig on 24 Mar 2011
@nitya
Well yes, everyone can see theta and AF defined. What we didn't see in your initial post are x, y, B, d, and N. Now we know what x and y are, but not the rest of the unknowns. Did you try the code?
Matt Fig
Matt Fig on 24 Mar 2011
@ Sean de
I thought of that too, but guessed y must be a variable given the context. It is still a mystery how that line didn't error.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!