quit program using if
Show older comments
hi, i create a program:
% optimal algorithm
clear all
close all
%%Insert value in Matlab
dlg_title = 'Insert Factor Value';
x1 = inputdlg('Enter number of channels:',dlg_title, [1 50]);
n = str2num(x1{:});
x2 = inputdlg('Enter input power for each channel (mW):',dlg_title, [1 50]);
p = str2num(x2{:})*10^-3;
x3 = inputdlg('Enter channel spacing (nm):',dlg_title, [1 50]);
delta_lambda = str2num(x3{:})*10^-9;
x4 = inputdlg('Enter distance transmission (km):',dlg_title, [1 50]);
distance = str2num(x4{:});
CreateStruct.Interpreter = 'tex';
CreateStruct.WindowStyle = 'modal';
choice = menu('Choose optical fiber type','Single-mode fiber ( G.652 )','Dispersion-shifted fiber ( G.653 )','Non-zero dispersion-shifted fiber ( G.655 )');
if choice==1
alphadb = 0.20;
dispersion=16;
slope=0.080;
A=80;
recommend=sprintf('Single-mode fiber ( G.652 ) is not suitable for this situation');
elseif choice==2
alphadb = 0.22;
dispersion=0.001;
slope=0.075;
A=50;
recommend=sprintf('Dispersion-shifted fiber ( G.653 ) is not suitable for this situation');
else
alphadb = 0.23;
dispersion=3;
slope=0.050;
A=72;
recommend=sprintf('Non-zero dispersion-shifted fiber ( G.655 ) is not suitable for this situation');
end
B=2.5
i also have some code below
now if the: distance > 104000/(B^2*dispersion) , i want to DISPLAY a message box: "distance is not good. try again" and QUIT the program, else the program CONTINUES .
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!