0

I used ssGetT(S), for some reason doesn't seem to work. Simple model, is the 'timestwo' with fixed time step 0.01 sec (auto solver)

I call it in the mdlOutput()

static void mdlOutputs(SimStruct *S, int_T tid)
{
    int_T i;
    InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);
    real_T *y = ssGetOutputPortRealSignal(S,0);
    int_T width = ssGetOutputPortWidth(S,0);

    //for (i=0; i<width; i++) {
    //     *y++ = 2.0 *(*uPtrs[i]);
    //}

    *y = (real_T)ssGetT(S);
}
Sam Gomari
  • 733
  • 4
  • 13
  • 37
  • What is the output? How do you see the output? – Navan Nov 16 '18 at 15:11
  • I get zero in the output. The length of the sim time is 10 seconds – Sam Gomari Nov 16 '18 at 15:15
  • Some more information is needed. What is this block's sample time? Have you set ssSetInputPortRequiredContiguous to true? Also try changing solver to discrete with fixed step. – Navan Nov 16 '18 at 16:55
  • No, this is the timestwo example from matlab. There is no place for ssSetInputPortRequiredContinuous . I changed the solver to discrete. Still it's zero. Head scratching – Sam Gomari Nov 16 '18 at 17:56
  • Can you put your whole s-function here and screenshot of model? May be we can try reproducing with that. – Navan Nov 16 '18 at 20:43
  • Making that one change to the example code works as expected. How many inputs to the S-Function do you have? If you have n inputs then you will have n outputs, but that code change only puts the time into the first output, the other n-1 outputs will be zero. – Phil Goddard Nov 17 '18 at 01:06

0 Answers0