メインコンテンツ

Results for


Teodo
Teodo
Last activity 2024 年 11 月 5 日 21:55

Here presented MATLAB code is designed to create a seamless loop animation that visualizes an isosurface derived from random data.
This entry, titled "The Scrambled Predator's Cube", builds upon my previous work and has been adapted to include dynamic elements.
MATLAB Shorts Mini Hack: The Scrambled Predator's Cube
In this explanation, I will break down the relatively short code, making it accessible whether you are a beginner in MATLAB or an experienced user. Let's go through the MATLAB code step by step to understand each line in detail.
Code Breakdown
d = rand(8,8,8);
Random Data Generation: This line creates a three-dimensional array d with dimensions 8×8×8 filled with random values. The rand function generates values uniformly distributed in the interval (0,1). This array serves as the input data for generating the isosurface.
iv = .5 + (f / 10000);
Isovalue Calculation: Here, the isovalue iv is computed based on the frame number f. The expression f / 10000 causes iv to increase very slowly as f increments. Starting from 0.50, this means that for every increment of f, iv changes slightly (specifically, by 0.0001). This gradual increase creates a smooth transition effect in the isosurface over time, making it look dynamic as the animation progresses.
h = patch(isosurface(d, iv), 'FaceColor', 'blue', 'EdgeColor', 'none');
Isosurface Creation: The isosurface function extracts a 3D surface from the data array d at the specified isovalue iv. The result is a patch object h that represents the isosurface in the 3D plot. The 'FaceColor', 'blue' argument sets the face color of the surface to blue, while 'EdgeColor', 'none' specifies that no edges should be drawn, giving the surface a solid appearance.
isonormals(d, h);
Surface Normals Calculation: This function calculates the normals at each vertex of the isosurface h, based on the data in d. Normals are vectors perpendicular to the surface at each point and are crucial for proper lighting calculations. By using isonormals, the appearance of depth and texture is enhanced, allowing the lighting to interact more realistically with the surface.
patch(isocaps(d, iv), 'FaceColor', 'interp', 'EdgeColor', 'none');
Isocaps Visualization: The isocaps function creates flat surfaces (caps) at the boundaries of the isosurface where the data values meet the isovalue iv. The resulting caps are then rendered as patches with 'FaceColor', 'interp', meaning the colors of the caps are interpolated based on the data values. The caps provide a more complete visual representation of the isosurface, improving its overall appearance.
colormap hsv;
Color Map Setup: This line sets the colormap of the current figure to HSV (Hue, Saturation, Value). The HSV colormap allows for a wide range of colors, which can enhance the visual appeal of the rendering by mapping different values in the data to different colors.
daspect([1, 1, 1]);
Aspect Ratio Setting: The daspect function sets the data aspect ratio of the plot to be equal in all three dimensions. This means that one unit in the x-direction is the same length as one unit in the y-direction and z-direction, ensuring that the visual representation of the 3D data is not distorted.
axis tight;
Tight Axis Setting: This command adjusts the limits of the axes so that they fit tightly around the data, removing any excess white space. It helps to focus the viewer's attention on the isosurface and related visual elements.
view(3);
3D View Configuration: The view(3) command sets the current view to a 3D perspective, allowing the viewer to see the structure of the isosurface from an angle that reveals its three-dimensional nature.
camlight right;
camlight left;
Lighting Effects: These commands add two light sources to the scene, positioned to the right and left of the view. The additional lighting enhances the shading and depth perception of the isosurface, making it appear more three-dimensional and visually appealing.
axis off;
Hide Axes: This command turns off the display of the axes in the plot. Removing the axes provides a cleaner visual representation, allowing the viewer to focus solely on the isosurface and its lighting effects without distraction from the grid lines or axis labels.
lighting phong;
Lighting Model: This line sets the lighting model to Phong. The Phong model is widely used in computer graphics as it provides smooth shading and realistic reflections. It calculates how light interacts with surfaces, enhancing the overall appearance by creating a more natural look.
MATLAB Shorts Mini Hack: The Scrambled Predator's Cube
This code creates a visually dynamic and appealing representation of an isosurface derived from random data. The gradual change in the isovalue allows for smooth transitions, while the combination of lighting, colors, and shading contributes to a rich 3D visualization. Each component plays a vital role in rendering the final output, showcasing advanced techniques in data visualization using MATLAB.
Edgar Guevara
Edgar Guevara
Last activity 2024 年 10 月 15 日

I'd like to share some tips about the 2024 mini hack contest, specifically related to audio:
  1. First (and most important), credit your source: unless you are composing your own audio, I think it's important to give credit to the original sources. It is a little sad to see several contributions with an empty line:
'Cite your audio source here (if applicable):'
  1. A great place to get royalty-free and high-quality music and audio (among other media) is https://pixabay.com. Be sure to check it out! I used one of their audio clips in my submission EKG pulse
  2. The right music can enhance the overall experience of your animation. Sometimes getting the animation to match the music beat can be hard. I suggest you try the other way around: get your music/sound effects to match the animation rhythm with a little editing. A free audio editor with many capabilities (more than enough for this contest, I think) is https://www.audacityteam.org/
  3. Choose a 4-second audio clip with a consistent tempo and seamless loop points, ensuring it complements your animation's mood and loops smoothly over 12 seconds without abrupt changes.
I think that when the right music is paired with the right animation, it can create a more impactful experience.
Safin
Safin
Last activity 2024 年 10 月 14 日

Well, this is my first time to participate in such community competitions and guess what, I've gone for 4 submissions so far (Feels Great!!)
So I wanna share some tricks that I followed for my first submission named Happy Shaping' ( Go Check it out!!):
1. Dynamic Background Color Change:
  • Technique: The background color of the figure window is gradually changed using sine and cosine functions.
  • Reason: These trigonometric functions (sin and cos) create smooth, oscillating transitions over time, which gives a fluid effect to the background's color shift.
  • Implementation:
Color = [0.1 + 0.5*abs(sin(f/10)), 0.1 + 0.5*abs(cos(f/15)), 0.9 -
0.5*abs(sin(f/20))];
  • Benefit: This introduces a smooth, visually appealing animation effect.
2. Smooth Object Motion Using Sine and Cosine:
  • Technique: The position and shape of objects are based on trigonometric functions.
  • Reason: Using sin(t) and cos(t) ensures that the movement is circular or elliptical, creating continuous and natural motion in animations.
  • Implementation (for object position):
x = 10 * cos(t * 2 * pi) * (1 + 0.5 * sin(t * pi));
y = 10 * sin(t * 2 * pi) * (1 + 0.5 * cos(t * pi));
  • Benefit: Circular and smooth motions are pleasing and easily controlled by tweaking the frequency and phase of sine/cosine functions.
3. Polygon Shape Changing Over Time:
  • Technique: The number of sides of the polygon (sides) changes dynamically based on t.
  • Reason: It creates variation in shape, maintaining user interest as the shape transitions from a triangle to a hexagon.
  • Implementation:
sides = 3 + round(3 * abs(sin(t)));
  • Benefit: This provides dynamic shape transitions over time, keeping the animation non-static.
4. Use of the fill Function for Color-Filled Shapes:
  • Technique: The fill function is used to draw a polygon with smoothly changing colors.
  • Reason: Filling polygons with varying colors based on time (t) allows for continuous color transitions, adding more complexity to the animation.
  • Implementation:
fill(xp, yp, c, 'EdgeColor', 'none');
  • Benefit: Combining both color changes and shape changes enhances the visual impact.
5. Consistent Use of hold on and hold off:
  • Technique: hold on allows multiple graphic objects to be drawn on the same axes without clearing previous objects.
  • Reason: This is crucial for drawing multiple elements (like polygons, circles, and lines) on the same figure.
  • Benefit: It helps manage and layer different graphical elements effectively within the same frame.
6. Use of rectangle for a Smooth Ball Motion:
  • Technique: The ball's motion is defined by rectangle with a Curvature of [1, 1] to make it circular.
  • Reason: Using the rectangle function simplifies the process of drawing a filled circle, and controlling its position and size is intuitive.
  • Benefit: It provides a straightforward way to animate circular objects within the plot.
7. Animating the Connection Line:
  • Technique: A white dashed line (w--) is drawn between the polygon and the moving ball to show a connection between these objects.
  • Reason: This adds interactivity to the scene, as it gives the impression that the polygon and the ball are related or connected in some way.
  • Implementation:
plot([x bx], [y by], 'w--', 'LineWidth', 2);
  • Benefit: A dynamic element that adds depth and narrative to the animation, guiding the viewer’s attention.
8. Frame Synchronization with Time (f and t):
  • Technique: The variable f is used as a frame number, while t = f / 24 creates a link between frame and time.
  • Reason: Ensuring smooth and continuous transitions in the animation over time is critical, so f acts as the control for time-based changes in shape, color, and position.
  • Benefit: This makes it easy to manage frame rates and time-based updates for the animation.
I composed 30 sound loops for use in the Mini Hack.
If you like them, please feel free to use them for free.
Try to install MATLAB2024a on Ubuntu24.04. In the image below, the button indicated by the green arrow is clickable, while the button indicated by the red arrow are unclickable, and input field where text cannot be entered, preventing the installation.
Let's say you have a chance to ask the MATLAB leadership team any question. What would you ask them?
What is the side-effect of counting the number of Deep Learning Toolbox™ updates in the last 5 years? The industry has slowly stabilised and matured, so updates have slowed down in the last 1 year, and there has been no exponential growth.Is it correct to assume that? Let's see what you think!
releaseNumNames = "R"+string(2019:2024)+["a";"b"];
releaseNumNames = releaseNumNames(:);
numReleaseNotes = [10,14,27,39,38,43,53,52,55,57,46,46];
exampleNums = [nan,nan,nan,nan,nan,nan,40,24,22,31,24,38];
bar(releaseNumNames,[numReleaseNotes;exampleNums]')
legend(["#release notes","#new/update examples"],Location="northwest")
title("Number of Deep Learning Toolbox™ update items in the last 5 years")
ylabel("#release notes")
Mike Croucher
Mike Croucher
Last activity 2024 年 9 月 15 日

Hot off the heels of my High Performance Computing experience in the Czech republic, I've just booked my flights to Atlanta for this year's supercomputing conference at SC24.
Will any of you be there?
John D'Errico
John D'Errico
Last activity 2024 年 11 月 8 日 14:47

syms u v
atan2alt(v,u)
ans = 
function Z = atan2alt(V,U)
% extension of atan2(V,U) into the complex plane
Z = -1i*log((U+1i*V)./sqrt(U.^2+V.^2));
% check for purely real input. if so, zero out the imaginary part.
realInputs = (imag(U) == 0) & (imag(V) == 0);
Z(realInputs) = real(Z(realInputs));
end
As I am editing this post, I see the expected symbolic display in the nice form as have grown to love. However, when I save the post, it does not display. (In fact, it shows up here in the discussions post.) This seems to be a new problem, as I have not seen that failure mode in the past.
You can see the problem in this Answer forum response of mine, where it did fail.
goc3
goc3
Last activity 2024 年 11 月 11 日 13:56

I was browsing the MathWorks website and decided to check the Cody leaderboard. To my surprise, William has now solved 5,000 problems. At the moment, there are 5,227 problems on Cody, so William has solved over 95%. The next competitor is over 500 problems behind. His score is also clearly the highest, approaching 60,000.
Please take a moment to congratulate @William.
Has this been eliminated? I've been at 31 or 32 for 30 days for awhile, but no badge. 10 badge was automatic.

Formal Proof of Smooth Solutions for Modified Navier-Stokes Equations

1. Introduction

We address the existence and smoothness of solutions to the modified Navier-Stokes equations that incorporate frequency resonances and geometric constraints. Our goal is to prove that these modifications prevent singularities, leading to smooth solutions.

2. Mathematical Formulation

2.1 Modified Navier-Stokes Equations

Consider the Navier-Stokes equations with a frequency resonance term R(u,f)\mathbf{R}(\mathbf{u}, \mathbf{f})R(u,f) and geometric constraints:

∂u∂t+(u⋅∇)u=−∇pρ+ν∇2u+R(u,f)\frac{\partial \mathbf{u}}{\partial t} + (\mathbf{u} \cdot \nabla) \mathbf{u} = -\frac{\nabla p}{\rho} + \nu \nabla^2 \mathbf{u} + \mathbf{R}(\mathbf{u}, \mathbf{f})∂t∂u​+(u⋅∇)u=−ρ∇p​+ν∇2u+R(u,f)

where:

• u=u(t,x)\mathbf{u} = \mathbf{u}(t, \mathbf{x})u=u(t,x) is the velocity field.

• p=p(t,x)p = p(t, \mathbf{x})p=p(t,x) is the pressure field.

• ν\nuν is the kinematic viscosity.

• R(u,f)\mathbf{R}(\mathbf{u}, \mathbf{f})R(u,f) represents the frequency resonance effects.

• f\mathbf{f}f denotes external forces.

2.2 Boundary Conditions

The boundary conditions are:

u⋅n=0 on Γ\mathbf{u} \cdot \mathbf{n} = 0 \text{ on } \Gammau⋅n=0 on Γ

where Γ\GammaΓ represents the boundary of the domain Ω\OmegaΩ, and n\mathbf{n}n is the unit normal vector on Γ\GammaΓ.

3. Existence and Smoothness of Solutions

3.1 Initial Conditions

Assume initial conditions are smooth:

u(0)∈C∞(Ω)\mathbf{u}(0) \in C^{\infty}(\Omega)u(0)∈C∞(Ω) f∈L2(Ω)\mathbf{f} \in L^2(\Omega)f∈L2(Ω)

3.2 Energy Estimates

Define the total kinetic energy:

E(t)=12∫Ω∣u(t)∣2 dΩE(t) = \frac{1}{2} \int_{\Omega} \mathbf{u}(t)^2 \, d\OmegaE(t)=21​∫Ω​∣u(t)∣2dΩ

Differentiate E(t)E(t)E(t) with respect to time:

dE(t)dt=∫Ωu⋅∂u∂t dΩ\frac{dE(t)}{dt} = \int_{\Omega} \mathbf{u} \cdot \frac{\partial \mathbf{u}}{\partial t} \, d\OmegadtdE(t)​=∫Ω​u⋅∂t∂u​dΩ

Substitute the modified Navier-Stokes equation:

dE(t)dt=∫Ωu⋅[−∇pρ+ν∇2u+R] dΩ\frac{dE(t)}{dt} = \int_{\Omega} \mathbf{u} \cdot \left[ -\frac{\nabla p}{\rho} + \nu \nabla^2 \mathbf{u} + \mathbf{R} \right] \, d\OmegadtdE(t)​=∫Ω​u⋅[−ρ∇p​+ν∇2u+R]dΩ

Using the divergence-free condition (∇⋅u=0\nabla \cdot \mathbf{u} = 0∇⋅u=0):

∫Ωu⋅∇pρ dΩ=0\int_{\Omega} \mathbf{u} \cdot \frac{\nabla p}{\rho} \, d\Omega = 0∫Ω​u⋅ρ∇p​dΩ=0

Thus:

dE(t)dt=−ν∫Ω∣∇u∣2 dΩ+∫Ωu⋅R dΩ\frac{dE(t)}{dt} = -\nu \int_{\Omega} \nabla \mathbf{u}^2 \, d\Omega + \int_{\Omega} \mathbf{u} \cdot \mathbf{R} \, d\OmegadtdE(t)​=−ν∫Ω​∣∇u∣2dΩ+∫Ω​u⋅RdΩ

Assuming R\mathbf{R}R is bounded by a constant CCC:

∫Ωu⋅R dΩ≤C∫Ω∣u∣ dΩ\int_{\Omega} \mathbf{u} \cdot \mathbf{R} \, d\Omega \leq C \int_{\Omega} \mathbf{u} \, d\Omega∫Ω​u⋅RdΩ≤C∫Ω​∣u∣dΩ

Applying the Poincaré inequality:

∫Ω∣u∣2 dΩ≤Const⋅∫Ω∣∇u∣2 dΩ\int_{\Omega} \mathbf{u}^2 \, d\Omega \leq \text{Const} \cdot \int_{\Omega} \nabla \mathbf{u}^2 \, d\Omega∫Ω​∣u∣2dΩ≤Const⋅∫Ω​∣∇u∣2dΩ

Therefore:

dE(t)dt≤−ν∫Ω∣∇u∣2 dΩ+C∫Ω∣u∣ dΩ\frac{dE(t)}{dt} \leq -\nu \int_{\Omega} \nabla \mathbf{u}^2 \, d\Omega + C \int_{\Omega} \mathbf{u} \, d\OmegadtdE(t)​≤−ν∫Ω​∣∇u∣2dΩ+C∫Ω​∣u∣dΩ

Integrate this inequality:

E(t)≤E(0)−ν∫0t∫Ω∣∇u∣2 dΩ ds+CtE(t) \leq E(0) - \nu \int_{0}^{t} \int_{\Omega} \nabla \mathbf{u}^2 \, d\Omega \, ds + C tE(t)≤E(0)−ν∫0t​∫Ω​∣∇u∣2dΩds+Ct

Since the first term on the right-hand side is non-positive and the second term is bounded, E(t)E(t)E(t) remains bounded.

3.3 Stability Analysis

Define the Lyapunov function:

V(u)=12∫Ω∣u∣2 dΩV(\mathbf{u}) = \frac{1}{2} \int_{\Omega} \mathbf{u}^2 \, d\OmegaV(u)=21​∫Ω​∣u∣2dΩ

Compute its time derivative:

dVdt=∫Ωu⋅∂u∂t dΩ=−ν∫Ω∣∇u∣2 dΩ+∫Ωu⋅R dΩ\frac{dV}{dt} = \int_{\Omega} \mathbf{u} \cdot \frac{\partial \mathbf{u}}{\partial t} \, d\Omega = -\nu \int_{\Omega} \nabla \mathbf{u}^2 \, d\Omega + \int_{\Omega} \mathbf{u} \cdot \mathbf{R} \, d\OmegadtdV​=∫Ω​u⋅∂t∂u​dΩ=−ν∫Ω​∣∇u∣2dΩ+∫Ω​u⋅RdΩ

Since:

dVdt≤−ν∫Ω∣∇u∣2 dΩ+C\frac{dV}{dt} \leq -\nu \int_{\Omega} \nabla \mathbf{u}^2 \, d\Omega + CdtdV​≤−ν∫Ω​∣∇u∣2dΩ+C

and R\mathbf{R}R is bounded, u\mathbf{u}u remains bounded and smooth.

3.4 Boundary Conditions and Regularity

Verify that the boundary conditions do not induce singularities:

u⋅n=0 on Γ\mathbf{u} \cdot \mathbf{n} = 0 \text{ on } \Gammau⋅n=0 on Γ

Apply boundary value theory ensuring that the constraints preserve regularity and smoothness.

4. Extended Simulations and Experimental Validation

4.1 Simulations

• Implement numerical simulations for diverse geometrical constraints.

• Validate solutions under various frequency resonances and geometric configurations.

4.2 Experimental Validation

• Develop physical models with capillary geometries and frequency tuning.

• Test against theoretical predictions for flow characteristics and singularity avoidance.

4.3 Validation Metrics

Ensure:

• Solution smoothness and stability.

• Accurate representation of frequency and geometric effects.

• No emergence of singularities or discontinuities.

5. Conclusion

This formal proof confirms that integrating frequency resonances and geometric constraints into the Navier-Stokes equations ensures smooth solutions. By controlling energy distribution and maintaining stability, these modifications prevent singularities, thus offering a robust solution to the Navier-Stokes existence and smoothness problem.

J.K043006
J.K043006
Last activity 2024 年 8 月 29 日

I've been working on some matrix problems recently(Problem 55225)
and this is my code
It turns out that "Undefined function 'corr' for input arguments of type 'double'." However, should't the input argument of "corr" be column vectors with single/double values? What's even going on there?
Matthew Rademacher
Matthew Rademacher
Last activity 2024 年 8 月 19 日

So generally I want to be using uifigures over figures. For example I really like the tab group component, which can really help with organizing large numbers of plots in a manageable way. I also really prefer the look of the progress dialog, uialert, confirm, etc. That said, I run into way more bugs using uifigures. I always get a “flicker” in the axes toolbar for example. I also have matlab getting “hung” a lot more often when using uifigures.

So in general, what is recommended? Are uifigures ever going to fully replace traditional figures? Are they going to become more and more robust? Do I need a better GPU to handle graphics better? Just looking for general guidance.

Salam Surjit
Salam Surjit
Last activity 2024 年 11 月 3 日 12:49

Hi everyone, I am from India ..Suggest some drone for deploying code from Matlab.
Zahraa
Zahraa
Last activity 2024 年 8 月 14 日

Hello :-) I am interested in reading the book "The finite element method for solid and structural mechanics" online with somebody who is also interested in studying the finite element method particularly its mathematical aspect. I enjoy discussing the book instead of reading it alone. Please if you were interested email me at: student.z.k@hotmail.com Thank you!
David
David
Last activity 2024 年 8 月 8 日

A library of runnable PDEs. See the equations! Modify the parameters! Visualize the resulting system in your browser! Convenient, fast, and instructive.

Hi everyone,

I've recently joined a forest protection team in Greece, where we use drones for various tasks. This has sparked my interest in drone programming, and I'd like to learn more about it. Can anyone recommend any beginner-friendly courses or programs that teach drone programming?

I'm particularly interested in courses that focus on practical applications and might align with the work we do in forest protection. Any suggestions or guidance would be greatly appreciated!

Thank you!

I have picked the title but don't know which direction to take it. Looking for any and all inspiration. I took the project as it sounded interesting when reading into it, but I'm a satellite novice, and my degree is in electronics.