MATLAB: Excel import and operations

excel operationsMATLABMATLAB Report Generatorsimulink

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.??

Best Answer

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.