Reading large Excel array into MATLAB - arrays

So I have a huge excel file with 210 columns from(A all the way to CK)-Each of these columns have 80000-300000 values.I want to read this into a MATLAB array.I have two problems:
1.Is there any way that I can loop through the letters iteratively(from A to CK)?
2.When I try to read the file as a whole it says no storage-but I am able to create a matrix of ones of size-300000*210....So Im a bit puzzled and dont know what to do..??
Thanks!!

Save in the .csv format from EXCEL, then use load -ascii in matlab.

You can loop through the Excel column with the option xlRange of xlsread (doc).
And both the output num = xlsread(...) and [num,txt,raw] = xlsread(...) duplicate the information being read in several variables (type edit xlsread in the command window).

Related

Setting one CSV as an array to compare data from another CSV

I am new to Python and am over complicating the coding on a project so I am starting with much smaller data sets in order to learn the process. My boss is having me compare two CSV files. The first CSV only contains the data 1,2,3,4,5,6 all in a single column. He wants me to set this CSV file as an array so I can compare the second CSV against it. The second CSV contains the data 3,5,6 all in a single column. The code should result in a print out of 1,2,4 as it is the only data not found in both CSV files.
I originally tried to write a code to import both CSV files and compare data without setting it as an array but this did not work so the first CSV file needs to be set as an array. The problem is I am not sure exactly how to do this with an array. This is what I have so far, any help anyone could give me would be greatly appreciated. I have been working on this project for a week now and am at a total loss, even with this simplified form.
import csv
temp_list = []
with open('1.csv','rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
In terms of psuedo-code, what you need to do here is import both csv files into two separate arrays, Array A and Array B for example.
Now what you need to do is compare each index position in one array, to each index position in the other array.
You need to create a nested loop, where the outer loop will choose an index position in A and then inner loop chooses a position in B.
After you check one index in A with each position in B, and no positions are the same, I suggest adding this value into a third array, C. You can check which positions are the same by using a boolean flag. When your code is done, C will have any values that don't exist in both A and B.
I suggest following these tutorials to learn more about python syntax:
https://www.w3schools.com/python/
Good luck

Adding numbers from 3 different CSV columns

I am newer to programming and I am trying to figure out how I can add all of the numbers from the B column together and all of the C column together and the D column together with those variables named x y and z respectively. I have been searching everywhere for an answer. All I have gotten is to read the first line of the csv file.
This is a screenshot of part of the CSV file:
Once you've read it in, you need to somehow split it up into actual columns. Check this function, that should help.
strtok()
Then you need to store it in some kind of array. Then index which elements in the array you want, and process them by using a cumulative sum. This might require a while loop until you've reached the last line of the file.
I will leave the actual code to you, but this should get you going.

How to Write multiple Arrays in excel using Matlab

I have list of values save in variables like. A= 1,2,3,4,5,6,7 and B = 4,5,6,73,2,3,2 //This may be Array or column. Easy one will be preffered
Note A and B values will be dynamic which will be get through some function.
I want to save A's and B's Values in Excel Sheet, like A's values in First column and B's values in 2nd Column.
I read about xlswrite but did not find any scenerio as i require.
And when They are saved then Again want to read them, and to save them in some other variables like C and D. I want to save Data of first column in C and second column data in D.
I read about C = xlsread('filename') but problem with it is. This save all the values in one variable. like if Excell have two columns. Those both will be saved in one variable C. But my requirment is one colum in one varibale and so on.
Take a look at the Documentation
Syntax for writing to excel file
xlswrite(filename,A,sheet,xlRange)
Code:
%// As your variable is a row vector, it is transposed to column vector
%// before writing, as you preferred
xlswrite('outputFileName.xlsx',[A.',B.'],1,'D2')
Note: Make sure that the excel file is closed while writing
Syntax for reading from excel file
num = xlsread(filename,sheet,xlRange)
Code:
%// reading the range into one temporary variable
temp = xlsread('outputFileName.xlsx',1,'D2:E7')
C = temp(:,1)
D = temp(:,2)
I know English is not your primary language, but please try to be as gramatically correct as you can, it will make your questions easier to understand, and easier to answer to.
As for your question, I think you want to use the additional parameter in the functions you found to specify the columns you are writing to:
xlswrite('sheet.xls', A, 'E3')
will write the data of A on the cells E3, ..., E9.
And when you want to retrieve it, you do the same:
C = xlsread('sheet.xls', 'E3-E9')
This will read E3 to E9 cells and put the value in C.

Array multiplication in Excel

In my excel document I have two sheets. The first is a data set and the second is a matrix of the relationship between two of the variables in my data set. Each possibility of the variable is a column in my matrix. I'm trying to get the sum of the products of the elements in two different arrays. Right now I'm using the formula {=SUM(N3:N20 * F3:F20)} and manually changing the columns each time. But my data set is over 800 items...
Ideally I'd like to know how to write a program that reads the value of the variable in my dataset looks up the correct columns in the matrix, multiplies them together, sums the products, and puts the result in the correct place in my data set. However, just knowing the result for all the possible combinations of columns would also save me alot of time. Its an 18x18 matrix. Thanks for any feedback!
Your question is a little bit ambiguous but as far as i understand your question you want to multiply different sets of two columns in the same sheet and put their result into the next sheet, is it so? if so, please post images of your work (all sheets). Your answer is possible even in Excel only without any vba code, thanks.
you can also use =SUMPRODUCT(N3:N20,F3:F20) for your formula instead of {=SUM(N3:N20 * F3:F20)}

Matlab Multidimensional Arrays with string + Exporting to Excel

i have a code that works on all files in folder and analyise it and come then export results into excel sheet.
My question is, by the end i alot of excel sheets and i need to combine them all together (i also need them separate) so i do this manualy and its really painfull and time wasting !
So i want to ask is there a way to create an array to save the results of each analysis my code process and export all at the end to one excel file.
Example of my code Workflow:
Read files in current dir
Open files one by one.
Do math equations and get results into 2 arrays amp[] signal[] (both are equal in size)
Export results into Excel using
xlswrite([b '.xls'],[amp' signal'],1);%%b=file name (example.avi ==> example.avi.xls)
And so on.
So i want to save the results after that to array with the filename and at the end past all into 1 excel sheet with the file name on top of each column :)
I dont know why i'm having a brain block on how to do it !
Thanks alot for your help in advance
Xlswrite supports that you give a start point or range where you want to put your data. See Xlswrite.
You can quickly calculate the column name using this.
But you must be aware that excel only supports 255 columns and 1024 rows in a sheet. This happened often to me and then one gets a very uninformative error.

Resources