フィルターのクリア

After running, the MysPow is displaying as NaN, any ideas as to why?

1 回表示 (過去 30 日間)
Ethan Wilson
Ethan Wilson 2022 年 4 月 22 日
回答済み: Walter Roberson 2022 年 4 月 22 日
KWatts = [100 500 900];
Ohms100 = [1.1900, 1.1845, 1.1776, 1.1746, 1.1797, 1.1925];
Ohms100Avg = median(Ohms100);
Ohms500 = [1.0272; 1.0292; 1.0243; 1.0212; 1.0235; 1.0241; 1.0249; 1.0245; 1.0208; 1.0167; 1.0194];
Ohms500Avg = median(Ohms500);
Ohms900 = [0.8770, 0.8730, 0.8721, 0.8676, 0.8668, 0.8675, 0.8681, 0.8661, 0.8637, 0.8617, 0.8597];
Ohms900Avg = median(Ohms900);
OhmsMys = [0.9694, 0.9770, 0.9762, 0.9814, 0.9846, 0.9839, .9932, .9928, .9919, .9954, .9964, .9870, .9841];
OhmsMysAvg = median(OhmsMys);
Ohms = [Ohms100Avg, Ohms500Avg, Ohms900Avg];
MysPow = interp1(KWatts, Ohms, OhmsMysAvg);

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 4 月 22 日
KWatts = [100 500 900];
Ohms100 = [1.1900, 1.1845, 1.1776, 1.1746, 1.1797, 1.1925];
Ohms100Avg = median(Ohms100);
Ohms500 = [1.0272; 1.0292; 1.0243; 1.0212; 1.0235; 1.0241; 1.0249; 1.0245; 1.0208; 1.0167; 1.0194];
Ohms500Avg = median(Ohms500);
Ohms900 = [0.8770, 0.8730, 0.8721, 0.8676, 0.8668, 0.8675, 0.8681, 0.8661, 0.8637, 0.8617, 0.8597];
Ohms900Avg = median(Ohms900);
OhmsMys = [0.9694, 0.9770, 0.9762, 0.9814, 0.9846, 0.9839, .9932, .9928, .9919, .9954, .9964, .9870, .9841];
OhmsMysAvg = median(OhmsMys);
Ohms = [Ohms100Avg, Ohms500Avg, Ohms900Avg];
MysPow = interp1(KWatts, Ohms, OhmsMysAvg);
numel(MysPow)
ans = 1
nnz(isnan(MysPow))
ans = 1
[min(KWatts), max(KWatts)]
ans = 1×2
100 900
[min(OhmsMysAvg), max(OhmsMysAvg)]
ans = 1×2
0.9846 0.9846
Your queiry position of 0.9846 is outside the range of index values for the input, 100 to 900. interp1() by default returns nan for values out of range.
If we examine the variable names, we would note that your index value is in kilowatts, and your dependent value is in Ohms, but your query value is in Ohms. Your query value needs to be in the same units as the corresponding index parameter, so kilowatts in this case.
If you want to use ohms values to look up kilowatt values, then the indexing vector (first parameter) would have to be ohms rather than kilowatts.

カテゴリ

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