I received this error when trying to plot a random walk and title it with a number:
"Error in matlab.graphics.interaction.actions.Linger
Warning: Error occurred while executing the listener
callback for event ButtonExited defined for class
matlab.graphics.primitive.canvas.JavaCanvas:
Execution of script num2str as a function is not
supported:
/Users/Rocketroos/MATLAB-Drive/QuadrantofSubplotsExample/num2str.m
Error in timer (line 133)
obj.Name = ['timer-'
num2str(mltimerpackage('Count'))];
Error in
matlab.graphics.controls.ToolbarController/createTooltipTime"
My code:
N = 1000;
%p is the probability for the person to step forward
p =0.5;
position (1) = 0;
for i = 2:N
number =rand;
if number > p
position(i) = position (i-1)+1;
else
position(i) = position (i-1)-1;
end
end
plot (position)
%for adding text to a number
%Name the string in front of the word string
EndPositionString = num2str(solution(N));
title (['End Position = ', EndPositionString])

 채택된 답변

Walter Roberson
Walter Roberson 2023년 5월 15일

0 개 추천

You need to remove /Users/Rocketroos/MATLAB-Drive/QuadrantofSubplotsExample from your MATLAB path, or else you need to rename /Users/Rocketroos/MATLAB-Drive/QuadrantofSubplotsExample/num2str.m to something else.
The code there is interfering with using MATLAB's num2str() function.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2023년 5월 15일

답변:

2023년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by