Array Definition and 481 Threads

  1. R

    Designing an LED Array Circuit for Real-Time Feedback on Exercise Equipment

    I've modified a piece of exercise equipment so that it generates 12v dc. Max current is almost certainly less than 1 amp (more than that, and the subject (exerciser) poops out fast). Standard (car lighter) plug allows any appropriate device to be powered. Current generation is being...
  2. D

    Perl. Locate position of maximum value in an array

    Hi guys. I need to locate the maximum value in an array in Perl. So let's say it looks as follows: # Define array my @a; # Define inputs in array a[1]=11; a[2]=12; a[3]=13; a[4]=14; a[5]=15; a[6]=13; a[7]=12; a[8]=14; Then I would like to do something like max[@a] given the result "15" and...
  3. F

    Merge sort with array of structs

    Homework Statement I need to be able to copy full structs in a temporary array based on a value in that struct (an integer), but I'm not sure exactly how to go about it. I have commented where I need to copy over structs. Also in the other code block, what is the problem here? It doesn't...
  4. A

    Calculating the RMS of an array

    Right, this may be really simple but I am seriously struggling with it! I have an array of data which shows a map of Sweden (the sea is masked out so all the values over the sea are set to 0). I need to calculate the root mean square of only the values not equal to 0 in my array, but I...
  5. T

    Mathematica - turning two lists into an array

    Hi I need to turn two lists in the form {a1,a2,a3...} {b1,b2,b3...} into {{a1,b1},{a2,b2},{a3,b3}..} I've looked everywhere on the Wolfram website and the best i found was: Riffle[{list1},{list2}] which gives me {a1,b1,a2,b2,a3,b3} does anyone know the function to use? Thanks
  6. clope023

    Bubble sort 2D int array with c

    hi, I'm not sure if there is a homework forum for programming but I thought I'd post my problem here; I'm supposed to bubble sort a 2d integer array with elements 15 and 2; this is what my code looks like so far: #include <stdio.h> #include <stdlib.h> #include <time.h> #define cards 15 #define...
  7. H

    Finding an object in an array

    Finding an "object" in an array Say I have a vector of 64 cells. Each cell can have a value of 0-7 (each represents a color). Inside this vector I may have an "object" which would be defined as a set of consecutive non-zero (zero=black) cells with the same value. The object is no longer than 45...
  8. Z

    C/C++ Inputting an array in to a function or returning an array? (C++)

    I recently came up with a bit of a mathematical problem for myself and decided I needed a bit of code to help me. My understanding of C++ is pretty basic and I seem to have found myself stuck mixing arrays and functions. I wrote the function: int worko (int c[], int tri) { //turns...
  9. J

    How to Write a 2D Array to a File in Fortran for 3D Graph Creation?

    Hello, i have a problem and i was wondering whether anyone in here can give me a hand. I want to write a 2D array to a file in format that can be read from another program in order to make a 3D graph. I'm using fortran. In few words i want to place the data in columns and rows in the file...
  10. V

    A for loop to set a 2D array in C

    Is there anything wrong with this code? I am trying to make each set of [i] read like this: 0,200,0,200,0,200,0,200... ect. for some reason the numbers are not being set correctly. for (i = 0; i < loopCount1; i++) { for (j = 0; j < loopCount2; j++) {...
  11. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    Hi, I need help taking the atomic numbers from a list of elements and putting them in an array. I have my data in a text file in the form: Ac 227 Actinium 89 Al 26.981539 Aluminium 13 Am 243 Americium 95 etc. This is what I am have so far: FILE *fp; char myStr[1000]; char...
  12. L

    Magnetism and Reentry: Could a Halbach Array Reduce Heat?

    I was just wondering; What would happen if a Halbach array of magnets were placed just beneath the heat shield on a reentry vehicle? The plasma produced by reentry is, essentially, charged particles moving at high speed. Would a Halbach array magnetically levitate the reentry vehicle away...
  13. J

    In C how would i write an array to a file

    In C how would i create, open and write an array to a text file The array is EeV[i], does it make a difference if I am using ubuntu or windows
  14. R

    Directivity of array of antennas

    Homework Statement I am trying to understand how the total directivity of an array of antennas is calculated. Homework Equations 1. A_e = (D * lambda^2)/(4 * pi) where: A_e = effective aperature (or area of antenna) D = Directivity of one antenna lambda = wavelength 2. D_t =...
  15. E

    Printing an array of char to a string in MIPS

    I am trying to mimic the function below in MIPS: extern void print_int(int x); extern void print_string(char x[]); char y[1]; void main(void) { char y[1]; y[0] = 'a'; y[1] = '\0'; print_string(y); } and my MIPS code for the above C code is below can someone tell me...
  16. 3

    Passing a 2d array to a function in C

    I am currently writing a simulation of the game of life in C. I can create a dynamically sizes 2d array in C. However I then want to pass this array to a function. I have tried to do this however I cannot pass the array if at least one of the dimension sizes and not defined at compile time...
  17. C

    RC4 Stream Cipher: Investigating Permutations of the Initial Array

    hi, I had a question regarding the rc4 stream cipher. I understand it is a bunch of permutations to the initial Array that goes from 0 to 255 with respect to the key. However is there such a key such that after the permutation S is still the same? (ie still goes from 0 to 255)? Any help...
  18. T

    Is it Correct to Replace '\0' with a Website Address in a Char Array?

    in this code i got a chat type pointer which is an array who consists out of 4 char cells in order that each pointer cell of this array will point to some place we need to give it an address some thing like &chr "Monday morning" is not an address and its not a single char this...
  19. T

    Arrays in C: Pointers vs Structures

    printf("%p\n", array); i know that unlike other variables when we want to do some operation on an array it uses the physical address of the array but there are many cells in the array does it prints every one of them?? does the array always defined as pointer ?? even if we make...
  20. F

    Changing kinetic E of charged particle in magnetic field - Halbach array

    changing kinetic E of charged particle in magnetic field -- Halbach array hi, I read somewhere that you can't change a charged particle's (we'll say electron) kinetic energy with a strong magnetic field, that you only change the electron's direction. I'm assuming a frictionless environment...
  21. A

    How can I control an LED array for creating patterns and designs?

    Hello all, I recently became interested in building an LED lamp as a gift for a friend. I have a good understanding of technology, but I have only a small understanding of electrical engineering. I have researched and understand how to build an actual LED lamp where I would have all the LEDs...
  22. S

    Troubleshooting: Array Values Stored as 0.10000001

    I am allocating a value of 0.1 to a position in an array and it seems to be storing itself as 0.10000001. The problem is that once all the values in the array have reached 0.1 the average should be 0.1 and the loop stops, but as it is being stored as 0.1000001 the average is > 0.1 and the loop...
  23. S

    C/C++ C++, Laplace Equation in a 20*20 array

    The code should solve laplace equation through an iterative technique until values change less than the specified tollerence, in this case maxdiff. I've used 3 arrays. one to store all values including initial and boundary conditions, and 2 more to store the new values and differences between...
  24. H

    MATLAB MATLAB: Sum & Remove Array Entries (0, 1 & >1)

    Hi, How can I find the following from an array with entries of 0, 1, and >1: Find the sum of all the entries in the matrix that are not equal to 0. Find the sum of all the entries in the matrix. Find the sum of all the zero and 1 entries in the matrix. How to remove the entries in the...
  25. P

    How to search for duplicate values in an array of integers?

    I'm trying to search for duplicate values in a array of integers in Java. The array of intergers is sorted. Could anyone give me an idea on how to get started. :confused:
  26. G

    Array inside a class having problems

    An exercise I am trying to complete is to create a base class pointType which has functions to get two coordinates, store and print them; then to create another class derived from pointType that will find the radius, centre, area of a circle, and print these; then to create another class...
  27. G

    Char array initialisation problem

    I'm currently playing around with strings and char arrays and having problems initialising a char array properly. Basically I've got a text file whose length I want to check before putting the contents into a char array I define my ifstream variable as in_data and a string as str1. Then...
  28. H

    MATLAB MATLAB Array Pre-allocation help

    Hi everyone. I'm working on a piece of code and I'm having a bit of trouble with array pre-allocation. Here it is: function [react_in1 react_in2 react_out1 react_out2]=oneVtwoXone(masses,prec); prec = 1e-4; N=length(masses); masses=[0;masses]; % adding dummy metabolite with zero mass...
  29. L

    What Are the Key Equations for a Phased Antenna Array?

    What are the equations for a phased antenna array due to: 1. Individual element gain and the number of elements 2. Aperture of the array I have been googling these for god knows how long and can't find the slightest hint, except the site Microwaves 101 (http://www.microwaves101.com/)...
  30. A

    How Can I Take the Inverse of an Image Matrix in MATLAB?

    I'm trying to take the inverse of an image matrix by doing the following: >> A=imread ('noise.jpg'); >> inv(A) But I'm getting the following error: ? Undefined function or method 'inv' for input arguments of type 'uint8'. How can I change the image matrix so that I can take the...
  31. C

    C/C++ Solving C++ Complex Array with Time-Dependent Schrodinger Equation

    Hi, I've been trying to write a program to solve a propagation of a wave packet using the time dependent schrodinger equation. and I noticed I would need to use complex numbers. I know that I need to use #include<complex> I declare my array, and I started with a simple 1-d array...
  32. D

    How can I tell when I've reached the end of an array?

    Ok, for my first post, here goes: I'm working on an assignment for school that states: Write a function that receives two one-dinemsional arrays that correspond to the flight-path angles and the corresponding coefficients of lift. The function should sort the flight-path angles into...
  33. L

    MATLAB Why am I not getting an array when using inverse tangent on an array in MATLAB?

    Hi guys, I am having a problem here with a MATLAB m.file, I am trying to take the inverse tangent of an array and expect from this function to get another array, but for some reason I don't get an array just a single number. Any MATLAB guru that could help me with this problem? Thanks...
  34. L

    C/C++ Can Array Overruns Lead to Catastrophic Failures?

    Can over running of array lead to the catastrophic failures? If ‘Yes’ then why does not C++ provide bound checking on array operations and who is responsible to prevent array overruns?
  35. N

    Help Reading A .txt File Into A 2D Array In C

    Homework Statement The program is to read in a file full of numbers formatted like this: The first line contains a single int n. Following this line, there will be n lines with n ints each separated by whitespace. So I have asked the user for a file path and read in the first number ('n')...
  36. L

    Proving Boundedness of Double Index Array | Math Problem

    I'm just don't get this question. from my text: define\ t_{mn}\ =\ \sum^{m}_{i=1}\sum^{n}_{j=1}|a_{ij}|, [a_{ij}\ is\ a\ doubly\ indexed\ array\ of\ real\ numbers.] (a)\ prove\ that\ the\ set\ \{t_{mn}\ :\ m,n\ \in\ N\}\ is\ bounded\ above. (b)\ use\ (a)\ to\ conclude\ that\ (t_{nn})\...
  37. S

    Infinite Loop problem in an array sorting program

    Hi, I am writing a function that takes in a real data array and a key partition value, which will rearrange the array so that elements with a lower value than x are placed before the elements with values >= the partition value. It then returns the index of the last element of the array with a...
  38. K

    What is the equation for finding the maximum frequency in a towed-array sonar?

    Homework Statement A towed - array sonar comprises 100 transducers equally spaced at every 3m and towed behind a ship so the array stays just below the surface of the water (effectively horizontal). An adjustable phase delay can be introduced for each transducer, allowing the sonar beam to be...
  39. L

    Coding a Bubble Sort routine using a pointer array

    I have been asked to code a Bubble Sort using a pointer array and pointer notation as opposed to the square bracket notation...(there should be two uses of square brackets when declaring the arrays). It will not work! :( Basically the data does not sort. I am trying to swap pointer array...
  40. N

    Help With Assigning An Array With rand()

    Homework Statement I need to write a function that takes an int array and the size of the array as parameters, then finds the largest num in the array, returns this value and then sets the value to zero. Then in the main part of the program, I need to create an int array of 20 nums, assign...
  41. E

    Constructing a Tubular Bell Array: Solving the Wave Equation

    I have the next theoretical-practical problem. I have to build a tubular bell array (like that at symphonic orchrestas) with tubes (not rods) of aluminium or copper. The principal problem I have is I don't know how to state the wave equation for a tube (I have done it for a string). How I do it...
  42. B

    Comp Sci Find the Second Largest Integer in a Java Array | Simple Function Example

    Q1. Write a function that accepts an array of integers and returns the second largest integer in the array. Return -1 if there is no second largest. The signature of the function is public class ID { public static void main(String[] args){ } int f(int[ ] a) { } } Examples...
  43. M

    Square array (electric field question)

    Homework Statement Four charges q1 = q3 = -q and q2 = q4 = +q, where q = 6 µC, are fixed at the corners of a square with sides a = 1.3 m. (see attached .gif) Calculate the x- and y-components of the net electric field at the midpoint M of the bottom side of the square. Homework...
  44. E

    Understanding Array Elements: n^2 vs. 8*n

    Homework Statement For the problem at this site http://www.kalva.demon.co.uk/putnam/psoln/psol859.html, how an array with n^2 elements contain 8*n elements (8 for each positive integer) when n is not equal to 8? Does that type of algebra not work with an infinite number of elements...
  45. P

    Java How can I add an integer to a sorted array using binary search in Java?

    Hello, I need to write a method that adds an interger to a sorted array of integers. I'm using the following code to search for an interger in the array private static int binarySearch(int[] list, int key, int low, int high) { while (low <=...
  46. T

    SKA: What's Being Planned & Job Prospects?

    Does anyone know what kinds of things are being planned for study at the SKA when its built? i know its going to be a radio telescope, and hopefully in Australia/NewZealand instead of South Africa (it'll be based only a few hours out of Perth WA, where i live :biggrin:)... and also, what...
  47. P

    Comp Sci Trouble Expanding an Array of pointers in C++

    Homework Statement I am working on a program that reads in names (strings), sorts them, and then later is searchable. The problem I am having is this. When I enter the first 20 elements of the array, everything works fine. When I enter the 21 element (when it goes into the if loop) I get...
  48. G

    C/C++ How can I pass a 2D array in C++ without errors?

    1. The problem I am having is that I am trying to pass a two dimensional array from my main function to a secondary function. I know it has to be call by reference and using the name of the matrix, "matrix" in my case should send the location. Also since it has more than one dimension there...
  49. D

    How can I read values from multiple textboxes into a 2-D array in VB.NET?

    Hi I am a new-comer to VB.Net & I am working with arrays at the moment.i want to write a procedure that accepts two 2-D arrays(max size being a 4*4 matrix). i don't know how i could get the procedure to read in these values from the sixteen different textboxes i have created...i started using a...
  50. S

    Inputting Array Values in Assembly: Solving the Problem

    Well I'm hoping it's simple, after all I'm not too good at this lol i am trying to get the user to input values for an array using: #include <stdio.h> #include <stdlib.h> int main(void){ int marks[4]; char format[] = "%i"; _asm { markone: lea eax, marks[0]; push eax; lea...
Back
Top