필터 지우기
필터 지우기

Hello guys how can put this equation into matlab FAR is probability i would like to use for loop to find solution when various n=0:1:4 and plot this

조회 수: 2 (최근 30일)
q1=0.1587;
q2=1-q1;
for n=0:1:4;
FAR=q1.^n.*(1+q2+q2.^2+q2.^3)/((q1.^n.*(1+q2+q2.^2+q2.^3)+(q2.^n.*(1+q1+q1.^2+q1.^3))))
plot(n,FAR)
end

채택된 답변

Walter Roberson
Walter Roberson 2021년 12월 18일
q1=0.1587;
q2=1-q1;
for n=0:1:4;
FAR=q1.^n.*(1+q2+q2.^2+q2.^3)/((q1.^n.*(1+q2+q2.^2+q2.^3)+(q2.^n.*(1+q1+q1.^2+q1.^3))))
plot(n,FAR, '*-');
hold on
end
FAR = 0.7258
FAR = 0.3330
FAR = 0.0861
FAR = 0.0175
FAR = 0.0033
xlim([-.5 4.5])
hold off
You are only plotting one point at a time, and MATLAB never draws connecting lines if you only plot one point at a time. If you want connecting lines you should record your n values and your results and plot() after the loop.
q1=0.1587;
q2=1-q1;
nvals = linspace(0,4);
num_n = length(nvals);
FAR = zeros(1, num_n);
for nidx = 1 : num_n
n = nvals(nidx);
FAR(nidx) = q1.^n.*(1+q2+q2.^2+q2.^3)/((q1.^n.*(1+q2+q2.^2+q2.^3)+(q2.^n.*(1+q1+q1.^2+q1.^3))));
end
plot(nvals, FAR)
xlim([-.5 4.5])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by