getting string from cell using if statement

[~,~,raw] = xlsread('StudentData_20students.xlsx');
header = raw(1,:);
data = raw(2:end,:);
x = data(:,3)
for q = 1:20
n = x(q,1)
if n == 'ON'
b = 'TRUE'
end
end

Respuestas (1)

Star Strider
Star Strider el 16 de Abr. de 2018

0 votos

The best way to compare strings is to use the strcmp (link) or related functions (linked to at the end of that page).

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Abr. de 2018

Respondida:

el 16 de Abr. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by