How to generate function after importing files

4 Ansichten (letzte 30 Tage)
Joël ESPEL
Joël ESPEL am 21 Feb. 2017
Kommentiert: Rik am 6 Mär. 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 Kommentare
Joël ESPEL
Joël ESPEL am 5 Mär. 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 am 6 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by