Times table that takes a lo and hi values and makes lo to hi times table

1 view (last 30 days)
What I need is to get this to take the first row and columns and multiple each row and columns to produce a times table. I did, at some point, get the rows and columns to multiply each other and proudce the correct answe. However, I can't for the life of me get that code into this one's vector. Help?
function multiTable= timesTable(lo,hi)
n=lo:hi;
x=(hi-lo)+2;
sizeoftable=[0,(lo:1:hi)];
multiTable=zeros(x,x);
multiTable(:,1)=[sizeoftable];
multiTable(1,:)=[sizeoftable];
end

Answers (1)

Voss
Voss on 26 Oct 2022
lo = 6;
hi = 12;
n=lo:hi;
x=(hi-lo)+2;
sizeoftable=[0,(lo:1:hi)];
multiTable=zeros(x,x);
multiTable(:,1)=[sizeoftable];
multiTable(1,:)=[sizeoftable];
multiTable(2:x,2:x) = (lo:hi).*(lo:hi).'
multiTable = 8×8
0 6 7 8 9 10 11 12 6 36 42 48 54 60 66 72 7 42 49 56 63 70 77 84 8 48 56 64 72 80 88 96 9 54 63 72 81 90 99 108 10 60 70 80 90 100 110 120 11 66 77 88 99 110 121 132 12 72 84 96 108 120 132 144
  2 Comments
Shilo
Shilo on 26 Oct 2022
Thank you, thank you, thank you!! I was thinking of something along those lines but I couldn't get anything to work. So thank you, thank you dearly.
Voss
Voss on 27 Oct 2022
You're welcome! Any questions, let me know. Otherwise, please "Accept This Answer". Thanks!

Sign in to comment.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!