# We can access MATLAB's powerful fsurf charts using fig2plotly!

**URL:** https://community.plotly.com/t/we-can-access-matlabs-powerful-fsurf-charts-using-fig2plotly/56734
**Category:** Plotly for MATLAB®
**Created:** [September 18, 2021, 12:34pm UTC](https://community.plotly.com/t/we-can-access-matlabs-powerful-fsurf-charts-using-fig2plotly/56734 "2021-09-18T12:34:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gilbertogalvis](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/gilbertogalvis/32/16377_2.png) [@gilbertogalvis](https://community.plotly.com/u/gilbertogalvis)
#### Post date: [September 18, 2021, 12:34pm UTC](https://community.plotly.com/t/we-can-access-matlabs-powerful-fsurf-charts-using-fig2plotly/56734/1 "2021-09-18T12:34:54Z")

</div>

Using MATLAB we can incredibly plot 3-D surfaces just by entering a _mathematical expression_ given by  
`z = f(x, y)`. We can do this using the MATLAB function `fsurf`.

Now, depending on the mathematical expression that we pass as the input argument in `fsurf`, MATLAB will show us really interesting 3-D surfaces. But, `fig2plotly` will go further 😃 🕶

To address the `fsurf` functionality, you just need to invoke `fig2plotly` at the end of your MATLAB code and set the optional `'offline'` parameter to `true` or `false`, depending on the **offline/online mode** you want to use. Let’s see the following example

```auto
r = @(u,v) 2 + sin(7.*u + 5.*v);
funx = @(u,v) r(u,v).*cos(u).*sin(v);
funy = @(u,v) r(u,v).*sin(u).*sin(v);
funz = @(u,v) r(u,v).*cos(v);
fsurf(funx,funy,funz,[0 2*pi 0 pi]) 
camlight;

fig2plotly(gcf, 'offline', false); % online mode

```

After executing the above code, the charts generated by MATLAB and `fig2plotly` are shown in the following image.

 ![Screen Shot 2021-09-13 at 4.22.56 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/2/72436bb8b61b997ca802faf8b43f35dbc7a7ee3a.jpeg)

As we can see, on the left of the screenshot above appears the surface plotted by MATLAB, but on the right we delight in the beauty of Plotly.

Following this [link](https://chart-studio.plotly.com/~galvisgilberto/4370/#/), you will be able to experience this directly in Chart-Studio.

[Here](https://github.com/plotly/ssim_baselines/tree/main/matlab/code-examples/surface-and-mesh-plots/fsurf) you can find more examples using `fsurf`, which you can recreate using `fig2plotly` . Please try to do it! I did it and was fascinated again! 😆 I attach below screenshots with results from my end

 ![Screen Shot 2021-09-13 at 4.21.38 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/1/c/1cd6b5fc0dfc371e33c057973d2c2810a0e17cf1.jpeg)  
 ![Screen Shot 2021-09-13 at 4.22.06 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/1/1/11997aa97bd30c85de6849d787c37fa381ad897f.jpeg)  
 ![Screen Shot 2021-09-13 at 4.23.40 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/1/3/1305cc0df9c30d2836e74ffd224a6f172940cccb.jpeg)  
 ![Screen Shot 2021-09-13 at 4.24.29 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/9/b/9b5a92f9456f7cf015084e72e03b12772ea81d79.jpeg)  
 ![Screen Shot 2021-09-13 at 4.25.06 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/d/c/dcbe896af712c336f57f7e21ac1cf02d42f7ccdd.jpeg)  
 ![Screen Shot 2021-09-13 at 4.25.41 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/8/f89db09e69b36b882dc7e02a06e0bad2e5614a6d.jpeg)  
 ![Screen Shot 2021-09-13 at 4.26.13 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/4/a/4a890d9843b6899c1e6f2c7dd2a65e7f82e4a512.jpeg)  
 ![Screen Shot 2021-09-13 at 4.26.42 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/2/0/20826254fa7bed0d62d40eb169999cfcc0d90fa9.jpeg)  
 ![Screen Shot 2021-09-13 at 4.27.14 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/2/b/2b818db987a4a9ae651174b30e66abc9119c3d35.jpeg)  
 ![Screen Shot 2021-09-13 at 4.27.44 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/e/7efa3502bb56bd563e8894ff2860cabbb1ec8ceb.jpeg)
