octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comparing plots to Matlab


From: Ben Abbott
Subject: Re: Comparing plots to Matlab
Date: Sun, 05 Dec 2010 11:45:15 -0500

On Dec 5, 2010, at 4:56 AM, Søren Hauberg wrote:

> fre, 03 12 2010 kl. 12:03 -0500, skrev John W. Eaton:
>> On  3-Dec-2010, Ben Abbott wrote:
>> 
>> | By the end of the day, I'll have pushed fixes for each, except for the 
>> errorbar. The errorbar problem is due to a conflict between line and 
>> errorbar format conflicts. 
>> | 
>> | To allow for a more complete comparison, can a Matlab version of 
>> somebrero() be used? ... or should the demos be modified to use peaks()? 
>> 
>> How about modifying Søren's script to substitute peaks for sombrero
>> (maybe everywhere except the demo for sombrero itself)?
> 
> I just made sombrero matlab compatible and added it to the path of the
> matlab instance I used to generate the plots. I've re-run the script
> which gave some more images. The source-forge page has been updated with
> these new images.
> 
> Søren

I did something similar. I turned your script into a function and included 
Octave functions called by the demos that do not exist in Matlab.

>   ## Include octave functions used by the demos
>   for mfile = {"sombrero", "wblpdf"}
>     f = which (mfile{1});
>     fid2 = fopen (f);
>     code = char (fread (fid2));
>     code = oct2mat (code);
>     fprintf (fid, "%s", code);
>     fclose (fid2);
>   endfor
> 
>   fprintf (fid, "function x = vec (x)\n")
>   fprintf (fid, "x = x(:);\n")
>   fprintf (fid, "end\n")
> 
>   fprintf (fid, "function str = cstrcat (varargin)\n")
>   fprintf (fid, "str = [varargin{:}];\n")
>   fprintf (fid, "end\n")


I also added a simple oct2mat() function (not from OctaveForge)

> function code = oct2mat (code)
>   ## Simple hacks to make things Matlab compatible
>   code = strrep (code, "%!", "%%");
>   code = strrep (code, "!", "~");
>   code = strrep (code, "\"", "'");
>   code = strrep (code, "#", "%");
>   ## Fix the format specs for the errobar demos
>   code = strrep (code, "%r", "#r");
>   code = strrep (code, "%~", "#~");
>   endkeywords = {"endfor", "endif", "endwhile", "end_try_catch", 
> "endfunction"};
>   for k = 1:numel (endkeywords)
>     in = endkeywords {k};
>     out = in; out (4:end) = " ";
>     code = strrep (code, in, out);
>   endfor
> endfunction


This simplifies running under Matlab. Some line continuation, and other Octave 
features, must still be fixed. To make that task more convenient, I've produced 
a patch. For those interested I've attached it ... but do not plan to push it.

As there are at several of us tinkering with different modified version of your 
original, does it make sense to add dump_demos.m to Octave's sources, but only 
for development purposes (i.e. don't include it in module.mk)?

Ben


Attachment: changeset.patch
Description: Binary data




reply via email to

[Prev in Thread] Current Thread [Next in Thread]