主要内容
Results for
You reached this milestone by providing valuable contribution to the community since you started answering questions in Since September 2011.
You were very active in the first year, and took some break, but you steadily rose ranks in the recent years to achieve this milestone.
You provided 3954 answers and received 1503 votes. You are ranked #25 in the community. Thank you for your contribution to the community and please keep up the good track record!
MATLAB Central Team
In honor of National Pet Day on April 11th, we're excited to announce a fun contest that combines two of our favorite things: our beloved pets and our passion for MATLAB/Simulink! Whether you're a cat enthusiast, a dog lover, or a companion to any other pet, we invite you to join in the fun and showcase your creativity.
How to Participate:
- Take a photo of your pet featuring any element of MATLAB/Simulink.
- Post it in the Fun channel of the Discussions area.
- Include a brief description or story behind the photo - we love to hear about your pets and your creative process!
🏆 Prizes:
We will be selecting 3 winners for this contest, and each winner will receive a MathWorks T-shirt or hat! Winners will be chosen based on creativity, originality, and how well they incorporate the MATLAB/Simulink element into their photo.
📅Important Dates:
Contest ends on April 12th, 2024, at 11:59:59 pm, Eastern Time
We can't wait to see all of your adorable and creative pet photos. Let's celebrate National Pet Day in true MathWorks style. Good luck, and most importantly, have fun!
What's the weather like in your place?
I'm excited to share some valuable resources that I've found to be incredibly helpful for anyone looking to enhance their MATLAB skills. Whether you're just starting out, studying as a student, or are a seasoned professional, these guides and books offer a wealth of information to aid in your learning journey.
These materials are freely available and can be a great addition to your learning resources. They cover a wide range of topics and are designed to help users at all levels to improve their proficiency in MATLAB.
Happy learning and I hope you find these resources as useful as I have!
I found this link posted on Reddit.
https://workhunty.com/job-blog/where-is-the-best-place-to-be-a-programmer/Matlab/
Let S be the closed surface composed of the hemisphere and the base Let be the electric field defined by . Find the electric flux through S. (Hint: Divide S into two parts and calculate ).
% Define the limits of integration for the hemisphere S1
theta_lim = [-pi/2, pi/2];
phi_lim = [0, pi/2];
% Perform the double integration over the spherical surface of the hemisphere S1
% Define the electric flux function for the hemisphere S1
flux_function_S1 = @(theta, phi) 2 * sin(phi);
electric_flux_S1 = integral2(flux_function_S1, theta_lim(1), theta_lim(2), phi_lim(1), phi_lim(2));
% For the base of the hemisphere S2, the electric flux is 0 since the electric
% field has no z-component at the base
electric_flux_S2 = 0;
% Calculate the total electric flux through the closed surface S
total_electric_flux = electric_flux_S1 + electric_flux_S2;
% Display the flux calculations
disp(['Electric flux through the hemisphere S1: ', num2str(electric_flux_S1)]);
disp(['Electric flux through the base of the hemisphere S2: ', num2str(electric_flux_S2)]);
disp(['Total electric flux through the closed surface S: ', num2str(total_electric_flux)]);
% Parameters for the plot
radius = 1; % Radius of the hemisphere
% Create a meshgrid for theta and phi for the plot
[theta, phi] = meshgrid(linspace(theta_lim(1), theta_lim(2), 20), linspace(phi_lim(1), phi_lim(2), 20));
% Calculate Cartesian coordinates for the points on the hemisphere
x = radius * sin(phi) .* cos(theta);
y = radius * sin(phi) .* sin(theta);
z = radius * cos(phi);
% Define the electric field components
Ex = 2 * x;
Ey = 2 * y;
Ez = 2 * z;
% Plot the hemisphere
figure;
surf(x, y, z, 'FaceAlpha', 0.5, 'EdgeColor', 'none');
hold on;
% Plot the electric field vectors
quiver3(x, y, z, Ex, Ey, Ez, 'r');
% Plot the base of the hemisphere
[x_base, y_base] = meshgrid(linspace(-radius, radius, 20), linspace(-radius, radius, 20));
z_base = zeros(size(x_base));
surf(x_base, y_base, z_base, 'FaceColor', 'cyan', 'FaceAlpha', 0.3);
% Additional plot settings
colormap('cool');
axis equal;
grid on;
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Hemisphere and Electric Field');
I feel like no one at UC San Diego knows this page, let alone this server, is still live. For the younger generation, this is what the whole internet used to look like :)
In short: support varying color in at least the plot, plot3, fplot, and fplot3 functions.
This has been a thing that's come up quite a few times, and includes questions/requests by users, workarounds by the community, and workarounds presented by MathWorks -- examples of each below. It's a feature that exists in Python's Matplotlib library and Sympy. Anyways, given that there are myriads of workarounds, it appears to be one of the most common requests for Matlab plots (Matlab's plotting is, IMO, one of the best features of the product), the request precedes the 21st century, and competitive tools provide the functionality, it would seem to me that this might be the next great feature for Matlab plotting.
I'm curious to get the rest of the community's thoughts... what's everyone else think about this?
---
User questions/requests
- https://www.mathworks.com/matlabcentral/answers/480389-colored-line-plot-according-to-a-third-variable
- https://www.mathworks.com/matlabcentral/answers/2092641-how-to-solve-a-problem-with-the-generation-of-multiple-colored-segments-on-one-line-in-matlab-plot
- https://www.mathworks.com/matlabcentral/answers/5042-how-do-i-vary-color-along-a-2d-line
- https://www.mathworks.com/matlabcentral/answers/1917650-how-to-plot-a-trajectory-with-varying-colour
- https://www.mathworks.com/matlabcentral/answers/1917650-how-to-plot-a-trajectory-with-varying-colour
- https://www.mathworks.com/matlabcentral/answers/511523-how-to-create-plot3-varying-color-figure
- https://www.mathworks.com/matlabcentral/answers/393810-multiple-colours-in-a-trajectory-plot
- https://www.mathworks.com/matlabcentral/answers/523135-creating-a-rainbow-colour-plot-trajectory
- https://www.mathworks.com/matlabcentral/answers/469929-how-to-vary-the-color-of-a-dynamic-line
- https://www.mathworks.com/matlabcentral/answers/585011-how-could-i-adjust-the-color-of-multiple-lines-within-a-graph-without-using-the-default-matlab-colo
- https://www.mathworks.com/matlabcentral/answers/517177-how-to-interpolate-color-along-a-curve-with-specific-colors
- https://www.mathworks.com/matlabcentral/answers/281645-variate-color-depending-on-the-y-value-in-plot
- https://www.mathworks.com/matlabcentral/answers/439176-how-do-i-vary-the-color-along-a-line-in-polar-coordinates
- https://www.mathworks.com/matlabcentral/answers/1849193-creating-rainbow-coloured-plots-in-3d
- https://groups.google.com/g/comp.soft-sys.matlab/c/cLgjSeEC15I?hl=en&pli=1 (a question asked in 1999!)
- ... the list goes on, and on, and on...
User-provided workarounds
- https://undocumentedmatlab.com/articles/plot-line-transparency-and-color-gradient
- https://www.mathworks.com/matlabcentral/fileexchange/19476-colored-line-or-scatter-plot
- https://www.mathworks.com/matlabcentral/fileexchange/23566-3d-colored-line-plot
- https://www.mathworks.com/matlabcentral/fileexchange/30423-conditionally-colored-line-plot
- https://www.mathworks.com/matlabcentral/fileexchange/14677-cline
- https://www.mathworks.com/matlabcentral/fileexchange/8597-plot-3d-color-line
- https://www.mathworks.com/matlabcentral/fileexchange/39972-colormapline-color-changing-2d-or-3d-line
- https://www.mathworks.com/matlabcentral/fileexchange/37725-conditionally-colored-plot-ccplot
- https://www.mathworks.com/matlabcentral/fileexchange/11611-linear-2d-plot-with-rainbow-color
- https://www.mathworks.com/matlabcentral/fileexchange/26692-color_line
- https://www.mathworks.com/matlabcentral/fileexchange/32911-plot3rgb
- And perhaps more?
MathWorks-provided workarounds
- https://www.mathworks.com/videos/coloring-a-line-based-on-height-gradient-or-some-other-value-in-matlab-97128.html
- https://www.mathworks.com/videos/making-a-multi-color-line-in-matlab-97127.html
- https://www.mathworks.com/matlabcentral/fileexchange/95663-color-trajectory-plot (contributed by a MathWorks staff member)
- And perhaps more?
isempty( [ ] )
10%
isempty( { } )
13%
isempty( '' ) % 2 single quotes
13%
isempty( "" ) % 2 double quotes
24%
c = categorical( [ ] ); isempty(c)
18%
s = struct("a", [ ] ); isempty(s.a)
22%
1324 个投票
Looking for 10 candidates for a closed beta on new MATLAB live script features.
Do you use live scripts regularly in MATLAB? Do you collaborate with others using live scripts?
MathWorks is looking for 10 candidates for a closed beta on new features for live scripts. Help us develop exciting new features with your feedback.
If you are selected, you will receive an email invitation to sign an NDA
I will post here when the quota is filled
The image was created with DALL-E 3.
Hello, brilliant minds of our engineering community!
We hope this message finds you in the midst of an exciting project or, perhaps, deep in the realms of a challenging problem, because we've got some groundbreaking news that might just make your day a whole lot more interesting.
🎉 Introducing PreAnswer AI - The Future of Community Support! 🎉
Have you ever found yourself pondering over a complex problem, wishing for an answer to magically appear before you even finish formulating the question? Well, wish no more! The MathWorks team, in collaboration with the most imaginative minds from the realms of science fiction, is thrilled to announce the launch of PreAnswer AI, an unprecedented feature set to revolutionize the way we interact within our MATLAB and Simulink community.
What is PreAnswer AI?
PreAnswer AI is our latest AI-driven initiative designed to answer your questions before you even ask them. Yes, you read that right! Through a combination of predictive analytics, machine learning, and a pinch of engineering wizardry, PreAnswer AI anticipates the challenges you're facing and provides you with solutions, insights, and code snippets in real-time.
How Does It Work?
- Presentiment Algorithms: By simply logging into MATLAB Central, our AI begins to analyze your recent coding patterns, activity, and even the intensity of your keyboard strokes to understand your current state of mind.
- Predictive Insights: Using a complex algorithm, affectionately dubbed "The Oracle", PreAnswer AI predicts the questions you're likely to ask and compiles comprehensive answers from our vast database of resources.
- Efficiency and Speed: Imagine the time saved when the answers to your questions are already waiting for you. PreAnswer AI ensures you spend more time innovating and less time searching for solutions.
We are on the cusp of deploying PreAnswer AI in a beta phase and are eager for you to be among the first to experience its benefits. Your feedback will be invaluable as we refine this feature to better suit our community's needs.
---------------------------------------------------------------
Spoiler, it's April 1st if you hadn't noticed. While we might not (yet) have the technology to read minds or predict the future, we do have an incredible community filled with knowledgeable, supportive members ready to tackle any question you throw their way.
Let's continue to collaborate, innovate, and solve complex problems together, proving that while AI can do many things, the power of a united community of brilliant minds is truly unmatched.
Thank you for being such a fantastic part of our community. Here's to many more questions, answers, and shared laughs along the way.
Happy April Fools' Day!
More than 500,000 people have subscribed to the MATLAB channel. MathWorks would like to thank everyone who has taken the time to watch one of our videos, leave us a comment, or share our videos with others. Together we’re accelerating the pace of engineering and science.
Although, I think I will only get to see a partial eclipse (April 8th!) from where I am at in the U.S. I will always have MATLAB to make my own solar eclipse. Just as good as the real thing.
Code (found on the @MATLAB instagram)
a=716;
v=255;
X=linspace(-10,10,a);
[~,r]=cart2pol(X,X');
colormap(gray.*[1 .78 .3]);
[t,g]=cart2pol(X+2.6,X'+1.4);
image(rescale(-1*(2*sin(t*10)+60*g.^.2),0,v))
hold on
h=exp(-(r-3)).*abs(ifft2(r.^-1.8.*cos(7*rand(a))));
h(r<3)=0;
image(v*ones(a),'AlphaData',rescale(h,0,1))
camva(3.8)
One of the privileges of working at MathWorks is that I get to hang out with some really amazing people. Steve Eddins, of ‘Steve on Image Processing’ fame is one of those people. He recently announced his retirement and before his final day, I got the chance to interview him. See what he had to say over at The MATLAB Blog The Steve Eddins Interview: 30 years of MathWorking
Before we begin, you will need to make sure you have 'sir_age_model.m' installed. Once you've downloaded this folder into your working directory, which can be located at your current folder. If you can see this file in your current folder, then it's safe to use it. If you choose to use MATLAB online or MATLAB Mobile, you may upload this to your MATLAB Drive.
This is the code for the SIR model stratified into 2 age groups (children and adults). For a detailed explanation of how to derive the force of infection by age group.
% Main script to run the SIR model simulation
% Initial state values
initial_state_values = [200000; 1; 0; 800000; 0; 0]; % [S1; I1; R1; S2; I2; R2]
% Parameters
parameters = [0.05; 7; 6; 1; 10; 1/5]; % [b; c_11; c_12; c_21; c_22; gamma]
% Time span for the simulation (3 months, with daily steps)
tspan = [0 90];
% Solve the ODE
[t, y] = ode45(@(t, y) sir_age_model(t, y, parameters), tspan, initial_state_values);
% Plotting the results
plot(t, y);
xlabel('Time (days)');
ylabel('Number of people');
legend('S1', 'I1', 'R1', 'S2', 'I2', 'R2');
title('SIR Model with Age Structure');
What was the cumulative incidence of infection during this epidemic? What proportion of those infections occurred in children?
In the SIR model, the cumulative incidence of infection is simply the decline in susceptibility.
% Assuming 'y' contains the simulation results from the ode45 function
% and 't' contains the time points
% Total cumulative incidence
total_cumulative_incidence = (y(1,1) - y(end,1)) + (y(1,4) - y(end,4));
fprintf('Total cumulative incidence: %f\n', total_cumulative_incidence);
% Cumulative incidence in children
cumulative_incidence_children = (y(1,1) - y(end,1));
% Proportion of infections in children
proportion_infections_children = cumulative_incidence_children / total_cumulative_incidence;
fprintf('Proportion of infections in children: %f\n', proportion_infections_children);
927,447 people became infected during this epidemic, 20.5% of which were children.
Which age group was most affected by the epidemic?
To answer this, we can calculate the proportion of children and adults that became infected.
% Assuming 'y' contains the simulation results from the ode45 function
% and 't' contains the time points
% Proportion of children that became infected
initial_children = 200000; % initial number of susceptible children
final_susceptible_children = y(end,1); % final number of susceptible children
proportion_infected_children = (initial_children - final_susceptible_children) / initial_children;
fprintf('Proportion of children that became infected: %f\n', proportion_infected_children);
% Proportion of adults that became infected
initial_adults = 800000; % initial number of susceptible adults
final_susceptible_adults = y(end,4); % final number of susceptible adults
proportion_infected_adults = (initial_adults - final_susceptible_adults) / initial_adults;
fprintf('Proportion of adults that became infected: %f\n', proportion_infected_adults);
Throughout this epidemic, 95% of all children and 92% of all adults were infected. Children were therefore slightly more affected in proportion to their population size, even though the majority of infections occurred in adults.
Are you going to be in the path of totality? How can you predict, track, and simulate the solar eclipse using MATLAB?
I would like to propose the creation of MATLAB EduHub, a dedicated channel within the MathWorks community where educators, students, and professionals can share and access a wealth of educational material that utilizes MATLAB. This platform would act as a central repository for articles, teaching notes, and interactive learning modules that integrate MATLAB into the teaching and learning of various scientific fields.
Key Features:
1. Resource Sharing: Users will be able to upload and share their own educational materials, such as articles, tutorials, code snippets, and datasets.
2. Categorization and Search: Materials can be categorized for easy searching by subject area, difficulty level, and MATLAB version..
3. Community Engagement: Features for comments, ratings, and discussions to encourage community interaction.
4. Support for Educators: Special sections for educators to share teaching materials and track engagement.
Benefits:
- Enhanced Educational Experience: The platform will enrich the learning experience through access to quality materials.
- Collaboration and Networking: It will promote collaboration and networking within the MATLAB community.
- Accessibility of Resources: It will make educational materials available to a wider audience.
By establishing MATLAB EduHub, I propose a space where knowledge and experience can be freely shared, enhancing the educational process and the MATLAB community as a whole.
Hey MATLAB Community! 🌟
March has been bustling with activity on MATLAB Central, bringing forth a treasure trove of insights, innovations, and fun. Whether you're delving into the intricacies of spline conversions or seeking inspiration from Pi Day celebrations, there's something for everyone.
Here’s a roundup of the top posts from the past few weeks that you won't want to miss:
Interesting questions
Dive into the technicalities of converting spline forms with a focus on calculating coefficients. A must-read for anyone dealing with spline representations.
Explore the challenges and solutions in tuning autopilot gains within a non-linear model of a business jet aircraft.
Popular discussions
Celebrate Pi Day with cool MATLAB implementations and code. A delightful read filled with π-inspired creativity.
Get a glimpse of fun with MATLAB through an engaging visual shared by Athanasios. A light-hearted thread that showcases the fun side of mathematics.
From File Exchange
Unlock the secrets of global climate data with MATLAB. This thread offers tools and insights for analyzing precipitation variability.
Interact with a numerical puddle in real-time and explore the dynamics of disturbances. A fascinating exploration of fluid dynamics simulation.
From the Blogs
Revisit Pi Day with Jiro's picks of the coolest π visualizations. A post that combines art, math, and the joy of exploration.
Discover the synergy between MATLAB and Visual Studio Code, enhanced by GitHub Copilot support. A game-changer for MATLAB developers.
These threads are just the tip of the iceberg. Each post is a gateway to new knowledge, ideas, and community connections. Dive in, explore, and don't forget to contribute your insights and questions. Together, we make MATLAB Central a vibrant hub of innovation and support.
Happy Coding!
The latest release is pretty much upon us. Official annoucements will be coming soon and the eagle-eyed among you will have started to notice some things shifting around on the MathWorks website as we ready for this.
The pre-release has been available for a while. Maybe you've played with it? I have...I've even been quietly using it to write some of my latest blog posts...and I have several queued up for publication after MathWorks officially drops the release.
At the time of writing, this page points to the pre-release highlights. Prerelease Release Highlights - MATLAB & Simulink (mathworks.com)
What excites you about this release? why?
sort(v)
8%
unique(v)
16%
union(v, [ ])
17%
intersect(v, v)
14%
setdiff(v, [ ])
12%
All return sorted output
33%
1193 个投票