Could anyone can help me with a question about function workspace?
Afficher commentaires plus anciens
I came to a question with following code:
Function [x,y] = myworkspace(a,b)
x = a + b;
y = x * b;
z = a + b;
end
Example Q1: What will the value of a,b,x,y and z be after the following code is run?
Example A1 is as follows:
>>clear all
>>a = 2;
>>b = 3;
>>z = 1;
>>[y,x] = myworkspace(b,a)
y = 5
x = 10
*>>z
z = 1*
Example Q2: What will the value of a,b,x,y and z be after the following code is run?
Example A2 is as follows as well:
>>x = 5;
>>y = 3;
>>[b,a] = myworkspace(x,y)
b = 8
a = 24
*>>z
??? Undefined function or variable 'z'.*
I am wondering why the values of z above are like that (in Bold)? I am confusing since z = a + b and both elements are defined...
Could you please tell me why it is the case?
1 commentaire
Henry Mao
le 19 Sep 2015
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Entering Commands 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!