Is there a way to convert from Excel data to code conversion?

6 visualizaciones (últimos 30 días)
Haritha
Haritha el 1 de Abr. de 2019
Editada: Adam Danz el 2 de Abr. de 2019
Hi,
I have excel data implemented with formulas and i want to implement the same data in matlab. Is there a way to import the code directly instead of writing line by line?
Example excel data:
Column1= 1:10
column2 = 2:11
column3= Column1^3+Colum2^2
Column4=root(Column1)+Colum2^5
Column5= If(Colum3>Column4)
Output = 1 else Output = 0
Like this i have lot of columns with different kinds of formulas.
Is there any tool in matlab to get all the formulas directly from excel to matlab code?
Thanks in advance
  3 comentarios
Haritha
Haritha el 1 de Abr. de 2019
Editada: per isakson el 1 de Abr. de 2019
IFERRROR(+VLOOOKUP(A2,'File directory[Filename.xlsx]Lookup'!$A$1:N18,2,FALSE),"")
If any one knows how to implement this formula in matlab
Adam Danz
Adam Danz el 1 de Abr. de 2019
I replied below in the answer section.

Iniciar sesión para comentar.

Respuestas (1)

Adam Danz
Adam Danz el 1 de Abr. de 2019
Editada: Adam Danz el 1 de Abr. de 2019
If any one knows how to implement this formula in matlab
IFERRROR(+VLOOOKUP(A2,'File directory[Filename.xlsx]Lookup'!$A$1:N18, 2, FALSE),"")
% [1] |----------------------[2]-------------------|[3] [4]
This vlookup function searches the first column of the dynamically produced table [2] for the value stored in A2 [1] and returns the value stored in the 2nd column [3] of that row. The 'false' flag [4] requires an exact match.
The first step is to get the data from "'File directory[Filename.xlsx]Lookup'!$A$1:N18" and put it into a matrix. I assume this has already been done *(see comment below).
Below is the vlookup function in matlab and a demo.
% Create vlookup equation that looks for value 'v' in column 1 of matrix 'd'
% and returns the corresponding value in column 'c'.
vlookup = @(v,d,c) d(d(:,1)==v,c);
% Produce fake data
data = magic(5)
% look up value 36 in column 1 of 'data' and
% return corresponding value in column 3
vlookup(10, data, 3)
It returns an empty value which is the same thing your excel line is designed to do.
  1 comentario
Adam Danz
Adam Danz el 1 de Abr. de 2019
Editada: Adam Danz el 2 de Abr. de 2019
(*) judging by that single line of code and the dynamically defined table (matrix), I have a feeling a large part of your project will be to load the data into matlab and organize it. Take your time with this. Data cleaning is often 80% of the job.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by