How to merge two .mat files?
조회 수: 2 (최근 30일)
이전 댓글 표시
I am trying to do svm training https://in.mathworks.com/matlabcentral/fileexchange/55098-plant-leaf-disease-detection-and-classification-using-multiclass-svm-classifier and https://in.mathworks.com/matlabcentral/fileexchange/55107-brain-mri-tumor-detection-and-classification in the above two link when i load the training data-set i get two or more .mat file Example in the first link when i load Training_Data it open Train_feat and Train_label...how can i do this? but before this what am trying is... i have one folder who have 3 types of training image each type have 50 image, totally 150 training image(3 class) i add one row which count the no of row, class one will have record from row 1-50, second 51-100, third 101-150 while testing if k value falls from this it will display the class label of that training image, but the out put is not too good...so i want to try the above two link examples..thank you sorry and for this boring write.
댓글 수: 0
채택된 답변
Walter Roberson
2018년 3월 11일
편집: Walter Roberson
2018년 3월 11일
s1 = load('FirstFile.mat');
s2 = load('SecondFile.mat');
fn1 = fieldnames(s1);
fn2 = fieldnames(s2);
if any(ismember(fn1, fn2))
error('Those files have at least one variable with the same name, cannot merge them');
end
for K = 1 : length(fn2)
thisfield = fn2{K};
s1.(thisfield) = s2.(thisfield);
end
save('MergedFile.mat', '-struct', 's1');
The output MergedFile.mat will contain all of the variables that were in each of the other two files.
... But I have no idea why you think merging .mat files will be useful in your situation.
댓글 수: 2
Walter Roberson
2018년 3월 11일
Merging mat files is not going to somehow give you better fitting results than the vague "output is not good" that you mention.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!