How to convert const real_T value to double ?

Hi, I have a problem with a piece of my code:
static void mdlOutputs(SimStruct *S, int_T tid)
{
#ifndef MATLAB_MEX_FILE
InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);
ds1104_slave_dsp_pwm_duty_write_register(task_id, &ch1_index, 1);
if (*uPtrs < 1.0)
ds1104_slave_dsp_pwm_duty_write(task_id, ch1_index, 0.0);
else
ds1104_slave_dsp_pwm_duty_write(task_id, ch1_index, 1.0);
#endif
}
It doesn't work because of incompatible operand types ("const real_T *" and "double") here : " *uPtrs < 1.0 "
I don't know how to correct it, your help will be welcome.
Thanks

 Réponse acceptée

Titus Edelhofer
Titus Edelhofer le 20 Août 2012
Modifié(e) : Kaustubha Govind le 20 Août 2012
Hi,
the function ssGetInputPortRealSignalPtrs allows Simulink to have the inputs organized in chunks. That's good for optimization (and for large input arrays) but is more difficult for the user. My suggestion would be to use the simpler ssGetInputPortRealSignal:
const real_T *u = ssGetInputPortRealSignal(S,0);
if (*u < 1.0)
...
Otherwise, if you leave it as is:
if (u[0][0] < 1.0)
Titus

3 commentaires

Alice
Alice le 20 Août 2012
Thanks, it works with your solution.
I don't have other problems
Kaustubha Govind
Kaustubha Govind le 20 Août 2012
@Titus: I fixed your code to use ssGetInputPortRealSignal (as I think you intended) instead of ssGetInputPortRealSignalPtrs. Hope you don't mind. :)
Titus Edelhofer
Titus Edelhofer le 20 Août 2012
Of course that's fine, thanks! Yes, that was what I wanted to write ... ;-).

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Functions dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by