Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
"save -ascii" not simple "format short"

Subject: "save -ascii" not simple "format short"

From: Suguleasa

Date: 29 Nov, 2008 07:36:04

Message: 1 of 3

Hi guys,

I need some help with format and save.

I want to save different vectors in ASCII format, but when I look at the files the output has the small e at the end. Is there a way of saving without the scientific notation?
I want only numbers and no "e"s and "-"s in my .txt file.
 

Here is my snippet:
clear B;
format short;
B = [];

for i = 1:3

b = rand(3,1);
B = [B,b];

filename = ['b' num2str(i) '.txt'];

save(filename,'b','-ASCII');
end
b
B

Thanks for your help and time

Subject: "save -ascii" not simple "format short"

From: Walter Roberson

Date: 30 Nov, 2008 02:49:07

Message: 2 of 3

Suguleasa wrote:

> I need some help with format and save.

The 'format' command never affects the 'save' command.

> I want to save different vectors in ASCII format, but when I look at the files the
> output has the small e at the end. Is there a way of saving without the scientific notation?
> I want only numbers and no "e"s and "-"s in my .txt file.

No, there isn't. save('-ascii') and save('-ascii','-double') are the only two formats
you get can out of the save() command. If they do not suit your purposes, then
you cannot use save().

save -ascii is so inflexible that I -never- use it in real programming. Instead,
I use dlmwrite() or fprintf().

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Subject: "save -ascii" not simple "format short"

From: Carlos Adrian Vargas Aguilera

Date: 2 Dec, 2008 15:44:03

Message: 3 of 3

take a look to SAVEASCII:

http://www.mathworks.com/matlabcentral/fileexchange/10243

it may help you...

Carlos

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us