[Scilab-users] Formatting

classic Classic list List threaded Threaded
5 messages Options
James Holland James Holland
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Formatting

I'm trying to generate a file for an arbitrary waveform generator, the format
is csv but I am having problems formatting the output, this is my current
attempt.
<code>
for i = 1:nr
    mfprintf(fd,'%i', points(i,1));
    mfprintf(fd, ',');
    mfprintf(fd,'%.2E\n\r', points(i,2));
end
</code>

Its close it puts a '+' in the output for positive E numbers and the AWG
software rejects this. For example I have:

<code>
97,-2.50E+00
98,-2.50E+00
99,-2.50E+00
100,-2.50E+00
101,6.00E+00
102,6.00E+00
103,6.00E+00
104,6.00E+00
</code>

but I need:

<code>
97,6.00E00
98,6.00E00
99,6.00E00
100,6.00E00
101,-2.50E00
102,-2.50E00
103,-2.50E00
</code>

is it possible to achieve this just using formatting tags?
TIA James




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Formatting

Why not using decimal floating point output?

mfprintf(fd,'%.2f\n\r', points(i,2));

 

Regards,

Rafael

 

-----Original Message-----
From: users [mailto:[hidden email]] On Behalf Of James Holland
Sent: Sunday, January 07, 2018 8:49 PM
To: [hidden email]
Subject: [Scilab-users] Formatting

 

I'm trying to generate a file for an arbitrary waveform generator, the format is csv but I am having problems formatting the output, this is my current attempt

<code>

for i = 1:nr

    mfprintf(fd,'%i', points(i,1));

    mfprintf(fd, ',');

    mfprintf(fd,'%.2E\n\r', points(i,2)); end </code>

 

Its close it puts a '+' in the output for positive E numbers and the AWG software rejects this. For example I have:

 

<code>

97,-2.50E+00

98,-2.50E+00

99,-2.50E+00

100,-2.50E+00

101,6.00E+00

102,6.00E+00

103,6.00E+00

104,6.00E+00

</code>

 

but I need:

 

<code>

97,6.00E00

98,6.00E00

99,6.00E00

100,6.00E00

101,-2.50E00

102,-2.50E00

103,-2.50E00

</code>

 

is it possible to achieve this just using formatting tags?

TIA James

 

 

 

 

--

Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html

_______________________________________________

users mailing list

[hidden email]

http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
James Holland James Holland
Reply | Threaded
Open this post in threaded view
|

Re: Formatting

Rafael Guerra wrote
> Why not using decimal floating point output?
> mfprintf(fd,'%.2f\n\r', points(i,2));
> Regards,
> Rafael

I tried that but it won't accept that format. Unfortunately I don't have a
description of the format so all I can do is copy the format from an
existing file that was generated using the manufacturer's software. In the
past I have used Excel but it puts additional commas at the end of the data
lines which also cause a problem. Ultimately I would like to be able to
generate an AWG file mathematically or from an oscilloscope capture.
Regards
James




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Formatting

You can use strsubst to remove the + sign:
   
    str = msprintf('%.2E', points(i,2));
    mfprintf(fd,'%s\n\r', strsubst(str,"+",""));

Regards,
Rafael

-----Original Message-----
From: users [mailto:[hidden email]] On Behalf Of James Holland
Sent: Monday, January 08, 2018 4:42 PM
To: [hidden email]
Subject: Re: [Scilab-users] Formatting

Rafael Guerra wrote
> Why not using decimal floating point output?
> mfprintf(fd,'%.2f\n\r', points(i,2));
> Regards,
> Rafael

I tried that but it won't accept that format. Unfortunately I don't have a description of the format so all I can do is copy the format from an existing file that was generated using the manufacturer's software. In the past I have used Excel but it puts additional commas at the end of the data lines which also cause a problem. Ultimately I would like to be able to generate an AWG file mathematically or from an oscilloscope capture.
Regards
James


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
James Holland James Holland
Reply | Threaded
Open this post in threaded view
|

Re: Formatting

Thank you, that's a nice simple solution If I take the data that generates
and place it in a known good file then that will load.



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users