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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:24:20+00:00 2026-05-24T00:24:20+00:00

assume that a C program has a structure instantiated as follows: b.param1 = 20;

  • 0

assume that a C program has a structure instantiated as follows:

b.param1 = 20;
b.parm2 = 42;
b.param3 = 30;

The question is, what do we need to do or to have to be able to write from Matlab

>> b = [bInC.param1; bInC.param2; bInC.param3];

where bInC points to the memory allocated by the above mentioned C program

  • 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-24T00:24:20+00:00Added an answer on May 24, 2026 at 12:24 am

    You have a couple options, depending on your situation.

    1) If your C code is structured in such a way that it could be called from matlab, you can compile your C code as a mex file. You would then call your C function from matlab and return your result. To return your structure you have to create a matlab array in your C code and copy the structure parameters into it. The interface for this is the mxArray. It isn’t the most convenient process ever but it works well.

    mex files and mxArray: http://www.mathworks.com/help/techdoc/matlab_external/f29502.html

    2) Use the matlab engine to load your values into matlab without having to compile your code into a mex. The engine will let you execute matlab commands from your C program. You can also load variables into the workspace. You will still have to create an mxArray containing the values you want to copy. You can then use the engPutVariable function to copy the mxArray into your matlab workspace.

    Note that the engine maintains its own workspace, it will not automatically copy the variable into the workspace of your current matlab session by default. There are commands to move variables between workspaces but I have not investigated this. I have found it faster to just save the variables to a mat file and load it in the main workspace, but this is not ideal if you need an automated approach.

    matlab engine: http://www.mathworks.com/help/techdoc/matlab_external/f29148.html

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

Sidebar

Related Questions

Assume that we have the following code: class Program { static volatile bool flag1;
Lets assume that I have a computer which has a multicore processor and a
I have the following question on java keystores and keytool. I assume that a
I have a fairly simple question that has me stymied. I am trying to
This is a bit hypothetical and grossly simplified but... Assume a program that will
Assume that we have N erlang nodes, running same application. I want to share
Assume that you have a running SQL Server Express instance named (local)\SQLEXPRESS. Its database
Assume that the core project has a base entity and every plugin maybe extends
Assume that I have this piece of code: @interface Foo : NSObject { Bar
This question is rather agnostic than related to a certain version control program. Assume

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.