Multiply 3x3 and 3x1 vectors in a loop

2 ビュー (過去 30 日間)
sharonb
sharonb 2022 年 11 月 16 日
コメント済み: Matt J 2022 年 11 月 16 日
I am trying to multiply a 3x3 vector (matrix) with a 3x1 vector in a loop. The 3x1 vectors are stored variables and I would like the loop this until all 3x1 vectors are loaded. I am fairly new and this is what I have so far (editted to by generic):
% Define 3x3
V1= [1 0 0; 0 1 0 ; 0 0 1]
% load 3x1 vectors from mat file and create a loop
for k = 1:3
load(['vectors.mat'])
V2Array=vv(k, :)
end
% Multiply 3x3 and 3x1 vectors
calc = V1*V2
Results = sprintf( '%s%d', 'Results')
  3 件のコメント
sharonb
sharonb 2022 年 11 月 16 日
移動済み: Stephen23 2022 年 11 月 16 日
the mat file contains row vectors (3) and is outputted as vv. I changed the name to vectors.mat. In additional, I thought I need to convert these to an array if I want to multiply it with the 3x3 matrix
Matt J
Matt J 2022 年 11 月 16 日
I thought I need to convert these to an array if I want to multiply it with the 3x3 matrix
It looks like vv is already a 3x3 array, so see my answer below.

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2022 年 11 月 16 日
編集済み: Matt J 2022 年 11 月 16 日
Might be what you want:
calc=V1*load('vectors.mat').vv

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by