From making 2D line plots to making 3D surface plots: How to preserve my current workflow?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
0 votes
- I would like to continue looping through beta;
- To keep things organized and de-cluttered, I would like to continue calling my functions which are stored in separate files;
- For doing careful mathematics, I would like to continue expressing vectors as linear combinations of basis vectors; and
- I would like to keep all the functions to be plotted scalar-valued.
Accepted Answer
29 Comments
Hi Star Strider!
Yes the third coordinate of ip and jp is zero; my problem is quasi-2D.
The issue is, say I have this
velocity = vx * ip + vy * jp,
where vx = cos(beta)*sin(alpha),
and vy is something similar.
The surface plot will be against beta and alpha, so I write
beta = linspace(0,pi,20)
alpha = (0,pi/2,100).
But now, vx * ip gives the error that arrays are incompatible.
Sorry for the late response: I think I’ll loop through Beta?
Set theta = 0, since my model is invariant to changes in theta.

Hi Star Strider!
Can I loop through both beta and alpha? Also, my function is in a separate function file, which my surface plotting code calls. Does this cause issues? Should I instead keep my function locally defined within my surface plotting code? Thanks!
Hi Star Strider,
For making surface plots, I have to use Beta and Alpha, the outputs from meshgrid(alpha, beta), as inputs to the functions. But before I get to the functions I want to code up terms, which are vectors, as linear combinations of rotating basis vectors. Matlab is telling me about arrays having incompatible sizes, when I try to do this, because Beta is a vector, Alpha is a vector, and a rotating basis vector is a vector. This is tricky to get right, in contrast to making simple line plots, where I didn’t have much issues. I’m a little frustrated with myself. I’m going to try again tomorrow. Goodnight, and thanks for your time!
- I would like to continue looping through beta;
- To keep things organized and de-cluttered, I would like to continue calling my functions which are stored in separate files; and
- For doing careful mathematics, I would like to continue expressing vectors as linear combinations of basis vectors, etc.


More Answers (1)

Categories
Find more on Matrix Indexing in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)