I am faced with a problem. I came to know that large scale problems in MATLAB are very slow and with loops they are even slower.
I have the MATLAB script below that does some large scale computation for my school project work. I've been running this code for long now but all it did was to create more problems for me both in space and time complexities. So, I remove the loop and showing you the "non-loop" code below. (Maybe others can use it if they want to solve a similar problem )
What I used to do was previously using a "for loop" I used to generate values for j, but that was too slow. I then used to compute number of lines in each file, which again takes up some CPU time.
What I have done now is using the command created a file:
file_list.txt
Generated the file names along with number of lines. (I had to remove some ./ characters though)
So, now my file_list.txt file look like this. I have even sorted the filenames (second column sorted):
In the above list, first column contains the numbers of lines in each file and second column contains the file identifier names (my files are all named as 1.dat, 2.dat, 3.dat 6.dat etc) I removed .dat from file_list.txt file.
PS: The file identifier names are not continuously named like 1 2 3 4 until end but in between one or two files are missing like you see above after 4, 6 comes in.
Now, I want to use file_list.txt to create a "very long" MATLAB script "without loop". So, now what I intend to do is to replace all 'j' variable in my MATLAB script to file identifier values (that is second column in file_list.txt) sequentially line by line (it should not ignore any line else my results will all be meaningless).
Second, the 'numlines' variable in my MATLAB script has to be replaced with the number of lines from file_list.txt (first column).
My intended output file should look something like below, so that if I run the code by pressing RUN button entire script begins to run at once.
[/CODE]
And this is how it continues in the entire file to create one single MATLAB script file which I can run overnight. Unfortunately, my file list file is too huge to do it manually.
I am open to suggestions too, if anyone can kindly suggest me any better way of doing what I intend to do. I am using Linux.
Last edited by shoaibjameel123; 10-11-2011 at 06:58 AM..
Reason: Minor grammar
Yup. You can do this by making a "hereto" document and replacing your CHANGE HERE parameters with shell variable names, like $LINECOUNT and $FILENAME. THen wrap that in a big loop.
But m4 offers a sleeker way. Name your placeholders as above but without the $ sign and save the changes to a file, say matlab.tmpl
Last edited by otheus; 10-18-2011 at 09:13 AM..
Reason: I thought m4 could handle macros beginning with $. It cannot
Hi, I am having a problem compiling a program with gfortran. The program compiles with g77 and f77 but I don't have those. I edited the makefile from FC = g77 to FC = gfortran but when I run it I get a slew of undefined reference errors. Any suggestions? (8 Replies)
I installed in VM the Mandriva Linux with 2.6.27 kernel.
But presently when I fire make the modules .ko does not get built.
I get the following output on firing command in the kernel module folder.
$ make
Building first_driver.c ... make: Entering directory... (1 Reply)
Hi all,
I'm trying to set up a chroot sftp using OpenSSH.
But I'm still having problems.
I'm using AIX 5.3
My system and OpenSSH version as follows
host1:/>oslevel
5.3.0.0
host1:/>oslevel -r
5300-10
host1:/>ssh -V
OpenSSH_5.0p1, OpenSSL 0.9.8h 28 May 2008
host1:/>lslpp -l | grep open... (2 Replies)
Is there any command or VARIABLE in unix to display only bash builtin commands?. Some days back I worked on that, but now I do not remember.
Can anyone please reply for this?... (4 Replies)
i installed fedora core6, then came to know that java is not supplied with it, can u help me by naming some distros with built in java, does RHL5+ has it? (2 Replies)
I'm using Mac OS 10.2.2 and I need to find a command line hex editor. I figure there's already one built-in, but I just don't know enough about Unix, yet. Basically, what I want to do is tell the hexeditor to open a file, replace a specific offset with a new value, then put the resulting file... (7 Replies)
I'm playing around with the kqemu accelerator for the QEMU virtualization software. I can't remember which version of gcc I used to build my kernel. I have 3.4.6 and 4.1.1 on this (Gentoo) system. I seem to remember there is some command I can run against binaries that will tell me what gcc (and... (5 Replies)
I am new to Unix scripting. I would like to know if someone can point me to a site which lists any built-in commands in there scripted form. I thought to start with the basics and learn from example.
Thanks
JSP (2 Replies)
Dear experts
I am learning awk command through some books on Solaris 8.
I have tested the folloing command
awk 'BEGIN { print match ("And" , /d/)}'
then the result is as following
awk: syntax error near line 1
awk: illegal statement near line 1
Could you please help on this and just... (4 Replies)