help with xlswrite [char write and blank data]

6 views (last 30 days)
franco otaola
franco otaola on 18 Nov 2016
Answered: KSSV on 18 Nov 2016
hello currently I am working with a matlab that takes the date of the experience of the folder where it reads some information so for example the folder has the name "2016-11-15 Test 1" and I need to save some information that the program produce in an excel and I am struggling with two things first with the date I have coded like this
xlswrite(['Path\excel.xlsx'],Date, Test,'C2');
so, date is going to be a char of 1x10 and my problem is that the matlab when it writes inside excel it puts like this the date
1 | | | | | | | | | | | | |
2 | | |2|0|1|6|-|1|1|-|1|5|
and I would like something like this
|A|B| C |D|
1 | | | | |
2 | | |2016-11-15| |
another problem I have is that the sheet where I place the info has already information in it for example, in excel.xlsx has the sheet "Test 1" already existing with information in the A17:A50 and in the F17:I17 and I am placing some information in the matrix C17:E[] with a matrix that is going to be [A,Area,Concentration] that are defined inside matlab so I put it
xlswrite(['Path\excel.xlsx'],horzcat(A, Area, Concentration), Test,'C17');
my problem is that the matlab erase the info that is already in the sheet even if it doesn’t write things in it (so all the cells in A17:A50 and in the F17:I17 after running the program will be empty). it is possible to say to matlab to "don’t touch" the cells that it doesn’t has to write? thanks

Answers (1)

KSSV on 18 Nov 2016
clc; clear all ;
close all;
dirdata = dir(fullfile(pathname,'.'));
dirdata= dirdata(arrayfun(@(x), dirdata) ~= '.');
fnsz = size(dirdata);
numfiles = fnsz(1);
filenames = cell(numfiles-1,1) ;
for n=1:numfiles-1
[savefile,savepath]=uiputfile('*.xlsx', 'Save results in an Excel file');
if ispc

Community Treasure Hunt

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

Start Hunting!

Translated by