## Can I construct a matrix multiplying a scalar and a vector?

Asked by Jaime De La Mota Sanchis

### Jaime De La Mota Sanchis (view profile)

on 11 Sep 2019
Latest activity Commented on by Jaime De La Mota Sanchis

on 11 Sep 2019

### Jan (view profile)

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?

2019 年 9 月 11 日

### Jan (view profile)

2019 年 9 月 11 日
採用された回答

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 Comment

Jaime De La Mota Sanchis

### Jaime De La Mota Sanchis (view profile)

on 11 Sep 2019
This is my current code. I am trying to construct a Smolyak collocation matrix. This general case is the construction of two rows of said matrix. If you are curious, this is the code I am using.
close all
clear
clc
number_of_rv=2;
mat_index = ones(number_of_rv+1, number_of_rv);
mat_ampl = zeros(2*number_of_rv+1, number_of_rv);
longitud_mat_ampl=length(mat_ampl);
for i=2: number_of_rv+1