Hi, May I know if App Designer supports Peter Corke Robotics Toolbox ?
MATLAB: Does app designer support Peter Corke robotics toolbox
#appdesigner #petercorkeroboticstoolbox
Related Solutions
[original post below]
There's no way to directly save the 'figure' produced by UIAxes in app designer (bummer). An alternative would have been to copy the UIAxes onto a new figure using copyobj(axHand, figHand) which works with axes developed in guide() but that functionality is not supported with UIAxes from app designer (double bummer).
A workaround is, from within your app,
- Create a new figure and new axes
- Copy the UIAxes children on to the new axes
- Copy most of the UIAxes properties over to the new axes
Some axes properties are read-only so we can't copy those over to the new axes. Also, there are some axes properties that you don't want to copy over such as parent, children, X/Y/ZAxis, which will cause errors. In addition to those, you'll see in the code below where I added the "Position" and "OuterPosition" properties to the list of properties not to copy. In your app, the axes are probably small and if you want your new axes to also be the same size, you could remove the two position properties from the 'badFields' list.
% Create new figure and new axes
figureaxNew = axes; % Copy all objects from UIAxes to new axis
copyobj(app.UIAxes.Children, axNew)% Save all parameters of the UIAxes
uiAxParams = get(app.UIAxes);uiAxParamNames = fieldnames(uiAxParams); % Get list of editable params in new axis
editableParams = fieldnames(set(axNew)); % Remove the UIAxes params that aren't editable in the new axes (add others you don't want)
badFields = uiAxParamNames(~ismember(uiAxParamNames, editableParams)); badFields = [badFields; 'Parent'; 'Children'; 'XAxis'; 'YAxis'; 'ZAxis';'Position';'OuterPosition']; uiAxGoodParams = rmfield(uiAxParams,badFields); % set editable params on new axes
set(axNew, uiAxGoodParams)
For trouble shooting, or to loop through each property rather then setting them all at once, replace the last line of the code above with this for-loop below which indicates the property being edited in the command window.
% Set new axis params
allf = fieldnames(uiAxGoodParams); for i = 1:length(allf) fprintf('Property #%d: %s\n', i, allf{i}); set(axNew, allf{i}, uiAxGoodParams.(allf{i}))end
One alternative worth mentioning: Instead of your app hosting the axes, you could program your app to plot the data onto an external figure and then you wouldn't have this problem.
Interactive features such as "KeyPressFcn" are not yet supported for App Designer UI figures. For a list of features that are supported you can refer to the following link:
As a workaround, if you need to use any of the features that are not supported, you can use traditional figures inside the App Designer. Note that these figures will not be embedded inside the app. It will instead appear as a popped-out figure.
You can setup your App Designer code to include a button, which when pressed opens up a new traditional figure. For this new figure you can then define your "KeyPressFcn" or any other figure callback functions. Here is a small example of using the button-pushed callback function to generate a new traditional figure for which you can then define the "KeyPressFcn".
% Button pushed function: Button
function ButtonPushed(app, event) figure('KeyPressFcn', @KeyFcn, 'Name', 'Key Press Demo'); % new traditional figure with interactive features
plot(1:100); function KeyFcn(~, ~) plot(100:-1:1); end end
Best Answer