Menu pop up will not display plot
Show older comments
Hello, my code will display the plot for the first option: 'Thrust SSC', however when the option: 'North American X-15' is selected the plot will not display. Why is this? (nums, txt etc are data-sets)
My code:
choice = menu('Where are you travelling from?','Mercury','Venus','Earth','Mars','Jupiter','Saturn','Uranus','Neptune'); if choice == 1; choice = menu('Where are you travelling to?', 'Venus', 'Earth', 'Mars', 'Jupiter','Saturn','Uranus','Neptune'); if choice == 1; choice = menu('How are you travelling?', 'Thrust SSC', 'North American X-15', 'Walking', 'Space Shuttle','Millenium Falcon','None of the above'); if choice ==1; [nums1, txt1] = xlsread('Planet Distance.xlsx','Distance'); [nums2, txt2] = xlsread('Planet Distance.xlsx','Velocity'); menu_title = sprintf('You are travelling from %s to %s, this journey is %d Km or %d Miles. You have chosen to travel by %s, which travels at %4d Km/h or %3d mph. You will arrive at your destination in %s hours', txt1{2,1}, txt1{2,2}, nums1(1,2), nums1(1,3),txt2{2,1}, nums2(1,1), nums2(1,2),nums1(1,2)/nums2(1,2) ); menu(menu_title,'Plot Distance v Time graph'); if choice ==1; X = [0 nums1(1,2)]; % my dependent vector of interest t = [0 nums1(1,2)/nums2(1,2)]; % my independent vector figure % create new figure plot(t, X) end;
elseif choice ==2;
[nums1, txt1] = xlsread('Planet Distance.xlsx','Distance');
[nums2, txt2] = xlsread('Planet Distance.xlsx','Velocity');
menu_title = sprintf('You are travelling from %s to %s, this journey is %d Km or %d Miles. You have chosen to travel by %s, which travels at %4d Km/h or %3d mph. You will arrive at your destination in %s hours', txt1{2,1}, txt1{2,2}, nums1(1,2), nums1(1,3),txt2{3,1}, nums2(2,1), nums2(2,2),nums1(1,2)/nums2(2,2) );
menu(menu_title,'Plot Distance v Time graph');
if choice ==1;
X = [0 nums1(1,2)]; % my dependent vector of interest
t = [0 nums1(1,2)/nums2(2,2)]; % my independent vector
figure % create new figure
plot(t, X)
end;
end;
end;
end;
1 Comment
Jan
on 29 Nov 2016
Do you notice that your code is not readable? Use the "{} Code" button to fix this.
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic 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!