473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Execluding an array member ( equivelent to [] operator in MATLAB )

Hi Guys,

I am new to this web. I have a fairly simple problem. I have an array of certain double precision numbers. What would be the best way for execluding one of the array members without affecting the other values. For example:

Input array: [ 0 1 2 7 6 **0** 4 9 8]

Desired Ouput array is: [ 0 1 2 7 6 4 9 8]

I know in MATLAB it can be done by [] brackets any idea of a good function that would carry out such functionality.

Best regards,

BASHAR
Jul 26 '07 #1
3 1274
ravenspoint
111 100+
It may be time to upgrade from arrays to STL vectors. If you do so you will gain many things, incuding the method erase which removes a specified element,
Jul 26 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
I agree with ravenspoint.

However, if you wish to do it the hard way, use a second array as a map:

Input array: [ 0 1 2 7 6 0 4 9 8]
Map array: [ 1 1 1 1 1 0 1 1 1]

Then iterate the map array and only use elements from the input array that are marked in the map.
Jul 26 '07 #3
ravenspoint
111 100+

Then iterate the map array and only use elements from the input array that are marked in the map.
That's a clever solution.

Use a bit array for the the map, so as not to double your storage requirements.

If you enjoy fancy footwork, make the map entirely abstract and use simple compression, so that

[ 1,1,1,0,1,1] becomes [0-2,4-5]
Jul 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Michael Drumheller | last post by:
(If you're not interested in NumArray, please skip this message.) I am new to NumArray and I wonder if someone can help me with array-indexing. Here's the basic situation: Given a rank-2 array...
10
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
2
by: jccorreu | last post by:
I'm taking in data from multiple files that represents complex numbers for charateristics of different elements. I begin with arrays of doubles and interpolate to get standard values in real and...
16
by: Frederick Gotham | last post by:
Inspired by page 219 of Nicolai M. Josuttis's book, I set out to write a class for an intrinsic array which would behave, to as far an extent as possible, like a container. Also though, I wanted no...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
3
by: Andrew Gentile | last post by:
Hello, I am trying to write a function which takes several floats as inputs, then returns 1x6 array of floats. I normally program in Matlab, and I am often confused by C. It seems that this...
1
by: =?Utf-8?B?aGFrYW5zaWx2ZXI=?= | last post by:
Dear all, We try to access a third party Matlab dll (which was created using Matlab COM Builder) from C#. It works fine when using strings and one-dimensional arrays but fails with...
7
by: John Koleszar | last post by:
Hi all, I'm porting some code that provides compile-time assertions from one compiler to another and ran across what I believe to be compliant code that won't compile using the new compiler. Not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.