Index exceeds matrix dimensions

After running my code I find an error that is Index exceeds matrix dimensions.My full code is here clear all clc fullpathToDll = 'Z:\Farha\2015_02_26_photometer_Datenlogger\PC-Software\CGMultChan.dll'; fullpathToHeader = 'Z:\Farha\2015_02_26_photometer_Datenlogger\PC-Software\CGMultChan.h'; fullpathToHeader; fullpathToDll; loadlibrary(fullpathToDll, fullpathToHeader); libfunctions ('CGMultChan'); %loadlibrary(fullpathToDll, fullpathToHeader,'alias','CGMultChanLib3'); TI_ms = calllib('CGMultChan','CGMultChan_SetIntTime',.02*1000); %User Defined Properties delete(instrfindall); serialPort = 'COM1'; % define COM port #
plotTitle = 'Serial Data Log'; % plot title xLabel = 'Elapsed Time (s)'; % x-axis label yLabel = 'Illuminance'; % y-axis label plotGrid = 'on'; % 'off' to turn off grid min = 0; % set y-min max = 1.5; % set y-max scrollWidth = 10; % display period in plot, plot entire data log if <= 0 delay = .01; % make sure sample faster than resolution %Define Function Variables time = 0; output = 0; count = 0; %Set up Plot plotGraph = plot(time,output,'-mo',... 'LineWidth',1,... 'MarkerEdgeColor','k',... 'MarkerFaceColor',[.49 1 .63],... 'MarkerSize',2); title(plotTitle,'FontSize',25); xlabel(xLabel,'FontSize',15); ylabel(yLabel,'FontSize',15); axis([0 10 min max]); grid(plotGrid);
IP = calllib('CGMultChan','CGMultChan_Connect','192.168.100.158');%Connect to Data Loger if (IP == 0) end out = instrfind('Port','COM1');
%Open Serial COM Port s = serial(serialPort);
set(s,'BaudRate',57600,'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none','Terminator','CR'); set(s,'Timeout',10); disp('Close Plot to End Session'); fopen(s); TI_ms = calllib('CGMultChan','CGMultChan_SetIntTime',.02*100); clear pBuffer tic while ishandle(plotGraph) %Loop when Plot is Active BufferSize=16; pBuffer = libpointer('singlePtr',zeros(BufferSize,1));
data = calllib('CGMultChan','CGMultChan_MeasureAll',pBuffer);%Measurement output = pBuffer.Value; %Read Data into the Buffer
if(~isempty(output) && isfloat(output)) %Make sure Data Type is Correct
count = count + 1;
time(count) = toc; %Extract Elapsed Time
data(count) = output(1); %Extract 1st Data Element
%Set Axis according to Scroll Width
if(scrollWidth > 0)
set(plotGraph,'XData',time(time > time(count)-scrollWidth),'YData',output(time > time(count)-scrollWidth));
%set(plotGraph,'Xdata',time,'YData',output);
axis([time(count)-scrollWidth time(count) min max]);
else
set(plotGraph,'XData',time,'YData',output);
axis([0 time(count) min max]);
end
%Allow MATLAB to Update Plot
pause(delay);
end
end
%Close Serial COM Port and Delete useless Variables fclose(s); clear pBuffer
clear count result delay max min plotGraph plotGrid plotTitle s ... scrollWidth serialPort xLabel yLabel;
calllib('CGMultChan','CGMultChan_Disconnect');%Disconnect from Data Logger Error is in the line 71 set(plotGraph,'XData',time(time > time(count)-scrollWidth),'YData',output(time > time(count)-scrollWidth));

댓글 수: 1

Jan
Jan 2016년 3월 30일
The code is unreadable. Please use the "{} Code" button to format it. Then edit the question and add the complete error message, such that we do not have to guess the line, which fails.

답변 (0개)

이 질문은 마감되었습니다.

태그

질문:

2016년 3월 30일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by