2D Contour plot with multiple files

hello, i have a list of data files. like 50-60 basically representing CAD. each files consists of columns of different variables. among which one is "x" which represents radius and the other one is mass fraction of "Hiroy SOOT". the latter quantity changes in each file. I want to make a contour plot of Hiroysoot mass. (can be calculated for each col file by multiplying Hiroy soot column with MASS column). X-axis being CAD progression, y-axis being the radius with accumulated hiroy soot plotted as a contour. Basicallly the accumulated soot at each CAD along radius. The files are attached below.
any idea will be appreciated.

7 comentarios

KSSV
KSSV el 12 de Nov. de 2022
It looks like you have 3D data. You want to plot contour for 3D data?
Usama Bin Khalid
Usama Bin Khalid el 12 de Nov. de 2022
The data is 3D infact.. I need is radial values along Y-axis which is X or Y in col file.. I attach the contour which I am trying to plot somehow
Below i tried to plot the points listed in the files by using the x,y and z values. However, at first glance there are not enough data points to cover a full grid.
You will need to provide more information about the data... Try to avoid technical nomenclature (for me CAD means computer aided design, in your questions it likley means something else).
% unzip the file
Files = unzip("https://nl.mathworks.com/matlabcentral/answers/uploaded_files/1190023/output.zip");
for i = 1:length(Files)
% read the current file
currFile = readtable(Files{i},'FileType','text');
% plot the locations of the data points (i.e. x,y and z values in the file)
figure(i)
scatter3(currFile.x,currFile.y,currFile.z)
axis equal
grid on
view(3)
title("Data points for "+Files{i})
end
Usama Bin Khalid
Usama Bin Khalid el 12 de Nov. de 2022
Hello Thank you for your effort It's not what am looking for actually The Cad represents the file names which you named as data points I want the accumulated soot(z in your case) plotted along radius (X in your case) with CAD (data points ) along x-axis.( It will be a 2D contour) You can refer to the picture of contour I attached
The data points are not enough as I had file attachment restrictions Thanks again for your feedback..
DGM
DGM el 12 de Nov. de 2022
Editada: DGM el 12 de Nov. de 2022
If I understand it, this is part of combustion analysis in engine design. CAD would refer to crank angle in degrees. So we're looking at byproduct formation over a range of timings? I don't know if that's an accurate interpretation or if it's helpful either way.
I'm not really sure how it's intended to be plotted, and I'm not really sure we're talking about the same things. A lot of people say "contour" when they mean something more analgous to a heatmap. A contour map takes a (e.g.) surface and reduces it to a series of isolines. Extending that one dimension higher gets cumbersome to visualize. It's either going to be a series of nested isosurfaces (which will tend to obscure each other), or it will be sliced on one dimension and represented as stacked isoline plots (see contour3).
On the other hand, If you want your data visualized as a smooth colored map (as in the one 2D plot you showed) that's not a contour map. It might still be cumbersome to visualize, but we'd need to know what we're trying to do in order to work in the right direction.
That said, what I see is a sequence of multiple 3D maps that need to be combined into one visualization. I'm not really sure how you want to do that. Obviously plotting all 4 dimensions is out, but it could be sliced or permuted such that it could be represented as a series of 2D or 3D plots of some sort.
Usama Bin Khalid
Usama Bin Khalid el 12 de Nov. de 2022
Hello DGM yes you are right, it's related to combustion . The picture I attached is as a reference from exp data.. The data now I have is from 3D CFD. Like you said your second point I want the 2D representation of accumulated soot along the radius for each CAD ( for each cad the the data can be summed and saved along the radius ) AND then combine then to make smooth contour which can be called as map not a contour.. I hope this clarifies the problem. I think it can be done with MESHGRID but I lack the excat sequence of how it can be done ....
Usama Bin Khalid
Usama Bin Khalid el 15 de Nov. de 2022
Editada: Usama Bin Khalid el 15 de Nov. de 2022
Hello, i figured out the way how to do it, first i attach the data files on the link
i create the slice for one of the files, by using the script. with this the contour is created as shown below. NOW What i want is to divide this picture into equal circular portions (we can call them rings of width 0.5mm) and then calculate the average of the plotted contour in each ring (by summing the whole mass present in each ring and diving by area of each ring). In this way i will get a vector of averaged values of each ring along the radius.
By doing the same procedure then for other files, we can merge all together and create the plot where we have files names (CAD) along x-axis, radius on y axis and contour in between as per picture i uploaded earlier..
So, i need now help for splitting the image into rings and the calculating the average value of quantity in each ring then plotting it along radius..Finally merging the data of all files to create a 2D map.
%(Radius can be calculated from X and Y given in files). then image should be split in circular portions along radius......
any help will be appreciated. thanks
clear all
cd 'C:\Users\VK\Downloads\output'
data=readtable('tt000045_+3.60647e+02.dat');
data=table2array(data);
datasort=data;
resolution=0.0002;
range=[0 0.00005];
F=scatteredInterpolant(datasort(:,1),datasort(:,2),datasort(:,6),'linear','none');
[X,Y]=meshgrid(min(datasort(:,1)):resolution:max(datasort(:,1)),min(datasort(:,2)):resolution:max(datasort(:,2)));
data2plot=F(X,Y); %this data2plot should be divided into rings in my opinion
imshow(data2plot,range);colormap("hot")
contourf(X,Y,data2plot,5);
xlim([-0.03255 0.03255])
ylim([-0.03255 0.03255])
colormap("jet");
colorbar;
set(gca,'fontweight','bold','fontsize',12)

Iniciar sesión para comentar.

Respuestas (0)

Productos

Versión

R2021b

Preguntada:

el 12 de Nov. de 2022

Editada:

el 15 de Nov. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by