Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 611

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/classes.php on line 728

Strict Standards: Redefining already defined constructor for class wpdb in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/wp-db.php on line 306

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/cache.php on line 425

Strict Standards: Redefining already defined constructor for class WP_Dependencies in /nfs/c02/h09/mnt/40423/domains/lizardinthesun.com/html/cloudblog/wp-includes/class.wp-dependencies.php on line 15
Loglet in the Clouds

Matlab, jQuery and JSON

I do all my numerical algorithm development in Matlab, so I needed a way to easily get results from Matlab into javascript. Here is a (a pretty cool if I don’t say so myself) matlab code that creates a JSON file from a matlab data structure.


data.x = rand(10,1);
data.y = rand(10,1)

dataname = 'data' 

fid = fopen('matlab.json','w');

numdata = max(size(fieldnames(eval(dataname))))

fdata = char(fieldnames(eval(dataname)));

fprintf(fid,'{ "%s" : {\n ',dataname)
for dataiter=1:numdata,
  fprintf(fid,' "%s" : [ \n',fdata(dataiter));
  stmp = sprintf('%s.%s',dataname,fdata(dataiter));
  for i=1:(max(length(eval(stmp))))-1,
    stmp = sprintf('%s.%s(%i)',dataname,fdata(dataiter),i);
    fprintf(fid,'%1.10e , \n',eval(stmp));
  end
  stmp2 =  sprintf('%s.%s',dataname,fdata(dataiter));;
  stmp = sprintf('%s.%s(%i)',dataname,fdata(dataiter),(max(length(eval(stmp2)))));
  fprintf(fid,'%1.10e  \n',eval(stmp));

  if dataiter == numdata ,
    fprintf(fid,'] \n');
  else
    fprintf(fid,'], \n');
  end

end

fprintf(fid,'} } \n');

And then reading it in and parsing it with jQuery is really simple.


 var x = [];
 var y = [];
 $.ajaxSetup({ async: false});
  $.getJSON("matlab.json", function (json)
            {
              x = json.data.x.slice(0);
              y = json.data.y.slice(0);
            }
            );
  

Welcome to Loglet in the Clouds

I am currently (re)-writing the Loglet Lab¬†software application into a “cloud” application.¬† Basically, it means re-writing the algorithms in javascript, so that it is easy to plug into and “mash up” the Web 2.0 “cloud” (i.e. as a plug-in (gadget) for google spreadsheets).¬† As the code will be open source ( current license LPGL 2.1 ), I’ll post things that other users or developers of Loglet Lab Cloud edition might find useful.

Here is an example of a proof-of-concept google gadget for google spreadsheets, which uses the excellent flot plotting library for the jQuery framework: