Why I get error :Cannot find ‘get’ method for matlab.graphics.internal.GraphicsMetaProperty class?
Hello there
My code is:
function plot_kx2_slider()
% Create a figure with a slider and a plot
f = figure;
k=1
slider = uicontrol(‘Style’, ‘slider’, ‘Units’, ‘normalized’, …
‘Position’, [0.1, 0.9, 0.8, 0.05], …
‘Value’, 1, ‘Min’, -5, ‘Max’, 5);
axes_handle = axes(‘Position’, [0.1, 0.1, 0.8, 0.7]);
% Create a function to update the plot based on the slider value
function update_plot(source, eventdata)
% Get slider value using get function
k = get(source, ‘Value’);
x = linspace(-5, 5, 100);
y = k * x.^2;
plot(axes_handle, x, y);
title([‘f(x) = ‘, num2str(k), ‘x^2’]);
xlabel(‘x’);
ylabel(‘f(x)’);
end
% Set the initial plot
update_plot(slider, [0]);
% Add a listener to the slider to update the plot when the slider value changes
addlistener(slider, ‘Value’, ‘PostSet’, @update_plot);
end
this code should plot the function f(x)=kx^2 but MATLAB shows me these errors:
————————-
Warning: Error executing listener callback for PostSet event on Value dynamic property in object of
matlab.ui.control.UIControl class:
Error using get
Cannot find ‘get’ method for matlab.graphics.internal.GraphicsMetaProperty class.
Error in plot_kx2_slider/update_plot (line 13)
k = get(source, ‘Value’);
————————-
guys can you help me?Hello there
My code is:
function plot_kx2_slider()
% Create a figure with a slider and a plot
f = figure;
k=1
slider = uicontrol(‘Style’, ‘slider’, ‘Units’, ‘normalized’, …
‘Position’, [0.1, 0.9, 0.8, 0.05], …
‘Value’, 1, ‘Min’, -5, ‘Max’, 5);
axes_handle = axes(‘Position’, [0.1, 0.1, 0.8, 0.7]);
% Create a function to update the plot based on the slider value
function update_plot(source, eventdata)
% Get slider value using get function
k = get(source, ‘Value’);
x = linspace(-5, 5, 100);
y = k * x.^2;
plot(axes_handle, x, y);
title([‘f(x) = ‘, num2str(k), ‘x^2’]);
xlabel(‘x’);
ylabel(‘f(x)’);
end
% Set the initial plot
update_plot(slider, [0]);
% Add a listener to the slider to update the plot when the slider value changes
addlistener(slider, ‘Value’, ‘PostSet’, @update_plot);
end
this code should plot the function f(x)=kx^2 but MATLAB shows me these errors:
————————-
Warning: Error executing listener callback for PostSet event on Value dynamic property in object of
matlab.ui.control.UIControl class:
Error using get
Cannot find ‘get’ method for matlab.graphics.internal.GraphicsMetaProperty class.
Error in plot_kx2_slider/update_plot (line 13)
k = get(source, ‘Value’);
————————-
guys can you help me? Hello there
My code is:
function plot_kx2_slider()
% Create a figure with a slider and a plot
f = figure;
k=1
slider = uicontrol(‘Style’, ‘slider’, ‘Units’, ‘normalized’, …
‘Position’, [0.1, 0.9, 0.8, 0.05], …
‘Value’, 1, ‘Min’, -5, ‘Max’, 5);
axes_handle = axes(‘Position’, [0.1, 0.1, 0.8, 0.7]);
% Create a function to update the plot based on the slider value
function update_plot(source, eventdata)
% Get slider value using get function
k = get(source, ‘Value’);
x = linspace(-5, 5, 100);
y = k * x.^2;
plot(axes_handle, x, y);
title([‘f(x) = ‘, num2str(k), ‘x^2’]);
xlabel(‘x’);
ylabel(‘f(x)’);
end
% Set the initial plot
update_plot(slider, [0]);
% Add a listener to the slider to update the plot when the slider value changes
addlistener(slider, ‘Value’, ‘PostSet’, @update_plot);
end
this code should plot the function f(x)=kx^2 but MATLAB shows me these errors:
————————-
Warning: Error executing listener callback for PostSet event on Value dynamic property in object of
matlab.ui.control.UIControl class:
Error using get
Cannot find ‘get’ method for matlab.graphics.internal.GraphicsMetaProperty class.
Error in plot_kx2_slider/update_plot (line 13)
k = get(source, ‘Value’);
————————-
guys can you help me? error MATLAB Answers — New Questions