problem plotting random vector

4 ビュー (過去 30 日間)
daniele
daniele 2012 年 1 月 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 Center および File ExchangeNumerical 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