A table of s versus t.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Trying to make a table of s versus t and printing the results to both the screen and to the file.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1228442/image.png)
r = 9 cm, ω = 100 revolutions per second, and b = 14 cm.
0 ≤ t ≤ 0.01 s. Using 20 subdivisions on the t
domain.
r=9
omega=100
b=14
t=0:20:0.01
s(t) = r* cos(2*pi*omega*t)+ sqrt((b^2)-(r^2)*(sin(2*pi*omega*t)^2))
table(s,t)
what is wrong with this code?
0 commentaires
Réponses (2)
Les Beckham
le 12 Déc 2022
Modifié(e) : Les Beckham
le 12 Déc 2022
r=9;
omega=100;
b=14;
t = linspace(0, 0.01, 20) % <<< use linspace instead to generate your t vector
% remove the (t) on the left side and use .^2 to do element-wise operation
s = r* cos(2*pi*omega*t)+ sqrt((b^2)-(r^2)*(sin(2*pi*omega*t).^2))
table(s,t)
0 commentaires
Davide Masiello
le 12 Déc 2022
Modifié(e) : Davide Masiello
le 12 Déc 2022
There are a couple of errors in your code.
First, the way you define the array t.
Second, for array operations, use the dot notation.
Third, no need to specify the s dependence on t.
r = 9;
omega = 100;
b = 14;
t = linspace(0,0.01,20)';
s = r*cos(2*pi*omega*t)+sqrt(b^2-(r^2)*sin(2*pi*omega*t).^2);
table(s,t)
It seems like you might be new to Matlab, so I suggest reading some of the basic documentation. e.g.
0 commentaires
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!