Why can´t I show last three channel from file.trc?

1 次查看(过去 30 天)
Dear all,
I have this code (GUI):
function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI.M with the given input arguments.
%
% GUI('Property','Value',...) creates a new GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help GUI
% Last Modified by GUIDE v2.5 17-Oct-2016 17:54:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_OpeningFcn, ...
'gui_OutputFcn', @GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before GUI is made visible.
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUI (see VARARGIN)
% Choose default command line output for GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
%Načíst data
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
handles = guidata(hObject)
[filename pathname]=uigetfile({'*.trc'}, 'File Selector');
fullpathname=strcat(pathname, filename);
text = fileread(fullpathname);
set(handles.text3,'String', fullpathname)
data=fopen(fullpathname); %otevreni datoveho souboru
a=fread(data); %cteni datoveho souboru
sampling_rate=a(9:10,:);
channel_number_on_display=a(3:4,:);
number_of_stored_channel=a(185:186,:);
handles.number_of_stored_channel=number_of_stored_channel;
%ZÍSKÁNÍ ADRESY DAT
adress_data1=a(184,:); %nacteni prvniho adresoveho byte
adress_data2=a(183,:); %nacteni druheho adresveho byte
prvni_adresa= (dec2bin(adress_data1,8));%prevod prvniho adresoveho byte z dekadicke do binarni
druha_adresa=dec2bin(adress_data2,8);%prevod druheho adresoveho byte z dekadicke do binarni
prvni=num2str(prvni_adresa);%prevod prvniho adresoveho byte na string
druha=num2str(druha_adresa);%prevod druheho adresoveho byte na string
C=[prvni,druha];%spojeni adresovzch stringu
D=bin2dec(C);%ziskani adresy v dekadickem tvaru
D=D+1;% posunuti adresy o 1 aby byla zajistena korecke matlabu a datovych souboru
DATA_NAMERENA=a(D:end,:); %vyjmuti pouze datove casti podle adresy
num_chan=number_of_stored_channel(1,:);
handles.DATA_NAMERENA=DATA_NAMERENA;
handles.num_chan=num_chan;
guidata(hObject, handles);
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Smazat data
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
cla reset;
set(handles.slider1,'Value', 0);
set(handles.text5,'String', 0);
set(handles.text3,'String','');
set(handles.text4,'String', 0);
set(handles.text6,'String', 10);
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
slider_hodnota=get(handles.slider1,'Value');
set(handles.text5,'String', slider_hodnota);
handles = guidata(hObject);
num_chan=handles.num_chan;
number_of_stored_channel=handles.number_of_stored_channel;
DATA_NAMERENA=handles.DATA_NAMERENA;
hold off;
r=1; %prvni pozice radku do matice svodu
d=1;% prvni pozice datoveho souboru
for i=1:((10*128)) %opakovani pro pocet dat v 10s
for s=1:(number_of_stored_channel) %opakovani pro pocet kanalu aby se yapsalo pokazde do jineho sloupce
z(r,s)=DATA_NAMERENA(d+((slider_hodnota*10*128)*num_chan),:); %zapis dat do svodu
d=d+1; %posunuti na dalsi hodnotu v datovem souboru
%pomocna promenna aby se vedelo, kolik zaspisu probehlo
end
i=i+1;
r=r+1; %posun na dalsi radek 20ti svodu
end
p=1;%pozice prvniho svodu
k=0;%pomocna promenna pro posunuti dalsich svodu v jednom grafu
for p=1:(number_of_stored_channel) %pocet opakovani pro pocet svodu
t=1:((10*128)); %casova osa
plot(t,z(:,p)+k)
set(gca,'XTick',[0 128 256 384 512 640 768 896 1024 1152 1280])
set(gca,'XTickLabel',str2mat('0','1','2','3','4','5','6','7','8','9','10'))%vykresleni svodu
set(gca,'YTick',[100 350 600 850 1100 1350 1600 1850 2100 2350 2600 2850 3100 3350 3600 3850 4100 4350 4600 4850 5100 5350 5600 5850 6100])
set(gca,'YTickLabel',str2mat('GND','FP1','FP2','F3','F4','F7','F8','FZ','C3','C4','CZ','P3','P4','PZ','O1','O2','T3','T4','T5','T6','EOG','EMG','ECG','PNG','AUX','MKR','GNDp'))%vykresleni svodu
hold on; %podrzeni svodu v jednom grafu
k=k+250; %posunuti svodu nahoru
end
set(handles.text4,'String', 0+(slider_hodnota*10));
set(handles.text6,'String', 10+(slider_hodnota*10));
guidata(hObject, handles);
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%Vykresli data
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
slider_hodnota=get(handles.slider1,'Value');
handles = guidata(hObject);
number_of_stored_channel=handles.number_of_stored_channel;
DATA_NAMERENA=handles.DATA_NAMERENA;
num_chan=handles.num_chan;
r=1; %prvni pozice radku do matice svodu
d=1;% prvni pozice datoveho souboru
for i=1:((10*128)) %opakovani pro pocet dat v 10s
for s=1:(number_of_stored_channel) %opakovani pro pocet kanalu aby se yapsalo pokazde do jineho sloupce
z(r,s)=DATA_NAMERENA(d+((slider_hodnota*10*128)*num_chan),:); %zapis dat do svodu
d=d+1; %posunuti na dalsi hodnotu v datovem souboru
%pomocna promenna aby se vedelo, kolik zaspisu probehlo
end
i=i+1;
r=r+1; %posun na dalsi radek 20ti svodu
end
p=1;%pozice prvniho svodu
k=0;%pomocna promenna pro posunuti dalsich svodu v jednom grafu
for p=1:(number_of_stored_channel) %pocet opakovani pro pocet svodu
t=1:((10*128)); %casova osa
plot(t,z(:,p)+k)
set(gca,'XTick',[0 128 256 384 512 640 768 896 1024 1152 1280])
set(gca,'XTickLabel',str2mat('0','1','2','3','4','5','6','7','8','9','10'))%vykresleni svodu
set(gca,'YTick',[100 350 600 850 1100 1350 1600 1850 2100 2350 2600 2850 3100 3350 3600 3850 4100 4350 4600 4850 5100 5350 5600 5850 6100])
set(gca,'YTickLabel',str2mat('GND','FP1','FP2','F3','F4','F7','F8','FZ','C3','C4','CZ','P3','P4','PZ','O1','O2','T3','T4','T5','T6','EOG','EMG','ECG','PNG','AUX','MKR','GNDp'))%vykresleni svodu
hold on; %podrzeni svodu v jednom grafu
k=k+250; %posunuti svodu nahoru
end
set(handles.text4,'String', 0+(slider_hodnota*10));
set(handles.text6,'String', 10+(slider_hodnota*10));
guidata(hObject, handles);
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I can´t show last three channel concretely AUX,MKR,GNDp
Thank you for your answers.

回答(1 个)

Walter Roberson
Walter Roberson 2016-10-17
set(gca,'YTick',[100 350 600 850 1100 1350 1600 1850 2100 2350 2600 2850 3100 3350 3600 3850 4100 4350 4600 4850 5100 5350 5600 5850 6100])
that is 25 tick locations
set(gca,'YTickLabel',str2mat('GND','FP1','FP2','F3','F4','F7','F8','FZ','C3','C4','CZ','P3','P4','PZ','O1','O2','T3','T4','T5','T6','EOG','EMG','ECG','PNG','AUX','MKR','GNDp'))
that is 27 labels.
Note: it is preferred to use
set(gca,'YTickLabel', {'GND', 'FP1', 'FP2', 'F3', 'F4', 'F7', 'F8', 'FZ', 'C3', 'C4', 'CZ', 'P3', 'P4', 'PZ', 'O1', 'O2', 'T3', 'T4', 'T5', 'T6', 'EOG', 'EMG', 'ECG', 'PNG', 'AUX', 'MKR', 'GNDp'} )
Or better yet, assign the part in {} to a variable and use the variable in both places.
  4 个评论
Walter Roberson
Walter Roberson 2016-10-18
sliders are not certain to generate integer values. You should round() the index.
Walter Roberson
Walter Roberson 2016-10-18
You have
number_of_stored_channel=a(185:186,:);
handles.number_of_stored_channel=number_of_stored_channel;
so at the very least number_of_stored_channels will have two elements, and it could be a 2D array. It will be a column vector at the least, if not multiple columns with 2 rows.
You then use it with code like
number_of_stored_channel=handles.number_of_stored_channel;
for s=1:(number_of_stored_channel)
so you are using that column vector (or 2D array) as the upper limit on a : operation. You should only ever have a scalar as the upper limit. MATLAB sometimes warns about that but often does not. Instead it just typically uses the first element. Is that the right one? We as readers do not know; we do know the code is at the very least unclear.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by