Results for
w = logspace(-1,3,100);
[m,p] = bode(tf(1,[1 1]),w);
size(m)
and therefore plotting requires an explicit squeeze (or rehape, or colon)
% semilogx(w,squeeze(db(m)))
Similarly, I'm using page* functions more regularly and am now generating 3D results whereas my old code would generate 2D. For example
x = [1;1];
theta = reshape(0:.1:2*pi,1,1,[]);
Z = [cos(theta), sin(theta);-sin(theta),cos(theta)];
y = pagemtimes(Z,x);
Now, plotting requires squeezing the inputs
% plot(squeeze(theta),squeeze(y))
Would there be any drawbacks to having plot, et. al., automagically apply squeeze to its inputs?
The ability to plot multiple signals on a plot and then use the plot browser to interactively control which ones are displayed has been one of the most useful features of the plotting tools and many of my scripts embed  the command to open it after results analysis and plotting. It's been removed in 2025A with the comment that the Property Inspector provides the alternative. It doesn't. Having to go back into the menu to select the plot edit features to get to the Property Inspector (which doesn't provide an efficient alternative to the plot browser) has made the workflow very inefficient. Please bring it back a.s.a.p. !!!!
I want to use Simulink for model-based development of the TC3XX series development board, but I am not sure about the development process and toolchain? Is there a free toolchain available for me to use? Do you have a detailed development tutorial? 
I have a pressure vs. time plot resulting from the input of an elastic wave, which I obtained from an Abaqus simulation. So, I have access to all the data. Now, I want to convert this time-domain graph into a frequency-domain graph using FFT in MATLAB.
I came across a code through ChatGPT, but I’m not fully confident in relying on it. Could anyone kindly clarify whether the formulas used for FFT in MATLAB are universal for all types of signals? Or is there a more effective and reliable method I should consider for this purpose?
Hi guys!
Im doing a project where i need to simulate a ship connected to the grid. I have a grid->converter AC-DC-AC -> dynamic load. My converter has to keep the voltage consistent and what changes is the current. Can somebody help me? 
I like this problem by James and have solved it in several ways. A solution by Natalie impressed me and introduced me to a new function conv2. However, it occured to me that the numerous test for the problem only cover cases of square matrices. My original solutions, and Natalie's, did niot work on rectangular matrices. I have now produced a solution which works on rectangular matrices. Thanks for this thought provoking problem James.
I have written, tested, and prepared a function with four subsunctions on my computer for solving one of the problems in the list of Cody problems in MathWorks in three days. Today, when I wanted to upload or copy paste the codes of the function and its subfunctions to the specified place of the problem of Cody page, I do not see a place to upload it, and the ability to copy past the codes. The total of the entire codes and their documentations is about 600 lines, which means that I cannot and it is not worth it to retype all of them in the relevent Cody environment after spending a few days. I would appreciate your guidance on how to enter the prepared codes to the desired environment in Cody.  
I've long used the Tensor Toolbox from Sandia in order to use tensors in Matlab, but recently found myself wanting to apply it on symbolic arguments, which don't appear supported.  Some google-fu'ing resulted in (non-free) Tensorlab and some file-exchange entries of mixed quality.  And of course, there's the recent tensorprod, which a) doesn't support symbolics and b) arguments aren't strictly tensors (rather "representations of tensors in a matrix type"). 
This all got me to thinking that it would be mighty nice to have general / native / comprehensive support for a tensor class in official Matlab - even if it were in a separate toolbox.
Hello ThingSpeak Community, 
I have an energy meter sending data of energy consumed in 4 rooms in hexadecimal values to Sigfox and I was trying to decode the payload and route it to ThingSpeak.
All the datas are sent at the same time. 
But ThingSpeak only receives 1 of them and plots them. 
However, the rest 3 are missing. Is this because I am trying the free version ?
Would the payed version be capable of receiving all the 4 messages ?
Hi! I'm Joseff and along with being a student in chemical engineering, one of my great passions is language-learning. I learnt something really cool recently about Catalan (a romance language closely related to Valencian that's spoken in Andorra, Catalonia, and parts of Spain) — and that is how speakers tell the time.
While most European languages stick to the standard minutes-past / minutes-to between hours, Catalan does something really quite special, with a focus on the quarters (quarts [ˈkwarts]). To see what I mean, take a look at this clock made by Penguin___Lover on Instructables :

If you want to tell the time in Catalan, you should refer to the following hour (the one that's still to come), and how many minutes have passed or will pass for the closest quarter (sometimes half-quarter / mig quart [ˈmit͡ʃ kwart]) — clear as mud? It's definitely one of the more difficult things to wrap your head around as a learner. But fear not, with the power of MATLAB, we'll understand in no time!
To make a tool to tell the time in Catalan, the first thing we need to do is extract the current time into its individual hours, minutes and seconds*
function catalanTime = quinahora()
    % Get the current time
    [hours, minutes, seconds] = hms(datetime("now"));
    % Adjust hours to 12-hour format
    catalanHour = mod(hours-1, 12)+1;
    nextHour = mod(hours, 12)+1;
Then to defining the numbers in catalan. It's worth noting that because the hours are feminine and the minutes are masculine, the words for 1 and 2 is different too (this is not too weird as languages go, in fact for my native Welsh there's a similar pattern between 2 and 4).
    % Define the numbers in Catalan
    catNumbers.masc = ["un", "dos", "tres", "quatre", "cinc"];
    catNumbers.fem = ["una", "dues", "tres", "quatre",...
                  "cinc", "sis", "set", "vuit",...
                  "nou", "deu", "onze", "dotze"];
Okay, now it's starting to get serious! I mentioned before that this traditional time telling system is centred around the quarters — and that is true, but you'll also hear about the mig de quart (half of a quarter) * which is why we needed that seconds' precision from earlier!
    % Define 07:30 intervals around the clock from 0 to 60
    timeMarks = 0:15/2:60;
    timeFraction = minutes + seconds / 60; % get the current position
    [~, idx] = min(abs(timeFraction - timeMarks)); % extract the closest timeMark
    mins = round(timeFraction - timeMarks(idx)); % round to the minute
After getting the fraction of the hour that we'll use later to tell the time, we can look into how many minutes it differs from that set time, using menys (less than) and i (on top of). There's also a bit of an AM/PM distinction, so you can use this function and know whether it's morning or night!
    % Determine the minute string (diffString logic)
    diffString = '';
    if mins < 0
        diffString = sprintf(' menys %s', catNumbers.masc(abs(mins)));
    elseif mins > 0
        diffString = sprintf(' i %s', catNumbers.masc(abs(mins)));
    end
    % Determine the part of the day (partofDay logic)
    if hours < 12
        partofDay = 'del matí'; % Morning (matí)
    elseif hours < 18
        partofDay = 'de la tarda'; % Afternoon (tarda)
    elseif hours < 21
        partofDay = 'del vespre'; % Evening (vespre)
    else
        partofDay = 'de la nit'; % Night (nit)
    end
    % Determine 'en punt' (o'clock exactly) based on minutes
    enPunt = '';
    if mins == 0
        enPunt = ' en punt';
    end
Now all that's left to do is define the main part of the string, which is which mig quart we are in. Since we extracted the index idx earlier as the closest timeMark, it's just a matter of indexing into this after the strings have been defined.
    % Create the time labels
    labels = {sprintf('són les %s%s%s %s', catNumbers.fem(catalanHour), diffString, enPunt, partofDay), ...
              sprintf('és mig quart de %s%s %s', catNumbers.fem(nextHour), diffString, partofDay), ...
              sprintf('és un quart de %s%s %s', catNumbers.fem(nextHour), diffString, partofDay), ...
              sprintf('és un quart i mig de %s%s %s', catNumbers.fem(nextHour), diffString, partofDay), ...
              sprintf('són dos quarts de %s%s %s', catNumbers.fem(nextHour), diffString, partofDay), ...
              sprintf('són dos quarts i mig de %s%s %s', catNumbers.fem(nextHour), diffString, partofDay), ...
              sprintf('són tres quarts de %s%s %s', catNumbers.fem(nextHour), diffString, partofDay), ...
              sprintf('són tres quarts i mig de %s%s %s', catNumbers.fem(nextHour), diffString, partofDay), ...
              sprintf('són les %s%s%s %s', catNumbers.fem(nextHour), diffString, enPunt, partofDay)};
    catalanTime = labels{idx};
Then we need to do some clean up — the definite article les / la and the preposition de don't play nice with un and the initial vowel in onze, so there's a little replacement lookup here.
    % List of old and new substrings for replacement
    oldStrings = {'les un', 'són la una', 'de una', 'de onze'};
    newStrings = {'la una', 'és la una', 'd''una', 'd''onze'};
    % Apply replacements using a loop
    for i = 1:length(oldStrings)
        catalanTime = strrep(catalanTime, oldStrings{i}, newStrings{i});
    end
end
quinahora()
So, can you work out what time it was when I made this post? 🤔
And how do you tell the time in your language?
Fins després!
Imagine you are developing a new toolbox for MATLAB. You have a folder full of a few .m files defining a bunch of functions and you are thinking 'This would be useful for others, I'm going to make it available to the world'
What process would you go through? What's the first thing you'd do? 
I have my own opinions but don't want to pollute the start of the conversation :)
It is time to support the cameraIntrinsics function to accept a 3-by-3 intrinsic matrix K as an input parameter for constructing the object. Currently, the built-in cameraIntrinsics function can only be constructed by explicitly specifying focalLength, principalPoint, and imageSize. This approach has drawbacks, as it is not very intuitive. In most application scenarios, using the intrinsic matrix 
K=[fx,0,cx;
0,fy,cy;
0,0,1]
is much more straightforward and effective!
intrinsics = cameraIntrinsics(K)
tiledlayout(4,1);
% Plot "L" (y = 1/(x+1), for x > -1)
x = linspace(-0.9, 2, 100); % Avoid x = -1 (undefined)
y =1 ./ (x+1) ;
nexttile;
plot(x, y, 'r', 'LineWidth', 2);
xlim([-10,10])
% Plot "O" (x^2 + y^2 = 9)
theta = linspace(0, 2*pi, 100);
x = 3 * cos(theta);
y = 3 * sin(theta);
nexttile;
plot(x, y, 'r', 'LineWidth', 2);
axis equal;
% Plot "V" (y = -2|x|)
x = linspace(-1, 1, 100);
y = 2 * abs(x);
nexttile;
plot(x, y, 'r', 'LineWidth', 2);
axis equal;
% Plot "E" (x = -3 |sin(y)|)
y = linspace(-pi, pi, 100);
x = -3 * abs(sin(y));
nexttile;
plot(x, y, 'r', 'LineWidth', 2);
axis equal;
I've been trying this problem a lot of time and i don't understand why my solution doesnt't work.
In 4 tests i get the error Assertion failed but when i run the code myself i get the diag and antidiag correctly.
function [diag_elements, antidg_elements] = your_fcn_name(x)
    [m, n] = size(x);
    % Inicializar los vectores de la diagonal y la anti-diagonal
    diag_elements = zeros(1, min(m, n));
    antidg_elements = zeros(1, min(m, n));
    % Extraer los elementos de la diagonal
    for i = 1:min(m, n)
        diag_elements(i) = x(i, i);
    end
    % Extraer los elementos de la anti-diagonal
    for i = 1:min(m, n)
        antidg_elements(i) = x(m-i+1, i);
    end
end
Check out the result of "emoji matrix" multiplication below.
- vector multiply vector:
a = ["😁","😁","😁"]
b = ["😂";
    "😂"
    "😂"]
c = a*b
d = b*a
- matrix multiply matrix:
matrix1 = [
  "😀", "😃";
  "😄", "😁"]
matrix2 = [
  "😆", "😅";
  "😂", "🤣"]
resutl = matrix1*matrix2
enjoy yourself!
For Valentine's day this year I tried to do something a little more than just the usual 'Here's some MATLAB code that draws a picture of a heart' and focus on how to share MATLAB code. TL;DR, here's my advice
- Put the code on GitHub. (Allows people to access and collaborate on your code)
- Set up 'Open in MATLAB Online' in your GitHub repo (Allows people to easily run it)
I used code by @Zhaoxu Liu / slandarer and others to demonstrate. I think that those two steps are the most impactful in that they get you from zero to one but If I were to offer some more advice for research code it would be
        3. Connect the GitHub repo to File Exchange (Allows MATLAB users to easily find it in-product).
       4. Get a Digitial Object Identifier (DOI) using something like Zenodo. (Allows people to more easily cite your code)  
There is still a lot more you can do of course but if everyone did this for any MATLAB code relating to a research paper, we'd be in a better place I think.  
Here's the article: On love and research software: Sharing code with your Valentine » The MATLAB Blog - MATLAB & Simulink 
What do you think?
I got thoroughly nerd-sniped by this xkcd, leading me to wonder if you can use MATLAB to figure out the dice roll for any given (rational) probability. Well, obviously you can. The question is how. Answer: lots of permutation calculations and convolutions.

In the original xkcd, the situation described by the player has a probability of 2/9. Looking up the plot, row 2 column 9, shows that you need 16 or greater on (from the legend) 1d4+3d6, just as claimed.
If you missed the bit about convolutions, this is a super-neat trick
[v,c] = dicedist([4 6 6 6]);
bar(v,c)
% Probability distribution of dice given by d
function [vals,counts] = dicedist(d)
% d is a vector of number of sides
n = numel(d); % number of dice
% Use convolution to count the number of ways to get each roll value
counts = 1;
for k = 1:n
    counts = conv(counts,ones(1,d(k)));
end
% Possible values range from n to sum(d)
maxtot = sum(d);
vals = n:maxtot;
end
MATLAB FEX(MATLAB File Exchange) should support Markdown syntax for writing. In recent years, many open-source community documentation platforms, such as GitHub, have generally supported Markdown. MATLAB is also gradually improving its support for Markdown syntax. However, when directly uploading files to the MATLAB FEX community and preparing to write an overview, the outdated document format buttons are still present. Even when directly uploading a Markdown document, it cannot be rendered. We hope the community can support Markdown syntax!
BTW,I know that open-source Markdown writing on GitHub and linking to MATLAB FEX is feasible, but this is a workaround. It would be even better if direct native support were available.
I noticed recently that my data is no longer updating on thingspeak again. Is there a connectivity issues with thingspeak
















