主要内容

Results for


Updating some of my educational Livescripts to 2024a, really love the new "define a function anywhere" feature, and have a "new" idea for improving Livescripts -- support "hidden" code blocks similar to the Jupyter Notebooks functionality.
For example, I often create "complicated" plots with a bunch of ancillary items and I don't want this code exposed to the reader by default, as it might confuse the reader. For example, consider a Livescript that might read like this:
-----
Noting the similar structure of these two mappings, let's now write a function that simply maps from some domain to some other domain using change of variable.
function x = ChangeOfVariable( x, from_domain, to_domain )
x = x - from_domain(1);
x = x * ( ( to_domain(2) - to_domain(1) ) / ( from_domain(2) - from_domain(1) ) );
x = x + to_domain(1);
end
Let's see this function in action
% HIDE CELL
clear
close all
from_domain = [-1, 1];
to_domain = [2, 7];
from_values = [-1, -0.5, 0, 0.5, 1];
to_values = ChangeOfVariable( from_values, from_domain, to_domain )
to_values = 1×5
2.0000 3.2500 4.5000 5.7500 7.0000
We can plot the values of from_values and to_values, showing how they're connected to each other:
% HIDE CELL
figure
hold on
for n = 1 : 5
plot( [from_values(n) to_values(n)], [1 0], Color="k", LineWidth=1 )
end
ax = gca;
ax.YTick = [];
ax.XLim = [ min( [from_domain, to_domain] ) - 1, max( [from_domain, to_domain] ) + 1 ];
ax.YLim = [-0.5, 1.5];
ax.XGrid = "on";
scatter( from_values, ones( 5, 1 ), Marker="s", MarkerFaceColor="flat", MarkerEdgeColor="k", SizeData=120, LineWidth=1, SeriesIndex=1 )
text( mean( from_domain ), 1.25, "$\xi$", Interpreter="latex", HorizontalAlignment="center", VerticalAlignment="middle" )
scatter( to_values, zeros( 5, 1 ), Marker="o", MarkerFaceColor="flat", MarkerEdgeColor="k", SizeData=120, LineWidth=1, SeriesIndex=2 )
text( mean( to_domain ), -0.25, "$x$", Interpreter="latex", HorizontalAlignment="center", VerticalAlignment="middle" )
scaled_arrow( ax, [mean( [from_domain(1), to_domain(1) ] ) - 1, 0.5], ( 1 - 0 ) / ( from_domain(1) - to_domain(1) ), 1 )
scaled_arrow( ax, [mean( [from_domain(end), to_domain(end)] ) + 1, 0.5], ( 1 - 0 ) / ( from_domain(end) - to_domain(end) ), -1 )
text( mean( [from_domain(1), to_domain(1) ] ) - 1.5, 0.5, "$x(\xi)$", Interpreter="latex", HorizontalAlignment="center", VerticalAlignment="middle" )
text( mean( [from_domain(end), to_domain(end)] ) + 1.5, 0.5, "$\xi(x)$", Interpreter="latex", HorizontalAlignment="center", VerticalAlignment="middle" )
-----
Where scaled_arrow is some utility function I've defined elsewhere... See how a majority of the code is simply "drivel" to create the plot, clear and close? I'd like to be able to hide those cells so that it would look more like this:
-----
Noting the similar structure of these two mappings, let's now write a function that simply maps from some domain to some other domain using change of variable.
function x = ChangeOfVariable( x, from_domain, to_domain )
x = x - from_domain(1);
x = x * ( ( to_domain(2) - to_domain(1) ) / ( from_domain(2) - from_domain(1) ) );
x = x + to_domain(1);
end
Let's see this function in action
Show code cell
from_domain = [-1, 1];
to_domain = [2, 7];
from_values = [-1, -0.5, 0, 0.5, 1];
to_values = ChangeOfVariable( from_values, from_domain, to_domain )
to_values = 1×5
2.0000 3.2500 4.5000 5.7500 7.0000
We can plot the values of from_values and to_values, showing how they're connected to each other:
Show code cell
-----
Thoughts?
I recently had issues with code folding seeming to disappear and it turns out that I had unknowingly disabled the "show code folding margin" option by accident. Despite using MATLAB for several years, I had no idea this was an option, especially since there seemed to be no references to it in the code folding part of the "Preferences" menu.
It would be great if in the future, there was a warning that told you about this when you try enable/disable folding in the Preferences.
I am using 2023b by the way.
In the MATLAB editor, when clicking on a variable name, all the other instances of the variable name will be highlighted.
But this does not work for structure fields, which is a pity. Such feature would be quite often useful for me.
I show an illustration below, and compare it with Visual Studio Code that does it. ;-)
I am using MATLAB R2023a, sorry if it has been added to newer versions, but I didn't see it in the release notes.
Dear members, I’m currently doing research on the subject of using Generative A.I. as a digital designer. What our research group would like to know is which ethical issues have a big impact on the decisions you guys and girls make using generative A.I.
Whether you’re using A.I. or not, we would really like to know your vision and opinion about this subject. Please empty your thoughts and oppinion into your answers, we would like to get as much information as possible.
Are you currently using A.I. when doing your job? Yes, what for. No (not yet), why not?
Using A.I., would you use real information or alter names/numbers to get an answer?
What information would or wouldn’t you use? If the client is asking/ordering you to do certain things that go against your principles, would you still do it because order is order? How far would you go?
Who is responsible for the outcome of the generated content, you or the client?
Would you still feel like a product owner if it was co-developed with A.I.?
What we are looking for is that we would like to know why people do or don’t use AI in the field of design and wich ethical considerations they make. We’re just looking for general moral line of people, for example: 70% of designers don’t feel owner of a design that is generated by AI but 95% feels owner when it is co-created.
So therefore the questions we asked, we want to know the how you feel about this.
As far as I know, the MATLAB Community (including Matlab Central and Mathworks' official GitHub repository) has always been a vibrant and diverse professional and amateur community of MATLAB users from various fields globally. Being a part of it myself, especially in recent years, I have not only benefited continuously from the community but also tried to give back by helping other users in need.
I am a senior MATLAB user from Shenzhen, China, and I have a deep passion for MATLAB, applying it in various scenarios. Due to the less than ideal job market in my current social environment, I am hoping to find a position for remote support work within the Matlab Community. I wonder if this is realistic. For instance, Mathworks has been open-sourcing many repositories in recent years, especially in the field of deep learning with typical applications across industries. I am eager to use the latest MATLAB features to implement state-of-the-art algorithms. Additionally, I occasionally contribute through GitHub issues and pull requests.
In conclusion, I am looking forward to the opportunity to formally join the Matlab Community in a remote support role, dedicating more energy to giving back to the community and making the world a better place! (If a Mathworks employer can contact me, all the better~)
How long until the 'dumbest' models are smarter than your average person? Thanks for sharing this article @Adam Danz

Hello MathWorks Community,

I am excited to announce that I am currently working on a book project centered around Matrix Algebra, specifically designed for MATLAB users. This book aims to cater to undergraduate students in engineering, where Matrix Algebra serves as a foundational element.

Matrix Algebra is not only pivotal in understanding complex engineering concepts but also in applying these principles effectively in various technological solutions. MATLAB, renowned for its powerful computational capabilities, is an excellent tool to explore and implement these concepts, making it a perfect companion for this book.

As I embark on this journey to create a resource that bridges theoretical matrix algebra with practical MATLAB applications, I am looking for one or two knowledgeable individuals who have a firm grasp of both subjects. If you have experience in teaching or applying matrix algebra in engineering contexts and are familiar with MATLAB, your contribution could be invaluable.

Collaborators will help in shaping the content to ensure it is educational, engaging, and technically robust, making complex concepts accessible and applicable for students.

If you are interested in contributing to this project or know someone who might be, please reach out to discuss how we can work together to make this book a valuable resource for engineering students.

Thank you and looking forward to your participation!

I created an ellipse visualizer in #MATLAB using App Designer! To read more about it, and how it ties to the recent total solar eclipse, check out my latest blog post:
Github Repo of the app (you can open it on MATLAB Online!):
Mari is helping Dad work.
Today, he got dressed for work to design some new dog toy-making algorithms. #nationalpetday
Transforming my furry friend into a grayscale masterpiece with MATLAB! 🐾 #MATLABPetsDay
This is Stella while waiting to see if the code works...
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/
MatGPT was launched on March 22, 2023 and I am amazed at how many times it has been downloaded since then - close to 16,000 downloads in one year. When AI Chat Playground came out on MATLAB Central, I thought surely that people will stop using MatGPT. Boy I was wrong.
In early 2023 I was playing with the new shiny toy called ChatGPT like everyone else but instead of having it tell me jokes or haiku, I wanted to know how I can use it on MATLAB, and I started collecting the prompts that worked. Someone suggested I should turn that into an app, and MatGPT was born with help from other colleagues.
Here is the question - what should I do with it now? Some people suggested I could add other LLMs like Gemini or Claude, but I am more interested in learning how people actually use it.
If you are a MatGPT user, do you mind sharing how you use the app?
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');
David
David
Last activity 2024-4-2

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
User-provided workarounds
MathWorks-provided workarounds