obtain 300 values from 840 values
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everybody,
I have one column S with 840 values. I would like to ultimately obtain 300 values because I would like to do a correlation analysis with another column containing 300 values. What would be the formula to use to do that? Could I do an average from several values, and how could I write that?
Thank you!
4 Kommentare
Antworten (1)
Image Analyst
am 19 Aug. 2018
Anastasia, you still haven't specified what you want, so here is one guess. I just interpolate between all the points and uniformly sample the 300 points between the first point and the last point:
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 15;
% Make 840 random values
numPoints = 840
period = 100;
x = 1 : numPoints;
v = 3 * cos(2 * pi * x / period) + rand(1, numPoints);
% Get 300 "x" values
xq = linspace(1, length(v), 300);
v300 = interp1(x, v, xq);
% Plot everything
subplot(3, 1, 1);
plot(x, v, 'b.-', 'LineWidth', 2, 'MarkerSize', 10);
grid on;
title('840 Points', 'FontSize', fontSize);
subplot(3, 1, 2);
plot(xq, v300, 'ro', 'LineWidth', 2, 'MarkerSize', 7);
grid on;
title('300 Points', 'FontSize', fontSize);
% Smooth the signal
vSmooth = conv(v, ones(1, 15), 'same');
% Get 300 "x" values
xq = linspace(1, length(v), 300);
vs300 = interp1(x, vSmooth, xq);
subplot(3, 1, 3);
plot(xq, vs300, 'ro', 'LineWidth', 2, 'MarkerSize', 7);
grid on;
title('300 Smoothed Points', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193927/image.png)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!