S-function error, How do I initialise the output correctly?
1 次查看(过去 30 天)
显示 更早的评论
Hi Guys, I am currently using example code from Arduino to an S-Function where I am trying to output the acceleration values of X, Y and Z on a scope. I am getting an error for each axis when I try and upload the code to the arduino.
../Accelerometer_wrapper.cpp:73:9: error: assignment of read-only location '* y0'
y0[0] = event.acceleration.x;
^
../Accelerometer_wrapper.cpp:74:9: error: assignment of read-only location '*(y0 + 4u)'
y0[1] = event.acceleration.y;
^
../Accelerometer_wrapper.cpp:75:9: error: assignment of read-only location '*(y0 + 8u)'
y0[2] = event.acceleration.z;
^
*** [Accelerometer_wrapper.o] Error 1
The was I initialised the output is this way
if (xD[0]!=1) {
#ifndef MATLAB_MEX_FILE
/* Get a new sensor event */
sensors_event_t event;
accel.getEvent(&event);
/* Display the results (acceleration is measured in m/s^2) */
y0[0] = event.acceleration.x;
y0[1] = event.acceleration.y;
y0[2] = event.acceleration.z;
# endif
xD[0]=1;
}
The way it is on the Arduino is
void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
accel.getEvent(&event);
/* Display the results (acceleration is measured in m/s^2) */
Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" ");
Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" ");Serial.println("m/s^2 ");
delay(500);
}
And since its an accelerometer, it doesn't require any inputs just one output with three rows. Any help would be appreciated. Thanks
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!