Only plot outline of graph

this is my code:
% Plot the conductivity levels along the line (as an outline)
figure;
plot(lineX, conductivityValues, 'k-', 'LineWidth', 1.5, 'Marker', 'none');
xlabel('X [m]');
ylabel('Conductivity');
title(['Conductivity along Y = ', num2str(targetY)]);
box on
and now i get this plot:
I only wantt to plot the outline of this plot how do I do this?

댓글 수: 5

Dyuman Joshi
Dyuman Joshi 2023년 12월 21일
Sort the x values and get the corresponding indices.
Then plot the x values vs y values sorted according to the indices.
Lara
Lara 2023년 12월 21일
편집: Lara 2023년 12월 21일
Thank you. I get this graph:
Is there a way to only plot the outline of this plot without using the scatter function?
Star Strider
Star Strider 2023년 12월 21일
Perhaps taking the maximum of the ‘conductivityValues’ will give you that.
Matt J
Matt J 2023년 12월 21일
편집: Matt J 2023년 12월 21일
It is always advisable to attach a .mat file of sample input data to accompany your code, so that the forum can more easily develop and demonstrate solutions.
You can plot the local maximas -
% Numerical data (generated as an example)
% Taken from Matt J's answer
N = 1e3;
t = linspace(-4, 2, N);
R = randn(1,N);
y = sin(t) + 0.5*sin(2*t) + 0.2*sin(3*t)+cos(t) + 0.5*cos(2*t) + 0.2*cos(3*t)+.2*R;
IND = (y<0);
y(IND)=abs(y(IND));
idx = islocalmax(y);
plot(t, y, t(idx), y(idx), 'k--')

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

답변 (2개)

Matt J
Matt J 2023년 12월 21일
편집: Matt J 2023년 12월 21일

0 개 추천

Use movmax to get the upper envelope of a sequence of data points, and possibly smooth it with sgolayfilt, e.g.,
% Numerical data (generated as an example)
N = 1e3;
t = linspace(-4, 2, N);
R = randn(1,N);
y = sin(t) + 0.5*sin(2*t) + 0.2*sin(3*t)+cos(t) + 0.5*cos(2*t) + 0.2*cos(3*t)+.2*R;
IND = find(y<0);
y(IND)=abs(y(IND));
yupper=sgolayfilt( movmax(y,25), 4,41);
% Data is Plotted
plot(t, y, t,yupper,'LineWidth', 1.5);
legend('Data','Outline',Location='northwest')
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 12월 21일

0 개 추천

In this exercise, envelope() with 'peaks' options does a good job, e.g.:
% Numerical data (generated as an example)
N = 1e3;
t = linspace(-4, 2, N);
R = randn(1,N);
y = sin(t) + 0.5*sin(2*t) + 0.2*sin(3*t)+cos(t) + 0.5*cos(2*t) + 0.2*cos(3*t)+.2*R;
IND = find(y<0);
y(IND)=abs(y(IND));
% Data is Plotted
plot(t, y, 'LineWidth', 1.5, 'DisplayName','Data');
hold on;
% Envelope function is applied
[UP, ~] = envelope(y,15, 'peaks');
% UPPER Envelope is plotted
plot(t, UP, 'k-', 'linewidth', 2.5, 'DisplayName','Outer Profile Shape')
legend('Location', 'Best')
hold off;

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2023년 12월 21일

댓글:

2023년 12월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by