problem in drawing my small program

1 visualización (últimos 30 días)
reem
reem el 16 de Abr. de 2011
After greetings and respect
please,anyone tell me about my problem here
when I want to plot using plot command,nothing appear in my
graph,why??
Thanks in advance
clear all;
randn('state',0)
M=input('Enter the number of realization:');
counter=0;
X=randn(M,1);
for k=1:M
if X(k)>2
counter=counter+1;
end
end
proestimated = counter/M;
disp('estimated probability:')
display(proestimated)
plot([-4:1:4],proestimated);

Respuesta aceptada

Walter Roberson
Walter Roberson el 16 de Abr. de 2011
proestimated will be a single scalar. The plot documentation does say,
If Xn is a scalar and Yn is a vector, plots discrete Yn points vertically at Xn.
but it does not include the reverse case, where Yn is a scalar and Xn is a vector.
You will need to make the size of the Y value to be plotted the same as your X value to be plotted.

Más respuestas (1)

reem
reem el 16 de Abr. de 2011
Thanks alot Walter,the graph appeared in my program Thank you so so much

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by