Append columns from a known variable into cell
Show older comments
Hi!
I can't seem to find the solution to this problem.
In my program I'm extracting data from multiple e.g. 6 excel files (through readcell), all with the same structure: column 1 with the quantity, column 2 with the value and column 3 with the unit of measurement, obtaining a {28,3} cell.
I then extract in a for loop the second column, and create a matrix of all the numeric values adding column after column for the different examines files.
What i'd like to do now is to create a cell with:
- column 1 from the first cell with the quantity names;
- column 2:(6+1) with the different values of the quantity across the 6 files
- column 8 with the units of measurement;
Here is the script that I tried:
clear all
dataset=uigetfile('*.xlsx','Multiselect','on');
for i=1:length(dataset)
tri=readcell((dataset{1,i}));
estrai(:,i)=cell2mat(tri(:,2));
end
output=[tri(:,1),estrai];
xlswrite('Analysis',output)
If I run the script i get the following error:
Dimensions of arrays being concatenated are not consistent. Consider converting input arrays to the same type before concatenating.
I also tried writing output as output={tri(:,1),estrai} but instead of a 28x7 cell it returns a 1x2 cell, in which element {1,1} is a 28x1 cell and {1,2} is a 28x6 double. xlswrite('Analysis',output) in this case returns an empty excel file.
Any help?
Accepted Answer
More Answers (0)
Categories
Find more on Tables in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!