Matlab-Plotting a probability matrix

조회 수: 7 (최근 30일)
Carlos Maldonado
Carlos Maldonado 2021년 3월 12일
댓글: Star Strider 2021년 3월 13일
Hi,
I would like to produce a scatter plot of the data below. The first column is the x axis and the first row would be y axis. I would like to produce a scatter plott with their respective value. Any help would be appreciated.
Thank you.

채택된 답변

Star Strider
Star Strider 2021년 3월 13일
Try this:
D = readmatrix('New_MP_CS.csv');
x = D(2:end,1); % Original ‘x’ Vector
y = D(1,2:end); % Original ‘x’ Vector
M = D(2:end,2:end); % Probability Matrix
[r,c] = find(M>0); % Indices Of Non-Zero Probabilities
xv = x(r); % Corresponding ‘x’ Values
yv = y(c); % Corresponding ‘y’ Values
zv = M(M>0); % Corresponding Vector Of Non-Zero Probabilities
figure
stem3(xv, yv, zv, ':.') % Optional, Helps Locate Scatter Points
hold on
scatter3(xv, yv, zv, 5, zv, 'filled') % Color Points By ‘z’ Values
hold off
axis([min(x) max(x) min(y) max(y) zlim]) % Set Axis Limits
xlabel('x')
ylabel('y')
zlabel('Probability')
.
  댓글 수: 2
Carlos Maldonado
Carlos Maldonado 2021년 3월 13일
Thank you very much!
Star Strider
Star Strider 2021년 3월 13일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by