473,467 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

why is the script not working?

I am trying to make a function that returns a smaller matrix from a
bigger one. For example, if the inputed matrix is:

test = [
[2 2 5 2 5],
[5 7 7 2 7],
[3 8 3 0 4],
[9 3 8 4 9]];

and the coords array is: [2,2,4,4]

then it should return:

output = [
[7 7 2],
[8 3 0],
[3 8 4]];

The script is located at: ali.freezope.org/submatrix text

It says the error is at line 133. It says: object expected. I dont see
why there is no object.

Jul 23 '05 #1
2 989
greenflame wrote:
I am trying to make a function that returns a smaller matrix from a
bigger one. For example, if the inputed matrix is:

test = [
[2 2 5 2 5],
[5 7 7 2 7],
[3 8 3 0 4],
[9 3 8 4 9]];

and the coords array is: [2,2,4,4]

then it should return:

output = [
[7 7 2],
[8 3 0],
[3 8 4]];

The script is located at: ali.freezope.org/submatrix text
Broken link :-(

Post links thusly:

<URL:http://mydomain.com/mypath/myfile.html>

The following is based on a presumption of what I expect you are doing.

You appear to be looking for row index 2 to 4 and column index 2 to 4,
*but* your test matrix does not have a row index 4 (it has four rows of
index 0-3).

Your function call seems to have the syntax:

subArray ( matrix, from_row, from_column, to_row, to_column )

So here is a function that does what you want:

function subArray( X, a, b, c, d ){
var Y = [];
for ( var i=0; i+a <= c; i++ ){
Y[i] = [];
for ( var j=0; j+b <= d; j++ ){
Y[i][j] = X[i+a][j+b];
}
}
return Y;
}

I think a more obvious syntax would be:

subArray ( matrix, from_row, to_row, from_column, to_column )

e.g.

var z = subArray( X, 2, 4, 2, 4 );

and the function becomes:

function subArray( X, a, b, c, d ){
var Y = [];
for ( var i=0; i+a <= b; i++ ){
Y[i] = [];
for ( var j=0; j+c <= d; j++ ){
Y[i][j] = X[i+a][j+c];
}
}
return Y;
}

It says the error is at line 133. It says: object expected. I dont see
why there is no object.


Post a working link and we'll see. :-)
--
Rob
Jul 23 '05 #2
OK. I will try the suggestions. Also the fixed like is:
ali.freezope.org/submatrix test

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Flynn | last post by:
My understanding of javascript is very limited. Could some one help me out. I found this code for an image gallery viewer. It works fine on my site, but I'd like to modify it so that the mainpic...
2
by: Nasir Wasim | last post by:
How can Access DIV Properties in Script while using Netscape 7.2. I want to use the div id with it's Visibility and left propertyin script but it's not working :-( Main File : ----------- ...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
1
by: Steve Richter | last post by:
have just installed the Microsoft script debugger for windows 2000: http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en ( notice the "this...
1
by: Q1tum | last post by:
Hi all, I have a problem with my script, I'm using javascript DOM to update my page. The getPortals() function updates a select list whichs shows portals. The doUpdate() function updates a...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
2
by: Tereska | last post by:
I want to delete script added before. I'm adding script dynamically and i'm removing later. Why it is still working? I have something like this: <html> <head> <title>JS Script...
9
by: whitgurley | last post by:
I've searched the web as well as I can for a solution to this problem but have found nothing and just don't know enough about JavaScript to figure out what's going. What I'm trying to do is convert...
9
by: Jerim79 | last post by:
Here it is: <?php if($_SERVER=='POST'){ $Number=$_POST; $Email=$_POST; $Number2=0; $error=0;
3
by: malaysiauser | last post by:
Dear all, Last year I install a download control script in Linux server. its working. This year i'd changed my hosting server to other company. i'd tried install the script. It was installed...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.