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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:11:54+00:00 2026-05-23T06:11:54+00:00

I know how to write a basic C Mex function with one output of

  • 0

I know how to write a basic C Mex function with one output of type double. I tried to write a C Mex with two outputs but I got segmentation violation errors. The first output is a double, the second an integer. Here is the code where I try to assign the output pointers:

plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL); //works fine
plhs[1] = mxCreateNumericArray(1, 1, mxINT32_CLASS, mxREAL); //causes segmentation violation

I searched the internet, but almost all the examples have just one output or outputs of the same type. What should be done to get two outputs, one of type double, the other of type integer?

  • 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-23T06:11:55+00:00Added an answer on May 23, 2026 at 6:11 am

    Firstly, you’re calling mxCreateNumericArray incorrectly. You need to do something like this:

    #include "mex.h"
    
    void mexFunction( int nlhs, mxArray * plhs[], 
                      int nrhs, const mxArray * prhs[] ) {
        plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
        if ( nlhs > 1 ) {
            mwSize nd = 2;
            mwSize dims[] = { 3, 4 };
            plhs[1] = mxCreateNumericArray(nd, dims, mxINT32_CLASS, mxREAL);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to write the basic c# code to send emails, but I'm
Very basic question: how do I write a short literal in C++? I know
I know I could write scripts and create jobs to run them, but at
So I know I can write my own HTML-encoding function like this: function getHTMLEncode(t)
I know that this is really basic, but I looked everywhere and I cant
Does anyone know of any semi-portable way to write console applications (e.g. basic animation)
I know this is very basic question, but I need to know, how I
Does anybody know how I could write a function, that was able to create
This is child's play for all of you, but I don't know Visual Basic
Am not sure if this question makes sense. But I know all the basic

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.