Can I create a sample input file for simplicity?
2 views (last 30 days)
Show older comments
Hi,
I have written an script which calls several custom functions. It needs many input to be entered by user. However, evertime I run the script, I need ti eneter all inputs. Is there any way simplifies this process? What I'm thinkg is to create a file (or excel), define all input samples ( inputs include stiring, arrau and scalar), and everytime I run the script, it automatically find the input values from the file.
As an example, I pase a part if my code as follows:
elseif (fu>1500 && fu<1920)
fprintf(2,'\nYou need to use Okumura Model or Extended Hata Model (Cost-231)\n');
prompt = 'Which Model do you intend to use? (Insert O for Okumora or E for Exctended Hata (Cost-231)';
inp = input(prompt,'s');
%%%%%% Okumora is selected
if strcmpi(inp,'O')
fprintf(2,'\nOkumora is selected\n');
Ht=input('BS antenna Height in m (30m<Ht<1000m): ');
while (Ht<30 || Ht>1000)
fprintf(2,'\nFrequency must be between 3m to 1000m\n');
Ht=input('BS antenna Height in m (30m<Ht<1000m): ');
end
Hr=input('MS anenna Height in m(3m<Hr<10m): ');
while (Hr<3 || Hr>10)
fprintf(2,'\nReciever Height must be between 30m to 100m\n');
Hr=input('Mobile antenna Height in m (30m<Ht<1000m): ');
end
d=input('Distance bt Tx and Rx in Km (1Km<d<100 Km) : ');
while (d<1 || d>100)
fprintf(2,'\nDistance must be between 30m to 100m\n');
d=input('Distance bt Tx and Rx in Km (1Km<d<100 Km): ');
end
fu=input('Enter the frequency in MHz: \n Note that if you need to plot, you should enter multiple frequencies');
Amu=input('Enter the Median Attenuation in dB: \n Note that if you need to plot, you should enter multiple valuses corrsponding to frequencies in array format: ');
Ga=input('Enter Correction Factor due to environment type: \n Note that if you need to plot, you should enter multiple valuses corrsponding to frequencies in array format: ');
Kter=input('Correction factor on Rolling Hilly Terain (Undulation): \n Note that if you need to plot, you should enter multiple valuses corrsponding to frequencies in array format: ');
Ksp=input('Correction Factor on Sloping Terrain: \n Note that if you need to plot, you should enter multiple valuses corrsponding to frequencies in array format: ');
Kls=input('Correction factor on Land Sea Terrain: \n Note that if you need to plot, you should enter multiple valuses corrsponding to frequencies in array format: ');
L=Okumura(fu,Ht,Hr,d,Amu,Ga,Kter,Ksp,Kls);
%%%%%% Extended Hatat is selected
Thanks
0 Comments
Answers (1)
Star Strider
on 25 Dec 2020
One option is to comment-out all the lines that request inputs and instead use a deal function assignment that assigns all the variable values automatically.
You need to decide what option would be best.
I leave that to you.
0 Comments
See Also
Categories
Find more on Analysis, Benchmarking, and Verification 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!