Making a table for degrees and radians
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I'm trying to make a table off of two arrays but on using the 'table' function, I'm only getting the size of the arrays.
clc;
clear all;
Degrees=[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360];
%for i=1:length(Degrees)
% Radians(i)=Degrees(i)*(pi/180);
%end
T=table(Degrees);
T.Radians=(T.Degrees*pi)./180;
T(1:1,:)
How do I make the table display the values of the arrays Degrees and Radians?
0 commentaires
Réponse acceptée
madhan ravi
le 4 Sep 2020
TABLE = array2table([Degrees(:), deg2rad(Degrees(:))], 'VariableNames', {'DEGREES', 'RADIANS'})
2 commentaires
Matt J
le 4 Sep 2020
Please Accept-click madhan's answer, since it resolved your problem.
Plus de réponses (1)
Steven Lord
le 4 Sep 2020
In your original code Degrees was a row vector. When you put something that's sufficiently wide into a table variable, we only show the dimensions of that variable. Instead you probably want to have each row of the table contain one value each for Degrees and Radians. In that case start off with a column vector of degrees, convert it to radians with deg2rad, and assemble your table using those two variables.
Degrees = (0:10:360).';
Radians = deg2rad(Degrees);
T = table(Degrees, Radians);
% Show the first part of the resulting table
head(T)
0 commentaires
Voir également
Catégories
En savoir plus sur Logical 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!