- Import data (e.g. right click file -> Import data... -> generate code)
- Use scattered interpolant: Interpolating Scattered Data - MATLAB & Simulink (mathworks.com)
Finding data on specific point from large set data
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a folder named 'THETHA'. Inside folder I have 360 csv file named '1.csv', '2.csv',...'360.csv'. Each csv file has a data of temperature for different location (X ,Y, Z ,T). Each csv file has different number of rows because result is generated from comsol. I want to estimate temperature on specific point in each csv file. I have made another folder named "DATA" which contains my specific point(X, Y ,Z) in which i want to estimate temperature in each csv file. It is possible that our specific point may not be in csv file so i need to find temperature on that point with the help of interpolation. I am attaching my 'DATA' file and one csv file. Please help me.
0 Commenti
Risposta accettata
AndresVar
il 9 Mar 2022
Modificato: AndresVar
il 9 Mar 2022
clear;
%%% get XYZ locations to interpolate
opts = delimitedTextImportOptions("NumVariables", 3);
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
opts.VariableNames = ["VarName1", "VarName2", "VarName3"];
opts.VariableTypes = ["double", "double", "double"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
data = readtable("DATA.csv", opts);
XYZq = table2array(data);
%%% import data from a Theta file
clearvars opts;
opts = delimitedTextImportOptions("NumVariables", 4);
opts.DataLines = [10, Inf];
opts.Delimiter = ",";
opts.VariableNames = ["X", "Y", "Z", "TKThetha1"];
opts.VariableTypes = ["double", "double", "double", "double"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
data = readtable("1.csv", opts);
data = table2array(data);
% create a scattered interpolant object
T_data = scatteredInterpolant(data(:,1:3),data(:,4));
% interpolate the values
T_interp = T_data(XYZq)
12 Commenti
AndresVar
il 30 Mar 2022
what do the numbers represent?
Anyway, here is one way
XYZq = csvread("DATA.csv");
num1s = 1:71;
num2s = 1:41;
T_interp = nan(size(XYZq,1),numel(num1s),numel(num2s)) % 3 dimensions
for num1 = num1s
for num2 = num2s
dataFilename = sprintf("%d_%d.csv",num1,num2)
data = csvread(dataFilename,9)
T_data = scatteredInterpolant(data(:,1:3),data(:,4));
T_interp(:,num1,num2) = T_data(XYZq);
end
end
The alternative is you put the csv files in a folder and read all. for each file make a variable name and assignit in a table or struct. This would be useful if you don't know num1s and num2s
Più risposte (1)
Vedere anche
Categorie
Scopri di più su MATLAB Report Generator in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!