How to generate function after importing files

4 visualizaciones (últimos 30 días)
Joël ESPEL
Joël ESPEL el 21 de Feb. de 2017
Comentada: Rik el 6 de Mzo. de 2017
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 comentarios
Joël ESPEL
Joël ESPEL el 5 de Mzo. de 2017
yes, you are right...the problem is that, in tutorials they can actually "generate function"
Which is not possible in my version of matlab
So, what can I do?
Rik
Rik el 6 de Mzo. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by