Menu pop up will not display plot
Afficher commentaires plus anciens
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 commentaire
Jan
le 29 Nov 2016
Do you notice that your code is not readable? Use the "{} Code" button to fix this.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!