Interpolate different sets of data using the same interval
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone,
I'm working on an university project in CFD, basically i have a fluid flowing in a pipe, i need to verify that the solution of the simulation in Fluent is mesh independent, so i have 3 type of grid, the raw one, medium and the finest one. I plot the velocity values along the axis and i must compare the results in 3 cases (if the root mean square is < then 2%, it's ok). My problem is, since the finest mesh have more cells then the medium one etc, I have more values for the finest mesh on the same interval.
Like:
raw mesh x = 0 --> y = 1 x = 0,5 --> y = 1,2
medium mesh x = 0 --> y = 1 x = 0,1 --> y = 1 x = 0,2 --> y = 1,01 x = 0,3 --> y = 1,05 x = 0,4 --> y = 1,1 x = 0,5 --> y = 1,2
I need to have a fixed number of points for X, (50 points for example) and have the Y values associated to be able to compare the 3 different cases.
I think it can be done with interp1 function but i'm not really sure how to do that, i hope someone can help me, thank you in advance.
Regards, Vlad.
0 Kommentare
Antworten (1)
Martin Schätz
am 16 Okt. 2015
Hi, as you said you can use interp1 function. You will have the raw mesh like this:
x = 0:1:10; %step by 1
v = sin(x);
with smaller step.
figure
plot(x,v,'o');
title('Original Data');
To interpolate data, you have to create new variable with smaller steps (now is the step 0.1 as u want for your medium mesh).
xq = 0:0.1:10; % new step by 0.1
vq1 = interp1(x,v,xq,'spline');
Then after interpolation, you will get data with smaller step.
figure
plot(xq,vq1,'o');
title('(Default) Linear Interpolation');
You can easily use this code, but look at the help for interp1 and choose right interpolation method for your data.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Computational Fluid Dynamics (CFD) 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!