Matlab-Plotting a probability matrix

6 visualizaciones (últimos 30 días)
Carlos Maldonado
Carlos Maldonado el 12 de Mzo. de 2021
Comentada: Star Strider el 13 de Mzo. de 2021
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.

Respuesta aceptada

Star Strider
Star Strider el 13 de Mzo. de 2021
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 comentarios
Carlos Maldonado
Carlos Maldonado el 13 de Mzo. de 2021
Thank you very much!
Star Strider
Star Strider el 13 de Mzo. de 2021
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by