필터 지우기
필터 지우기

Insert the date and time on an excel file from a .mat file

조회 수: 2 (최근 30일)
Samah EL QASSAH
Samah EL QASSAH 2017년 9월 20일
댓글: Samah EL QASSAH 2017년 9월 21일
Hi,
I wrote a script that converts a .mat file into an Excel file:
% --- Executes on button press in Push
function Push_Callback(hObject, eventdata, handles)
g = get(handles.Push,'value');
if g == 1
%%Stop the simulation
set_param('MAJ','SimulationCommand','stop');
stop(handles.t);
set(handles.Stop,'BackgroundColor', 'red');
%%%%%%%%%%%%%%%%%%%%%%%%%%%
data=load('Exchange(1).mat');
h=fieldnames(data);
for k=1:size(h,1)
T = {'TIMER'};
A = {'FT5Lock'};
xlswrite('Suivi_monitoring.xlsx',data.(h{k}),'sheet_A', 'B1')
xlswrite('Suivi_monitoring.xlsx', T , 'sheet_A', 'A1')
xlswrite('Suivi_monitoring.xlsx', A , 'sheet_A', 'A2')
end
winopen Suivi_monitoring.xlsx
end
where the first line indicates the simulation time. I want to know if there is a possibility to indicate in the first line the system time (HH: MM: SS) instead of the simulation time?
I know there are quite a few functions dedicated to return the current time and date of the system like "clock" but I do not know how to do it.
  댓글 수: 2
Rik
Rik 2017년 9월 20일
What is your question exactly? Do you want to get the system time and convert to a string of the 'HH:MM:SS' format? If so, just take a look at the datestr family of functions.
Samah EL QASSAH
Samah EL QASSAH 2017년 9월 20일
I used a tofile block to write the data into a .mat file that I exported to an excel file. So the first line indicates the simulation time and the second line the data.
I want to display on the Excel file on the first line the date on which the data is written in the .mat instead of the simulation time.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 9월 20일
This might be a job for m2xdate:
date = m2xdate(now);
xlswrite('Suivi_monitoring.xlsx', date, 'sheet_A', 'B1')
Or if you do not have the Financial Toolbox use this relation:
sdate_Matlab = sdate_Excel + 693960;
  댓글 수: 1
Samah EL QASSAH
Samah EL QASSAH 2017년 9월 21일
I used a tofile block to write the data into a .mat file that I exported to an excel file. So the first line indicates the simulation time and the second line the data.
I want to display on the Excel file on the first line the date on which the data is written in the .mat instead of the simulation time.
When I use :
date = m2xdate(now);
xlswrite('Suivi_monitoring.xlsx', date, 'sheet_A', 'B1')
I get this:
I tried this:
d = datestr(now, 'HH:MM:SS');
xlswrite('Suivi_monitoring.xlsx', d , 'sheet_E', 'A3')
I get the following result:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by