Given the following code
TA = 0TB = 0TC = 0x = [12 64 24];s = num2str(x);n = length(s)for k=1:nswitch s(k) case 12 TA = TA + 1; case 24 TB = TB + 1; case 64 TC = TC + 1;endend
I would like to create a switch case depending on the value on x.
Following the code, the final result should be
TA = 1TB = 1TC = 1
But I don't know how to write x in the right character array, and the code give me a wrong result.
Which is the most clever way to solve this problem?
Best Answer