Variable "H" might be set by a nonscalar operator

조회 수: 52 (최근 30일)
Marshall Botta
Marshall Botta 2022년 2월 13일
편집: Jan 2022년 2월 14일
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
Jan 2022년 2월 13일
Please post code as text, not as screenshot. Then it is easier to suggest modifications using copy&paste.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
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
Marshall Botta
Marshall Botta 2022년 2월 14일
Unforunately this didn't work for me, my (alp,Fy) graph changed competely and (s,Fx) isnt what im looking for. Thank you for the help i think ima just give up on this for right now.
Jan
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 CenterFile Exchange에서 Tires and Vehicles에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by