Multiplying 3X3 array by a 3x1
Show older comments
Hello I am here trying to multiply contents of a 3x3 array by a 3x1 vector. The code I have developed is displayed below. The outputs I have for matricies C through H are what I am looking for but when I try to do some matrix math I get different Arrays with not quite the right outputs.
clear all;
close all;
% Import the data file
M = importdata('6x300_input_data.txt');
%u,v,w are inputs taken from the data file that are each their own column
u = M.data(:,3);
v = M.data(:,4);
w = M.data(:,5);
% Time variable in seconds that is pulled from data
t_in = M.data(:,6);
lamda = -60; %longitude in degrees
omega = 0.004; %Rate
phi = 30; %measurement in degrees
UVW = [u,v,w];
%Array to populate the serires of A matrices that will be multiplied by
%each instance of UVW
A = arrayfun(@(t_in)[ -sind(lamda - omega*t_in) cosd(lamda - omega*t_in) 0;
-sind(phi)*cosd(lamda-omega*t_in) -sind(phi)*sind(lamda - omega*t_in) cosd(phi);
cosd(phi)*cosd(lamda - omega*t_in) cosd(phi)*sind(lamda - omega*t_in) sind(phi)],t_in,'UniformOutput',false);
%proper outputs that are desired but want to find a better way...
C = A{1,1}*UVW(1,:)'
D = A{2,1}*UVW(2,:)'
E = A{3,1}*UVW(3,:)'
F = A{4,1}*UVW(4,:)'
G = A{5,1}*UVW(5,:)'
H = A{6,1}*UVW(6,:)'
disp(C:H);
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!