Import units from excel sheet

I want to import values and units separately from an excel file:
Capture.PNG
How can I identify the units and relate them to the values?
Instead of writing COST.u.EUR, is it possible to have it as [COSTvalue Costunits] but identified from the input file?

10 件のコメント

dpb
dpb 2019 年 8 月 14 日
Attach the file (or a short section of one)
Jyotsna Talluri
Jyotsna Talluri 2019 年 8 月 20 日
Is that a dropdownlist in the currency column??
Aikaterini Mountraki
Aikaterini Mountraki 2019 年 8 月 20 日
編集済み: Aikaterini Mountraki 2019 年 8 月 20 日
Yes, it is a dropdown list. The excel is my input file, so I have restricted the possible options with dropdown lists.
dpb
dpb 2019 年 8 月 20 日
Again I reiterate once more..."attach the file"
Aikaterini Mountraki
Aikaterini Mountraki 2019 年 8 月 21 日
編集済み: Adam Danz 2019 年 8 月 21 日
the script goes like this:
------------
% Import Data Files
RawCCostData = readtable('UserData.xlsx',"Sheet",'CCost');
% Identify Parameters
Process_i = categorical(RawCCostData.Process)
cost = RawCCostData.Cost
syms u1 u2
u = symunit;
u1 = isUnit( RawCCostData(:,2) );
u2 = isUnit( RawCCostData{:,3} );
-----------------
So when I want to convert unit systems I usually do:
Cost = unitConvert(Cost,u.USD)
But my problem is that since cost and units (currency) are inserted by different columns, they are not related together in the input file. So, how can I relate those two?
Thanks for the help
Adam Danz
Adam Danz 2019 年 8 月 21 日
編集済み: Adam Danz 2019 年 8 月 21 日
I believe dpb was refering to the excel file UserData.xlsx.
Aikaterini Mountraki
Aikaterini Mountraki 2019 年 8 月 21 日
Here is the input file
dpb
dpb 2019 年 8 月 21 日
Ah! I was thinking the problem had to do with importing the spreadsheet owing to the dropdown boxes or somesuch...not to using symbolic TB and the symbolic names feature. Since I don't have that TB, not much I can actually do but to note that in the table the variables are associated by row index across all variables so reference a specific row or set of rows and you'll have all the associated data with it. I dunno how the symbolic variables interact with a table, but I'd probably convert the Currency variable to categorical as well.
To convert to another set of units in a table you would have to either pull out the data to convert to the symbolic form (and I have no idea how it would deal with currency conversion given the rate of conversion isn't a fixed number as with physical units) or have a function that uses the table data and "knows" how to do the allowable conversions of which column is associated with the column containing the currency specification.
Don't know that there is a canned solution.
Aikaterini Mountraki
Aikaterini Mountraki 2019 年 8 月 22 日
I will give it a try. Thanks
dpb
dpb 2019 年 8 月 22 日
If you had the financial toolbox, perhaps there's something in it dealing with currency conversions??? I don't know that, just a guess that's where something like that might reside if it exists...

サインインしてコメントする。

回答 (0 件)

製品

リリース

R2019a

質問済み:

2019 年 8 月 14 日

コメント済み:

dpb
2019 年 8 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by