I generate some points with latin hypercube sampling and also by for loop I tried to separate out(i,j) to 4 kinds for plotting .but it only plots like below picture.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sogol bandekian
am 19 Mai 2022
Kommentiert: sogol bandekian
am 22 Mai 2022
rng default
LHsampling=lhsdesign(100,5,"criterion","correlation","smooth","off"); %criterion','correlation' give "equal distribution".
for i=1:size(LHsampling,1)
for j=1:size(LHsampling,2)
out(i,j)=(LHsampling(i,j)*2+12*LHsampling(i,j)^2)^3;
if out(i,j)>5
scatter(size(LHsampling,1),out(i,j),'s','r');
hold on;
elseif out(i,j)>50
scatter(size(LHsampling,1),out(i,j),'o','b');
hold on
elseif out(i,j)>100
scatter(size(LHsampling,1),out(i,j),'m','*');
hold on
else
scatter(size(LHsampling,1),out(i,j),'x','g ');
end
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1006210/image.png)
2 Kommentare
Torsten
am 20 Mai 2022
Although I'm not Star Strider I can tell you that "out" has only 1 column, thus out(:,2) does not exist.
Akzeptierte Antwort
Walter Roberson
am 21 Mai 2022
if out(i,j)>5
scatter(size(LHsampling,1),out(i,j),'s','r');
hold on;
elseif out(i,j)>50
Under what circumstances can out>5 fail but then out>50 succeeds?
Why do you use the number of rows (size) as the x coordinates?
You scatter() once for each point. That is very inefficient.
I recommend that you calculate out once before the loop using vectorized calculations. Then use logical indexing to select all of points in a color range and scatter() all of them at the same time.
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!