How to generate function after importing files
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

