How to compare the index of first 12 values with the next set of 12 values?

2 ビュー (過去 30 日間)
Ashish
Ashish 2014 年 5 月 23 日
編集済み: Henric Rydén 2014 年 5 月 23 日
I have a structure named - (handles.GEN.kWhprice) in which the monthly price of energy is stored. I have to implement a check which compares the first 12 values with the next set of 12 values.
I.e. first 12 values are taken as a reference and the set of next 12 values (each year) are compared. If the values for each month match, then I set a flag as 1 -( set( handles.checkbox_year,'Value',1);
What should be the code for comparing such a trend?

回答 (1 件)

Henric Rydén
Henric Rydén 2014 年 5 月 23 日
編集済み: Henric Rydén 2014 年 5 月 23 日
Assuming handles.GEN.kWhprice is a structure with two fields, one for last year and one for this:
if ~all(handles.GEN.kWhprice.lastyear - handles.GEN.kWhprice.lastyear)
set( handles.checkbox_year,'Value',1);
end
Note that the statement is only true if the entire array is equal, and there is no tolerance level. This means that any variation in any month will make your flag 0.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by