Showing posts with label Matlab. Show all posts
Showing posts with label Matlab. Show all posts

Thursday, May 7, 2009

[C/C++ & MATLAB]As Same as U did~(Triangular....)

Coding

[C/C++]
Triangular.c


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int i,k,e;
printf("Input number:");
scanf("%d",&e);
for(i=e;i>0;i--)
{
for(k=i;k>0;k--)printf("* ");
printf("\n");
}

system("pause");
return 0;
}


[MATLAB]
Triangular.m


clear all
e= input('Input number:');
for k = e:-1:1
for i = k:-1:1
fprintf('* ')
end
fprintf('\n')
end


Compile and Run

[C/C++]
Type the command
~$gcc Triangular.c -o Triangular.exe
~$Triangular.exe

[MATLAB]
Open the m-file and press “F5”

Result should be like this:

*******
******
*****
****
***
**
*

Sunday, May 3, 2009

[MATLAB] Matlab R2009a Unix/Linux Installation (TIP)

Well...It is only quite recently that LKS started learning what LKS needs in M.D..
MATLAB SIMLUINK, of course, is what LKS must learn during a period of studying Automatic Control System. Hmmm...Enough talking...

After installation, LKS found that there “IS” a problem about configuration...
(still exist since MATLAB 2007b)

Install Java Runtime Environment support (JRE):
  • suns-java6-bin
  • suns-java6-jre
  • suns-java6-jdk(optional, development kit)

Modify the “matlab” script($MATLABROOT = where you installed matlab):
nano $MATLABROOT/bin/matlab
ADD:
export MATLAB_JAVA=/usr/lib/jvm/java-6-sun/jre/
export LIBXCB_ALLOW_SLOPPY_LOCK=1

If it still no use, add one more command:
export AWT_TOOLKIT=MToolkit

Because LKS's OS is Kubuntu 9.04, there is no need to do thing as above...
But LKS found that it will slightly improve visual performance.

Desktop Setting:

If you want to add MATLAB to start menu, you should add command to start menu

matlab -desktop

Well, of course you need complete the symbolic link first to use “matlab” directly.
(MATLAB R2009a has a script “install_matlab” at $MATLABROOT, it will automatically do the symbolic link for you. )