Array Definition and 501 Threads

  1. R

    Comp Sci Java: Reading a file into an array

    Homework Statement How do I read in a file line by line into an array without using arraylist? Homework Equations NoneThe Attempt at a Solution I know how to do this using BufferedReader, but I am wondering how to do this using Scanner? When I used BufferedReader I noticed that there must...
  2. camila

    Fortran {FORTRAN}How can i read blank steps without using iostat

    hello, I have a tricky question with arrays involved. I am trying to made a code who can read precipitation, so i have 3 kinds of strings: 1.numbers, 2.0 ,3. blank steps. I need to change the blanks into the smallest number who can read fortran. I was reading and the other options is using...
  3. Antonija

    Comp Sci Fortran:store loop value in array

    Homework Statement My program calculates the value of a function. Then it prints them on the screen. This is the part: do while(x<=b) variablesvalues(1)=x x=x+delta call recog_variables (func, variables) answer=evaluate(variablesvalues) print*, answer end do What I need to do now is to save...
  4. T

    Synchronize a dc pulse through an array of parallel wires

    Hi everyone, my question is related to producing a magnetic field from an array of straight parallel wires. In my scenario, imagine the wires as being stacked into a regular array similar to the way a pile of lumber is usually stacked, so that the ends are exposed, eg: ====================...
  5. L

    Fortran Fortran 90/95: Array Help with IF Statement

    Hi, For fortran 90/95, I've written a 10x10 array of numbers. 2 do loops (n,m) from 1 to 10 indicate the subscript of the elements in this array. I've applied a generic rule to the array elements where they become 0 if they are above a certain number. Using an if statement to change the...
  6. Antonija

    Comp Sci Allocatable character array in Fortran

    Homework Statement I have character array in fortran which is defined as allocatable. When program runs, user inputs something like: [1,2,3,4...], and then program reads it and counts the particles, and then allocate array with dimension it just read. Thats' how I understood it. This program...
  7. B

    DOUBLE cannot convert the input expression into double array

    Hi Folks, I have a symbolic A=18*1*18 array containing symbols/expressions. I want to populate certain entries of this array into another matrix. For example K(1,1)=A(1,1,1) I get the following ? The following error occurred converting from sym to double: Error using ==> mupadmex Error in...
  8. B

    Far-field power-pattern of the antenna array Beam-Steering

    Hi all, I have a problem to firstly understand and secondly solve this problem : here is the Problem : Consider three (coherent) antennas variously arranged on the x-y-plane where each individual antenna radiates an isotropic electric field E(x). 1 - Write down an expression for the far-field...
  9. 22990atinesh

    How to check whether an array represents max heap

    Homework Statement Does the following array represents the binary max heap 99,98,97,55,49,49,48,13,54 99,98,97,55,54,49,49,48,13 Homework EquationsThe Attempt at a Solution I've tried to construct the tree structure and all the above array representation satisfies the binary max heap property...
  10. M

    Matlab Issue with aligning text in table format in .txt file

    Homework Statement uData is a 30x5 matrix with numbers. name_Database is a 30x1 cell array with strings of Names (e.g. Fake Subject 1, Fake Subject 2, Bob). What would fix the code so that the data aligns? (please see image for the misalignment). Homework EquationsThe Attempt at a Solution...
  11. Silicon Waffle

    C/C++ [C++] Reading a binary file into a byte array

    I have to read a binary file into a byte array and chop it wherever I like. I'd like to use a vector of char to do this. But reading some resources from known people, I find they tend to use char* or char []. Using a vector of chars seems easier for retrieval of any block of bytes. Which means...
  12. Henry R

    MHB Explore the Manipulated Contents of an Array with Multiplication and Addition

    Please identify the contents of the array after the following manipulations. int arr[5]; arr[0] = 2; arr[1] = arr[0] + 1; arr[2] = arr[0] * arr[1]; arr[3] = arr[1] / arr[0]; arr[4] = arr[3] * arr[3]; *Involves multiplication, addition from the array. Solve it...
  13. SalfordPhysics

    Comp Sci Efficient Fortran Method for Trajectory Plotting with 4d Vector-First Order ODE

    Homework Statement I have a code that successfully plots the trajectory of a ball moving under gravity and air resistance, but my method is rather long-winded and I want to use a 4d vector-first order ODE instead - but I don't know how to do it. I've tried writing some simple skeletons but...
  14. M

    MHB Why Use a Helper Variable When Inserting an Element in an Array?

    Hey! :o How can I insert an element in an array in time complexity O(1)? What variables do I have to use to achieve this? (Wondering)
  15. I

    C/C++ Accessing Array Elements: i vs. .at(i)

    ok I am a little confused. can both [i] and .at(i) be used to same way to access an array element?
  16. M

    C/C++ C++ - dynamically allocating memory to array of structs

    Let me start by saying I know this is a funky way to program, but my teacher is requiring us to go about it this way. also: I CANT use std::string, classes, constructors for this project. I am required to use this archaic method of c-style strings with dynamic memory allocation occurring...
  17. Medicol

    How Can You Determine the Number of Strings in a C++ Static Array?

    1. Using new to create a memory block for a static array of strings. How to know the number of strings in an array of strings Homework Equations new The Attempt at a Solution 1. static char ** array=new char*[]; // why the empty [] ? Will I get a minus point if coding like this ...
  18. DivergentSpectrum

    Getting input from an array of textboxes for another window (wpf)

    Hi, I am working on an n-body solver. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input...
  19. Matterwave

    Fortran Can equations be used in Fortran array declarations with parameters?

    Hi, I'm just wondering real quick, are equations allowed in array declarations? For example: int :: y=2 int, dimension(2*y):: x ?
  20. N

    Plano-convex vs Double-convex (fly's eye) cylindrical microlens array

    I am trying to find out if I could substitute a Plano-convex cylindrical microlens array with a Double-convex (fly's eye) cylindrical microlens array for laser beam homogenization in 1 dimension. Assuming that the lens parameters are the same, how would the quality of performance be affected...
  21. E

    Calculating Probability for Array of Balls

    Hi! Here is my task: There are 4 white and 6 red balls in array. Find probability that there are three white balls in beginning of array. How to calculate m?
  22. gfd43tg

    Cell Array manipulation (matlab)

    Homework Statement Write a line of MATLAB code that uses the cell array A to generate the string 'Cal Golden Bears'Homework Equations The Attempt at a Solution A = {'Cal', 'Golden', 'Bears', [5 7], {[1 2 3 4]}} A = 'Cal' 'Golden' 'Bears' [1x2 double] {1x1 cell} The...
  23. adjacent

    C# How Can I Replicate PHP Array Addition in C#?

    The title. A friend of me told me the code in php <?php for($i=0; $i<=100; $i++) { if($i%5==0) { $out[] = $i; } } foreach($out as $val) { echo $val."<br>"; } ?> The result is the multiples of 5 in the first 100. How do I reproduce this part:"$out[] = $i...
  24. M

    Array multiplication and array division

    Hi, in Matlab I encounter with two new operations for me which are array multiplication and array division. I want to learn that do they have physical applications in real world physics problems or are they be related with banking and accounting.
  25. gfd43tg

    While end loop to find pattern in array

    Homework Statement Write code using a while loop that will assign to the variable numOccursSep the number of times a certain pattern of 0's and 1's occurs separately in V. The variable pattern gives the certain pattern to look for. For this problem overlap is not allowed, i.e. if pattern =...
  26. gfd43tg

    Loops to create an array (matlab)

    Homework Statement Attached imageHomework Equations The Attempt at a Solution I am basing my code off a template I found in a textbook for using loops to create an array. If I didn't find this example I don't think I would even know where to begin with this. Here is what I came up with so far...
  27. cosmik debris

    Mean distance between points of 2D array

    Say I have an N X N array of points, I would like a formula to give the mean distance between the points. There are lots of short distances but only two long ones (diagonal). There are plenty of algorithms to do this but I would like to work out a formula if there is one. Can someone point me in...
  28. gfd43tg

    Matlab changing word in character array

    Homework Statement Let sentence1, string1, and string2 be three variables whose values are character strings. Using only the MATLAB function strfind and array concatenation, write code that will replace the first occurrence of string1 in sentence1 with string2, assigning the result to...
  29. gfd43tg

    What is the Purpose of Using Arrays in Complex Expressions?

    Homework Statement I am working on problem 4 in the PDF attachment now, but I will show my code for 2 and 3 since they are related to 4. The values for 2 and 3 were given in the editor. Homework Equations The Attempt at a Solution 2. P = [1.6, 4, 2.9, -8]; N = 3; PextDown = repmat(P,3,1)...
  30. gfd43tg

    Concatenating 2D Array: Adding Rows | Step-by-Step Guide for Problem 1(d)"

    Homework Statement I'm working on problem 1, specifically part (d) in the attached PDF file. I will show my code for (a) - (c) so you can see where I am coming fromHomework Equations The Attempt at a Solution (a) A1 = [1.3 5.2; 7.4 3.8; 9 2] A1 = 1.3000 5.2000 7.4000 3.8000...
  31. gfd43tg

    Character array command to find # of specific word in a paragraph

    Homework Statement Download the mat file Gettysburg.mat. View in a new window and load it in the workspace using the command clear; load Gettysburg; This loads a 1-by-1452 char array GA that is the Gettysburg Address in English. Display the first 100 or so characters for yourself to see this...
  32. gfd43tg

    What is the purpose of max(A,[],1)?

    Homework Statement Homework Equations The Attempt at a Solution A = [2.1, 4.2, 6.7; 8.3, 5.3, 5.4] A = 2.1000 4.2000 6.7000 8.3000 5.3000 5.4000 [mVal, I] = max(A,[],1) mVal = 8.3000 5.3000 6.7000I = 2 2 1 I don't understand what max(A,[],1) is...
  33. gfd43tg

    Index notation matlab for 2D array

    Homework Statement Homework Equations The Attempt at a Solution Hello, I am having some confusion over the notation used in matlab. I don't really know what they mean A = [1:3; 4:6; 7:9] A = 1 2 3 4 5 6 7 8 9 A(1:2, 1:2) ans = 1 2...
  34. F

    Diffraction with a large array of slits

    Hi all, exams soon and I'm stressing out over this small question. If anyone could guide me through, explaining why you're doing what you're doing that'd be beyond great. I posted this in the introductory thread but with no replies thought I should move it here (unsure of how to delete the other...
  35. F

    Diffraction with a large array of slits

    Hi all, exams soon and I'm stressing out over this small question. If anyone could guide me through, explaining why you're doing what you're doing that'd be beyond great. Homework Statement Light of wavelength λ is incident normally on a screen with a large array of slits having equal widths...
  36. H

    Fortran Fortran: How to make a long character made with an array

    Lets see if I explain myself. I want to FILL a string with the components of a character array. I have no idea, but seeing this example: character(len=*),parameter::fname=" Paul",lname="Scholes" character(len=20)::fullname fullname=fname//" "//lname I try this one...
  37. A

    Fortran Array Reference is out of bounds error? Fortran

    So, I have a bunch of errors which need resolving here but majority are based on the "out of bounds" error and hence the topic title :). Would be great if you are able to help me resolve the errors. Quite a newbie with fortran. So please bear with any silly questions that I may throw at you...
  38. B

    The Force of an Array of Perm. Magnets on a Large Iron Body

    For my senior physics research project I've developed an orbital analysis program that calculates the minimum \Delta V required (applied in an instantaneous impulse) to deflect an inbound Earth impacting asteroid. I've generated data for several different hypothetical orbits and now my advisor...
  39. R

    Having trouble with CSC assignment. Trying to make an array of Strings

    Homework Statement I need to write a program that takes a text file, and looks for how many unique words it has, as well as the number of times they occur in the file. Homework Equations None The Attempt at a Solution public static void main(String[] args) throws FileNotFoundException {...
  40. M

    Array reduction for a reaction matrix

    Homework Statement My problem is with a portion of a much larger problem, I'm working on an exercise involving the production of synthesis gas in where there's a reactor in which it is postulated that the following reactions take place: CH4 + CO2 ⇔ 2CO + 2H2 CO + H2O ⇔ CO2 + H2 CH4 + H2O ⇔ CO...
  41. E

    MATLAB Matlab : Function handle givin array to cell array of function handles

    Hi. I am currently in a situation where I have a function handle giving as putput an array of doubles. I would like to convert this to a cell array of function handles, each giving a component of the previous array. The original function handle is produced by a built-in MATLAB function, so...
  42. S

    Fortran FORTRAN error array bound is not scalar integer

    FORTRAN error "array bound is not scalar integer" I'd like to know if a loop can be created, inside which I can call a subroutine in which there are arrays to be defined whose size varies as a function of loop variable. I tried as following, but got error "array bound is not scalar integer"...
  43. T

    Python Python (Numpy) Non-Elementwise Array Operations

    Python (numpy) question: I have two 2D numpy arrays, A[i,j] and B[k,l], but the indexes are unrelated to each other (A and B won't even have the same dimensions in general). I want to be able to add/multiply these two together to get a 4D matrix: C[i,j,k,l] = A[i,j] + B[k,l] or C[i,j,k,l] =...
  44. I

    Array of magnets around a sphere

    An array of N magnets which can turn freely about their centers in any direction in 3d space is distributed uniformly around a spherical surface (their centers). What is the configuration of equilibrium of the system after some time? (minimum energy) Do you know of any work showing that...
  45. N

    C programming: array declared before main() and initialised in main()

    Hello! I am sure I am again missing something obvious: I tried to declare the array and assing value within main() as follows: #include <stdio.h> float array_1[10]; int main( void ) { array_1[10] = { 1,1,2,3,4,5,6,7,8,9 }; ...other stuff... return 0; } I can declare and...
  46. S

    Geolocation of emitters using an interferometer array

    Hello, in a paper about geolocation of emitters using an interferometer array I read such a description about a kind of array: Such arrays support locating emitters using some form of triangulation or bearings-only geolocation over several dwells as the satellite moves in its orbit. I...
  47. M

    Runge-Kutta 4 order method. Severe 161: Array bounds exceeded.

    So here I am trying to solve Rayleigh's differential equation using Rungen-Kutta 4th order analytic method. This is what the exercise gives me: X(0 to 40), Y1(0)=0.1, Y2(0)=0, H=0.1, μ=0.5 This is what I ve written and gives me this error: IMPLICIT REAL*8(A-K,O-Z) DIMENSION...
  48. N

    Analytic expression to find the range of non-negative numbers in array

    Hello, I have an array of length M. Some of the indices are non-negative. I need to derive a function/analytic expression (preferably linear or convex) that finds the span of indices for which the indices are non-negative. Example: Let p denote the desired vector. Let, p = [0 0 0.3 2.6...
  49. I

    Fortran Fortran90 issue: nonzero out of bounds array elements

    Hi to all. I am programing a new code for some calculation and i have detected a strange issue. I have my all arrays strictly defined for example real, dimension(-2:2,-3:2) A, B complex, dimension(-2:2,1:2) C In my time dependend calculations i expect the matrix element C(-2,1) to...
  50. Ackbach

    MHB How to typeset an array of figures?

    I want to typeset a 3 x 2 array of figures (that is, three rows of two columns), for answers to a multiple-choice question. How can I do that? The standard \begin{figure} environment seems to want to be outside of any environment. Ideas?
Back
Top