??? Undefined function or variable 'swap'.
Mostra commenti meno recenti
Risposte (3)
There is no need to write your own function: if you want to swap variables, then you can use the inbuilt deal function to do exactly this:
>> X = 3;
>> Y = 2;
>> [Y,X] = deal(X,Y)
Y =
3
X =
2
It even works for multiple arguments!
Walter Roberson
il 12 Giu 2015
function [y,x]=swap(x,y)
end
is the entire code. To use it, for example,
a = 5; b = 48;
[a,b] = swap(a,b)
ishan s
il 13 Giu 2015
0 voti
Categorie
Scopri di più su Variables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!