How to interpolate the given plot?
Afficher commentaires plus anciens
I plot speed vs. width (the first three columns are the velocity components and the last the width, please see first file here https://drive.google.com/drive/folders/1CgeDuCahVZvLXXkNkGWlPg8lSGyurmI3) using the following code
clc
close all
clear all
warning('OFF', 'MATLAB:table:ModifiedAndSavedVarnames')
%step 0
Qi = readmatrix("004timestepN2Void30mm.csv");
[v,w] = size(Qi);
%step 1
fCom_004 = Qi(:,1);
sCom_004 = Qi(:,2);
tCom_004 = Qi(:,3);
width_004 = [0;Qi(:,w)+0.0075];
U_004 = sqrt(fCom_004.^2 + sCom_004.^2 + tCom_004.^2);
refined_U_004 = [0;U_004];
%step 3
figure
plot(width_004,refined_U_004)
legend('0.004 timestep','Location','bestoutside')
xlabel('width [m] | 30mm profile')
ylabel('U magnitude [m/s]')
axis square;
grid on;
You'll see that the peak is far from being smooth. To fix the issue I am trying to use interpolation. To do so I modified step 3
newX = linspace (0, 0.015,3e3);
newY = interp1(width_0002,refined_U_0002,newX);
figure
plot(newX,newY)
legend('0.004 timestep','Location','bestoutside')
xlabel('width [m] | 30mm profile')
ylabel('U magnitude [m/s]')
axis square;
grid on;
But the following error pops up "Sample points must be unique."
I think I know why this is happening.
By default, Matlab seems to only read the first four decimals of a given number. Notice that in the last column many numbers only differ from the fifth number; that's why Matlab sees them as equal.
Assuming that I am right, how to make Matlab read the full given numbers of a file?
Thanks in advance! :)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



