Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7060015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:18:06+00:00 2026-05-28T04:18:06+00:00

Let A be an array of arbitrary dimension (2 or 3 in my case).

  • 0

Let A be an array of arbitrary dimension (2 or 3 in my case).
How can I flatten (reshape to 1D) this array without knowing in advance the number of dimensions ?

If I knew the number of dimensions, I could easily obtain the total number of elements (by using a combination of “Array Size” function) and then reshape A to 1D using this number.
Unfortunately, the “Array Size” function itself returns an array whose number of elements is equal to the number of dimensions, which brings us back to the initial problem.

I have “solved” the problem by creating a function (VI) that returns the total number of elements of a 3D array (the most common type of arrays that I expect to handle), so that I can give this as an argument to the Reshape function. Problem: it won’t accept a 2D array, even though the algorithm would work with such an array ! (it seems that in Labview, array controls are strict about the number of dimensions they accept, which isn’t the case in Matlab for instance).

A nice solution would be a simple way to multiply all the elements of the array given by “Array Size” to quickly get the total number of elements, without having to wrap this in a sub VI.
Overall, isn’t there a simple and efficient way to solve this problem ? It should be quite standard..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:18:07+00:00Added an answer on May 28, 2026 at 4:18 am

    I belive this is what you are looking for :

    http://zone.ni.com/reference/en-XX/help/371361E-01/glang/reshape_array/

    You would do :

    n-DimInputArray –> ArraySize –> 1D_SizesOUT

    This returns a 1D array containing the sizes of all of the array dimensions.

    You then go :

    1D_SizeOUT –> MultiplyArrayElements –> NumberOfElementsIn_n-DimInputArray

    This value goes in as the dimension size for ReshapeArray – done.

    http://zone.ni.com/reference/en-XX/help/371361E-01/glang/array_size/

    http://zone.ni.com/reference/en-XX/help/371361E-01/glang/multiply_array_elements/

    Here’s a snippet of the above code:
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a .NET Array of n number of dimensions. I would
I tried to follow this but the default modelbinder let my array null on
With an array let foo = [|1;2;3;4|] I can use any of the following
how can i filter an array using key value combination. let array is a=>1
Consider the following code fragment in VS2010 Beta 1: let array = Array2D.zeroCreate 1000
I have a 2D bitmap-like array of let's say 500*500 values. I'm trying to
Let say I have an array like: Array ( [0] => Array ( [Data]
Let's say I have array of bytes: byte[] arr = new byte[] { 0,
Let's say I have an array, and I know I'm going to be doing
Let's say I have an array of lots of values (C++ syntax, sorry): vector<double>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.