In place function on a structure or a class
Afficher commentaires plus anciens
Hi,
I've encountered the following problem with in place editing. I have an in-place function, x = f(x). If I put x in a structure it is no longer in-place. Any ideas?
In-place:
function tmp
format debug
x = rand(1, 5);
x
x = cumsum(x);
x
end
/
>> tmp
x =
Structure address = 13e0854b0
m = 1
n = 5
pr = 60000f633020
0.1068 0.6538 0.4942 0.7791 0.7150
x =
Structure address = 13e11e5c0
m = 1
n = 5
pr = 60000f633020
0.1068 0.7605 1.2547 2.0337 2.7488
Not in-place:
function tmp
format debug
s.x = rand(1, 5);
s.x
s.x = cumsum(s.x);
s.x
end
/
>> tmp
ans =
Structure address = 13e11eda0
m = 1
n = 5
pr = 60000f633020
0.6099 0.6177 0.8594 0.8055 0.5767
ans =
Structure address = 13e11da60
m = 1
n = 5
pr = 60000b1ca5e0
0.6099 1.2275 2.0870 2.8925 3.4692
Réponses (1)
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!