don_Gunner94
don_Gunner94

Reputation: 144

Formatting Problems in Displaying MATLAB Tables

I am doing a project for which I need to display data values in the form of a table. But when I try to view the table, the output is as shown in the screenshot that I have uploaded. But I need the data values to be seen. My code for creating the table is as follows:

    Results_table = table(pi_c,Wnet,back_work,SFC,Cycle_efficiency,Exergetic_Cycle_Efficiency,'Varia bleNames',{'PressureRatio','NetWorkOutput','BackWorkRatio','SpecificFuelConsumption','CycleEfficiency','SecondLawEfficiency'});

Is there something wrong with my display settings or what I dunno. Also, if I need to format my data values, please let me know.!

Screenshot of output in Command Window

Upvotes: 0

Views: 128

Answers (1)

Benoit_11
Benoit_11

Reputation: 13945

It looks like you simply need to provide column vectors to the table instead of row vectors (i.e. 4x1 vectors instead of 1x4) for them to be displayed.

Example with sample data:

clear
clc

pi_c = 100*rand(4,1);
Wnet = 100*rand(4,1);
back_work = 100*rand(4,1);
SFC = 100*rand(4,1);
Cycle_efficiency = 100*rand(4,1);
Exergetic_Cycle_Efficiency = 100*rand(4,1);

Results_table = table(pi_c,Wnet,back_work,SFC,Cycle_efficiency,Exergetic_Cycle_Efficiency,'VariableNames',{'PressureRatio','NetWorkOutput','BackWorkRatio','SpecificFuelConsumption','CycleEfficiency','SecondLawEfficiency'})

Which works fine:

Results_table = 

    PressureRatio    NetWorkOutput    BackWorkRatio    SpecificFuelConsumption    CycleEfficiency
    _____________    _____________    _____________    _______________________    _______________

     10.665           81.73           25.987           18.185                     86.929         
      96.19          86.869           80.007            26.38                      57.97         
    0.46342          8.4436           43.141           14.554                     54.986         
     77.491          39.978           91.065           13.607                     14.495         


    SecondLawEfficiency
    ___________________

    85.303             
    62.206             
    35.095             
    51.325   

whereas using row vectors gives the same result as you.

Upvotes: 3

Related Questions