Matlab create function - Invalid expression

1 view (last 30 days)
Mark S
Mark S on 26 Dec 2021
Edited: Mark S on 8 Jan 2022
can someone help me to insert a function in Matlab correctly. I don't know why it doesn't work for me.
I would like to be able to run this function in the command window
function [relative_pose_endeffector] = forward_kinematics(T_0_3, [0; 0; 0])
q_home = [0; 0; 0;];
relative_pose_endeffector = double(T_0_3(q_actual(1), q_actual(2),q_actual(3)))
In the square brackets I can enter numbers which will be used in the function.
The code already works but I would like to put these "forward kinematics" in a Matlab function. So that I can call this function in the command window.
Can anyone tell me or help me why my function is not working there? Thanks
Here is all my code:

Accepted Answer

Simon Chan
Simon Chan on 26 Dec 2021
Simply modify your function as follows.
function [relative_pose_endeffector] = forward_kinematics(T_0_3, q_actual)
relative_pose_endeffector = double(T_0_3(q_actual(1), q_actual(2),q_actual(3)))
Mark S
Mark S on 26 Dec 2021
Ok thanks very much for your help!

Sign in to comment.

More Answers (0)





Community Treasure Hunt

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

Start Hunting!