Clear Filters
Clear Filters

why do I keep getting *Error using PolarPlotA​ppExample/​ComponentV​alueChange​d Undefined function 'arduino' for input arguments of type 'char'.* error ?

3 views (last 30 days)
So I am making a GUI to control a stepper Motor's position and show the real time position on a polar plot. The interfacing with arduino is done with the help of matlab arduino support package. The issue is that the hardware works fine, but the software is not functioning the way I intended it too. To solve
properties (Access = private)
Pax % Polar axes
ar = arduino('COM3', 'Uno')
res = 0.0140625
end
methods (Access = private)
function updateplot(app)
des_angle = app.des_angleEditField.Value;
I am taking input from the user to get an input for my polar plot to set the angle but I keep on getting the error 'Error using PolarPlotAppExample/ComponentValueChanged Undefined function 'arduino' for input arguments of type 'char' and I am not able to comprehend where the error could be. I tried changing the app.des_angleEditField.Value to double using str2double functon but I keep on getting the same error.
This was not the case when I did'nt interface arduino with my GUI and could see the plot refersh itself every given delay period. I am only getting this bug when trying to implent a GUI but in case of a normal script it seems to work fine.
if(des_angle < 0)
des_angle = -1*des_angle;
writeDigitalPin(app.ar,'D7',1);
for i=0:deg2rad(app.res):deg2rad(des_angle)
writeDigitalPin(app.ar,'D6',1);
polarplot(app.Pax,i,5,'--+ r');
app.Pax.ThetaDir = 'clockwise';
pause(0.1);
writeDigitalPin(app.ar,'D6',0);
pause(0.1);
end
else
for i=0:deg2rad(app.res):deg2rad(des_angle)
writeDigitalPin(app.ar,'D6',1);
polarplot(app.Pax,i,5,'--o r');
pause(0.1);
writeDigitalPin(app.ar,'D6',0);
pause(0.1);
end
end
end
end
% Create des_angleEditFieldLabel
app.des_angleEditFieldLabel = uilabel(app.UIFigure);
app.des_angleEditFieldLabel.HorizontalAlignment = 'right';
app.des_angleEditFieldLabel.Position = [14 209 60 22];
app.des_angleEditFieldLabel.Text = 'des_angle';
% Create des_angleEditField
app.des_angleEditField = uieditfield(app.UIFigure, 'numeric');
app.des_angleEditField.ValueChangedFcn = createCallbackFcn(app, @ComponentValueChanged, true);
app.des_angleEditField.Position = [89 209 70 22];
This is a snippet from the function createComponents(app) method and I am getting an error
Unrecognized method, property, or field 'EditField' for class 'PolarPlotAppExample'.
Error in PolarPlotAppExample/updateplot (line 36)
des_angle = app.EditField.Value;
Error in PolarPlotAppExample/startupFcn (line 100)
updateplot(app);
Error using matlab.apps.internal.GraphicsCallbackProxy/runCallbackFunction (line 23)
Error while evaluating GraphicsCallbackProxy CallbackFcn.
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating NumericEditField PrivateValueChangedFcn.
Confused how to solve this.

Answers (1)

Raghav
Raghav on 4 May 2023
Hi,
Based on the question, it can be understand that there is some issue with arduino support package installation and some error in PolarPlotAppExample function.
The first error you mentioned, "Undefined function 'arduino' for input arguments of type 'char'", suggests that the arduino function is not recognized by MATLAB. This could be because the Arduino Support Package for MATLAB is not properly installed or loaded. Make sure that you have installed the support package and have followed the necessary steps to set up the hardware connection between the Arduino board and MATLAB.
As for the second error, "Unrecognized method, property, or field 'EditField' for class 'PolarPlotAppExample'", it seems that you are trying to access a property that does not exist in your PolarPlotAppExample class. Instead, you should use app.des_angleEditField.Value to get the value of the des_angle input from the user. Replace des_angle = app.EditField.Value with des_angle = app.des_angleEditField.Value in your updateplot method.
Also, make sure that the startFcn method is correctly calling the updateplot method. The error message suggests that there is an issue with the startupFcn method. Check the syntax and make sure that the method is defined correctly and that it is properly calling the updateplot method.
If these changes do not resolve the errors, please provide more information on the specific error messages and the full code of your GUI and any relevant classes.
Hope it helps,
Raghav Bansal

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!