필터 지우기
필터 지우기

value from graph

조회 수: 1 (최근 30일)
nitya ...
nitya ... 2011년 3월 24일
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

답변 (1개)

Matt Fig
Matt Fig 2011년 3월 24일
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
Matt Fig
Matt Fig 2011년 3월 24일
@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 2011년 3월 24일
@ 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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by