How to Display Data in Table

636 Ansichten (letzte 30 Tage)
Anthony Koning
Anthony Koning am 11 Dez. 2021
Kommentiert: Chunru am 4 Dez. 2023
I wanted to ask how it would be possible to display the data of an exteriment into a table. For instance, If I am doing 11 trials, starting from 0 and rising to 50 in incraments of 5, how would I be able to display data in a table? I understand that it would be possible to format everything into an array and enter all values manually , but is it possible to display results directly as a table (for instance, if I wanted to up the trials from 11 to 100, so I wouldnt have to enter all values manually)
The code I'm working with is:
v = 0:5:50
a_n=(-0.01.*(v+50))./(exp(-(v+50)./10)-1)
b_n= exp(-(v+60)./80)./8
a_m = (-.1.*(v+35))./(exp(-(v+35)./10)-1)
b_m = 4.*exp(-(v+60)./18)
a_h = .07.*exp(-(v+60)./20)
b_h = 1./(exp(-(v+30)./10)+1)
but I want to display the results as a neatly organized table rather than a general output, especially if I want to change the start/endpoint or intervals.

Akzeptierte Antwort

Chunru
Chunru am 12 Dez. 2021
Bearbeitet: Chunru am 4 Dez. 2023
v = (0:5:50)'; % use a column here
a_n=(-0.01.*(v+50))./(exp(-(v+50)./10)-1);
b_n= exp(-(v+60)./80)./8;
a_m = (-.1.*(v+35))./(exp(-(v+35)./10)-1);
b_m = 4.*exp(-(v+60)./18);
a_h = .07.*exp(-(v+60)./20);
b_h = 1./(exp(-(v+30)./10)+1);
% For same size data here, you can organize them into a table
T = table(v, a_n, b_n, a_m, a_h, b_h)
T = 11×6 table
v a_n b_n a_m a_h b_h __ _______ ________ ______ __________ _______ 0 0.50339 0.059046 3.609 0.0034851 0.95257 5 0.55226 0.055468 4.0746 0.0027142 0.97069 10 0.60149 0.052108 4.5506 0.0021138 0.98201 15 0.65098 0.048951 5.0339 0.0016462 0.98901 20 0.70064 0.045985 5.5226 0.0012821 0.99331 25 0.75042 0.043199 6.0149 0.0009985 0.99593 30 0.80027 0.040582 6.5098 0.00077763 0.99753 35 0.85017 0.038123 7.0064 0.00060562 0.9985 40 0.90011 0.035813 7.5042 0.00047166 0.99909 45 0.95007 0.033643 8.0027 0.00036733 0.99945 50 1 0.031605 8.5017 0.00028607 0.99966
% if you want to show part of the data
T(4:7, :)
ans = 4×6 table
v a_n b_n a_m a_h b_h __ _______ ________ ______ __________ _______ 15 0.65098 0.048951 5.0339 0.0016462 0.98901 20 0.70064 0.045985 5.5226 0.0012821 0.99331 25 0.75042 0.043199 6.0149 0.0009985 0.99593 30 0.80027 0.040582 6.5098 0.00077763 0.99753
% To display table with specific format:
% Round it and save to a new variable
T1 = varfun(@(x)(round(x, 2)), T)
T1 = 11×6 table
Fun_v Fun_a_n Fun_b_n Fun_a_m Fun_a_h Fun_b_h _____ _______ _______ _______ _______ _______ 0 0.5 0.06 3.61 0 0.95 5 0.55 0.06 4.07 0 0.97 10 0.6 0.05 4.55 0 0.98 15 0.65 0.05 5.03 0 0.99 20 0.7 0.05 5.52 0 0.99 25 0.75 0.04 6.01 0 1 30 0.8 0.04 6.51 0 1 35 0.85 0.04 7.01 0 1 40 0.9 0.04 7.5 0 1 45 0.95 0.03 8 0 1 50 1 0.03 8.5 0 1
  2 Kommentare
Shreen El-Sapa
Shreen El-Sapa am 3 Dez. 2023
to reduce dicemal to 2 dgits or 3, what can I do?
Chunru
Chunru am 4 Dez. 2023
See above.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by