Hi,
To modify your code to compute row 1 and row 2 of each mat file and place them in their corresponding mat file (A1 and A2), you can modify the loop that loads the mat files to extract the parameters for each row and store them separately in the output variables.
Here is an example of how you can modify your code to achieve this:
function [A1, A2] = Antoine(T)
% Load Antoine constants for element 1
load('main\Antoine1\Antoinecomp.mat', 'Antoinecomp');
% Extract parameters for row 1 and row 2
A1_1 = Antoinecomp(1,1:2);
A1_2 = Antoinecomp(2,1:2);
% Load Antoine constants for element 2
load('main\Antoine2\Antoinecomp.mat', 'Antoinecomp');
% Extract parameters for row 1 and row 2
A2_1 = Antoinecomp(1,1:2);
A2_2 = Antoinecomp(2,1:2);
% Compute A1 and A2 for each element and each row
A1 = [AntoineEqn(A1_1, T); AntoineEqn(A1_2, T)];
A2 = [AntoineEqn(A2_1, T); AntoineEqn(A2_2, T)];
end
function P = AntoineEqn(A, T)
% Compute vapor pressure using Antoine equation
P = 10.^(A(1) - A(2)./(T + A(3)));
end
In this modified code, we load the first mat file containing the Antoine constants for element 1, and then extract the parameters for row 1 and row 2 separately using indexing. We then repeat this process for the second mat file containing the Antoine constants for element 2.
Finally, we compute A1 and A2 separately for each element and each row, and store the results in the corresponding output variables.
Note that we also defined a separate helper function AntoineEqn to compute the vapor pressure using the Antoine equation, as this is a repetitive operation that can be easily encapsulated in a function.