Create a function called translate(dx,dy). Be sure your function suppresses all output, as we will want to use it later inside a large for loop. This function should return the matrix:
T = [1 0 dx]
[0 1 dy]
[0 0 1]
I am not sure how to get started with this, the function throws me off, please help.

답변 (1개)

Guillaume
Guillaume 2017년 2월 15일

1 개 추천

It would be difficult to come up with an easier assignment. I assume you've been told how to create a function and if not, searching for function in the doc would have told you how.
The assignment requires writing three lines of code only. Try harder.

댓글 수: 5

Pauline Li
Pauline Li 2017년 2월 16일
Not that I have not tried, I could not come up with a code that runs. This is what I have so far.
>>function T=translate (dx,dy)
>>T=[1 0 dx; 0 1 dy; 0 0 1];
>>end
Stephen23
Stephen23 2017년 2월 16일
@Pauline Li: your code concept is fine, but it is not possible to define a function like that in the command line. It must be defined in a file (with the same name as the function).
Pauline Li
Pauline Li 2017년 2월 16일
I understand, I have the script named after the function, however I keep getting not enough input arguments.
Do not click the green "Run" button. This is a pointless button that confuses all beginners. You can call your function from the command line and supply it with the required two input arguments, e.g.:
translate(2,5)
Guillaume
Guillaume 2017년 2월 16일
Note that the documentation that I linked in my answer explained both of these issues in the first few lines:
This type of function must be defined within a file, not at the command line. [...]
You can call the function from the command line, using the same syntax rules that apply to functions installed with MATLAB.

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

카테고리

도움말 센터 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

질문:

2017년 2월 15일

댓글:

2017년 2월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by