Help with Smooth graph interpolation
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Eric Yoshida
il 15 Apr 2020
Commentato: Star Strider
il 16 Apr 2020
I have two columns of data imported from excel in workspace labelled as "Sample 1". How can I take those columns and make a smooth graph? They are both 88 rows long with column 1 being my X values and column 2 being my Y values. Thank you!
0 Commenti
Risposta accettata
Star Strider
il 16 Apr 2020
I have no idea what your data are, and I am not certain what defines ‘smooth’.
With that proviso, try this:
xq = linspace(min(Sample_1(:,1)), max(Sample_1(:,1)), numel(Sample_1(:,1))*10);
yq = interp1(Sample_1(:,1), Sample_1(:,2), xq', 'pchip');
figure
plot(Sample_1(:,1), Sample_1(:,2), 'xb')
hold on
plot(xq, yq, '-r')
hold off
grid
.
6 Commenti
Star Strider
il 16 Apr 2020
No worries!
The ‘y’ field (the one that matches your description) is a table. It requires a bit of code to get its data.
Experiment with this:
D = load('Graph data.mat');
y = D.y;
vx = y.Column1;
vy = y.strain;
mult = 0.25;
xq = linspace(min(vx), max(vx), numel(vx)*mult);
yq = interp1(vx, vy, xq', 'pchip');
figure
plot(vx, vy, 'xb')
hold on
plot(xq, yq, '-r')
hold off
grid
Change the value of ‘mult’ and the interp1 'method' (here, 'pchip') to get the result you want.
.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!