User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Matlab Question Page [1]  
guitarzan
Veteran
468 Posts
user info
edit post

I have a matlab script file that calculates about 30 variables and spits them out in the command window. Like this:

ksteel =

5777306.99914545

kwood1 =

482002.958929051

..and so on.

I would like to find a quick solution to get these variable names and values into a nice table, they aren't in any sort of matrix, so it might not be possible?

9/30/2011 10:25:07 PM

lewisje
All American
9196 Posts
user info
edit post

Depending on how wide you want the table, you could try going 15x2, 10x3, or 6x5; anyway you'll need to look up the code for looping, and then have it type a line of hyphens, followed by lines with the actual data, padded with spaces for constant cell-width, with cells delimited by pipe characters.

9/30/2011 10:34:10 PM

guitarzan
Veteran
468 Posts
user info
edit post

I want a 2 column table, this seems complicated...

9/30/2011 10:42:57 PM

darkone
(\/) (;,,,;) (\/)
11610 Posts
user info
edit post

Typically when you call functions in Matlab you do it like this:
[output1, output2, etc...] = functionname(input1, input2, etc...);

The semicolon prevents the output from being written in the command window and the variables are stored based on what you specify for the output variables.

Things are different if you're using a script. With scripts, the outputs are hardcoded. You have to edit the script to change how they're stored.

If you can give me a specific example of what you're doing, I can tell you exactly what to do.

Are you wanting to store all the data in a single data structure (e.g. array, cell array, structure, etc...) for use in Matlab and/or do you want to write the data to some sort of external data format (e.g. CSV text file, HDF, netCDF, excel spreadsheet, etc...)?

9/30/2011 11:06:29 PM

guitarzan
Veteran
468 Posts
user info
edit post

The script is hard coded, i guess, like you said I have omitted the use of a semi colon so the output isn't suppressed. It's basically a simple program with a few critical variables at the top. The moment, force, and stress, and shear calculations are all carried out below and change when I update variables. I have used no matrix or array commands, or functions, this is a program consisting of statements like Fr = Mbz/L1, simple stuff with just variable names.

I was wondering if I could call up all of the stored variable names some way and spit them into some nice format like a 2 column by X row table, possibly an excel file would be nice, my ultimate goal is to get all of these values into a table in the appendix of a report, so I don't have to type them up.

I really appreciate any help, Thanks.

10/3/2011 10:08:17 AM

BigMan157
no u
103354 Posts
user info
edit post

doesn't the workspace window do this already?

10/3/2011 2:30:26 PM

darkone
(\/) (;,,,;) (\/)
11610 Posts
user info
edit post

I would use the fprintf command to write a formatted text files that you can either paste directly into your document or your favorite spreadsheet software.

10/3/2011 2:50:28 PM

guitarzan
Veteran
468 Posts
user info
edit post

Yeah, the workspace does in an indirect way. Thanks, I figured how get what I needed to do to work. The way I got this to work was a little indirect.

I first saved the workspace as a file. Then I typed in the command in MATLAB to open the file, open projectone.mat This spit out all of the variable names in the command window. Like this:

Faz: 100
Fax: 150
L1: 12
L2: 42.87862046
L3: 14
bo: 1.5
bi: 1
ho: 1.5
hi: 1
Ixx: 0.338541666666667
Jo: 0.677083333333333

I copied and pasted these into excel using the text import wizard and set the colon as a delimiter, and it separated my data into two columns with no prob. I could even specify text and numerical data. This will now easily copy into word formatted as a table, before this I can use excel to trim up the decimals to two digits, and I'm done.

10/3/2011 2:59:26 PM

The Coz
Tempus Fugitive
26097 Posts
user info
edit post

10/4/2011 8:37:33 PM

 Message Boards » Tech Talk » Matlab Question Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.