Save data sets in different places
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Bajdar Nour
il 19 Ago 2018
Commentato: Image Analyst
il 20 Ago 2018
the output result only saves the last (unusual1.dat) file instead of all three.
if f==1 save Norm.dat stats -ascii %Save data to dat file using ascii
else if f==2 save Unusual.dat stats -ascii
else
save Unusual2.dat stats -ascii
end
end
Could you help me where is my problem, please?
0 Commenti
Risposta accettata
Stephen23
il 20 Ago 2018
Modificato: Stephen23
il 20 Ago 2018
The mistake that both you and Image Analyst made is to use command syntax, whereas you need to use function syntax like this:
fnm = sprintf('Unusual%d.dat', f);
save(fnm,'stats','-ascii')
This is clearly explained in the MATLAB help: "When a function input is a variable, you must use function syntax to pass the value to the function."
1 Commento
Più risposte (1)
Image Analyst
il 19 Ago 2018
Modificato: Image Analyst
il 19 Ago 2018
I guess then that f never obtains the value of anything other than 1 or 2.
In your loop, construct the file name with sprintf and use that instead of the multiple if block:
filename = sprintf('Unusual%d.dat', f);
save filename stats -ascii
0 Commenti
Vedere anche
Categorie
Scopri di più su Low-Level File I/O in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!