How to generate function after importing files
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I have student license of Matlab and after importing data I want to recreate what I just did and put it on one file to avoid doing it manually if I want to read multiple files. So I suppose that I need to "generate function". However, I can't do it interactively as I can with generate script. So can anybody please help me with this issue?
in tutorial

my version of matlab

Joël
3 Commenti
Rik
il 6 Mar 2017
I have a student license as well. When check the 'generate script' box in the load interface (left click on .mat file), I get the following funtion:
function importfile(fileToRead1)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
% Auto-generated by MATLAB on 06-Mar-2017 19:58:16
% Import the file
newData1 = load('-mat', fileToRead1);
% Create new variables in the base workspace from those fields.
vars = fieldnames(newData1);
for i = 1:length(vars)
assignin('base', vars{i}, newData1.(vars{i}));
end
So I get a function. There is not much difference between a script and a function (mainly the variable scope), so I don't understand what part it is you want to automate/standardize.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

