Unable to write to an .xls file (MatLab) - matlab

I wanted to edit a certain .xls spreadsheet in MatLab by, say, inserting number 3 into cell H4. I typed out following code:
xlswrite('list.xls', 3, 1, 'H4')
but it doesn't change anything. The spreadsheet is left seemingly untouched but xlswrite returns 1 as the write succeeded output...
Any ideas on what might be going on?
Cheers.

Try with this:
xlswrite('test',3,'H4:H4')

Related

Reading from Excel gives ####### in some columns

I am using powershell to read data from a .xls file. All goes well, no need to display the code. But I have an issue that I have no idea how to solve.
Some columns in the excel are not wide enough to display their data:
In reality:
2016.04.01
As the column is displayed when opening the file:
########
When I am reading from the excel, the cell content I get in powershell is actually ########, not the actual cell content (= a date in this case).
I am reading 1000's of Excel files, all with the same issue. How can I fix this in my code? Is there a flag I need to set that I don't know about?
Any help would be much appreciated!

matlab lose response when use xlsread reading a large spreadsheet

I am trying to use xlsread functioin to read spreadsheets of 6000x2700 (xlsx file).
I have two questions:
First, when I use something like
[num,txt,~]=xlsread(input_file,input_sheet,'A1:CYY6596')
Matlab keeps showing 'busy' and lose response (while I can open it in excel within 30 seconds).
Is there any solution If I don't want to loop through ranges of the xlsx file? In other word, can I just dump spreadsheet of this size into matlab using xlsread?
Alternatively, Maybe I can use loops to read these files range by range, but I cannot identify the last column of each of the spreadsheets unless I read the whole file first. Therefore, If I cannot identify the last column, it is hard to make loops and do my interpretation on the file.
So My second questions is: Is there a way to identify the last column of the spreadsheet without reading the whole spreadsheet?
Thanks.
EDIT:However, if I run a similar code which only reads first 400 columns ('A1:RY6596') of the spreadsheet, such problem doesn't happen.
which version of matlab you are using?
matlab has a problem to load bix excell file.
convert the excell in csv and use M = csvread(filename).
You can try to convert .xlsx into .xls also.
You can Try the tool in
File Exchange

In Matlab read a specific column of data in a text file

I have a text file that, when opened in excel, contains columns of data.
I want to use textread in matlab to read a specific column of data.
So, if it were an excel file, I could do:
Data = 'My_data_file.xlsx';
Column_C = xlsread(Data,'C:C');
But how do I do this with a text file?
Thanks!
You will need to know the format of your file. If you have a file that looks like this :
Name,Price,Volume
Sally,120,4.8
John,135,35.49324
You could use the following code :
[~,~,C]=textread('file.txt',%s,%f,%f);
You will insert a ~ to suppress output of certain columns.
Not tested, but you can go through--
help textread;
help csvwrite;
Once you get csv from txt, by
[num, txt, all] = xlsread('My_data_file.csv');
you can get everything inall.
How to get the column, you know well.

xlsread function in matlab systematically loads the whole file and not the specified cells

I used the command
[num,txt,raw] = xlsread(excelPath,1,'C2:C3')
as it was done here (Reading strings into Matlab from excel?) but matlab systematically loaded the whole excel file. I don't need all the table and only want the specific cells C2 and C3. How can I do this ? (A more brutal solution would be to load the whole file and then look for the right place in num, txt or raw but I look for the other solution)
Thanks !
Have you just tried
num = xlsread(excelPath,1,'C2:C3')
Does this load only the specified cells?
EDIT
if you are using xlsread on a non-Windows O/S, then it uses the basic mode which "does not support an xlRange input when reading XLS files. In this case, use '' in place of xlRange." See the documentation for the xlsread function for more info.

Write a figure to a file automatically in MATLAB

Does anyone know if it's possible to automatically write a figure out to a .eps file in MATLAB?
I'm running a script that produces a large number of graphs, and it'd be nice if I didn't have to manually save each one!
print function does that:
Print figure or save to specific file format...
print(filename,formattype) saves the current figure to a file using the specified file format, such as print('BarPlot','-dpng'). If the file name does not include an extension, then print appends the appropriate one.
print(filename,formattype,formatoptions) specifies additional options that are available for some formats.
print prints the current figure to the default printer...
print or saveas will do the trick.
saveas(fig_handle, 'filename','eps')
print('-deps',fig_handle)
print -deps 1
If you want to specify the output file name, you're better off using saveas.
This was answered in this other question, using the PRINT command. Although that question dealt with making .tiff images, it should be straightforward to modify the code given in those answers to write a .eps.
Suppose, you are generating N numbers of figures in a loop, then you should try the command line:
saveas(gca,sprintf('Figure%02d.pdf',N )); it produces N figures Figure1.pdf - FigureN.pdf
saveas(gca,sprintf('Figure%02d.eps',N )); it produces N figures Figure1.eps - FigureN.eps
in place of gca one can use gcf also. First command line is a better solution.
Hope this will solve your issue.