Calculate Inner Product - MATLAB Cody - MATLAB Central

Problem 44950. Calculate Inner Product

Difficulty:Rate
Given two input matrices, x and y, check if their inner dimensions match.
  • If they match, create an output variable z which contains the product of x and y
  • Otherwise, z should contain a custom string message
Example:
x = [1 2;3 4]
y = [5;6]
z = [17;39]
x = [1 2 3;4 5 6]
y = [2 5;3 6]
z = "Have you checked the inner dimensions?"
OR
z = "The inner dimensions are 3 and 2. Matrix multiplication is not possible"
-------------------------------------------------------------------------------------------------------------------------------------------------------------
NOTE - An example of combining numbers and strings together is shown below:
x = "The sum of " + 4 + " and " + 3 + " equals " + 7
x =
"The sum of 4 and 3 equals 7"

Solution Stats

40.82% Correct | 59.18% Incorrect
Last Solution submitted on Mar 16, 2025

Problem Comments

Solution Comments

Show comments

Group

High School Challenge Image
High School Challenge
  • 50 Problems
  • 98 Finishers

Problem Recent Solvers7503

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page