Matrix Multiplication Calculator

Online Matrix Multiplication Calculator, helps you to calculate the product of two dimensional and three dimensional matrices effortlessly.

Features

  • Matrix multiplier is designed to work with matrices in few minutes.
  • Multiply 2D and 3D matrices using this javascript matrix multiplication calculator.
  • You can input only integer numbers in this online calculator.
  • Responsive and supports all modern browsers.
  • Note: Matrices multiplication is possible only when the number of columns of first matrix is equal to the number of rows of second matrix. e.g: (3x2)*(2x3), (3x3)*(3x1).

Preview

Multiply Matrices Online



Matrix 1


Matrix 2


    ©h

Downloads

Code


<!-- Script by hscripts.com -->
<!-- More scripts @www.hscripts.com -->
<html><head><title>Matrix Multiplication Calculator | Multiply Matrices Javascript Code</title></head><script type="text/javascript">
var ai=4;
var aj=4;
var bi=4;
var bj=4;
function seta(xx1, xx2)
{
if(xx1 == 1){ai = 4; aj = 4;}
else if(xx1 == 2){ai = 4; aj = 3;}
else if(xx1 == 3){ai = 3; aj = 4;}
else if(xx1 == 4){ai = 4; aj = 2;}
else if(xx1 == 5){ai = 2; aj = 4;}
else if(xx1 == 6){ai = 3; aj = 3;}
if(xx2 == 1){bi = 4; bj = 4;}
else if(xx2 == 2){bi = 4; bj = 3;}
else if(xx2 == 3){bi = 3; bj = 4;}
else if(xx2 == 4){bi = 4; bj = 2;}
else if(xx2 == 5){bi = 2; bj = 4;}
else if(xx2 == 6){bi = 3; bj = 3;}
}
function marka()
{var eleman=0;var eleman1=0;var xx1 = document.getElementById("amat").value;var xx2 = document.getElementById("bmat").value;
seta(xx1,xx2);
for(var a=1; a<4; a++)
{
for(var b=1; b<4; b++)
{
var sd = ("a"+a+b);eleman = document.getElementById(sd);eleman.removeAttribute("disabled"); document.getElementById(sd).value='';
if(a >= ai || b >= aj)
{eleman.disabled = true;document.getElementById(sd).value='0';
}
}
}
for(var a=1; a<4; a++)
{
for(var b=1; b<4; b++)
{
var sd = ("b"+a+b);eleman = document.getElementById(sd);document.getElementById(sd).value='';eleman.removeAttribute("disabled");
if(a >= bi || b >= bj){eleman.disabled = true;document.getElementById(sd).value='0';}
}
}
for(var a=1; a<4; a++)
{
for(var b=1; b<4; b++)
{
var sd = ("aa"+a+b);eleman = document.getElementById(sd);document.getElementById(sd).value='';eleman.removeAttribute("disabled");
if(a >= ai || b >= bj){eleman.disabled = true;}
}
}
for(var a=1; a<4; a++)
{
for(var b=1; b<4; b++)
{
var sd = ("ba"+a+b);eleman = document.getElementById(sd);document.getElementById(sd).value='';eleman.removeAttribute("disabled");
if(a >= ai || b >= bj){eleman.disabled = true;}
}
}
}
function madd()
{var xx1 = document.getElementById("amat").value;var xx2 = document.getElementById("bmat").value;
seta(xx1,xx2);
if(aj != bi)
{
alert("We can multiply two matrix only when the number of columns of first matrix is equal to number of rows of second matrix.");
}
else{var a11 = document.getElementById("a11").value;
var a12 = document.getElementById("a12").value;
var a13 = document.getElementById("a13").value;
var a21 = document.getElementById("a21").value;
var a22 = document.getElementById("a22").value;
var a23 = document.getElementById("a23").value;
var a31 = document.getElementById("a31").value;
var a32 = document.getElementById("a32").value;
var a33 = document.getElementById("a33").value;
var b11 = document.getElementById("b11").value;
var b12 = document.getElementById("b12").value;
var b13 = document.getElementById("b13").value;
var b21 = document.getElementById("b21").value;
var b22 = document.getElementById("b22").value;
var b23 = document.getElementById("b23").value;
var b31 = document.getElementById("b31").value;
var b32 = document.getElementById("b32").value;
var b33 = document.getElementById("b33").value;
var tmp;
for(var i=1;i<=3;i++)
{for(var j=1;j<=3;j++){tmp = document.getElementById("a"+i+""+j).value;if(tmp==""){alert("Enter all values for Matrix 1 "); return 0;}}
}
for(var k=1;k<=3;k++)
{for(var l=1;l<=3;l++){tmp = document.getElementById("b"+k+""+l).value;if(tmp==""){alert("Enter all values for Matrix 2 ");return 0;}}
}
var ssd = false;
for(var a=1; a<4; a++)
{
for(var b=1; b<4; b++)
{
if(a < ai && b < bi){
var axx = ("a"+a+b);
//alert("a"+a+b+"="+axx+" - - "+ai);
if(axx == "")
ssd = true;
}
if(a != aj && b != bj){
var bxx = ("b"+a+b);
if(bxx == "")
ssd = true;
}
}
}
if(ssd==true){
alert("Empty cells are present. Please fill proper values");
}
else
{
aa11 = "("+a11+"*"+b11+")+("+a12+"*"+b21+")+("+a13+"*"+b31+")";
aa12 = "("+a11+"*"+b12+")+("+a12+"*"+b22+")+("+a13+"*"+b32+")";
aa13 = "("+a11+"*"+b13+")+("+a12+"*"+b23+")+("+a13+"*"+b33+")";
aa21 = "("+a21+"*"+b11+")+("+a22+"*"+b21+")+("+a23+"*"+b31+")";
aa22 = "("+a21+"*"+b12+")+("+a22+"*"+b22+")+("+a23+"*"+b32+")";
aa23 = "("+a21+"*"+b13+")+("+a22+"*"+b23+")+("+a23+"*"+b33+")";
aa31 = "("+a31+"*"+b11+")+("+a32+"*"+b21+")+("+a33+"*"+b31+")";
aa32 = "("+a31+"*"+b12+")+("+a32+"*"+b22+")+("+a33+"*"+b32+")";
aa33 = "("+a31+"*"+b13+")+("+a32+"*"+b23+")+("+a33+"*"+b33+")";document.getElementById("aa11").value = aa11;document.getElementById("aa12").value = aa12;document.getElementById("aa13").value = aa13;document.getElementById("aa21").value = aa21;document.getElementById("aa22").value = aa22;document.getElementById("aa23").value = aa23;document.getElementById("aa31").value = aa31;document.getElementById("aa32").value = aa32;document.getElementById("aa33").value = aa33;
for(var a=1; a<4; a++)
{
for(var b=1; b<4; b++)
{
if(a < ai && b < bj){
}
else
{
var dfx = ("aa"+a+b);document.getElementById(dfx).value = "0";
}
}
}
for(var a=1; a<4; a++)
{
for(var b=1; b<4; b++)
{
if(a < ai && b < bj){
var axx = ("aa"+a+b);
var dfx = ("ba"+a+b);var new1 = document.getElementById(dfx);var new2 = document.getElementById(axx);new1.value = eval(new2.value);
}
else
{
var dfx = ("ba"+a+b);document.getElementById(dfx).value = "0";
}
}
}
}
}
}
var spl_Keys = new Array();spl_Keys.push(8);spl_Keys.push(39);
function check(ad)
{
var PATTERN = /^-?[0-9]*$/;if (!ad.value.match(PATTERN)) {ad.value = ad.value.replace(ad.value.slice(-1), "");
}
}
function chk(){
var sds = document.getElementById('dum');
if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");
document.getElementById("maindiv").style.visibility="hidden";
}
var sdss = document.getElementById("dumdiv");
if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
}
window.onload=chk;
</script>
<style>
label{float:left;padding:0 0 10px;}
h2 {border-bottom: 1px solid #ebebeb;color: #474747;font-size: 1.2em;font-weight: normal;line-height: 130%;
}
.frms
{
margin:0 auto;
-moz-border-radius:.3em;
-webkit-border-radius:.3em;
-o-border-radius:.3em;
font-family:Tahoma, Geneva, sans-serif;
color:#333;
font-size:.9em;
line-height:1.2em;
}
.frms label {font-size: 1em;
}
.frms select
{width:99% !important;
}
.frms input[type="text"],select
{
width:30%;
background:#fff;
border:#ddd 1px solid;
border-radius:.35em;
-moz-border-radius:.35em;
-webkit-border-radius:.35em;
-o-border-radius:.35em;
padding:0 .5%;
margin-top:5px;
margin-bottom:15px;
height:35px;
}
.frms input:hover,textarea:hover,select:hover
{
box-shadow:#dae1e5 0px 0px 5px;
-moz-box-shadow:#dae1e5 0px 0px 5px;
-webkit-box-shadow:#dae1e5 0px 0px 5px;
-o-box-shadow:#dae1e5 0px 0px 5px;
}
.frms input:focus,textarea:focus,select:focus
{
-webkit-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
-moz-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
border:#9d9983 1px solid;
}
.frms input[type="button"],input[type="reset"]
{
padding:7px 14px;
font-weight:bold;
color:#fff;
cursor:pointer;
border-radius:.3em;
-moz-border-radius:.2em;
-webkit-border-radius:.2em;
-o-border-radius:.2em;
margin:10px 0;
border:none;
}
input[type="button"]
{
background:#468cd2;
border-bottom:#3277bc 3px solid;
text-shadow:#214d73 1px 1px 0px;
}
.frms input[type="reset"]
{
background:#ee765d;
border-bottom:#d95e44 3px solid;
text-shadow:#8c3736 1px 1px 0px;
}
.resp_code
{
margin:5px 10px 10px 300px;
padding:10px 20px 10px 20px;
font:normal 1em/1.3em Tahoma, Geneva, sans-serif;
color:#333;
background:#f8f8f8;
border:#ddd 1px solid;
border-radius:.25em;
overflow:auto;width:50%;
}
@media screen and (max-width: 480px)
{
.resp_code
{width:auto !important;margin:0px !important;
}
}
</style>
<body>
<div class='resp_code'>
<div align='center'><h2>Multiply Matrices Online</h2></div><div class="frms" id='maindiv'>
<div class='clear'></div>
<form name=first>
<div align='left' style='margin-bottom:20px;'><h3> Matrix 1 </h3><div><label>Matrix Type</label></div><select id=amat onchange=marka()>
<option value=1>3x3</option>
<option value=2>3x2</option>
<option value=3>2x3</option>
<option value=4>3x1</option>
<option value=5>1x3</option>
<option value=6>2x2</option>
</select>
</div> <div>
<div><span><input id=a11 onkeyup=check(this)
type='text' maxlength=10> </span><span> <input id=a12
onkeyup=check(this)
type='text'> </span><span> <input id=a13 onkeyup=check(this)
type='text' maxlength=10> </span></div>
<div><span><input id=a21
onkeyup=check(this) type='text'> </span><span> <input id=a22 onkeyup=check(this)
type='text' maxlength=10> </span><span> <input id=a23 onkeyup=check(this)
type='text'> </span></div>
<div><span><input id=a31 onkeyup=check(this)
type='text' maxlength=10> </span><span> <input id=a32 onkeyup=check(this)
type='text' maxlength=10> </span><span> <input id=a33 onkeyup=check(this)
type='text' maxlength=10> </span></div></div><div><div align='left' style='margin-bottom:20px;'><h4> Matrix 2 </h4>
<div>
<label>Matrix Type </label></div><select id=bmat onchange=marka()>
<option value=1>3x3</option>
<option value=2>3x2</option>
<option value=3>2x3</option>
<option value=4>3x1</option>
<option value=5>1x3</option>
<option value=6>2x2</option></select></div>
<div><span><input id=b11 onkeyup=check(this) type='text' maxlength=10> </span>
<span> <input id=b12 onkeyup=check(this) type='text' maxlength=10> </span>
<span> <input id=b13 onkeyup=check(this) type='text' maxlength=10> </span></div>
<div><span><input id=b21 onkeyup=check(this) type='text' maxlength=10> </span>
<span> <input id=b22 onkeyup=check(this) type='text' maxlength=10> </span><span>
<input id=b23 onkeyup=check(this) type='text' maxlength=10> </span></div>
<div><span><input id=b31 onkeyup=check(this)
type='text' maxlength=10> </span><span> <input id=b32 onkeyup=check(this)
type='text' maxlength=10> </span><span> <input id=b33 onkeyup=check(this)
type='text' maxlength=10> </span></div></div><div align='center'>
<input type=button value=Calculate onclick=madd()>
<input type='reset' value=Reset><span
align='center' style="font-size: 10px;color: #dadada;" id="dumdiv">
<a href="https://www.hscripts.com" id="dum" style="font-size: 10px;color: #dadada;text-decoration:none;color: #dadada;">&copy;h</a></span></div>
<div class='result'><div>
<div><span><input id=aa11 2 type='text' readonly> </span><span> <input id=aa12 2 type='text' readonly> </span><span> <input id=aa13 2 type='text' readonly> </span></div>
<div><span><input id=aa21 2 type='text' readonly> </span><span> <input id=aa22 2 type='text' readonly> </span><span> <input id=aa23 2 type='text' readonly> </span></div>
<div><span><input id=aa31 2 type='text' readonly> </span><span> <input id=aa32 2 type='text' readonly> </span><span> <input id=aa33 2 type='text' readonly> </span></div></div><div>
<div><span><input id=ba11
type='text' readonly> </span><span> <input id=ba12
type='text' readonly> </span><span> <input id=ba13
type='text' readonly> </span></div>
<div><span><input id=ba21
type='text' readonly> </span><span> <input id=ba22
type='text' readonly> </span><span> <input id=ba23
type='text' readonly> </span></div>
<div><span><input id=ba31
type='text' readonly> </span><span> <input id=ba32
type='text' readonly> </span><span> <input id=ba33
type='text' readonly> </span></div></div>
</div>
</form>
</div>
</div>
</body>
</html>


  • Release Date - 09-03-2015
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Copy and paste the code into your HTML page to use this matrix calculator.
  • Select the matrix type and enter the values to multiply the respective matrices.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question