num2str error in random walk plot
Ältere Kommentare anzeigen
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])
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Surrogate Optimization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!