Container.map Error

4 ビュー (過去 30 日間)
Gregory Drake
Gregory Drake 2019 年 4 月 13 日
コメント済み: Gregory Drake 2019 年 4 月 13 日
Hello, I am receiver this error and I am not sure how to fix the key type when I pass this through a function.
Specified key type does not match the type expected for this container.
>> k_air = get_k_air(T);
function k_air = get_k_air(T1)
keys = {250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000};
values = [1.401,1.4,1.398,1.395,1.391,1.387,1.381,1.376,1.37,1.364,1.359,1.354,1.349,1.344,1.34,1.336];
lookup_table = containers.Map(keys,values);
k_air = lookup_table(T1);
end

採用された回答

Geoff Hayes
Geoff Hayes 2019 年 4 月 13 日
編集済み: Geoff Hayes 2019 年 4 月 13 日
Gregory - the error message is suggesting that your key, which is the input T (or T1 in your function), is of a data type that is not compatible the key set for your container. It looks like your keys are integer scalars so what are you passing in as T?
You may want to try using isKey to see if your container has the key before you try to access the container with your passed in key.
  1 件のコメント
Gregory Drake
Gregory Drake 2019 年 4 月 13 日
Thank you.
This was my "T" --- T = linspace(250,1000,16);
So I was trying to pass an entire array through the function instead of calling out specific values in the array I am trying to create an efficency table. I managed to understand what I was doing wrong from your answer.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by