Geometric Progression using inputdlg
4 views (last 30 days)
Show older comments
Hello guys, i'm trying to put this working, it's for a geometric progression, my problem is to validade the inputs (a1,r,n) using LeR LeR1 and LeN and after validating pass to gerarPG_v1...
switch menuProgGeometrica
case 1
prompt = {'Valor do primeiro termo(a1):','Valor da razão(r):', 'Número de elementos(n):'};
dlg_title = 'Valores para a progressão';
answer = inputdlg(prompt,dlg_title);
a1 =LeR(str2num(answer{1}));
r =LeR1(str2num(answer{2}));
n =Len(str2num(answer{3}));
switch menu('Gerar Progressão geométrica','ProgressãoGeométrica_V1','ProgressãoGeométrica_V2','ProgressãoGeométrica_V3','ProgressãoGeométrica_V4')
case 1
a = gerarPG_v1(a1,r,n);
disp(' ');
disp('A Progressão Geométrica gerada é:');
disp(' ');
if((n)>=20)
fprintf('%g\n',a)
else
disp(a);
end
ClassificadorPG(a1,r);
disp(' ');
input('Prima uma tecla para continuar ...');
1 Comment
Geoff Hayes
on 31 Oct 2015
Antonio - please clarify what the problem is with the above code. Is the validation failing, and if so, what is the error?
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!