Operator '>' is not supported for operands of type 'struct'
15 ビュー (過去 30 日間)
古いコメントを表示
i have two struct xin_s and yin_s and i need a1 and a2. i wrote:
lonsorgente = 14.2;
latsorgente = 40.8;
a1= xin_s > lonsorgente-0.5 & xin_s < lonsorgente+0.5;
a2= yin_s < latsorgente+0.5 & yin_s > latsorgente-0.5;
Error:
Operator '>' is not supported for operands of type 'struct'.
Error in prova_intdir_sorg (line 42)
a1= xin_s > lonsorgente-0.5 & xin_s < lonsorgente+0.5;
how can i select a range of values within a structure and get a1 and a2?
thanksss
1 件のコメント
Stephen23
2022 年 7 月 10 日
"how can i select a range of values within a structure and get a1 and a2?"
Structures do not have any values.
However they do have fields, and fields can contain values. So you need to access the relevant fields of that structure:
採用された回答
Image Analyst
2022 年 7 月 10 日
What are the fields of xin_s? Let's say it's lat and lon. So you can compare the fields of xin_s rather than the whole structure itself:
lonsorgente = 14.2;
latsorgente = 40.8;
a1 = (xin_s.lon > lonsorgente-0.5) && (xin_s.lon < lonsorgente+0.5);
a2 = (yin_s.lat < latsorgente+0.5) && (yin_s.lat > latsorgente-0.5);
0 件のコメント
その他の回答 (1 件)
Dhritishman
2022 年 7 月 10 日
a1= xin_s > lonsorgente-0.5 & xin_s < lonsorgente+0.5;
In the above code, xins_s is a structure. A structure has fields and those fields contain values. So, you need to compare the values of the fields of their structure, not the entire structure.
Let's say the structure xin_s has a field myField. You can now use the value of the myField field for comparison as done in your code. Access the field value by using a dot('.') in the following way:
a1= (xin_s.myField > lonsorgente-0.5) & (xin_s.myField < lonsorgente+0.5);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!