Effacer les filtres
Effacer les filtres

Excel import and operations

1 vue (au cours des 30 derniers jours)
dinesh kumar mohan
dinesh kumar mohan le 21 Sep 2019
Hi Everyone,
I have an excel sheet, in which Column 1 is text(eg: A,B,C..) and column 2 is numbers(1,2,3,...), column 3, 4,5,6, with numbers and text.
How to assign the values of column 1( which is text A,B, C,..) takes the values of numbers in column B. While doing operations further in my Matla with some formulas i need the value of column2(numbers) must be used in place of column 1 text and print the result??
So, that my fuction will use the alphabets and results comes from the column 2 nubers.??
  2 commentaires
Walter Roberson
Walter Roberson le 21 Sep 2019
I am having difficulty understanding what you want, but if I understand correctly, your first column contains variable names and your second column contains variable values, and you have some formulas written in terms of the variable names which you want to evaluate with the corresponding variable values used in place of th names?
dinesh kumar mohan
dinesh kumar mohan le 21 Sep 2019
Yes.. your right..

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Sep 2019
Probably the easiest way to do this is to use the symbolic toolbox. You can construct a struct in which the field name is the name from column 1, and the value is the entry from column 2, and you define a symbolic variable with the same name as column 1. Then you can subs(TheFormula, TheStructOfValues) and the symbolic toolbox will do all of the lookups for you.
This approach has the advantage of not needing to change the formula.
However, I would not say that is the best way.
One better way would involve writing the formulas with the variable names as fields referencing a struct. You would construct a struct in which the field name is the name from column 1, and the value is the entry from column 2, and then you would evaluate the formula in terms of the struct.
Another better way would involve writting the formulas with the variable names looking like indexing into an array, such as M('speed')*M('time') instead of speed*time . Then you would construct a containers.Map with the indices taken from the first column of the excel, and the value taken from the second column.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by