How do I call upon a function in another function?

3 views (last 30 days)
This is what I have:
function [Output] = Jamiesonlab5 ()
Result=input('Please press any key to roll the dice, press Q or q to quit program: ', 's');
if (Result == 'q' || Result == 'Q')
fprintf('program terminated')
else
X=rdmInt();
end
Output=getPhrase();
end
function [TextI] = num2txt (I)
if I==1
TextI='one';
elseif I == 2
TextI = 'two';
elseif I == 3
TextI = 'three';
elseif I == 4
TextI = 'four';
elseif I == 5
TextI = 'five';
else
TextI = 'six';
end
end
function [i] = rdmInt ()
Max=input('Max: ');
Min=input('Min: ');
x=rand();
d = x * (Max-Min+1);
e=floor(d);
i= d + Min;
end
function [] = getPhrase ()
x=rdmInt();
fileID = fopen( 'OUTPUTLAB5.txt', 'a+');
if x == 1
fprintf(fileID,'Congragulations!');
elseif x == 2
fprintf(fileID,'Way to go!');
elseif x == 3
fprintf(fileID,'Youre amazing!');
elseif x == 4
fprintf(fileID,'Fantastic!');
else
fprintf(fileID,'Wow!');
end
end
Essentially what I want to do, is get a number between 1 nd six, and output a message corresponding to that number from my first function. However, it claims I have too many output arguments at the top. Also ignore the num2text fumction, it hs no importance to my question.

Answers (1)

Matt J
Matt J on 3 Nov 2020
You request an output from getPhase() here,
Output=getPhrase();
but your implementation of getPhrase() does not return any output
function [] = getPhrase ()

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!