Making a table for degrees and radians

15 views (last 30 days)
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?

Accepted Answer

madhan ravi
madhan ravi on 4 Sep 2020
TABLE = array2table([Degrees(:), deg2rad(Degrees(:))], 'VariableNames', {'DEGREES', 'RADIANS'})
  2 Comments
Matt J
Matt J on 4 Sep 2020
Please Accept-click madhan's answer, since it resolved your problem.

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 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)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!