I've never heard of the function readMatrix. I'd suggest using the function readtable if your CSV file has headings as well as data. (This answer here on importing CSV data may also help). You also need to refer to the column (or table heading) and row number in your if conditions. In the example below, I assume your csv file has the same heading names you used in your if statemets:
myData = readtable('myfile.csv');
[numRows, numCols] = size(myData);
for i = 1:NumRows
if myData.Chest_Pain_Type(i) <=3 && myData.Induced_Angina(i) <=0 && myData.Age(i) <=55 && myData.Chest_Pain_Type(i) <=1 && GmyData.Gender(i) <=0
Patient0utput = 0;
elseif myData.Chest_Pain_Type(i) <=3 && myData.Induced_Angina(i) <=0 && myData.Age(i) <=55 && myData.Chest_Pain_Type(i) <=1 && myData.Gender(i) >0 && myData.Resting_ECG(i) <=1 && myData.Chest_Pain_Type(i) <=46
Patient0utput = 1;
end
Note: Although, I must say, you seem the have mutliple statements that are useless in some of your if conditions. For example, it seems pointless to me to have both
and
because if the value is less than or equal to 1, then the condition of being less than or equal to 3 is useless?
Best Answer