MATLAB: Problem while executing a switch case thread

condition statementsplotting

I have been trying to execute the program below, it works fine for all switch-case conditions except for the case instance 'ALL'. I know pretty much its a small mistake but couldn't figure it out. Couldn't get the 3 plots as expected if i try ALL.

clear all;
clear all;
% Correlation : zero-STATIC ; low = LOW ; med = MEDIUM ; high = HIGH
% Fading profiles: static = STATIC ; eva5 = EVA5Hz ; epa5 = EPA5Hz ; eva70 = EVA70Hz ; etu70 = ETU70Hz ; etu300 = ETU300Hz
%---------------------------------------------------------------%

HTMFILE=fopen('Test report2.htm','a');
fprintf(HTMFILE,'<h2 ALIGN=CENTER>Comparitive charts for two builds</h2>\n');
fprintf(HTMFILE,'<h3>Common Test Parameters</h3>\n');
fprintf(HTMFILE,'<p>Operating Band[PCC] = OB3<br>\n');
fprintf(HTMFILE,'<p>Operating Band[SCC] = OB5<br>\n');
fprintf(HTMFILE,'<p>Transmi Scheme[PCC] = OLSMultiplex<br>\n');
fprintf(HTMFILE,'<p>Transmi Scheme[SCC] = OLSMultiplex<br>\n');
fprintf(HTMFILE,'<p>DUT = 7260_ES2_01<br>\n');
fprintf(HTMFILE,'<p>Build_Information = Two_builds_for_Test<br>\n');
[d1, d2, r1] = xlsread('test1.csv') ;
xlswrite('test1.xls',d1);
[d11, d22, r2] = xlsread('test2.csv') ;
xlswrite('test2.xls',d11);
total_snr1 = d1( : ,5);
total_tput1 = d1( : ,6);
total_bler1 = d1( : ,7);
total_snr2 = d11( : ,5);
total_tput2 = d11( : ,6);
total_bler2 = d11( : ,7);
%---------------------------------------------------------------%
corr = input('Specify Correlation: ','s');
fp = input('Specify Fading profile: ','s');
switch(corr)
case 'zero'
switch (fp)
case 'static'
%function staticzero
h=figure(1);
snr_1 = total_snr1(1:31);
tput_1 = total_tput1(1:31);
bler_1 = total_bler1(1:31);
snr_11 = total_snr2(1:31);
tput_11 = total_tput2(1:31);
bler_11 = total_bler2(1:31);
subplot(1,2,1);
plot(snr_1,tput_1,'b--*',snr_11,tput_11,'r--o');
title 'Static-ZERO-CORR-THROUGHPUT';
hold on;
grid on;
grid minor;
set(h,'Name','Static-ZERO-CORR-TPUT');
ylabel('Throughput (Kbps)');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northwest');
subplot(1,2,2);
semilogy(snr_1,bler_1,'b--*',snr_11,bler_11,'r--o');
title 'Static-ZERO-CORR-BLER';
hold on;
grid on;
grid minor;
set(h,'Name','Static-ZERO-CORR-BLER');
xlabel('BLER');
ylabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northeast');
print(h,'-dpng','Static-ZERO-CORR-PERFORMANCE');
fprintf(HTMFILE,'<h2 ALIGN=CENTER>Static-ZERO-CORR-PERFORMANCE</h2>\n');
fprintf(HTMFILE,'</p>\n');
fprintf(HTMFILE,'<IMG SRC=./Static-ZERO-CORR-PERFORMANCE.png><br>\n');
%close(h);

break;
end
break;
case 'low'
switch (fp)
case 'eva5'
%function eva5low

h=figure(2);
snr_2 = total_snr1(33:63);
tput_2 = total_tput1(33:63);
bler_2 = total_bler1(33:63);
snr_22 = total_snr2(33:63);
tput_22 = total_tput2(33:63);
bler_22 = total_bler2(33:63);
subplot(1,2,1);
plot(snr_2,tput_2,'b--*',snr_22,tput_22,'r--o');
title 'EVA5HZ-LOW-CORR-THROUGHPUT';
hold on;
grid on;
grid minor;
set(h,'Name','EVA5HZ-LOW-CORR-TPUT');
ylabel('Throughput (Kbps)');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northwest');
subplot(1,2,2);
semilogy(snr_2,bler_2,'b--*',snr_22,bler_22,'r--o');
title 'EVA5HZ-LOW-CORR-BLER';
hold on;
grid on;
grid minor;
set(h,'Name','EVA5HZ-LOW-CORR-BLER');
ylabel('BLER');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northeast');
print(h,'-dpng','EVA5HZ-LOW-CORR-PERFORMANCE');
fprintf(HTMFILE,'<h2 ALIGN=CENTER>EVA5HZ-LOW-CORR-PERFORMANCE</h2>\n');
fprintf(HTMFILE,'</p>\n');
fprintf(HTMFILE,'<IMG SRC=./EVA5HZ-LOW-CORR-PERFORMANCE.png><br>\n');
%close(h);
break;
case 'epa5'
%function epa5low

h=figure(5);
snr_5 = total_snr1(129:159);
tput_5 = total_tput1(129:159);
bler_5 = total_bler1(129:159);
snr_55 = total_snr2(129:159);
tput_55 = total_tput2(129:159);
bler_55 = total_bler2(129:159);
subplot(1,2,1);
plot(snr_5,tput_5,'b--*',snr_55,tput_55,'r--o');
title 'EPA5HZ-LOW-CORR-THROUGHPUT';
hold on;
grid on;
grid minor;
set(h,'Name','EPA5HZ-LOW-CORR-TPUT');
ylabel('Throughput (Kbps)');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northwest');
subplot(1,2,2);
semilogy(snr_5,bler_5,'b--*',snr_55,bler_55,'r--o');
title 'EPA5HZ-LOW-CORR-BLER';
hold on;
grid on;
grid minor;
set(h,'Name','EPA5HZ-LOW-CORR-BLER');
ylabel('BLER');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northeast');
print(h,'-dpng','EPA5HZ-LOW-CORR-PERFORMANCE');
fprintf(HTMFILE,'<h2 ALIGN=CENTER>EPA5HZ-LOW-CORR-PERFORMANCE</h2>\n');
fprintf(HTMFILE,'</p>\n');
fprintf(HTMFILE,'<IMG SRC=./EPA5HZ-LOW-CORR-PERFORMANCE.png><br>\n');
%close(h);
break;
case 'eva70'
%function eva70low

h=figure(8);
snr_8 = total_snr1(225:255);
tput_8 = total_tput1(225:255);
bler_8 = total_bler1(225:255);
snr_88 = total_snr2(225:255);
tput_88 = total_tput2(225:255);
bler_88 = total_bler2(225:255);
subplot(1,2,1);
plot(snr_8,tput_8,'b--*',snr_88,tput_88,'r--o');
title 'EVA70HZ-LOW-CORR-THROUGHPUT';
hold on;
grid on;
grid minor;
set(h,'Name','EVA70HZ-LOW-CORR-TPUT');
ylabel('Throughput (Kbps)');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northwest');
subplot(1,2,2);
semilogy(snr_8,bler_8,'b--*',snr_88,bler_88,'r--o');
title 'EVA70HZ-LOW-CORR-BLER';
hold on;
grid on;
grid minor;
set(h,'Name','EVA70HZ-LOW-CORR-BLER');
ylabel('BLER');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northeast');
print(h,'-dpng','EVA70HZ-LOW-CORR-PERFORMANCE');
fprintf(HTMFILE,'<h2 ALIGN=CENTER>EVA70HZ-LOW-CORR-PERFORMANCE</h2>\n');
fprintf(HTMFILE,'</p>\n');
fprintf(HTMFILE,'<IMG SRC=./EVA70HZ-LOW-CORR-PERFORMANCE.png><br>\n');
%close(h);
break;
case 'etu70'
%function etu70low

h=figure(11);
snr_bb = total_snr1(321:351);
tput_bb = total_tput1(321:351);
bler_bb = total_bler1(321:351);
snr_BB = total_snr2(321:351);
tput_BB = total_tput2(321:351);
bler_BB = total_bler2(321:351);
subplot(1,2,1);
plot(snr_bb,tput_bb,'b--*',snr_BB,tput_BB,'r--o');
title 'ETU70HZ-LOW-CORR-THROUGHPUT';
hold on;
grid on;
grid minor;
set(h,'Name','ETU70HZ-LOW-CORR-TPUT');
ylabel('Throughput (Kbps)');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northwest');
subplot(1,2,2);
semilogy(snr_bb,bler_bb,'b--*',snr_BB,bler_BB,'r--o');
title 'ETU70HZ-LOW-CORR-BLER';
hold on;
grid on;
grid minor;
set(h,'Name','ETU70HZ-LOW-CORR-BLER');
ylabel('BLER');
xlabel('Geometry (db)');
axis auto;
hleg = legend('TESTBUILD-1','TESTBUILD-2');
set (hleg,'Location','Northeast');
print(h,'-dpng','ETU70HZ-LOW-CORR-PERFORMANCE');
fprintf(HTMFILE,'<h2 ALIGN=CENTER>ETU70HZ-LOW-CORR-PERFORMANCE</h2>\n');
fprintf(HTMFILE,'</p>\n');
fprintf(HTMFILE,'<IMG SRC=./ETU70HZ-LOW-CORR-PERFORMANCE.png><br>\n');
%close(h);
break;
case 'etu300'
%function etu300low

h=figure(14);
snr_gg = total_snr1(417:447);
tput_gg = total_tput1(417:447);
bler_gg = total_bler1(417:447);
snr_GG = total_snr2(417:447);
tput_GG = total_tput2(417:447);
bler_GG = total_bler2(417:447);
subplot(1,2,1);
plot(snr_gg,tput_gg,'b--*',snr_GG,tput_GG,'r--o');
title 'ETU300HZ-LOW-CORR-THROUGHPUT';
hold on;
grid on;
grid minor;

Best Answer

Sriharsha - in the future, please just attach your code to your question using the paperclip button.
Look at the case statement for 'all'
case 'all'
switch 'fp'
case 'EVA5'
Note the switch is for the string 'fp' rather than the variable fp. Change the line to switch(fp) and the code should work.
If you encounter a problem like this again, try putting in a breakpoint and stepping through the code. Explanations for why code isn't working can sometimes be solved in this way….