I need some Help coding a Database for Angles!

1 Ansicht (letzte 30 Tage)
Vandit Bhayani
Vandit Bhayani am 16 Mai 2020
Beantwortet: Jyotsna Talluri am 19 Mai 2020
I am not able to get the Plotting the Graphs of this Loop. It must show 3 Graphs simultaneously. Sorry for the Language not being English.
for index = (1:3)
%%For Loop ist für Repetition von einem Loop für "x" mal.
%%Eingabe als INPUT "I" gemeint
I = input('Geben Sie Zahl zwischen 3 und 6:');
%%IF und Else if in Kombination hilft die Conditionen/Logik zu überfprüfen.
if I < 3
disp('Eine Zahl zwischen 3 und 6 war gefragt. Bitte versuchen Sie es nocheinmal:')
elseif I > 6
disp('Eine Zahl zwischen 3 und 6 war gefragt. Bitte versuchen Sie es nocheinmal:')
end
%%Winkel berechnen oder Parameter
w = pi/I;
alpha = 0:w:2*pi;
%%Die Gleichungen beschreiben die zu plottenden Funktionen.
si = sin(alpha);
co = cos(alpha);
alpha = alpha*180/pi;
%%Hier wird ein Vektor erzuegt und dann mithilfe "M'" transponiert.
M = [alpha', si', co'];
%%Die Vektoren erzuegen die Matrix M mit x, ys, yc als Variablen.
x = M(:,1);
ys = M(:,2);
yc = M(:,3);
%%Datenbank erstellen
Daten= [x;ys;yc] ; %%Here is my Problem and i am not able to Code from here.
Winkel = M;
for index=1:1:Daten
Daten{index}=['Winkel Sinus Kosinus',num2str(Winkel(index))];
%%Graph Plotting
a = plot(Daten(index).alpha, Daten(index).si,'g');
b = plot(Daten(index).alpha, Daten(index).si,'rX');
c = plot(Daten(index).alpha, Daten(index).si,'b');
%%Drei Graphen werden hier geplottet. Datenbank wurde die Werte von Sinus und Cosinus speichern.
subplot(3,1,index);
plot(Daten(index).alpha, Daten(index).si,'g',Daten(index).alpha, Daten(index).si,'rX',Daten(index).alpha, Daten(index).si,'b');
grid on
axis on
title(['Dies ist der',numm2str(index),'.te Graph.'])
xlabel('Winkel(Grundmass)')
ylabel('Sinus,Cosinus')
legend([a c],{'Sinus','Cosinus'})
hold on
end
end

Antworten (1)

Jyotsna Talluri
Jyotsna Talluri am 19 Mai 2020
I have tried to understand what you want to achieved and tried to code it in a optimized way.
for index = 1: 3
I = input ('Enter number between 3 and 6:');
w = pi / I;
alpha = 0: w: 2 * pi;
%% The equations describe the functions to be plotted.
si = sin (alpha);
co = cos (alpha);
alpha = alpha * 180 / pi;
data(index).alpha = alpha;
data(index).si = si;
data(index).co = co;
%% Three graphs are plotted here. Database was storing the values ​​of sine and cosine.
subplot (3,1, index);
a= plot (data (index) .alpha, data (index) .si, 'g');
hold on;
c= plot(data (index) .alpha, data (index) .co, 'rX');
grid on
axis on
title (num2str(index));
xlabel ('angle (basic dimension)')
ylabel ('sine, cosine')
legend ([a,c], {'sine', 'cosine'})
hold on
end
Hope this helps

Produkte


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!