How to merge two .mat files?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Melaku Eneayehu
le 11 Mar 2018
Commenté : Walter Roberson
le 11 Mar 2018
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 commentaires
Réponse acceptée
Walter Roberson
le 11 Mar 2018
Modifié(e) : Walter Roberson
le 11 Mar 2018
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 commentaires
Walter Roberson
le 11 Mar 2018
Merging mat files is not going to somehow give you better fitting results than the vague "output is not good" that you mention.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!