Monday, November 14, 2011

Matlab Java space heap memory size problem solution

The solution is very simple
1- check what you have

2- To check the version of your Java, type the following in the Matlab prompt window:
version -java
3- to check the current size you have type:
java.lang.Runtime.getRuntime.maxMemory
java.lang.Runtime.getRuntime.totalMemory
java.lang.Runtime.getRuntime.freeMemory


To Solve it:
4-open a text file
5- write the following in it
For JVM of 1.2.2 and later, place the following in your java.opts file:
-Xmx256m

For JVM 1.1.8 'java.opts', place the following in your java.opts file:
-mx256m


6- Save the file with the following name:

java.opts


7- you can simply put a number more than 256 if your machine allow it for example (Xms512m)
8- Save the file in the matlab path directory
Simply will work :)

some people increase it from the cmd for dos like this,

    java -Xms64m -Xmx256m

I am not sure if this works, but the method I just described works for sure :)

Modifications to Run Matlab exe files for Windows 7

1- Open the system properties
2- go to "Advanced"
3- click on "Environment Variables"
4- go to "User variables for ...."
5- Click on "New"
6- for variable name:
PATH
7- for Variable value:
set PATH=C:\Program Files\MATLAB\MATLAB Compiler Runtime\v713\runtime\win32;

which is the location of the matlab runtime compiler, which you need to change according to your files location

Wednesday, July 6, 2011

Generate a controlled random number in matlab

The main idea here is to generate a random number knowing the minimum and maximum limits, also the size.
The command to do it is
randi([imin,imax],[m,n])
where :
imin: is the minimum number
imax: is the maximum number
m: is the rows in the array (which determine the result size)
n : is the columns in the array (which determine the result size)

a useful application for this, is when you want to generate random numbering in Hex.
at this point you can choose, the above function and then use the dec2hex

Tuesday, June 7, 2011

Remove weekend days from list of days MS access

One of the things that I faced, was how to remove the weekend dates from a list of days.
The solution was simple.
use the function:
DatePart 
This function is fully listed in the following link:
http://www.techonthenet.com/access/functions/date/datepart.php

What I did is the following to remove Sunday and Saturday.
the DatePart returns a number between 1(Sunday)-7 (Saturday)
so I did:
where DatePart("w",(DayColumnInDays.MM/DD/YYYY))<=6 And DatePart("w",(DayColumnInDays.MM/DD/YYYY))>1

This is how I removed the weekends

Wednesday, June 1, 2011

Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (latin1_general_ci,IMPLICIT)

This is a very common problem that you might run in at all times.
To over come it, do the following:
1- Open MySQL Query browser
2- Go to the first table you are facing a problem with.
3- right click and hit "Edit Table" OR hit (F2) for a short cut
4- click on the variable you have a problem with from the "Column Name"
5- Go to "Column Details" Tab
6- On the far right you will see the "Column Collate:" switch it to the default value you want (either swedish or general)
7- Do the same with the Other table
And that is it

Tuesday, May 31, 2011

unknown object in backup file

One of the biggest problems that dazzled me for a while was receiving this error message from Mysql while trying to restore my backup file. The file was only 3GB of size yet it failed and at different locations. After a long search online I found the answer, and I believe it is worth mentioning it.
do the following steps:
1- the main cause is the max_allowed_packet
2- use the mysql system tray monitor
3- run mysql query browser
4- type
show variables like 'max_allowed_packet'
5- you will notice that the size is low
6- change the size by typing
set global max_allowed_packet= 500*1024*1024;
7- you can increase the 500 number to larger or smaller, the important thing is to make it bigger than what you saw in step 4
8- now run mysql administrator
9- go to startup variables on the left
10- go to advanced networking tab
go to advanced
click on Data / Memory size
click on Max. Packet size and put the same number we put up their
and that is it