How to plot point-wise figures from existing one.

5 visualizaciones (últimos 30 días)
Dereje
Dereje el 27 de Mzo. de 2018
Comentada: Pawel Jastrzebski el 28 de Mzo. de 2018
According to the attached figure w is zero for specific z. Need help how to plot only the value of z for each case (when w becomes zero).

Respuestas (1)

Pawel Jastrzebski
Pawel Jastrzebski el 27 de Mzo. de 2018
Consider the following example:
% Data
w = -1:0.02:1;
z = (-w.^2)+10;
% Condition - logical vector
wAtZzero = w == 0;
% Plotting
% p(1) - all data
% p(2) - 'z' @ 'w=0'
f = figure;
p(1) = plot(w,z);
hold on
p(2) = scatter(w(wAtZzero),z(wAtZzero),'or');
xlabel('w');
ylabel('z');
set(gca(),...
'YAxisLocation', 'origin');
Figure output:
Terminal output:
>> z(wAtZzero)
ans =
10
  4 comentarios
Dereje
Dereje el 27 de Mzo. de 2018
I have attached the -mat file. w and z are changed with another variable. Thanks
Pawel Jastrzebski
Pawel Jastrzebski el 28 de Mzo. de 2018

It's a bit confusing. In your code:

  • The bit of code you've posted in your previous reply doesn't exist so I had to add it manually to see how it plots
  • But it doesn't plot because variable w doesn't exist anymore - what is a new w then?
  • Also you've got variable z which is a vector but you're trying to access is as if it was a cell
  • Therefore, please specify: which variables do I need to plot against each other to obtain the plot you attached to this question?

Other notes:

  • I recommend moving your figure(1) declaration outside the for loop

Iniciar sesión para comentar.

Categorías

Más información sobre Line 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