Can I construct a matrix multiplying a scalar and a vector?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jaime De La Mota Sanchis
am 11 Sep. 2019
Kommentiert: Jaime De La Mota Sanchis
am 11 Sep. 2019
I have a scalar i=3 and a vector j=[4; 5]. I want to generate the matrix k=[3 4; 3 5].
Is there a way to multiply i and j to generate the matrix k?
0 Kommentare
Akzeptierte Antwort
Jan
am 11 Sep. 2019
Bearbeitet: Jan
am 11 Sep. 2019
No, tis is not a standard multiplication. But you can create k based on i and j:
i = 3;
j = [4; 5];
% Solution 1:
k(:, 2) = j;
k(:, 1) = i;
% Solution 2:
k = i .* [1, 0; 1, 0] + j .* [0, 1; 0, 1]; % Auto-expanding, need Matlab >= R2016b
What is the general case? Why do you want a "multiplication"? Which is the problem you want to solve actually?
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!