Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me store data in a file for KZK equation in Matlab

Status
Not open for further replies.

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
Hi every body,
here is my pb, I've a long computing to do on matlab, so the memory is not enough, I thout to make a storing on a file but I don't know how in matlab!! I think that I must use something like fprintf and fscanf but it's not so easy
could you show me how thanks a lot
 

claint

Member level 5
Joined
May 21, 2004
Messages
94
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,288
Activity points
762
Re: about Matlab

Hi,
I know how to read and write files in Matlab, but I wonder whether file operation can
reduce memory useage.
 

suvendu

Full Member level 3
Joined
Oct 10, 2004
Messages
169
Helped
16
Reputation
32
Reaction score
3
Trophy points
1,298
Activity points
2,121
Re: about Matlab

u can take help from MATLAB BY CHAPPMAN OR "RUDRAPRATAP "BOOK.
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
638
Reputation
1,274
Reaction score
89
Trophy points
1,328
Location
USA
Activity points
33,176
about Matlab

Can you explain a little more what you are trying to do? How much data you have? Does MATLAB need to access it randomly or sequentially?

The operating system is suppose to provide virtual memory to the application (by using the hard drive), so it behaves as if you have more RAM installed.
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
about Matlab

ok this is the problem, I have to resolve the KZK equation on Matlab, so I must take aver 30000 samples on the z axis and over 1000 samples on r axis and that's 10 times, which makes the virtual memory too small for such data, so I have the idea to make the computing on 500 samples on z then to save in a file, after I will take the 500 next, then I could reuse the same location in the memory.
Thanks.
 

cwjcwjcwj

Full Member level 5
Joined
Nov 8, 2004
Messages
273
Helped
17
Reputation
34
Reaction score
12
Trophy points
1,298
Activity points
1,714
Re: about Matlab

I am curious to know so.....who can help on this?
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
638
Reputation
1,274
Reaction score
89
Trophy points
1,328
Location
USA
Activity points
33,176
about Matlab

Still not clear. I don't know how the KZK algorithm works.

You have 30000*1000*10 samples. Yes that may be too big for virtual memory on a 32-bit computer.

Where are those gigabytes of data coming from? From a file? From a data acquisition device? Or are you generating all that data in MATLAB? And what do you want to do with all that data after processing? Write to a file? Output somewhere? Delete it?

Maybe you can create a loop that uses fread() and fwrite() to read/write your binary input/output data files sequentially, one small chunk at a time. If your data is ASCII (ouch!), then you could use fscanf() and fprintf() instead, but it'll be slow.

How about getting a 64-bit computer? That removes the 2GB limit. I think MATLAB now supports 64-bit Windows and Linux.
 

yongchai

Junior Member level 1
Joined
Jun 11, 2005
Messages
15
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,420
about Matlab

In Matlab simulation, you can save the state of the simulation. This is particular useful when the system resources (e.g. memory) are not enough. In other words, you can divide the simulation into multiple stages. At each stage, you save the result to a different file. After all stages are performed, you combined all the files. I can do this in Matlab/Simulink. In my opinion, it could be done for any m-file type of simulation.
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
about Matlab

It's about calculating a wave propagating into a medium, for this I define the source on 1000 samples, after and on 30000 samples on z, I must calculate every point using the results I found earlier. more clearly and briefly u(j+1,i,n)=[T]^-1*u(j,i,n)+Sn(j,i) where T is a 30000*1000*10 matrix, S(n) is defined using every point u(j,i,n). it's a little bit complicated. So I cant save the state of simulation into multiple stage 'cose I must restor everytime my data.
For using fscanf I had a problem on argument it's about the size of my data, it's double (the default wiith matlab). here's the problem.
Any way please if you have any idea communicate them to me, and I do the same.
than,ks friends
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
Re: about Matlab

In fact,
When i'm saving the calculated samples in a file, using fwrite, I can't make suree that they are in the true order, so is there any other function for files in matlab?
 

paolone1340

Member level 3
Joined
Apr 6, 2005
Messages
57
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,288
Location
Pisa, ITALY
Activity points
2,104
about Matlab

Excuse me, why You don't try to work in C++? You can easily pass Your data by the C++ program to Matlab (use the command LOAD in matlab to read a .dat file generate by C++).

When I did a M.C. Simulation about the DIRC (a detector who work with Cerenkov's effect, and is part of the BaBar Detector), I can Simulate 30000*300 extractions in only 5 minutes with a pentiom 2,4 Ghz with 512MByte RAM.

With Matlab, the same simulation, requires a life with that computer!
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
about Matlab

Dear paolone, my problem with C++ is that I have to calculate a matrix invers, and the best language for matrix computing is MATLAB, else I must write a long script to do this invers, and that will be more late than with MATLAB.
 

zhaoyimiao

Member level 1
Joined
Jun 2, 2005
Messages
35
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,288
Activity points
1,559
about Matlab

It is not very difficult to write a Matrix inverse caculation algorithm in C. You can check the book "Numeric in C".
 

jakjoud

Full Member level 2
Joined
Feb 6, 2005
Messages
129
Helped
10
Reputation
20
Reaction score
1
Trophy points
1,298
Location
Marrakech
Activity points
954
about Matlab

OK thanks everybody, I think that I found the solution in matlab it's just the "write" and "read" but be careful about reading.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top