value from graph
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
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
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 Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!