Circle moving in a velocity field Matlab
Is there anyway to code a blob moving in from a smaller pipe to a larger pipe in matlab, when the velocity fields at a particular point is known. It doesn't have to be an animation. Just figures at different time step. So, the final figure would look something like this. Thanks
See also questions close to this topic

(MATLAB) How to alter Z axis (incorporate twist) into a stacked 2D voxel plot
I am creating a 3D vertical axis turbine using voxels, I have created a 2D surface or my design and then stacked it several times to create the VAWT. Is there a way to alter each level as it gets placed to create a spiral effect.
I am currently using the repmat function to "extrude" my 2D plane, is there a different function which will input a helix like pitch angle ?
% Extruding the base vertically
volume=repmat(base,1,1,nvz);

Printing html links/anchors in Matlab command window to files with spaces in path
The problem
When I run the following line in Matlab
sprintf('<a href="matlab:system(''start %s'');">%s</a>', url, text)
I get a clickable link in the Matlab command window. Which I use to allow the user to easily open: .png, .pdf or .html files on Windows
The problem start when the url contains whitespaces? Yes some of the users of the software likes to use spaces in paths...
What I Have Tried
None of the examples in the following script is working...
url = 'C:\Temp\path with space\test.htm'; text = 'test.htm' disp(sprintf('<a href="matlab:system(''start %s'');">%s</a>', url, text)); disp(sprintf('<a href="matlab:system(''start "%s"'');">%s</a>', url, text)); disp(sprintf('<a href="matlab:system(''start "%s"'');">%s</a>', url, text)); disp(sprintf('<a href="matlab:system([''start '' char(34) ''%s'' char(34)]);">%s</a>', url, text));

I need to optimize some parameters and the relation between them in matlab
I have parameter Z with definite value and four other parameters including "A,B,C,D" that Z is related to these parameters.How can I find an optimized combination of four parameters which are mentioned above to obtain the nearest value to the Z and the relation between these 5 parameters? I would be so thankful if anybody could help me.

What is correct syntax for limits of xaxis and yaxis when using fplot?
INPUT
disp('Solution Domain Range Input') prompt='lims='; lims=input(prompt); disp(' ')
OUTPUT Solution Domain Range Input
lims=[3 3 ] works fine, x axis range is from 3 to 3
also tried
lims=[3 3 3 3 ] gives error message
...
INPUT
odes = diff(Y)== A*Y + B [xSol(t), ySol(t)] = dsolve(odes); xSolvpa = vpa(xSol) ySolvpa = vpa(ySol) fplot(xSolvpa, lims) hold on fplot(ySolvpa,lims)
ERROR MSG
Error using fplot (line 145) Invalid parameter '3 3 ...'.
How to do? MM

Is it possible to change the 'colormap' scale in matlab?
I have a matrix with numbers would like to display an image with a different color for the numbers of the matrix. My problem is the following: I have 2 matrix. Matrix A contains values between 0 and 1 and matrix B contains values between 0 and 90. When I use the 'colormap' function with :
figure;colormap(jet);imshow(A);
The image displayed has several levels of gray, when I am supposed to have several colours (because I am using jet). When I use the 'colormap' function with :
figure;colormap(jet);imshow(B);
The image displayed is just completely white, probably because my values are higher than 64 (which is the max of jet).
How can I solve these two problems ? I rode a lot of tutos in several forums but I can't find the answer...
Thank you very much for answering my problem!

How to display contours of 2D data onto a (x,y,z) 3D plane of choice?
I am plotting the contours of a
2D matrix
inMatlab
. By default, the contours are laid on a (x,y) plane. Also by default, the (x,y) plane is located on the vertical level z = 0 in the3D space
.I am looking for a solution to display the 2D slice onto a (y,z) plane with a x value of my choice. That is to say I am trying to display the 2D horizontal slice as a 'vertical curtain' of which position on the x axis I choose.
I tried creating a
2D grid
and add to it a third grid at a chosen x level:[y,z] = meshgrid(coord1,coord2); % the 2D grid xlevel = 2; x = xlevel.*ones(size(y)); % the third grid
I was able to successfully use this grid to display the data using:
surf(x,y,z,data)
This produces the result I need, but it is a
surf
plot, not acontourf
plot. Thecontourf
function produces the following error message when given the same arguments:contourf(x,y,z,data)
Error using contourf (line 61)
Contour level values must be a vector or a scalar.
because the third argument (
z
) is treated as the data to display and the fourth argument (data
) is treated as the value of the contours/isolines to display (that's where the error message is created).For a reason I do not understand, the following does not produce an error message (but nothing is displayed either):
contourf(x,y,z,data,30)
Any ideas to use
contourf
to achieve the same result as what I get withsurf
?