Making a Table in Octave

Hey everyone!
So I was working on this code for school and it all works great, no problem with that…
However, I was wondering if there was a way to display my final values in a proper table with titles and all?
For now all I have is a display function listing the titles and below a matrix containing all my values, so basically i just want to join the two in a clean way.

CODE:

clear all
clc
close all

i=1; 
R=5; #Blade radius
tSR=7; #Tip speed ratio
lC=1; #lift coefficient
B=3; #Number of blades
aSP=[36.6,18.5,10.6,6.4,3.8,2,0.7,-0.2,-1,-1.6]; #Section pitch angle (in degrees)

for r =0.5:0.5:5;
  rTable(i)=r; #r for reference
  ratio(i)=r/R; #r/R ratio
  lSR(i)=tSR*ratio(i); #Local speed ratio
  aRW(i)=atand(2/(3*lSR(i))); #Angle of the relative wind
  chord(i)=(8*pi*r*sind(aRW(i)))/(3*B*lC*lSR(i)); #Chord
  aA(i)=aRW(i)-aSP(i); #Angle of attack
  i=i+1;
endfor

display "| r | r/R | Chord | Angle of relative wind | Angle of attack | Section pitch angle |"

tab(:,1)=rTable;
tab(:,2)=ratio;
tab(:,3)=chord;
tab(:,4)=aRW;
tab(:,5)=aA;
tab(:,6)=aSP

Anyways thanks in advance!

My system

  • OS: e.g. Windows 10 (version 2004) or Ubuntu 20.04
  • Octave version: e.g. Version 6.1.0
  • Installation method: e.g. Downloaded and installed “octave-6.1.0-w64-installer.exe” from https://www.octave.org/download.html

One option is to use the tablicious package:

pkg install "https://github.com/apjanke/octave-tablicious/archive/v0.3.5.tar.gz"
pkg load tablicious
prettyprint (array2table (tab, "VariableNames", ...
  {"r", "r_R", "Chord", "Angle_of_relative_wind", "Angle_of_attack", "Section_pitch_angle"}))

----------------------------------------------------------------------------------------
| r   | r_R | Chord   | Angle_of_relative_wind | Angle_of_attack | Section_pitch_angle |
----------------------------------------------------------------------------------------
| 0.5 | 0.1 | 1.3756  | 43.6028                | 7.0028          | 36.6                |
| 1   | 0.2 | 0.85757 | 25.4633                | 6.9633          | 18.5                |
| 1.5 | 0.3 | 0.60354 | 17.6126                | 7.0126          | 10.6                |
| 2   | 0.4 | 0.462   | 13.3925                | 6.9925          | 6.4                 |
| 2.5 | 0.5 | 0.37323 | 10.7843                | 6.9843          | 3.8                 |
| 3   | 0.6 | 0.3127  | 9.01932                | 7.0193          | 2                   |
| 3.5 | 0.7 | 0.26891 | 7.74777                | 7.0478          | 0.7                 |
| 4   | 0.8 | 0.23579 | 6.78897                | 6.989           | -0.2                |
| 4.5 | 0.9 | 0.2099  | 6.04057                | 7.0406          | -1                  |
| 5   | 1   | 0.18911 | 5.44033                | 7.0403          | -1.6                |
----------------------------------------------------------------------------------------

Unfortunately, spaces and slashes are not permitted as variable names.

Hey!
So i managed to get my tables working but the only problem is that when I hit run it takes forever, then displays the following messages:

warning: doc_cache_create: unusable help text found in file 'calendarDuration'
warning: doc_cache_create: unusable help text found in file 'categorical'
warning: doc_cache_create: unusable help text found in file 'datetime'
warning: doc_cache_create: unusable help text found in file 'duration'
C:\Users\ludov\AppData\Local\Temp\octave-help-UmACKS:137: misplaced {
C:\Users\ludov\AppData\Local\Temp\octave-help-UmACKS:137: misplaced }
C:\Users\ludov\AppData\Local\Temp\octave-help-FLrvAZ:136: misplaced {
C:\Users\ludov\AppData\Local\Temp\octave-help-FLrvAZ:136: misplaced }
warning: doc_cache_create: unusable help text found in file 'localdate'
warning: doc_cache_create: unusable help text found in file 'missing'
warning: doc_cache_create: unusable help text found in file 'string'
warning: doc_cache_create: unusable help text found in file 'table'

And then displays the table. the answer is probably quite simple but im too new at this to get why…

Just to be sure, the first line in @siko1056’s snippet, pkg intall ..., should only be executed once. After the package is installed on your system, you just need to pkg load tablicious once in a session to use related functions. That should avoid the warning and the long installation time.

1 Like

that did it thanks !