How to use if statements to compare data from matlab with excel data?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kenny Chintama
am 8 Mai 2016
Bearbeitet: Kenny Chintama
am 11 Mai 2016
Hey there guys, I'm new here and I'm doing a research for my thesis about eye detection. I've got the exact eye position in a .csv file as shown in this picture:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163708/image.jpeg)
problem is, there are some of the frames that is not detected and needed to be skipped from the frameNum as you can see in this excel file, there is no frame 9, 10, 11, 12, 13 and many more.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163709/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163711/image.jpeg)
BB = step(EyeDetectKanan,muka); %in this line, the frameNum should be compared with the Frame column in excel.
boxRightEye = BB;
My proposed algorithm for this problem is: 1. If frameNum = Frame, then show the value of right x, right y, right w, right h (without the commas like in this picture)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163713/image.jpeg)
2. If frameNum isn't in Frame, then skip into the next frameNum 3. This process will be continued until the end of the file.
My questions are, is it possible to use if statements between matlab and excel? and how can I do these algorithms I made?
Thanks. Sorry for the bad view and english...
3 Kommentare
Weird Rando
am 8 Mai 2016
Maybe something like in MATLAB?
for i = 1:10
if i ~= 5
continue
end
disp(i)
end
Akzeptierte Antwort
Walter Roberson
am 8 Mai 2016
for fn = 1 : frameNum
[tf, idx] = ismember(fn, Frame);
if tf
rx = rightx(idx); ry = righty(idx); rw = rightw(idx); rh = righth(idx);
lx = leftx(idx); ly = lefty(idx); lw = leftw(idx); lh = lefth(idx);
...
end
end
7 Kommentare
Walter Roberson
am 9 Mai 2016
for fn = 1 : frameNum
[tf, idx] = ismember(fn, T.Frame);
if tf
thisrow = T(idx,:);
rx = thisrow.rightX; ry = thisrow.rightY; rw = thisrow.rightW; rh = thisrow.rightH;
lx = thisrow.leftX; ly = thisrow.leftY; lw = thisrow.leftW; lh = thisrow.leftH;
...
end
end
Weitere Antworten (1)
Walter Roberson
am 8 Mai 2016
No, it is not possible to use "if" statements between excel and MATLAB.
You have two choices:
- Read the entire file and discard what you do not need;
- Read one line at a time and make decisions based upon the content.
To read the entire file at one time, xlsread(), readtable() and textscan() are all good routines.
To read one line at a time, textscan() can still be useful, but so can fgetl() together with strsplit()
1 Kommentar
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!