# Update only one component in a vector fespace

**URL:** <https://community.freefem.org/t/update-only-one-component-in-a-vector-fespace/2560>\
**Category:** General Discussion\
**Created:** [June 27, 2023, 6:01am UTC](https://community.freefem.org/t/update-only-one-component-in-a-vector-fespace/2560 "2023-06-27T06:01:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clthu](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@clthu](https://community.freefem.org/u/clthu)\
**Post date:** [June 27, 2023, 6:01am UTC](https://community.freefem.org/t/update-only-one-component-in-a-vector-fespace/2560/1 "2023-06-27T06:01:20Z")

</div>

Dear all,  
I met a problem when I tried to update only one component in a vector fespace, for example  
//  
fespace Vh(th,[P2,P2,P1])  
Vh [ux,uy,z]  
//  
During the calculation, z may become greater than 1, but I want to limit z in the range between 0 and 1 (I want to make z=z\*(z\<=1)+1\*(z\>1)) after each iteration, how can I do it?  
I thought about several methods. I tried to understant the componet in the array ux and only updated the z componet in the ux, but I didn’t find the pattern of z component in the ux for this [P2,P2,P1] fespace… (I use wz=z , and find that the componet of wz apprears in the 7th,10th,25th,34th … componets in the array ux. There seems to be no pattern…)  
Thanks very much~

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [June 27, 2023, 6:44am UTC](https://community.freefem.org/t/update-only-one-component-in-a-vector-fespace/2560/2 "2023-06-27T06:44:32Z")

</div>

Maybe this is what you are looking for?

> [ux,uy,z] = [ux,uy, z\*(z\<=1)+1\*(z\>1))];

---

<div class="post-metadata">

**Author:** ![clthu](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@clthu](https://community.freefem.org/u/clthu)\
**Post date:** [June 27, 2023, 12:07pm UTC](https://community.freefem.org/t/update-only-one-component-in-a-vector-fespace/2560/3 "2023-06-27T12:07:27Z")

</div>

It really works！！！  
Thank you~
