problem plotting random vector

hy, I have to make a hist(x,vet) where vet is a random vector of 1000 elements and vet is a vector of 10 elements. but the compuer tells me warning: hist: bin values not sorted on input how can i resolve? thanks

 Akzeptierte Antwort

Weitere Antworten (1)

daniele
daniele am 30 Jan. 2012

0 Stimmen

hy, thanks this solved the problem but now there is another on this is my code function gaussiana()
x=rand(1,1000)
vet=[0,0,0,0,0,0,0,0,0,0]
for k=1:1:1000,
if x(1,k)<0.1,
vet(1)=vet(1)+1;
else if x(1,k)<0.2,
vet(2)=vet(2)+1;
else if x(1,k)<0.3,
vet(3)=vet(3)+1;
else if x(1,k)<0.4,
vet(4)=vet(4)+1;
else if x(1,k)<0.5,
vet(5)=vet(5)+1;
else if x(1,k)<0.6,
vet(6)=vet(6)+1;
else if x(1,k)<0.7,
vet(7)=vet(7)+1;
else if x(1,k)<0.8,
vet(8)=vet(8)+1;
else if x(1,k)<0.9,
vet(9)=vet(9)+1;
else if x(1,k)<1,
vet(10)=vet(10)+1;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
vet
hist(x,sort(vet))
end function gaussiana()
i what an hist with on the y's the random numbers going between 0 and 1, and on the x's vet, the x's are ok, but on the y's there are just numbers between and 1000. how can i solve this problem?

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Hilfe-Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by