我试图用用户界面创建一个简单的程序。gui中的用户插入了Person Implements Serializable类的名称,姓氏和年龄。
一切正常,但仅适用于一个人,第一人!似乎每次我向文件发送新对象时,由于文件大小越来越大,确实将其写入文件。
问题是,当我读取带有对象的文件时,它仅返回一个,我希望返回存储在myFile中的class person的所有对象。
这是我的代码的简要介绍:
写对象按钮:
try {
per = new Person(name, sur, age);
FileOutputStream fos = new FileOutputStream("myFile", true);
ObjectOutputStream oos;
oos = new ObjectOutputStream(fos);
oos.writeObject(per);
oos.flush();
oos.close();
//some other code here
} catch (IOException e) {
//some code here
}
Run Code Online (Sandbox Code Playgroud)
读取对象按钮:
try {
FileInputStream fis = new FileInputStream("myFile");
ObjectInputStream ois;
ois = new ObjectInputStream(fis);
try {
rper = (Person) ois.readObject();
ois.close();
JOptionPane.showMessageDialog(null, "People:" + rper, "Saved Persons", JOptionPane.INFORMATION_MESSAGE);
} catch (ClassNotFoundException e) {
//some code here …Run Code Online (Sandbox Code Playgroud) 假设我们有一个64dim矩阵来聚类,假设矩阵数据集是dt = 64x150.
使用vl_feat的库中的kmeans函数,我将我的数据集聚集到20个中心:
[centers, assignments] = vl_kmeans(dt, 20);
Run Code Online (Sandbox Code Playgroud)
centers 是一个64x20矩阵.
assignments 是一个1x150矩阵,其中包含值.
根据手册:向量分配包含输入数据到集群的(硬)分配.
我仍然无法理解矩阵中的这些数字是什么assignments意思.我根本得不到它.有人介意帮我一点吗?一个例子或一些东西会很棒.这些价值观代表什么呢?