How to let 2 vector row to multiply by itself

6 views (last 30 days)
hi I want vector m to multiply with n but for some reason I got this
i =
4 5 6 7
output =
16 25 36 49
this is my code
function output=input(m,n)
Dai Nguyen
Dai Nguyen on 17 Sep 2020
my teacher doesn't require a loop at all, but I just wanna create a loop that can adapt to any inputs and still get the same answer.
Sorry I'm really new to matlab and I want to learn a lot from it.
Thank you for your time,

Sign in to comment.

Answers (1)

madhan ravi
madhan ravi on 17 Sep 2020
Edited: madhan ravi on 17 Sep 2020
m = 4;
n = 7;
prod(m : n)
  1 Comment
Dai Nguyen
Dai Nguyen on 17 Sep 2020
Thank you. I haven't used prod before but this command is pretty awesome, is it stand for product? is there other command that serve the same purpose as prod ?

Sign in to comment.


Find more on Loops and Conditional Statements in Help Center and File Exchange





Community Treasure Hunt

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

Start Hunting!

Translated by