Unknown Error Message from using interp1

1 回表示 (過去 30 日間)
Ashley Megow
Ashley Megow 2020 年 10 月 30 日
回答済み: Walter Roberson 2020 年 10 月 30 日
Using this table how do I resolve the error message below

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 10 月 30 日
if year < 1990 | year > 2018 | mod(year,2) == 1
disp("This is not an even year from 1990 to 2018");
else
male_vote = interp1(YourTable.Year, YourTable.Male, year);
female_vote = interp1(YourTable.Year, YourTable.Female, year);
go = 0;
end
But I would suggest
if year < 1990 | year > 2018 | mod(year,2) == 1
disp("This is not an even year from 1990 to 2018");
else
mask = YourTable.Year == year;
male_vote = YourTable(mask).Male;
female_vote = YourTable(mask).Female;
go = 0;
end

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by