problem with xlswrite function

조회 수: 5 (최근 30일)
Kalyan Seelam
Kalyan Seelam 2020년 1월 1일
댓글: Walter Roberson 2020년 1월 5일
how to write individual characters to string in a single cell (when the string is divided to individual characters in to the cells in xlswrite) . When executing the following code the date,day are seperated in to cells (dt = datestr(now,'mmmm dd, yyyy HH:MM');). Could any one plesae help me whether can i write entire date in single cell and day in another single cell..And is there any chance of writting a string in A cell while executing this code......(this code is about student attendance system updated in excel sheet)
function notout=Record_attendance()
%rec=handles.N;
clc
clear all;
close all;
TrainDatabasePath = 'C:\Users\HP\Documents\MATLAB\Attendance\TrainDatabase\';
TestDatabasePath = 'C:\Users\HP\Documents\MATLAB\Attendance\TestDatabase\';
%%%%%%%%%%%%%%%%%%%%%%%%%%% No. of test images
TrainFiles = dir('C:\Users\HP\Documents\MATLAB\Attendance\TestDatabase\');
Train_Number = 0;
for i = 1:size(TrainFiles,1)
if not(strcmp(TrainFiles(i).name,'.')|strcmp(TrainFiles(i).name,'..')|strcmp(TrainFiles(i).name,'Thumbs.db'))
Train_Number = Train_Number + 1; % Number of all images in the training database
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
v=Train_Number;
for j = 1:v
TestImage = num2str(j);
s=strcat('a',TestImage);
TestImage = strcat(TestDatabasePath,'\',char( TestImage),'.jpg');
T = CreateDatabase(TrainDatabasePath); % T is the 1D matrix of the traindatabase
[m, A, Eigenfaces] = EigenfaceCore(T);
[OutputName,Recognized_index] = Recognition(TestImage, m, A, Eigenfaces);
SelectedImage = strcat(TrainDatabasePath,'\', OutputName);
SelectedImage = imread(SelectedImage);
% axes(eval(['handles.axes', num2str(s)]));
imshow(SelectedImage);
switch Recognized_index
case 1
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'kalyan'];
msgbox(msg);
sd=strcat('D',num2str(1));
se=strcat('E',num2str(1));
dt = datestr(now,'mmmm dd, yyyy HH:MM AM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 2
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'kalyan'];
msgbox(msg);
sd=strcat('D',num2str(1));
se=strcat('E',num2str(1));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 3
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'kalyan'];
msgbox(msg);
sd=strcat('D',num2str(1));
se=strcat('E',num2str(1));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 4
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'nikhil'];
msgbox(msg);
sd=strcat('D',num2str(2));
se=strcat('E',num2str(2));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 5
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'nikhil'];
msgbox(msg);
sd=strcat('D',num2str(2));
se=strcat('E',num2str(2));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 6
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'nikhil'];
msgbox(msg);
sd=strcat('D',num2str(2));
se=strcat('E',num2str(2));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 7
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'neelu'];
msgbox(msg);
sd=strcat('D',num2str(3));
se=strcat('E',num2str(3));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 8
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'neelu'];
msgbox(msg);
sd=strcat('D',num2str(3));
se=strcat('E',num2str(3));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
case 9
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'neelu'];
msgbox(msg);
sd=strcat('D',num2str(3));
se=strcat('E',num2str(3));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att1.xlsx',dt,'Sheet1',se);
xlswrite('att1.xlsx','1','Sheet1',sd);
%{
case 10
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'k4'];
msgbox(msg);
sd=strcat('D',num2str(4));
se=strcat('E',num2str(4));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att.xlsx',dt,'Sheet1',se);
xlswrite('att.xlsx','1','Sheet1',sd);
case 11
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'k4'];
msgbox(msg);
sd=strcat('D',num2str(4));
se=strcat('E',num2str(4));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att.xlsx',dt,'Sheet1',se);
xlswrite('att.xlsx','1','Sheet1',sd);
case 12
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'k4'];
msgbox(msg);
sd=strcat('D',num2str(4));
se=strcat('E',num2str(4));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att.xlsx',dt,'Sheet1',se);
xlswrite('att.xlsx','1','Sheet1',sd);
case 13
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'k5'];
msgbox(msg);
sd=strcat('D',num2str(j));
se=strcat('E',num2str(j));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att.xlsx',dt,'Sheet1',se);
xlswrite('att.xlsx','1','Sheet1',sd);
case 14
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'k5'];
msgbox(msg);
sd=strcat('D',num2str(j));
se=strcat('E',num2str(j));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att.xlsx',dt,'Sheet1',se);
xlswrite('att.xlsx','1','Sheet1',sd);
case 15
strmsg1 = 'The recognised person is ';
msg = [strmsg1 'k5'];
msgbox(msg);
sd=strcat('D',num2str(j));
se=strcat('E',num2str(j));
dt = datestr(now,'mmmm dd, yyyy HH:MM');
dt=char(dt);
xlswrite('att.xlsx',dt,'Sheet1',se);
xlswrite('att.xlsx','1','Sheet1',sd);
%}
otherwise
strmsg1 = 'Person not recognised';
msgbox(strmsg1)
end
end
notout=1;
  댓글 수: 6
Kalyan Seelam
Kalyan Seelam 2020년 1월 5일
No,but after deleting its working fine.
There is problem with writing name(string)in A cell can you please clarify it...
Thank you
Walter Roberson
Walter Roberson 2020년 1월 5일
What is your current code?

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

답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by