Clear Filters
Clear Filters

expot to excel file

2 views (last 30 days)
Olga
Olga on 11 Mar 2012
I'm looking for some help about what should I do to export to excel file (preferably) all the results from my GUI. I mean the counted parameters and the plots. Can u help me with this?
That's how I'm doing the analysis and this is what I would like to export to excel file:
%handles.R_loc;
%handles.R_valu;
a1=handles.R_loc(1:end-1)/handles.fs;
a2=handles.R_loc(2:end)/handles.fs;
odstepRR=a2-a1;
% meanNN
meanNN=mean(odstepRR);
set(handles.meanNN, 'string', num2str(meanNN*1000));
%minNN
minNN=min(odstepRR);
set(handles.minNN, 'string', num2str(minNN*1000));
%maxNN
maxNN=max(odstepRR);
set(handles.maxNN, 'string', num2str(maxNN*1000));
%HR
hr=60./(odstepRR./1000);
HR=round(mean(hr))/1000;
set(handles.hr, 'string', num2str(HR));
% SDNN
SDNN=std(odstepRR);
set(handles.sdnn,'string',num2str(SDNN*1000)); % mnozymy przez 1000 bo jest w ms
% RMSSD
RMSSD=sqrt(sum(((mean(odstepRR)-odstepRR).^2))/length(odstepRR-1));
set(handles.rmssd,'string',num2str(RMSSD*1000)); % mnozymy przez 1000 bo jest w ms
% NN50
o1=odstepRR(1:end-1);
o2=odstepRR(2:end);
roznica_odstepowRR=o2-o1;
ss=zeros(1,length(o2));
ss(abs(roznica_odstepowRR)>0.05)=1;
NN50=sum(ss);
set(handles.nn50,'string',num2str(NN50));
%pNN50
pNN50=NN50/length(odstepRR);
set(handles.pnn50,'string',num2str(pNN50*100)); % * 100 bo mają być %
%Poincare plot
xp=odstepRR;
xp(end)=[];
xm=odstepRR;
xm(1)=[];
%SD1
SD1 = std(xp-xm)/sqrt(2);
set(handles.sd1, 'string', num2str(SD1*1000));
%SD2
SD2 = std(xp+xm)/sqrt(2);
set(handles.sd2, 'string', num2str(SD2*1000));
%SDRR
SDRR=sqrt(SD1^2+SD2^2)/sqrt(2);
set(handles.sdrr, 'string', num2str(SDRR*1000));
axes(handles.axes4);
set(handles.text44, 'visible', 'on')
plot(xm,xp,'.')
psdest = dspdata.psd(odstepRR, 'Fs',400);
TP = avgpower(psdest,[0.0 0.4]);
set(handles.tp, 'string', num2str(TP));
ULF = avgpower(psdest, [0.0 0.0033]);
set(handles.ulf, 'string', num2str(ULF));
VLF = avgpower(psdest, [0.0033 0.04]);
set(handles.vlf, 'string', num2str(VLF));
LF = avgpower(psdest, [0.04 0.15]);
set(handles.lf, 'string', num2str(LF));
HF = avgpower(psdest, [0.15 0.4]);
set(handles.hf, 'string', num2str(HF));
LFHF = LF/HF;
set(handles.lf_hf, 'string', num2str(LFHF));
axes(handles.axes5);
set(handles.text45, 'visible', 'on')
set(handles.axes5, 'visible', 'on')
plot(psdest)
%plot(freq,10*log10(psdest));
grid on;
guidata(hObject, handles);

Accepted Answer

Image Analyst
Image Analyst on 11 Mar 2012
Get your data into a numerical array, or a cell array, and then call xlswrite(). If you need to do this many times, you'll want to use ActiveX for speed. it's more complicated though. Let me know if you want ActiveX demo code.
  2 Comments
Olga
Olga on 12 Mar 2012
Thank you very much. ;)
Okey, I've done a cell array from my data. But how should I do this so that each time it is saved as a new excel file (doesn't overwrite previous)? Or so that the file is saved in Current DIrectory whatever it is (because I need to use it on various computers)? Is it possible?
I've done it like this:
wyniki = struct2cell(wynik);
savefile2 = 'wynikianalizy.dat';
save(savefile2, 'wyniki')
xlswrite('C:\Users\Owu\Documents\INŻ INŻ INŻ\inżynierka bangla\program 1.7\wynikianalizy.xls', wyniki, 'B1:B17');
Image Analyst
Image Analyst on 12 Mar 2012
Don't use save() - that saves it to a mat file - unless you want both an Excel and a mat file. Use xlswrite like you're doing but make sure to specify the full file name (folder + base filename). I would not use cd in your m-file. See the FAQ: http://matlab.wikia.com/wiki/FAQ#Where_did_my_file_go.3F_The_risks_of_using_the_cd_function.

Sign in to comment.

More Answers (1)

kyioshi hyb
kyioshi hyb on 8 Dec 2012
Hi,
Where did you get the handles function? Im a litle lost but i need to calculate the parameters for ECG signal and i dont know how
  1 Comment
Image Analyst
Image Analyst on 10 Dec 2012
It's created when you develop a GUI with GUIDE.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!