help-octave
[Top][All Lists]
Advanced

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

Getting a matlab proggie to work


From: Praedor Atrebates
Subject: Getting a matlab proggie to work
Date: Thu, 29 May 2008 14:43:39 -0400
User-agent: KMail/1.9.9

I have some data that I analyze by matlab normally but would like to be able 
to do it with octave as well (I wont pay >$1000 for ANY software ever).  

The program takes in a set of datafiles 
named 'rawdata5.0000', 'rawdata5.0150', 'rawdata5.0300', etc, etc, 
incrementing by 0.015 with each file up to 'rawdata46.0000' or higher.  These 
files contain data like this:

-3.000000E-2    4.115813E-1
-2.999600E-2    4.118906E-1
-2.999200E-2    4.119187E-1
-2.998800E-2    4.115906E-1
-2.998400E-2    4.120375E-1
-2.998000E-2    4.118875E-1
-2.997600E-2    4.118906E-1
-2.997200E-2    4.114375E-1
-2.996800E-2    4.114187E-1
-2.996400E-2    4.117313E-1
-2.996000E-2    4.119094E-1
-2.995600E-2    4.121812E-1
-2.995200E-2    4.114750E-1
-2.994800E-2    4.120188E-1
etc

The matlab program reads in the data of all the 42 or so files, does a little 
simple magic on it, and combines it into a single BIG file.  This big file 
contains the data necessary to render an interferometric surface scan of a 
silicon oxide disc using 'imagesc(<BIG file name>);'  There is another matlab 
function that converts this cartesian surface image into a radial 
reproduction of the actual circular disc.

Even though the data and the actual matlab program and functions are rather 
straight forward, I cannot run at least the initial matlab program in octave 
(the prog that takes in the thousands of datafiles and combines them into one 
processed mega file).  The important part of the failing code is here (file 
called "image_prep.m"):

% Rawdata read-in program.
% The parameter 1: the pitch length;
% The parameter 2: start position;
% The parameter 3: number of tracks; 
% The parameter 4: The forth is pixel number for one period of scan; 
% The parameter 5: The path to the folder keeping rawdata

% ILscan1 = 
Getting_RawData_single_channel(0.015,-42,2400,12500,'C\Data\Patrick\custom1038-2155\scan1\');
 ILscan2 = 
Getting_RawData_single_channel(0.015,5,2620,12500,'/home/praedor/Data/custom1038-2172/scan2/');
------------
In this case, ILscan2 = is uncommented (obviously).  It 
calls "Getting_RawData_single_channel.m" which contains:
-----------
% SurAnal.m
% 2D Analysis program for PC disks and chips
% Creates surface topology, then demodulates the carrier frequency
% User Input            % User modified parameters
function IL = 
Getting_RawData_single_channel(itrack,startrackpos,endtrack,endtime,folderpath)
startrack = 1;          % Starting track number
wspin = 1200;           % Spin frequency
startime = 1;           % Starting time
dt = 1e-6;              % time increment

fname = [folderpath,'rawdata'];

periodic = 0.9042*1024; % adjustable carrier frequency
df = 20e3;              % demodulation bandwidth (30e3)
dny = 0.2;              % demoduulation radius width (0.80)

dtrack = endtrack-startrack+1;      % Size of matrix in radius dimension
dtime = endtime-startime+1;         % Size of matrix in time dimension

% Loop through tracks
tracknum = startrack - 1;
for trackloop = 1:dtrack
    tracknum = tracknum +1;
    x = 1:dtime;
    t = dt*x;
    trackname = startrackpos + (tracknum-1)*itrack;
    filnam = [fname, num2str(trackname,'%5.4f')];
    fid=fopen(filnam);
    [a,b]=fscanf(fid,'%f    %f\n',[2 inf]); 
    status = fclose(fid);
    
% Subtract linear drift in data
IL(trackloop,1:dtime) = a(2,startime:endtime); %temp(1:dtime);    
endfor     % trackloop

return;
----------

And that's it.  When I try to run "image_prep.m" in octave (version 3.0.0) I 
get:

octave:2> run Image_preparation.m
error: fscanf: invalid stream number = -1
error: called from `Getting_RawData_single_channel' in 
file 
/home/praedor/Documents/BioCD/Analysis-of-SDI/Getting_RawData_single_channel.m 
near line 37, column 10

In the program file, line 37, column 10 falls in this portion of code:

    filnam = [fname, num2str(trackname,'%5.4f')];
    fid=fopen(filnam);
    [a,b]=fscanf(fid,'%f    %f\n',[2 inf]);    <--------------this line
    status = fclose(fid);

Given the information I provided above (file names, data format, and the 
requisite code) can anyone conjure a reason as to why octave refuses to run 
these simple code files and spits out the error that it does?

praedor
-- 
"As democracy is perfected, the office of president represents, more and more 
closely, the inner soul of the people. On some great and glorious day the 
plain folks of the land will reach their heart's desire at last and the White 
House will be adorned by a downright moron."
--H.L. Mencken
 

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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