Reputation: 138
im using the below code to test if some conditions are met and then i want to count the number of times each condition is met so i can do some further calculations.
for x = 1:35
N = csvread(fullpath1, 1);
Resultgenerated = N(x,1);
Resultgiven= N(x,2);
outcome1 = [];
outcome2 = [];
if (Resultgenerated >= 1) && (Resultgiven >= 1)
outcome1 = 1; %true positive
elseif (Resultgenerated <= 0) && (Resultgiven >= 1)
outcome1 = 2; %'False Positive';
end
if (Resultgenerated <= 0) && (Resultgiven <= 0)
outcome1 = 3; %'True Negative';
elseif (Resultgenerated >= 1) && (Resultgiven <= 0)
outcome1 = 4; %'False Negative';
end
hout{x} = outcome1;
end
sum(hout(:) == 4)
i'm getting the error
Undefined operator '==' for input arguments of type 'cell'.
Error in potential_compare (line 132)
sum(hout(:) == 4)
If anyone has any suggestions that would be brilliant!
thanks
Upvotes: 0
Views: 32
Reputation: 2802
Don't use cells if you don't have to. For your case you are storing the result outcome1
alone.
hout = zeros(1,35);
for x = 1:35
% bunch of stuff
hout(x) = outcome1;
end
sum(hout == 4)
Upvotes: 1