Learn R Programming

matlab2r (version 1.5.0)

times: Element-wise matrix multiplication

Description

Emulates the times() and .* operators from Matlab.

Usage

times(a, b)

Value

matrix with dimensions equal to the larger of the two factors

Arguments

a

first factor of the multiplication

b

second factor of the multiplication

Details

This function basically handles elements of different length better than the * operator in R, at least as far as behavior from a Matlab user is expecting.

Examples

Run this code
times(9, 6)
x <- matrix(1:4, 2)
y <- c(10, 3)
print(x)
print(y)
times(x, y)
x * y

Run the code above in your browser using DataLab