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 日間)
古いコメントを表示
Ted Erdenekhuyag
2021 年 12 月 18 日
回答済み: 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)
end
0 件のコメント
採用された回答
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
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!