I need to plot three Graphs for this Code in one go!
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Vandit Bhayani
 am 17 Mai 2020
  
    
    
    
    
    Kommentiert: Vandit Bhayani
 am 17 Mai 2020
            I was using Subplot but have had no success in running the Code. I need the Graphs of Sine and Cosine on the y axis and x axis containing the Values for Angles. 
dataBase=cell(3,3);
for n=1:3
t = input('Enter an integer between 3 and 6: ');
while (t<3 || t>6)
    t = input('Integer was too small/big. Please enter a number between 3 and 6.');
end
    alpha = ([0:pi/t:2.*pi]);
si = sin(alpha);
co = cos(alpha);
M =[rad2deg(alpha); si ; co]';
x=M(:,1)';
ys=M(:,2)';
yc=M(:,3)';
dataBase{n,1}=x;
dataBase{n,2}=ys;
dataBase{n,3}=yc;
end
0 Kommentare
Akzeptierte Antwort
  Mehmed Saad
      
 am 17 Mai 2020
        
      Bearbeitet: Mehmed Saad
      
 am 17 Mai 2020
  
      dataBase=cell(3,3);
f = figure
for n=1:3
t = input('Enter an integer between 3 and 6: ');
while (t<3 || t>6)
    t = input('Integer was too small/big. Please enter a number between 3 and 6.');
end
    alpha = ([0:pi/t:2.*pi]);
si = sin(alpha);
co = cos(alpha);
M =[rad2deg(alpha); si ; co]';
x=M(:,1)';
ys=M(:,2)';
yc=M(:,3)';
dataBase{n,1}=x;
dataBase{n,2}=ys;
dataBase{n,3}=yc;
subplot(310+n) % the subplot increment
plot(M(:,1),M(:,2:3))% plot Angle against sin and cos
end
If you want to plot after user enters all the input
set the figure visible property to off before for loop and set it to on at the end of the code
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!