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 860639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:50:46+00:00 2026-05-15T08:50:46+00:00

I am new to MATLAB, and I can’t fathom this from the documentation. function

  • 0

I am new to MATLAB, and I can’t fathom this from the documentation.

function GotData(sender, args)
    interval = args.DataBlock.TimeIntervalInMicroseconds;
    doubles = args.DataBlock.AsDoubleArray();
    x = 0;
    complexCount = length(double(doubles))/2;
    DATA = zeros(complexCount);
    for index = 1:(complexCount-1)
        realnum = doubles(2 * index);
        imagnum = 1i * doubles(2 * index + 1);
        complex = realnum + imagnum;
        x = x + interval;
        DATA(index) = [x complex];
    end
    disp(DATA)
end

I am getting an array of doubles from an event that fires in a .NET assembly. I’m splitting the array up so that each even item (in a 1 based array) is an imaginary number and each odd item is real. Then I create a two item array of the complex number and its interval. I want to then append this 1D array to a 2D array. How do I do that?

At the moment I’m getting an error: In an assignment A(I) = B, the number of elements in B and I must be the same.. What should I be doing?

interval is 1, but can be adjusted.

  • 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-15T08:50:46+00:00Added an answer on May 15, 2026 at 8:50 am

    If you want DATA to be a 2-D array, you need to initialize it and index it as such:

    % ...(your code)...
    DATA = zeros(complexCount-1, 2);   % Initialize DATA to an N-by-2 matrix
    % ...(your code)...
        DATA(index, :) = [x complex];  % Add the array to a row of DATA
    % ...(your code)...
    

    You can check out these MathWorks documentation links for further information about creating matrices and matrix indexing in MATLAB.

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

Sidebar

Related Questions

I guess this is something from new version of Matlab. But I can't figure
still fairly new to matlab, picked up this data analysis code from someone and
Am new to matlab. Can someone explain me the following code. this code is
Hello I am new to MATLAB , I wanted to know how can I
I'm new to MATLAB and mrVista. I'm running Matlab Version 7.8.0.347 (R2009a) 32-bit(win32) from
Apologies if this is a stupid question, I'm relatively new to Matlab. I've got
I am new to Python (coming from MATLAB) and was beginning to learn that
In MATLAB, when you click File -> New -> Function M-File, you get a
How can I create a function with MATLAB so I can call it any
Would somebody help me please in this question. I'm new in Matlab... And it's

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.