General - MATLAB Central Discussions

General
Suivre

Connectez-vous pour participer


David
David
Dernière activité le 15 Juil 2024

Hello and a warm welcome to all! We're thrilled to have you visit our community. MATLAB Central is a place for learning, sharing, and connecting with others who share your passion for MATLAB and Simulink. To ensure you have the best experience, here are some tips to get you started:
  1. Read the Community Guidelines: Understanding our community standards is crucial. Please take a moment to familiarize yourself with them. Keep in mind that posts not adhering to these guidelines may be flagged by moderators or other community members.
  2. Ask Technical Questions at MATLAB Answers: If you have questions related to MathWorks products, head over to MATLAB Answers (new question form - Ask the community). It's the go-to spot for technical inquiries, with responses often provided within an hour, depending on the complexity of the question and volunteer availability. To increase your chances of a speedy reply, check out our tips on how to craft a good question (link to post on asking good questions).
  3. Choosing the Right Channel: We offer a variety of discussion channels tailored to different contexts. Select the one that best fits your post. If you're unsure, the General channel is always a safe bet. If you feel there's a need for a new channel, we encourage you to suggest it in the Ideas channel.
  4. Reporting Issues: If you encounter posts that violate our guidelines, please use the 🚩Flag/Report feature (found in the 3-dot menu) to bring them to our attention.
  5. Quality Control: We strive to maintain a high standard of discussion. Accounts that post spam or too much nonsense may be subject to moderation, which can include temporary suspensions or permanent bans.
  6. Share Your Ideas: Your feedback is invaluable. If you have suggestions on how we can improve the community or MathWorks products, the Ideas channel is the perfect place to voice your thoughts.
Enjoy yourself and have fun! We're committed to fostering a supportive and educational environment. Dive into discussions, share your expertise, and grow your knowledge. We're excited to see what you'll contribute to the community!
Akshat Jain
Akshat Jain
Dernière activité environ 6 heures il y a

Using the colon operator and the linspace function, create the following row vectors:
  1. −6,−5,−4,−3,−2-6, -5, -4, -3, -2−6,−5,−4,−3,−2
  2. 6,8,106, 8, 106,8,10
  3. 9,7,59, 7, 59,7,5
Provide the MATLAB commands for both methods (colon operator and linspace).
Answer.
v1 = -6:-2;
v2 = 6:2:10;
v3 = 9:-2:5;
v1 = linspace(-6, -2, 5);
v2 = linspace(6, 10, 3);
v3 = linspace(9, 5, 3);
Write a MATLAB script that generates and prints a reverse multiplication table up to n, where n is an input taken from the user.
For example, if n=4n = 4n=4, the output should be:
4 8 12 16
3 6 9
2 4
1
The script should prompt the user to enter a positive integer nnn and then display the reverse multiplication table up to that number.
Answer.
n = input('Enter a positive integer: '); % Taking input from user
for i = n:-1:1
disp(i * (1:n)) % Display row-wise multiplication
end
Write a MATLAB command to convert 3π2\frac{3\pi}{2}23π​ radians to degrees and store it in a variable θ\thetaθ.
Answer.
theta = rad2deg(3*pi/2);
Evaluate the output of the expression x2+y2x^2 + y^2x2+y2 given that:
x=r⋅cos⁡θ,y=r⋅sin⁡θx = r \cdot \cos{\theta}, \quad y = r \cdot \sin{\theta}x=r⋅cosθ,y=r⋅sinθ
where r=3r = 3r=3 and θ=3π2\theta = \frac{3\pi}{2}θ=23π​.
Write your MATLAB code and the final output.
Answer.
% Given values
r = 3;
theta = (3 * pi) / 2;
% Compute x and y
x = r * cos(theta);
y = r * sin(theta);
% Compute the expression x^2 + y^2
result = x^2 + y^2;
% Display the result
disp(['The result of x^2 + y^2 is: ', num2str(result)]);
Solve the System of Linear Equations
Answer.
% Define the coefficient matrix
A = [6.2 -3.1 1.1;
-3.0 2.0 -1.0;
7.5 3.8 -6.9];
% Define the constants matrix
B = [28.9; -10.8; 2.3];
% Solve for x1, x2, and x3
X = A \ B;
% Display the results
disp(['x1 = ', num2str(X(1))]);
disp(['x2 = ', num2str(X(2))]);
disp(['x3 = ', num2str(X(3))]);
Create and Plot the Functions
Answer.
% Create x as 100 linearly spaced values between -2π and 2π
x = linspace(-2*pi, 2*pi, 100);
% Compute y1 as sine values of x
y1 = sin(x);
% Compute y2 as cosecant values of x (1/sin(x))
y2 = csc(x);
% Plot both sine and cosecant functions
figure;
plot(x, y1, 'b', 'LineWidth', 2); % Plot sine in blue
hold on;
plot(x, y2, 'r', 'LineWidth', 2); % Plot cosecant in red
hold off;
% Add title using \pi to properly display the Greek symbol π
title('Plot of sin(x) and csc(x) from -2\pi to 2\pi');
% Set x-axis and y-axis labels
xlabel('x values');
ylabel('Function values');
% Display a legend
legend('sin(x)', 'csc(x)');
% Enable grid for better visualization
grid on;
Function to Reverse a Vector
Answer.
function output = flipvec(input)
if isvector(input)
output = flip(input);
else
output = input;
end
end
% Test cases
row_vector = [1, 2, 3, 4, 5];
column_vector = [1; 2; 3; 4; 5];
matrix = [1 2 3; 4 5 6; 7 8 9];
disp('Reversed row vector:');
disp(flipvec(row_vector));
disp('Reversed column vector:');
disp(flipvec(column_vector));
disp('Matrix remains unchanged:');
disp(flipvec(matrix));
Writing a program that reads in a numerical grade and assigns a letter grade to it according to the following table:
  • If the grade is 95 or greater, assign A
  • If the grade is greater than 86 and less than or equal to 95, assign B
  • If the grade is greater than 76 and less than or equal to 86, assign C
  • If the grade is greater than 66 and less than or equal to 76, assign D
  • If the grade is greater than 0 and less than or equal to 66, assign F
Write an if-else construct in MATLAB that will assign the grades as previously described using multiple if, elseif, else conditions.
Answer.
% Input grade
grade = input('Enter the numerical grade: ');
% Assign letter grade using if-elseif-else construct
if grade >= 95
letter = 'A';
elseif grade > 86 && grade <= 95
letter = 'B';
elseif grade > 76 && grade <= 86
letter = 'C';
elseif grade > 66 && grade <= 76
letter = 'D';
elseif grade > 0 && grade <= 66
letter = 'F';
else
letter = 'Invalid grade';
end
% Display result
disp(['The assigned letter grade is: ', letter]);
Write three MATLAB functions to calculate the hyperbolic sine, cosine, and tangent functions:
Use your functions to plot the shapes of the hyperbolic sine, cosine, and tangent functions.
The functions are defined as follows:
Answer.
% Function to compute sinh(x)
function y = my_sinh(x)
y = (exp(x) - exp(-x)) / 2;
end
% Function to compute cosh(x)
function y = my_cosh(x)
y = (exp(x) + exp(-x)) / 2;
end
% Function to compute tanh(x)
function y = my_tanh(x)
y = (exp(x) - exp(-x)) ./ (exp(x) + exp(-x));
end
% Main Script to Compute and Plot Hyperbolic Functions
clc; clear; close all;
% Define x values from -2π to 2π
x = linspace(-2*pi, 2*pi, 100);
% Compute function values using custom functions
y_sinh = my_sinh(x);
y_cosh = my_cosh(x);
y_tanh = my_tanh(x);
% Create plots
figure;
% Plot sinh(x)
subplot(3,1,1);
plot(x, y_sinh, 'r', 'LineWidth', 2);
title('Hyperbolic Sine Function (sinh(x))');
xlabel('x');
ylabel('sinh(x)');
grid on;
% Plot cosh(x)
subplot(3,1,2);
plot(x, y_cosh, 'b', 'LineWidth', 2);
title('Hyperbolic Cosine Function (cosh(x))');
xlabel('x');
ylabel('cosh(x)');
grid on;
% Plot tanh(x)
subplot(3,1,3);
plot(x, y_tanh, 'g', 'LineWidth', 2);
title('Hyperbolic Tangent Function (tanh(x))');
xlabel('x');
ylabel('tanh(x)');
grid on;
Using the colon operator and also the linspace function, create the following row vectors:
  1. First vector: -4, -3, -2, -1, 0
  2. Second vector: 3, 5, 7
  3. Third vector: 6, 4, 2
Provide MATLAB commands for both methods (colon operator and linspace function).
Answer.
% Using Colon Operator
v1_colon = -4:0; % -4, -3, -2, -1, 0
v2_colon = 3:2:7; % 3, 5, 7
v3_colon = 6:-2:2; % 6, 4, 2
% Using Linspace Function
v1_linspace = linspace(-4, 0, 5); % -4, -3, -2, -1, 0
v2_linspace = linspace(3, 7, 3); % 3, 5, 7
v3_linspace = linspace(6, 2, 3); % 6, 4, 2
% Display Results
disp('Using Colon Operator:');
disp(['v1 = ', num2str(v1_colon)]);
disp(['v2 = ', num2str(v2_colon)]);
disp(['v3 = ', num2str(v3_colon)]);
disp('Using Linspace Function:');
disp(['v1 = ', num2str(v1_linspace)]);
disp(['v2 = ', num2str(v2_linspace)]);
disp(['v3 = ', num2str(v3_linspace)]);
The combined resistance R total of three resistors R one, R two, and R three in series is given by the formula:
Rtotal=Rone+Rtwo+RthreeR total = R one + R two + R threeRtotal=Rone+Rtwo+Rthree
  1. Create variables for the three resistors and store values in them.
  2. Calculate the combined resistance using the given formula.
Answer.
% Assign values to resistors
R1 = 5; % Example value, you can change it
R2 = 10; % Example value, you can change it
R3 = 15; % Example value, you can change it
% Calculate the total resistance in series
R_total = R1 + R2 + R3;
% Display the result
disp(['The total resistance in series is: ', num2str(R_total), ' ohms']);
Write a MATLAB command to convert two pi radians to degrees and store it in a variable theta.
What is the output of the relationship x2+y2x^2 + y^2x2+y2 when:
  • x=r×cos⁡(θ)x = r \times \cos(\theta)x=r×cos(θ)
  • y=r×sin⁡(θ)y = r \times \sin(\theta)y=r×sin(θ)
  • Given that r=4r = 4r=4, θ=2π\theta = 2\piθ=2π.
Answer.
% Convert 2π radians to degrees
theta = rad2deg(2*pi);
disp(['Theta in degrees: ', num2str(theta)]);
% Given values
r = 4;
theta_rad = 2*pi; % Theta in radians
% Compute x and y
x = r * cos(theta_rad);
y = r * sin(theta_rad);
% Compute x² + y²
result = x^2 + y^2;
% Display result
disp(['The value of x^2 + y^2 is: ', num2str(result)]);
Write a MATLAB program that will solve the following system of three linear equations:
5.7x1−2.3x2+0.9x3=30.15.7x_1 - 2.3x_2 + 0.9x_3 = 30.15.7x1​−2.3x2​+0.9x3​=30.1 −2.5x1+1.3x2=−12.6-2.5x_1 + 1.3x_2 = -12.6−2.5x1​+1.3x2​=−12.6 8.0x1+4.2x2−7.5x3=1.18.0x_1 + 4.2x_2 - 7.5x_3 = 1.18.0x1​+4.2x2​−7.5x3​=1.1
Answer.
% Define the coefficient matrix A
A = [5.7 -2.3 0.9;
-2.5 1.3 0;
8.0 4.2 -7.5];
% Define the constants matrix B
B = [30.1; -12.6; 1.1];
% Solve for x1, x2, x3
X = A \ B;
% Display results
disp(['x1 = ', num2str(X(1))]);
disp(['x2 = ', num2str(X(2))]);
disp(['x3 = ', num2str(X(3))]);
(a)
Create a matrix with random values between 600 and 800, ensuring that it has an even number of rows and an odd number of columns.
Find the overall maximum value in the matrix.
(b)
Find the cumulative matrix from (a).
(c)
For a vector v with length n, the function diff(v) will have n-1 elements.
Create a random integer matrix and find the difference on each column.
(d)
Create a matrix of all 10's.
(e)
Create a vector variable and add 7 to every element.
Answer.
a)
% Define matrix size with even rows and odd columns
rows = 4; % Example even number
cols = 5; % Example odd number
% Create matrix with values between 600 and 800
M = randi([600, 800], rows, cols);
% Find the overall maximum value
max_value = max(M(:));
% Display results
disp('Random matrix:');
disp(M);
disp(['Overall max value: ', num2str(max_value)]);
b)
% Compute cumulative sum of matrix M row-wise
cumulative_M = cumsum(M, 2);
% Display result
disp('Cumulative sum matrix:');
disp(cumulative_M);
c)
% Create a random integer matrix of size 5x4 (example)
random_matrix = randi([1, 50], 5, 4);
% Compute column-wise difference
column_diff = diff(random_matrix);
% Display results
disp('Random integer matrix:');
disp(random_matrix);
disp('Column-wise differences:');
disp(column_diff);
d)
% Define size of the matrix
rows = 4; cols = 5;
% Create matrix filled with 10's
matrix_tens = ones(rows, cols) * 10;
% Display result
disp('Matrix of all 10s:');
disp(matrix_tens);
e)
% Define a vector
V = [2, 4, 6, 8, 10];
% Add 7 to each element
V_new = V + 7;
% Display results
disp('Original vector:');
disp(V);
disp('Vector after adding 7:');
disp(V_new);
Create x as 100 linearly spaced values between -2π and 2π.
Create y1 as the sine values of x.
Create y2 as the cosecant values of x.
Plot both sets of data on the same graph.
Add a title to the chart using the title function.
Use \pi to display the Greek symbol π in the title.
Answer.
% Create x as 100 linearly spaced values between -2π and 2π
x = linspace(-2*pi, 2*pi, 100);
% Compute y1 as sine values of x
y1 = sin(x);
% Compute y2 as cosecant values of x (1/sin(x)), avoiding division by zero
y2 = 1 ./ sin(x);
% Plot both sine and cosecant functions
figure;
plot(x, y1, 'b', 'LineWidth', 2); % Plot sine in blue
hold on;
plot(x, y2, 'r', 'LineWidth', 2); % Plot cosecant in red
hold off;
% Add title using \pi to properly display the Greek symbol π
title('Plot of sin(x) and csc(x) from -2\pi to 2\pi');
% Set x-axis and y-axis labels
xlabel('x values');
ylabel('Function values');
% Display a legend
legend('sin(x)', 'csc(x)');
% Enable grid for better visualization
grid on;
Write a MATLAB program that solves for the roots of a quadratic equation and displays the result.
The inputs required are the coefficients a, b, and c of the quadratic equation: ax2+bx+c=0ax^2 + bx + c = 0ax2+bx+c=0
Test the program using the quadratic equation: 2x2+7x+10=02x^2 + 7x + 10 = 02x2+7x+10=0
Answer.
% Define coefficients for the quadratic equation: 2x² + 7x + 10 = 0
a = 2;
b = 7;
c = 10;
% Calculate the discriminant
D = b^2 - 4*a*c;
% Check the nature of roots and compute them
if D > 0
% Two distinct real roots
root1 = (-b + sqrt(D)) / (2*a);
root2 = (-b - sqrt(D)) / (2*a);
disp(['The roots are real and distinct: ', num2str(root1), ', ', num2str(root2)]);
elseif D == 0
% One real root (double root)
root1 = -b / (2*a);
disp(['The root is real and repeated: ', num2str(root1)]);
else
% Complex roots
realPart = -b / (2*a);
imagPart = sqrt(-D) / (2*a);
disp(['The roots are complex: ', num2str(realPart), ' ± ', num2str(imagPart), 'i']);
end
In aerodynamics, the Mach number is the ratio of an object's speed to the speed of sound.
If the Mach number is:
  • Less than 1 → The flow is subsonic.
  • Equal to 1 → The flow is transonic.
  • Greater than 1 → The flow is supersonic.
Write a MATLAB script that will:
  • Prompt the user to enter the speed of an aircraft.
  • Prompt the user to enter the speed of sound at the aircraft’s current altitude.
  • Calculate the Mach number.
  • Print the result, indicating whether the flow is subsonic, transonic, or supersonic.
Answer.
% Prompt the user for the speed of the aircraft
speed_aircraft = input('Enter the speed of the aircraft (m/s): ');
% Prompt the user for the speed of sound at the current altitude
speed_sound = input('Enter the speed of sound at the current altitude (m/s): ');
% Calculate the Mach number
mach_number = speed_aircraft / speed_sound;
% Determine the category of flight
if mach_number < 1
disp(['Mach Number: ', num2str(mach_number)]);
disp('The flow is subsonic.');
elseif mach_number == 1
disp(['Mach Number: ', num2str(mach_number)]);
disp('The flow is transonic.');
else
disp(['Mach Number: ', num2str(mach_number)]);
disp('The flow is supersonic.');
end
Hannah
Hannah
Dernière activité le 21 Fév 2025 à 16:34


On 27th February María Elena Gavilán Alfonso and I will be giving an online seminar that has been a while in the making. We'll be covering MATLAB with Jupyter, Visual Studio Code, Python, Git and GitHub, how to make your MATLAB projects available to the world (no installation required!) and much much more.
Steve Eddins
Steve Eddins
Dernière activité le 20 Fév 2025 à 17:45

General observations on practical implementation issues regarding add-on versioning
I am making updates to one of my File Exchange add-ons, and the updates will require an updated version of another add-on. The state of versioning for add-ons seems to be a bit of a mess.
First, there are several sources of truth for an add-on’s version:
  • The GitHub release version, which gets mirrored to the File Exchange version
  • The ToolboxVersion property of toolboxOptions (for an add-on packaged as a toolbox)
  • The version in the Contents.m file (if there is one)
Then, there is the question of how to check the version of an installed add-on. You can call matlab.addon.installedAddons, which returns a table. Then you need to inspect the table to see if a particular add-on is present, if it is enabled, and get the version number.
If you can get the version number this way, then you need some code to compare two semantic version numbers (of the form “3.1.4”). I’m not aware of a documented MATLAB function for this. The verLessThan function takes a toolbox name and a version; it doesn’t help you with comparing two versions.
If add-on files were downloaded directly and added to the MATLAB search path manually, instead of using the .mtlbx installer file, the add-on won’t be listed in the table returned by matlab.addon.installedAddon. You’d have to call ver to get the version number from the Contents.m file (if there is one).
Frankly, I don’t want to write any of this code. It would take too long, be challenging to test, and likely be fragile.
Instead, I think I will write some sort of “capabilities” utility function for the add-on. This function will be used to query the presence of needed capabilities. There will still be a slight coding hassle—the client add-on will need to call the capabilities utility function in a try-catch, because earlier versions of the add-on will not have that utility function.
I also posted this over at Harmonic Notes
Walter Roberson
Walter Roberson
Dernière activité le 18 Fév 2025 à 15:52

Are there parts of MATLAB that could disappear as far as you were concerned, things you don't need or which were "bad ideas" or which cause more trouble than they are worth in your experience?
One suggestion per answer please, so we can see how other people feel about the same matters.
Adam
Adam
Dernière activité le 17 Fév 2025 à 2:45

I am looking for a Simulink tutor to help me with Reinforcement Learning Agent integration. If you work for MathWorks, I am willing to pay $30/hr. I am working on a passion project, ready to start ASAP. DM me if you're interested.
Walter Roberson
Walter Roberson
Dernière activité le 15 Fév 2025 à 16:47

This topic is for discussing highlights to the current R2025a Pre-release.
Since May 2023, MathWorks officially introduced the new Community API(MATLAB Central Interface for MATLAB), which supports both MATLAB and Node.js languages, allowing users to programmatically access data from MATLAB Answers, File Exchange, Blogs, Cody, Highlights, and Contests.
I’m curious about what interesting things people generally do with this API. Could you share some of your successful or interesting experiences? For example, retrieving popular Q&A topics within a certain time frame through the API and displaying them in a chart.
If you have any specific examples or ideas in mind, feel free to share!
Matt J
Matt J
Dernière activité le 14 Fév 2025 à 15:39

On my computers, this bit of code produces an error whose cause I have pinpointed,
load tstcase
ycp=lsqlin(I, y, Aineq, bineq);
Error using parseOptions
Too many output arguments.
Error in lsqlin (line 170)
[options, optimgetFlag] = parseOptions(options, 'lsqlin', defaultopt);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The reason for the error is seemingly because, in recent Matlab, lsqlin now depends on a utility function parseOptions, which is shadowed by one of my personal functions sharing the same name:
C:\Users\MWJ12\Documents\mwjtree\misc\parseOptions.m
C:\Program Files\MATLAB\R2024b\toolbox\shared\optimlib\parseOptions.m % Shadowed
The MathWorks-supplied version of parseOptions is undocumented, and so is seemingly not meant for use outside of MathWorks. Shouldn't it be standard MathWorks practice to put these utilities in a private\ folder where they cannot conflict with user-supplied functions of the same name?
It is going to be an enormous headache for me to now go and rename all calls to my version of parseOptions. It is a function I have been using for a long time and permeates my code.
Walter Roberson
Walter Roberson
Dernière activité le 13 Fév 2025 à 17:10

At the present time, the following problems are known in MATLAB Answers itself:
  • Symbolic output is not displaying. The work-around is to disp(char(EXPRESSION)) or pretty(EXPRESSION)
  • Symbolic preferences are sometimes set to non-defaults
Daniele Lupo
Daniele Lupo
Dernière activité le 12 Fév 2025 à 11:32

Hi to all.
I'm trying to learn a bit about trading with cryptovalues. At the moment I'm using Freqtrade (in dry-run mode of course) for automatic trading. The tool is written in python and it allows to create custom strategies in python classes and then run them.
I've written some strategy just to learn how to do, but now I'd like to create some interesting algorithm. I've a matlab license, and I'd like to know what are suggested tollboxes for following work:
  • Create a criptocurrency strategy algorythm (for buying and selling some crypto like BTC, ETH etc).
  • Backtesting the strategy with historical data (I've a bunch of json files with different timeframes, downloaded with freqtrade from binance).
  • Optimize the strategy given some parameters (they can be numeric, like ROI, some kind of enumeration, like "selltype" and so on).
  • Convert the strategy algorithm in python, so I can use it with Freqtrade without worrying of manually copying formulas and parameters that's error prone.
  • I'd like to write both classic algorithm and some deep neural one, that try to find best strategy with little neural network (they should run on my pc with 32gb of ram and a 3080RTX if it can be gpu accelerated).
What do you suggest?
I don't like the change
16%
I really don't like the change
29%
I'm okay with the change
24%
I love the change
11%
I'm indifferent
11%
I want both the web & help browser
11%
38 votes
Hans Scharler
Hans Scharler
Dernière activité le 9 Fév 2025 à 16:12

Let's say you have a chance to ask the MATLAB leadership team any question. What would you ask them?
The MATLAB Online Training Suite has been updated in the areas of Deep Learning and traditional Machine Learning! These are great self-paced courses that can get you from zero to hero pretty quickly.
Deep Learning Onramp (Free to everyone!) has been updated to use the dlnetwork workflow, such as the trainnet function, which became the preferred method for creating and training deep networks in R2024a.
Machine Learning Onramp (Free to everyone) has been updated with the following enhancements:
  • Content streamlined to reduce the focus on data processing and feature extraction, and emphasize the machine learning workflow.
  • Course example simplified by using a sample of the original data.
  • Classification Learner used in the course where appropriate.
The rest of the updates are for subscribers to the full Online Training Suite
The Deep Learning Techniques in MATLAB for Image Applications learning path teaches skills to tackle a variety of image applications. It is made up of the following four short courses:
Two more deep learning short courses are also available:
The Machine Learning Techniques in MATLAB learning path helps learners build their traditional machine learning skill set:
Frank
Frank
Dernière activité le 1 Fév 2025 à 21:29

Hi
If you have used the playground and are familiar with its capabilities, I will be very interested in your opinion about the tool.
Thank you in advance for your reply/opinion.
At
cui,xingxing
cui,xingxing
Dernière activité le 29 Jan 2025 à 14:51

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")
Currently, according to the official documentation, "DisplayName" only supports character vectors or single scalar string as input. For example, when plotting three variables simultaneously, if I use a single scalar string as input, the legend labels will all be the same. To have different labels, I need to specify them separately using the legend function with label1, label2, label3.
Here's an example illustrating the issue:
x = (1:10)';
y1 = x;
y2 = x.^2;
y3 = x.^3;
% Plotting with a string scalar for DisplayName
figure;
plot(x, [y1,y2,y3], DisplayName="y = x");
legend;
% To have different labels, I need to use the legend function separately
figure;
plot(x, [y1,y2,y3], DisplayName=["y = x","y = x^2","y=x^3"]);
Error using plot
Value must be a character vector or a string scalar.
% legend("y = x","y = x^2","y=x^3");
So you've downloaded the R2025a pre-release, tried Dark mode and are wondering what else is new. A lot! A lot is new!
One thing I am particularly happy about is the fact that Apple Accelerate is now the default BLAS on Apple Silicon machines. Check it out by doing
>> version -blas
ans =
'Apple Accelerate BLAS (ILP64)'
If you compare this to R2024b that is using OpenBLAS you'll see some dramatic speed-ups in some areas. For example, I saw up to 3.7x speed-up for matrix-matrix multiplication on my M2 Mabook Pro and 2x faster LU factorisation.
Details regarding my experiments are in this blog post Life in the fast lane: Making MATLAB even faster on Apple Silicon with Apple Accelerate » The MATLAB Blog - MATLAB & Simulink . Back then you had to to some trickery to switch to Apple Accelerate, now its the default.
Go to top of page