problem plotting random vector

4 visualizzazioni (ultimi 30 giorni)
daniele
daniele il 30 Gen 2012
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

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 30 Gen 2012
hist(x,sort(vet))

Più risposte (1)

daniele
daniele il 30 Gen 2012
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?

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by