The second issue is that when I introduce my collected data to the plot I get a massive mess of a line that is unreadable, the data is correct and should plot a similar line above or below the analytical, except I get this:
What am I doing wrong here, my colleague mentioned that a meshgrid and scatteredInterpolant might be useful here but I am struggling to get those to work.
clear all ;
close all;
clc;
referenceData = importdata('C:\Users\...\Radial.dat');
referenceData = referenceData.data;
xRef = referenceData(:,1);
rhoRef = referenceData(:,2);
uRef = referenceData(:,3);
pRef = referenceData(:,4);
%% Explosion BJ
%Pressure
%Rusanov
BJRusP = importdata('C:\Users\...\p.dat');
BJRusP = BJRusP.data;
Pressure_Rus_BJ = BJRusP(1:14093,3);
xRusBJ = BJRusP(1:14093,1);
yRusBJ = BJRusP(1:14093,2);
figure(01); hold on
plot(xRef,pRef, '-');
plot(xRusBJ, Pressure_Rus_BJ, '-')
grid on
xlabel('x')
ylabel('Pressure ')
legend('Analytical', 'Rusanov', 'location', 'northwest')
title('Pressure ');
where radial.dat
is
X | RHO | U | P |
---|---|---|---|
-0.9998E+00 | 0.1250E+00 | 0.0000E+00 | 0.1000E+00 |
... | |||
0.9998E+00 | 0.1250E+00 | 0.0000E+00 | 0.1000E+00 |
and p.dat
is
X | Y | P |
---|---|---|
-0.1000E+01 | 0.0000E+00 | 0.1000E+00 |
... | ||
-0.9066E-02 | 0.3401E-02 | 0.9958E+00 |
EDIT: the first issue has been solved, I simply reduced the axis to x = (0,1) and the remaining values would just disappear, its the mess of a line that i cannot solve,
Matlab draws its plot lines between points in the order you give them, not in order across the domain of the graph. You need to sort your data to get a nice plot:
Pressure_Rus_BJ = BJRusP(1:14093,3);
xRusBJ = BJRusP(1:14093,1);
yRusBJ = BJRusP(1:14093,2);
[xRusBJ, I] = sort(xRusBJ);
Pressure_Rus_BJ = Pressure_Rus_BJ(I);
yRusBJ = yRusBJ(I);
figure(01); hold on
plot(xRef,pRef, '-');
plot(xRusBJ, Pressure_Rus_BJ, '-')