2021年7月6日 星期二
2014年12月26日 星期五
凌晨2:23
tea
程式範例
No comments
環境設定
To run Java 7 code from Matlab, Matlab needs to use JVM 1.7. To do this, see this MathWorks page, or follow these steps:
- Ensure that you are using Java 6 or earlier – no need to do anything if your Matlab already has Java 7
>> version -java ans = Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode - Download and install JRE 1.7 or JDK 1.7 from the Oracle website
- Create a new System Environment Variable called
MATLAB_JAVAwith the installation folder as its value. For example: “C:\Program Files\Java\jdk1.7.0_21\jre” - Restart Matlab and verify that it picked up the new Java version:
>> version('-java') ans = Java 1.7.0_21-b11 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
連結 using-java-7-in-matlab-r2013a-and-earlier
_______________
#配置MATLAB調用的Java庫
1.完成的Java代碼。
2.創建Java庫文件,即.jar文件。
3.將創建.jar文件的目錄使用Matlab的存儲庫之一,並添加相應的路徑
Matlab的配置文件,$ MATLABINSTALLDIR\$ MatlabVersion\工具箱\本地\ classpath.txt。
#配置MATLAB調用的Weka
1.下載WEKA
2.安裝WEKA
3。在环境变量的系统变量中的Path中加入jre6(或者其他的)中bin文件夹的绝对路径,如:
C:\ Program Files文件\的Java\ JRE6\ BIN;
4.查找MATLAB配置文件classpath.txt
其中classpath.txt%使用這個命令可以查找classpath.txt的位置
5.修改配置文件classpath.txt
編輯classpath.txt
在classpath.txt配置文件中將WEKA安裝目錄下的weka.jar的絕對安裝路徑填入,如:
C:\ Program Files文件\的Weka-3-6/ weka.jar
6.重啟MATLAB
7.運行如下命令:
屬性= JAVAOBJECT('weka.core.FastVector');
%如果MATLAB沒有報錯,就說明配置成功了
8. Matlab的在調用WEKA中的類時,經常遇見的堆空間溢出的情況,我們需要設置較大的堆棧,設置方法是:
Matlab->文件 - >優先 - >常規 - > Java堆內存,然後設置適當的值。
WEKA 筆記
2014年12月19日 星期五
晚上11:11
tea
程式範例
No comments
像 Linux 就直接 cd 相對路徑 或是絕對路徑就行了,可是在 Windows 直接輸入 cd 指令卻還是原本的目錄...
經過多方查詢 Windows 的指令之後,終於知道缺什麼了!
指令 cd 是對的沒錯,但是還需要 "/d" 來幫忙才會換過去唷
指令: cd /d 完整路徑
2013年8月19日 星期一
清晨7:37
tea
程式範例, JAVA
No comments
必須撰寫在synchronized的區塊內,
當wait()被呼叫時,則會釋放所有的鎖,
並寫在try-catch(InterruptedException e)內,
1. void wait()
讓執行緒進入等待狀態
2. void notify()
喚醒一個等待中的執行緒,若有多個執行緒,則由JVM決定
3. void notifyAll()
喚醒所有等待中的執行緒
注意:考慮在複雜程式上的邏輯正確,在執行緒交互呼叫wait()和notify()時,可能先配合滿足的條件再呼叫函式,例如設計前置布林值或計數器來作為呼叫的條件
當wait()被呼叫時,則會釋放所有的鎖,
並寫在try-catch(InterruptedException e)內,
1. void wait()
讓執行緒進入等待狀態
2. void notify()
喚醒一個等待中的執行緒,若有多個執行緒,則由JVM決定
3. void notifyAll()
喚醒所有等待中的執行緒
注意:考慮在複雜程式上的邏輯正確,在執行緒交互呼叫wait()和notify()時,可能先配合滿足的條件再呼叫函式,例如設計前置布林值或計數器來作為呼叫的條件
import static java.lang.System.out;
public class Ex_WaitNotify {
public static void main(String[] args) {
One one = new One();
one.start();
synchronized(one) { // 主執行緒取得one的鎖
String tName = Thread.currentThread().getName();
out.print("one 進入 wait pool ");
out.println("(" + tName + ")");
try {
one.wait();
} catch (InterruptedException e) {}
out.print("one 離開 wait pool ");
out.println("(" + tName + ")");
}
}
}
class One extends Thread {
public void run() {
synchronized (this) {
String tName = Thread.currentThread().getName();
out.print("呼叫 notify() ");
out.println("(" + tName + ")");
notify();
out.print("notify() 呼叫完畢! ");
out.println("(" + tName + ")");
}
}
}
清晨7:36
tea
程式範例, C/C加加
No comments
// X值與X-1值做AND運算,若傳回0,則為2次方數值int X;cin >> X;cout << !(X&(X-1)) << endl;
訂閱:
文章 (Atom)

