Yes I used
data1 = textscan(file1, '%s,%f,%f,%d\n', 'HeaderLines', 1, 'Delimiter',',')
and did adding the \r help or make any difference? and you tested on the exact same csv files you sent? i'm not sure why the exact same thing wouldn't work.
But again I want to get the difference between the 2nd and 3rd column based on condition and number. How do I map it and then compare the value?
Eg: condition ta and number 1 of the 4th row of file1 has to compare with
condition ta and number 1 of the 1st row of file2
Once you solve the problem reading in the data, you can pull subsets and do subtraction of the data.
if you prefer to work with named entities, you can pull them out of the cells:
file1 = fopen('file1.csv');
file2 = fopen('file2.csv');
data1 = textscan(file1, "%s,%f,%f,%d\n", "HeaderLines", 1, "Delimiter",",");
data2 = textscan(file2, "%s,%f,%f,%d\n", "HeaderLines", 1, "Delimiter",",");
fclose(file1);
fclose(file2);
condition1 = cell2mat(data1{1}); ##textscan made the char array into a cell array, so cell2mat pulls it back out.
supply1_1 = data1{2};
supply2_1 = data1{3};
number1 = data1{4};
condition2 = cell2mat(data2{1});
supply1_2 = data2{2};
supply2_2 = data2{3};
number2 = data2{4};
then, you use logical indexing to pull out subsets based on the values of condition1 and 2:
>> pos_a_1 = (condition1(:,2)=='a')
pos_a_1
=
0
0
0
1
1
0
0
0
>> supply1_1(pos_a_1)
ans =
1.2700
1.3700
>> supply1_2(pos_a_2)
ans =
5.010000
0.070000
>> supply1_1(pos_a_1) - supply1_2(pos_a_2)
ans =
-3.7400
1.3000
repeat for tb and tc. perform whatever math you want, and store and save the answers however you want.