Function returns mapping to another function variable
Afficher commentaires plus anciens
Questions:
- When i have 2 returns in the below function why does the "ans" only shows the value of "c" and not "d" or "absx" or "absy" ?
function [absx,absy] = my_first_function1()
input = 3;
b = [1 2 4; 3 4 6; 4 2 3];
c = input*b;
d = inv(c);
absx = c;
absy = d;
c
d
end
>> my_first_function1
c =
3 6 12
9 12 18
12 6 9
d =
-0.0000 -0.0667 0.1333
-0.5000 0.4333 -0.2000
0.3333 -0.2000 0.0667
ans =
3 6 12
9 12 18
12 6 9
2. How can i use the "absx" and "absy" inside another function.
My intention is to map x to absx and y to absy
function my_first_subfunction1()
my_first_function1
x = absx
y = absy
disp('..........')
z = x;
z
w = y;
w
end
If i use the above code it tends to throw an error like
Unrecognized function or variable 'absx'.
Error in my_first_subfunction (line 3)
x = absx
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!