Prev: How can I compute the probability that a set has normal distribution with zero mean
Next: How can I compute the probability that a set has normal distributionwith zero mean
From: chinedu on 27 Jul 2010 14:28 I created a listbox the played a series of random sound+noise.wav files. When a file was played it would ask me the patient got the response correct or not. It will continue asking me until I have hit 14 reversals (switching from yes to no responses). It displays the final db threshold of the SNR. Now I need help in printing out a few things such as: Pathname of the file Contents of listbox (in a colum) Contents in listbox with : Gain SNR If the response was correct Now I have no idea on how to begin. I have never had to display any results before outside of the command window so I need ideas. I do not what it to display the results in the command window also. It does that already. I need it when I hit a push button all the mentioned info above will be displayed in a text window or a notepad anything and be able to save it. Thank you! S.N I looked at fprintf and that had not been of any help
From: us on 27 Jul 2010 14:40 "chinedu " <chinedu.okoro(a)nyumc.org> wrote in message <i2n8g0$pkf$1(a)fred.mathworks.com>... > I created a listbox the played a series of random sound+noise.wav files. When a file was played it would ask me the patient got the response correct or not. It will continue asking me until I have hit 14 reversals (switching from yes to no responses). It displays the final db threshold of the SNR. Now I need help in printing out a few things such as: > > Pathname of the file > Contents of listbox (in a colum) > Contents in listbox with : Gain SNR If the response was correct > > Now I have no idea on how to begin. I have never had to display any results before outside of the command window so I need ideas. I do not what it to display the results in the command window also. It does that already. I need it when I hit a push button all the mentioned info above will be displayed in a text window or a notepad anything and be able to save it. > > Thank you! > S.N I looked at fprintf and that had not been of any help sigh... 1) since the results ...seem... to be displayed in the command window already: how do they get ...there... - a variable(?)... - a magic wand(?)... 2) WHY did FPRINTF not work(?)... - can you show your ML code that you tried to get to work(?)... us
From: Florin on 27 Jul 2010 14:49 "chinedu " <chinedu.okoro(a)nyumc.org> wrote in message <i2n8g0$pkf$1(a)fred.mathworks.com>... > I created a listbox the played a series of random sound+noise.wav files. When a file was played it would ask me the patient got the response correct or not. It will continue asking me until I have hit 14 reversals (switching from yes to no responses). It displays the final db threshold of the SNR. Now I need help in printing out a few things such as: > > Pathname of the file > Contents of listbox (in a colum) > Contents in listbox with : Gain SNR If the response was correct > > Now I have no idea on how to begin. I have never had to display any results before outside of the command window so I need ideas. I do not what it to display the results in the command window also. It does that already. I need it when I hit a push button all the mentioned info above will be displayed in a text window or a notepad anything and be able to save it. > > Thank you! > S.N I looked at fprintf and that had not been of any help Hi, fprintf should do the job. use something like : fid = fopen('output.txt','w'); fprintf(fid,"%f " ,path_to file); % and other info fclose(fid); Hope it helps, Florin
From: chinedu on 27 Jul 2010 16:29 > > sigh... > > 1) since the results ...seem... to be displayed in the command window already: > how do they get ...there... > - a variable(?)... > - a magic wand(?)... > > 2) WHY did FPRINTF not work(?)... > - can you show your ML code that you tried to get to work(?)... > > us here is my code global data; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Input of dB step size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% prompt = {'Threshold size:'}; dlg_title = 'Input db size'; num_lines = 1; def = {'','hsv'}; options.WindowStyle='default'; answer = inputdlg(prompt,dlg_title,num_lines,def); data.d=str2num(answer{1}); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Select file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [files path] = uigetfile('*.*','Please select a file', 'MultiSelect', 'on'); if isnumeric(files) %check to see if Cancel buttion was hit return; %if so, stop program end if ~path return; end inputImages = get(handles.listbox1,'String'); if iscell(files) == 0 inputImages{length(inputImages)+1} = fullfile(files); else for n = 1:length(files) inputImages{length(inputImages)+1} = fullfile(files{n}); end end set(handles.listbox1, 'String', inputImages); guidata(hObject, handles); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Loading files into listbox %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% contents = get(handles.listbox1,'String'); pathname = contents{get(handles.listbox1,'Value')}; pause(.5); %[data.y, data.Fs] = wavread(pathname); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Selecting files at random %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set(handles.listbox1,'value',1) m=length(contents); Indices=randperm(m); data.t=1; button = ''; oldp = m+1; dB=0:0.1:10; while strcmp(button,'Cancel') == 0; for q=1:m; p=Indices(q); % p = round((m-1)*randperm(1)+1); % while p == oldp % p = round((m-1)*rand(1)+1); % end % oldp = p; set(handles.listbox1,'value',p); pathname = contents{get(handles.listbox1,'Value')}; [data.y, data.Fs] = wavread(pathname); s=data.y(:,1); n=data.y(:,2); n2=data.t*n; assignin('base', 'n2', n2); data.y =[s, n2]; wavplay (data.y,data.Fs) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Increasing and decreasing of noise level %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [button]=questdlg('IS THE RESPONSE CORRECT','','Yes','No','Cancel','Yes') s=data.y(:,1); n=data.y(:,2); assignin('base', 'n', n); a=leq(s,length(s),.00002^2); b=leq(n,length(n),.00002^2); data.c(data.count+1)=a-b %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %For the 'Yes' button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if strcmp(button,'Yes') if strcmp(data.previous, 'No') data.count=data.count+1; if data.count==14 th(data.genCount) = sum(data.c(4:14))/10; msgbox(['14 reversals have been reached: Threshold Level = ' num2str(th(data.genCount))]) return data.count = 0; data.genCount=data.genCount+1; if data.genCount==3 finalTh=sum(th)/3; msgbox(['final thr: ' num2str(finalTh)]); end end end data.previous = 'Yes'; data.t=data.t*sqrt(10^((data.d)/10)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %For the 'No'button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(button, 'No') if strcmp(data.previous, 'Yes') data.count=data.count+1; if data.count==14 th(data.genCount) = sum(data.c(4:14))/10; plot(data.c); msgbox(['14 reversals have been reached: Threshold Level = ' num2str(th(data.genCount))]) return data.count = 0; data.genCount=data.genCount+1; if data.genCount==3 finalTh=sum(th)/3; msgbox(['final thr: ' num2str(finalTh)]); end end end data.previous= 'No'; data.t=data.t*sqrt(10^(-(data.d)/10)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %For the 'Cancel' button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(button, 'Cancel') return end end end Section I need help in % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, 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) contents = get(handles.listbox1,'String'); %pathname = contents{get(handles.listbox1,'Value')}; fnam='anew.txt'; com=fprintf('notepad %s',fnam); fprintf(contents); % fid=fopen(savename, 'w'); % for i=1:length(logfile) % cell=cell2mat(logfile(1,i)); % fprintf(fid, '%s\r\n', cell) % end system(com); all it does is just opens a notepad but does not display the contents of the listbox
From: us on 27 Jul 2010 16:34
On Jul 27, 10:29 pm, "chinedu " <chinedu.ok...(a)nyumc.org> wrote: > Section I need help in > contents = get(handles.listbox1,'String'); > %pathname = contents{get(handles.listbox1,'Value')}; > fnam='anew.txt'; > com=fprintf('notepad %s',fnam); > fprintf(contents); > % fid=fopen(savename, 'w'); > % for i=1:length(logfile) > % cell=cell2mat(logfile(1,i)); > % fprintf(fid, '%s\r\n', cell) > % end > system(com); > > all it does is just opens a notepad but does not display the contents of the listbox how could this possibly work(?!)... you're NEVER writing anything into anything... us |