Loop through every subfolder
Mostrar comentarios más antiguos
I have two subfolders in a folder named main: Antoine1(subfolder1) and Antoine2(subfolder2). In each subfolder I have a mat file named Antoinecomp which contains the Antoine constant parameters of two chemical elements such that row1 contains the parameters of element 1 and row 2 the parameters of the second chemical element.
I wrote a function called Antoine which takes these constants and the temperature to solve for A1 and A2. These mat files should contain two columns corresponding to each row. Following some examples available in MATLAB Answers, I came up with the following:
It works well, but this is computing the first row of both mat files and placing them in A1, and so on. How can I modify this code so it doesn't do this? Instead, I want the code to compute row 1 and row 2 of each mat file and placing them in their corresponding mat file (A1 and A2)
clear all; close all; clc
T = linspace(353.2,383.655,10); % Temperature in Kelvin
FileList = dir('**\*.mat');
for k = 1:numel(FileList)
File = fullfile(FileList(k).folder, FileList(k).name);
a = load(File);
A1(:,k) = Antoine(a.Antoinecomp(1,1),a.Antoinecomp(1,2),a.Antoinecomp(1,3),T)';
A2(:,k) = Antoine(a.Antoinecomp(2,1),a.Antoinecomp(2,2),a.Antoinecomp(2,3),T)';
end
Thank you in advance for any guidance.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!