How to get X and Y points (or function(s)) from a plotted line

1 回表示 (過去 30 日間)
Addison Collins
Addison Collins 2021 年 8 月 16 日
コメント済み: Addison Collins 2021 年 8 月 17 日
Hello all,
So I have a instrument that provides a handful of X and Y points based up on bins from a histogram. I plotted the graphs in matlab and would like a way to pull points from curve that were not in the original vector of points used to plot.
Is there a way I can pull a set amount of points from the line (say 1000 or so) or to pull a function?
I am aware of the function getpoints, but it only pulls points that were use in the plot to begin with (as far as I know). I have attached example code. I would like to have more points than just the ones I input, so I wanted to pull them from the curve fitted to the inputted points.
clear;clc;close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Set plot stuff:
set(0,'DefaultLineLineWidth',1.5)
set(0,'DefaultLineMarkerSize',15)
set(0,'DefaultAxesFontSize',20)
set(0,'DefaultFigureColor',[1,1,1])
set(0,'DefaultTextFontSize',18)
set(0,'DefaultTextFontName','Times-Roman')
set(0,'DefaultAxesFontName','Times-Roman')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type = '3-6 µm';
experiment = 'base';
class = 'Small';
%% Base PSD
xData = [0 0.4 0.8 1.2 1.6 2 2.4 2.8 3.2 3.6 4 4.4 4.8 5.2 5.6 6 6.4 6.8 7.2 7.6 8 8.4 8.8 9.2 9.6 10 10.4 10.8 11.2 11.6 12 12.4 12.8 13.2 13.6 14 14.4 14.8 15.2 15.6 16 16.4 16.8 17.2 17.6 18 18.4 18.8 19.2 19.6 20];
p3_base = [0 0.019 0.035 0.153 0.32 0.63 1.112 1.823 2.722 3.61 4.309 4.737 4.937 4.941 4.876 4.891 5.051 5.221 5.274 5.146 4.877 4.469 3.989 3.485 3.004 2.558 2.149 1.8 1.484 1.218 0.987 0.795 0.637 0.513 0.42 0.346 0.283 0.233 0.194 0.16 0.133 0.117 0.1 0.082 0.074 0.056 0.054 0.045 0.043 0.038 0.036];
yData = p3_base;
sizes = [];
tic
for i = 1:length(yData)
for j = 1:(yData(i)*1000)
sizes = [sizes xData(i)];
end
end
toc
%% q3 PSD
fig2 = figure('Renderer', 'painters', 'Position', [1300 10 947 900]);
plot(xData,smooth(q3_base),'color','black');
% daspect([1 1 1])
% title('3-6 µm Base PSD PDF')
title([class,' Glass Microspheres Base PSD PDF'])
xlabel('Particle diameter (µm)')
ylabel('Probability Density (%/µm)')

採用された回答

KSSV
KSSV 2021 年 8 月 17 日
yData = smooth(q3_base) ;
% Interpolation
m = 100 ; % change this for required number of points
xi = linspace(min(xData),max(xData),m) ;
yi = interp1(xData,yData,xi) ;
plot(xData,YData,'b',xi,yi,'.r');
  1 件のコメント
Addison Collins
Addison Collins 2021 年 8 月 17 日
Didn't even think of using interp1, good catch.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Acquisition Toolbox Supported Hardware についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by