help-octave
[Top][All Lists]
Advanced

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

: new to octave, confused about load(), dlmread et cetera


From: Roman.Griego
Subject: : new to octave, confused about load(), dlmread et cetera
Date: Wed, 1 Sep 2010 04:59:22 +0000

The best solution I have found is to use something like the following(Tested 
and Working):


close all;clear all;

fid=fopen("file.txt","r");
Row1=fgetl(fid);
Row2=fgetl(fid);
data=dlmread("file.txt");
data([1,2],:)=[]; #Erases first two blank lines
fclose(fid);
clear fid;


Row1=strsplit(Row1,"    ");#Tab character( I use Notepad++ and set to view all 
characters)
Row2=strsplit(Row2,"    ");

[r,c]=size(data);

This_Data=struct("Field1",Row1,"Field2",Row2,"Data",data);

for i=1:c
This_Data(i).Data=This_Data(i).Data(find(This_Data(i).Data)); #Strips all zeros
endfor

disp("Data saved into data structure.")



reply via email to

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