How can I multiply one output of this function with another output from this function?

3 Ansichten (letzte 30 Tage)
%Cadence Motley
%Script for DH Table multiplication
%ME422
%4/2/19
clc; clear all; format compact;
%% Inputs
%Indication of sys need: 1-value 0-sym should be a matrix that is nx1
A=0; %for a
D=1; %for d
C=1; %for alpha
O=0; %for theta
%For Value to go in place of a,d,theta or alpha
Av=0; %for a
Dv=0; %for d
Cv=0; %for alpha
Ov=0; %for theta
%% Variable Appropriation for Calculation
% a determination
if A == 1
a= Av;
else
a= sym('a');
end
% d determination
if D == 1
d= Dv;
else
d= sym('d');
end
% o determination - theta
if O == 1
o= Ov;
else
o= sym('o');
end
% c determination - alpha
if C == 1
c= Cv;
else
c= sym('c');
end
%% Homo Trans Calculation
if O==1 && C==1
Tp=[cosd(o),-sind(o)*cosd(c),sind(o)*sind(c),a*cosd(o);sind(o),cosd(o)*cosd(c),-cosd(o)*sind(c),a*sind(o);0,sind(c),cosd(c),d;0,0,0,1];
elseif O==1 && C==0
Tp=[cosd(o),-sind(o)*cos(c),sind(o)*sin(c),a*cosd(o);sind(o),cosd(o)*cos(c),-cosd(o)*sin(c),a*sind(o);0,sin(c),cos(c),d;0,0,0,1];
elseif O==0 && C==1
Tp=[cos(o),-sin(o)*cosd(c),sin(o)*sind(c),a*cos(o);sin(o),cos(o)*cosd(c),-cos(o)*sind(c),a*sin(o);0,sind(c),cosd(c),d;0,0,0,1];
else %O=0 and C=0
Tp=[cos(o),-sin(o)*cos(c),sin(o)*sin(c),a*cos(o);sin(o),cos(o)*cos(c),-cos(o)*sin(c),a*sin(o);0,sin(c),cos(c),d;0,0,0,1];
end
Tp
I need to be able to multiply the Tp matrix I get out of this script with another Tp matrix I get from this script using different or potentially the same input variables. How can I do this?

Akzeptierte Antwort

per isakson
per isakson am 2 Apr. 2019
Bearbeitet: per isakson am 2 Apr. 2019
  • comment out clear all;
  • run the script
  • rename Tp
  • run the a second time
Or convert the script to a function that returns Tp and call the function twice. That's more robust.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by