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

  • Home
  • SEARCH
  • 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 9024343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:59:02+00:00 2026-06-16T05:59:02+00:00

I apologize in advance for this question. I don’t like explain this code questions,

  • 0

I apologize in advance for this question. I don’t like “explain this code” questions, but I can’t find any documentation about my specific example.

Background
My issue is this. I am trying to translate some MATLAB code to C#, but I am at the same time having to learn MATLAB. I do not work with anyone that knows MATLAB code, I have no access to MATLAB, so I can’t test any of the code, and I can’t find any documentation on the following question. So…

Question(s)

  1. Is there a free online/desktop MATLAB compiler/interpreter somewhere that I can use to test out MATLAB code?

    …or…

  2. Is there someone that can explain the following code snippet:

    someVar.member1=myValue1;
    someVar.member2=myValue2;
    if (myCondition)
        for i=1:myTotal
            someVar(i).member3=myValue3;
        end;
    end;
    

    Does this make someVar into an array? Do I lose member1 and member2 or does it save what I have set somehow?

  • 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-06-16T05:59:03+00:00Added an answer on June 16, 2026 at 5:59 am

    Re: 1 – There is the excellent Matlab Documentation, including video tutorials, which will help you understand Matlab. This is much more useful than a compiler, since you’ll learn what the code intended, so that you can re-write it in a fashion that is appropriate for C#, rather than trying to copy Matlab-optimized syntax.

    However, to test-run Matlab code, there is Octave which provides most of the functionality of core Matlab, but may not support toolbox functions (additional modules of Matlab that you pay for extra).

    Re: 2 – Here’s what the code does

    Instantiate a structure array someVar (Matlab doesn’t need declaring variables beforehand) with a field member; assign it to myValue1

    someVar.member1=myValue1;
    

    Create an additional field member2, set it to myValue2

    someVar.member2=myValue2;
    

    If the condition is true, loop myTotal times, and set the field member3 of all i elements of someVar to myValue3. Thus, someVar goes from a 1-by-1 structure array to a 1-by-myTotal structure array. someVar(1).member1 remains myValue1, while someVar(i).member1 are initialized to empty ([]).

    if (myCondition)
        for i=1:myTotal
            someVar(i).member3=myValue3;
        end;
    end;
    

    /aside: This loop is a rather inefficient way to define the structure. So there may not be much Matlab-optimized syntax in the code you need to translate.

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

Sidebar

Related Questions

I apologize for this question in advance, but I've looked pretty hard and haven't
I apologize in advance for this somewhat ignorant question, but I have researched this
I apologize in advance for asking this question, I know similar questions have already
I apologize in advance if this question seems confused. The behaviour I am seeing
I apologize in advance, if this question doesn't make sense. I'm a newbie. I
I apologize in advance for not knowing how to better state this question. In
This question is probably borderline for stack overflow, so I apologize in advance if
I apologize in advance; this is a long question. I've tried to simplify as
This is a very noobish question, so I apologize in advance! I have two
This feels like a super newb question, so apologizes in advance. How does one

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.