Multiplying column with scalar

조회 수: 4 (최근 30일)
MarkoMagdelik
MarkoMagdelik 2016년 8월 20일
댓글: MarkoMagdelik 2016년 8월 20일
How can I multiply 2 sets of data with a scalar to get 3rd set of data. I got two sets of data. I don't know how to format them into a matrix or a vector that is the 1st problem. The 2nd problem is multiplying that with a scalar. Data is this : x= 1,2,3,4,5,6, . y = 7, 7, 7, 8, 9, 10.
And I need to multiply that with some scalar let's say 4. So I type in make matrix x = [1 2 3 4 5 6] and y= [7 ;7; 7; 8; 9; 10] And type this x*y*4 and get a 6x6 matrix. I want to get a 1x6 or 6x1 matrix with results. What would be optimal solution?

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 20일
편집: Azzi Abdelmalek 2016년 8월 20일
x = [1 2 3 4 5 6]
y= [7 ;7; 7; 8; 9; 10]
z=x.*y'*4
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 20일
편집: Azzi Abdelmalek 2016년 8월 20일
you can use ./ and .* and .^ to make element by element operation,
c=a.*b, where a and b have the same size, in your case, x and y should be both row vector or column vector, that's why I used y'
MarkoMagdelik
MarkoMagdelik 2016년 8월 20일
Many thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by