How can I read from file with loop ?
이전 댓글 표시
Hello to all, I am trying to read data from excel file and each 10 second update and plot it. Here is the main part of my m-code, if smb need I can paste the whole code.
function [x,y] = readExcelColumns (fileName, xColNum, yColNum)
a= xlsread(fileName);
x=a(:,xColNum);
y=a(:,yColNum)
function updateAxes (hObject, eventdata, handles)
xColNum = get(handles.popupmenuX, 'value');
yColNum = get(handles.popupmenuY, 'value');
fileName=handles.fileName;
inf = 1;
* for k=1:1000
[x,y] = readExcelColumns (fileName, xColNum, yColNum)
plot (handles.axes1,x,y)
pause (10);
if k==0
break;
end
end*
function pushbuttonSTOP_Callback(hObject, eventdata, handles)
inf = 0;
댓글 수: 3
Azzi Abdelmalek
2012년 8월 7일
i see you have a code, can you specify your problem?
Sriram
2012년 8월 7일
where you got stuck?
Dzhamshed
2012년 8월 7일
답변 (3개)
Sriram
2012년 8월 7일
plot axes is getting updated.. there is no issue on that ... make sure you have x an y variables updates....
for i = 1:1:10
x = rand(i);
y =rand(i);
plot(handles.axes1,x,y)
title(i)
pause(1)
end
the above sample code (as you did for plot) works fine... so try to make sure whether x and y variables get updated , and also make the delay (pause(10)in your code ) to be minimal when you debug whch ll be helpful...!
Dzhamshed
2012년 8월 7일
0 개 추천
댓글 수: 4
Sriram
2012년 8월 7일
Though you call the function - try to check in the next xls file your x and y (rows and coloumns) getting updated or not....
Do you get any error?
Does the loop goes on ???
Are you able to open as many - xls files - as the loop proceeds ?
Dzhamshed
2012년 8월 7일
Dzhamshed
2012년 8월 7일
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!