필터 지우기
필터 지우기

How to write a function for a specific direction?

조회 수: 3 (최근 30일)
Amanda
Amanda 2022년 10월 25일
답변: Walter Roberson 2022년 10월 25일
I am trying to write a function that make my arrow point to true north regardless of which way its point at a certain point of time. So far I have (Code below). Everytime I run it it tells me I have to many input arugements. Im not sure if im writing this correctly.
function turnNorth()
(getHeading(2))
turnLeft();
(getHeading(3))
turnLeft();
turnLeft();
(getHeading(4))
turnLeft();
turnLeft();
turnLeft();
end

답변 (1개)

Walter Roberson
Walter Roberson 2022년 10월 25일
My guess is that you need
function turnNorth()
current_heading = getHeading;
switch current_heading
case 2:
turnLeft();
case 3:
turnLeft();
turnLeft();
case 4:
turnLeft();
turnLeft();
turnLeft();
end

카테고리

Help CenterFile Exchange에서 Communications Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by