Variable "H" might be set by a nonscalar operator
52 ビュー (過去 30 日間)
古いコメントを表示
Hello,
My goal for my code is to simulate a tire model and H equation gets a error code saying "Variable H might be set by a nonscalar operator". I think it has to deal with my variable s being defined as a vector but I dont know how to change it into a scalar. Help please :).
1 件のコメント
Jan
2022 年 2 月 13 日
Please post code as text, not as screenshot. Then it is easier to suggest modifications using copy&paste.
回答 (1 件)
Jan
2022 年 2 月 13 日
If H is an array, what is the meaning of:
if H < 0.5
? The IF command requires a scalar condition. Therefore Matlab inserts an all() automatically. To be exact:
if all(H(:) < 0.5) && ~isempty(H)
It is not meaningful "to change H to a scalar" also.
You are running a loop over the elements of s. Maybe you do not want to access the vector s, but the elements s(i).
8 件のコメント
Jan
2022 年 2 月 14 日
編集済み: Jan
2022 年 2 月 14 日
Square brackets are the operator for concatenating arrays. Changing parentheses to brackets is not useful.
My suggested code produces the same output as the original code.
"(s,Fx) isnt what im looking for" - I do not know, what you are looking for. All I know is the code you have posted.
参考
カテゴリ
Help Center および File Exchange で Tires and Vehicles についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!