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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ted Erdenekhuyag
le 18 Déc 2021
Réponse apportée : Walter Roberson
le 18 Déc 2021
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 commentaires
Réponse acceptée
Walter Roberson
le 18 Déc 2021
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!