problem plotting random vector

2 次查看(过去 30 天)
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

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-1-30
hist(x,sort(vet))

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by