GUI error in push button

5 次查看(过去 30 天)
i am making a GUI in matlab and i am using a push button.
code runs in the push button and the code gives three output. whwn i am trying to copy output to another block, it gives eror.
error:
Unrecognized property 'value' for class 'matlab.ui.control.NumericEditField'.
code:
classdef app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Button matlab.ui.control.Button
LatEditFieldLabel matlab.ui.control.Label
LatEditField matlab.ui.control.NumericEditField
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button
function ButtonPushed(app, event)
lats = [34.1989 34.0105 34.067894 34.1166 34.0151]; longs = [72.0231 71.9876 71.992783 72.0216 71.5249];
[x,y] = grn2eqa(lats,longs,[34.1166, 72.0216]);
% x=[8 0 -8 0 ].*100; %%x=[x_1 x_2 x_3 x_p]
% x(5) = -x(5); y(5) = -y(5);
% y=[-4 8 -4 5].*100; %%y=[y_1 y_2 y_3 y_p]
z=[0 0 0 0]; %%z=[z_1 z_2 z_3 z_p]
c=2.997924580*10^8;
%% Source TDOA calculation
z_s=0.0098;
t1 = (sqrt((x(5)-x(4))^2+(y(5)-y(4))^2+(z_s-z(4))^2)-sqrt((x(5)-x(1))^2+(y(5)-y(1))^2+(z_s-z(1))^2))/c
t2 = (sqrt((x(5)-x(4))^2+(y(5)-y(4))^2+(z_s-z(4))^2)-sqrt((x(5)-x(2))^2+(y(5)-y(2))^2+(z_s-z(2))^2))/c
t3 = (sqrt((x(5)-x(4))^2+(y(5)-y(4))^2+(z_s-z(4))^2)-sqrt((x(5)-x(3))^2+(y(5)-y(3))^2+(z_s-z(3))^2))/c
%% Source localization
syms xs ys zs %our unknowns
eqn1 = sqrt((xs-x(4))^2+(ys-y(4))^2+(zs-z(4))^2)-sqrt((xs-x(1))^2+(ys-y(1))^2+(zs-z(1))^2)-(c*t1);
eqn2 = sqrt((xs-x(4))^2+(ys-y(4))^2+(zs-z(4))^2)-sqrt((xs-x(2))^2+(ys-y(2))^2+(zs-z(2))^2)-(c*t2);
eqn3 = sqrt((xs-x(4))^2+(ys-y(4))^2+(zs-z(4))^2)-sqrt((xs-x(3))^2+(ys-y(3))^2+(zs-z(3))^2)-(c*t3);
sol = solve([eqn1, eqn2, eqn3], [xs ys zs]);
%%
m = 1;
for n = 1:length(sol.xs)
possibleSol(1,m) = double(sol.xs(n));
possibleSol(2,m) = double(sol.ys(n));
possibleSol(3,m) = double(sol.zs(n))
m=m+1;
end
%%
%%Filtering Results
%idx = all(possibleSol < 0) | all(imag(possibleSol) ~=0)
idx = possibleSol(3,:) < 0 | any(imag(possibleSol) ~=0)
possibleSol(:, idx) = [];
[lat,long] = eqa2grn(possibleSol(1),possibleSol(2),[34.1166, 72.0216])
app.LatEditField.value=lat
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
% Create Button
app.Button = uibutton(app.UIFigure, 'push');
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
app.Button.Position = [135 436 100 22];
% Create LatEditFieldLabel
app.LatEditFieldLabel = uilabel(app.UIFigure);
app.LatEditFieldLabel.HorizontalAlignment = 'right';
app.LatEditFieldLabel.Position = [130 343 25 22];
app.LatEditFieldLabel.Text = 'Lat';
% Create LatEditField
app.LatEditField = uieditfield(app.UIFigure, 'numeric');
app.LatEditField.Position = [170 343 100 22];
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = app1
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end

采纳的回答

Mario Malic
Mario Malic 2021-2-5
Properties are case-sensitive.
app.LatEditField.Value=lat
  3 个评论
Mario Malic
Mario Malic 2021-2-7
HTML component has property called HTMLSource, use it to set the path to your file.
ali hassan
ali hassan 2021-2-9
i have given the path and it looks like this but now my push button is also giving error and html is not accessible

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by