Matlab Vector to xls - matlab

I have a vector V with a single row and 16761 columns.
I want to write it to an XLS file to use it for training of neural network.
I have tried following code but I got error:
V = reshape(I,1,16761);
filename = 'testdata.xls';
xlswrite(filename,V);`
Please help me to come out-off it.

As posted by the asker:
It was due to large size of vector, Excel supports only 256 columns
Note that versions after Excel 2003 support upto 16384 columns.

Related

Avoiding values to be written in engineering format in MATLAB while writing to csv

In MATLAB, I would like to write a matrix into a csv file using dlmwrite. The issue I am facing is that I would like all the numbers to be saved in the csv file in float (e.g. 0.0325 if it is float) or integer format (e.g. 12 if it is an integer), without them shown as engineering format:
I am trying it with :
dlmwrite(filename,item_statistics_new,'-append','Precision','%g%g%g%g%g%g%g%g%g%1.8f');
and
dlmwrite(filename,item_statistics_new,'-append','Precision','%1.8f');
or even
dlmwrite(filename,item_statistics_new,'-append','Precision','%g');
Here is the output :
24,4029,0.073663,0.00586759,3.6052,0.76092,0.0107733,2.86411,3,6.43734e-06
I am totally OK with all the columns (they are how I want) but I do not want the last column to be written in engineering format (6.43734e-06). The file will be passed into another program and having values in engineering format apparently is not supported.
The final columns of the matrix has got typically smaller values. Thanks for your suggestions.

Matlab csvread() creating wrong matrix

I simply want to import a matrix from a .csv into Matlab and find that Matlab is acting differently wrt length of a row in my csv. :
First, I read a file of 2 rows with 50000 columns and Matlab correctly shows a 2*50000 matrix in my workspace.
Now, if the file consists of 2 rows with 100000 columns, Matlab identifies it as a 200000*1 matrix.
What has gone wrong there?
What command are you using? csvread('filename.csv') ?
I would personally prefer to use
Data = importdata( 'filename.csv','\t');

Unable to load entire data set from CSV file

I'm unable to load an entire data set from CSV in Matlab. I'm new to Matlab so if the solution is trivial I apologize in advance.
The CSV is of dimension [2885 x 7].
I'm using data = importdata(filename, ','); which, according to the documentation is the correct usage.
However, the result of data of size [1332 x 7].
I've checked the CSV and there are no anomalies. Any ideas?

Text Categorization datasets for MATLAB

I am looking for a reliable dataset for Text categorization tasks in MATLAB format.
I want to run some experiments and don't want to spend too much time in preprocessing the text and creating feature vectors. I need something to be ready so I can plug it in my algorithm. I found a MATLAB files for reuters dataset here: link text
Everything is ready in here, but I want to use a subset of this. In this "fea" contains the feature vectors for each document. However, it seems that it is not a normal matrix. I want for example to select the top 1000 documents in this "fea". If you just download it and load it into MATLAB you will see what I mean.
So, If it is possible I need a solution for the above-mentioned dataset or any alternative datasets.
Thanks in advance.
It is stored as sparse matrix. Extract the first 1000 documents (rows), and if you have enough space, you can convert it to full dense matrix:
load Reuters21578.mat
TF = full( fea(1:1000,:) );
Lets check the variables we have:
>> whos
Name Size Bytes Class Attributes
TF 1000x18933 151464000 double
fea 8293x18933 4749196 double sparse
gnd 8293x1 66344 double
testIdx 2347x1 18776 double
trainIdx 5946x1 47568 double
so you can see TF is now about 150MB.
Other than that, the rest is self-explanatory:
fea: term-frequency matrix, rows are documents, columns are terms
gnd: category of each document, where numel(unique(gnd)) == 65
trainIdx/testIdx: split of instances (documents) for classification purposes, contains indices of rows, used as: tr = fea(trainIdx,:); tt = fea(testIdx,:);

Error " Index exceeds Matrix dimensions"

I am trying to read an excel 2003 file which consist of 62 columns and 2000 rows and then draw 2d dendrogram from 2000 pattern of 2 categories of a data as my plot in matlab. When I run the script, it gives me the above error. I don't know why. Anybody has any idea why I have the above error?
My data is here:
http://rapidshare.com/files/383549074/data.xls
Please delete the 2001 column if you want to use the data for testing.
and my code is here:
% Script file: cluster_2d_data.m
d=2000; n1=22; n2=40; N=62
Data=xlsread('data.xls','A1:BJ2000');
X=Data';
R=1:2000;
C=1:2;
clustergram(X,'Pdist','euclidean','Linkage','complete','Dimension',2,...
'ROWLABELS',R,'COLUMNLABELS',C,'Dendrogram',{'color',5})
After the xlsread statement you should get a 2000x62 double matrix Data. Then you transpose it and assign to X, so X is 62x2000 matrix. In the clustergram vectors for the properties RowLabels and ColumnLabels are supposed to match the size of your Data, but you pass a 2000-length vector as RowLabels and 2-length vector as ColumnLabels. This might cause the error.
What version of MATLAB are you using? It looks like pretty old, since you have clustergram as function, but in later versions of Bioinformatic Toolbox it was redesigned as object. In R2010a your code would generate
"ROWLABELS size does not match data"
but I'm not sure what it would be in old version.
Try to remove RowLabels and ColumnLabels, as well as other properties. Do you still get the error?