How to get all data from m-function?
Afficher commentaires plus anciens
Hello! I created a function for reading dpv files, it contains many parameters that I receive. But in the example of creating a function, there is only one
function A=ReadDPV(fileName) % When reading a file, 102 values come out
A=0.24*c
A1=0.1*f
B=1.2*b
...
Z2=2.4
end
When I try to read with this function, I only get the value A
X=ReadDPV(fileName)
% X=A;
How to get all 102 values that are read and counted in my function?
1 commentaire
Stephen23
le 10 Juin 2021
Best solution: use a structure.
Réponse acceptée
Plus de réponses (1)
Scott MacKenzie
le 10 Juin 2021
Modifié(e) : Scott MacKenzie
le 10 Juin 2021
0 votes
Your function is defined to only return A (which is perhaps a scalar). To return multiples values, return them as elements in a vector and define your function accordingly:
function [A, A1, B, ... ] = ReadDPV(fileName)
A = ...
A1 = ...
...
end
Then, use your function thus:
[x, y, ...] = ReadDPV(...)
x will be A, y will be A1, and so on
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!