主要内容

搜索


Is anyone else disappointed with uifigures? It seems apparent that these will eventually replace traditional figures, but there is still so much that doesn't quite work. I've tinkered with uifigures since their introduction in release 2016a, but even in 2020a I can't reliably export a uifigure to a graphics file. Sure it works sometimes, but not if a uipanel is present. The exportgraphics command is not as powerful as the print command, leaving some graphic formats (such as *.svg and *.eps) unsupported. How do you generate graphic files of a specific size? You can't even use subplots without overriding the default AutoResizeChildren setting!
Everything with uifigures seems to be slower and less stable than the figure variant. App Designer is much better than GUIDE, but that is not exactly high praise. I would rather generate "apps" programatically across several files instead of dealing with a single-file class definition containing 1000+ lines.
Where is this transition going? MATLAB graphics are moving away from Java in favor of JavaScript, and I'm not sure that we are at all ready for that.

WiDS Datathon 2021 is going on right now. The focus of the Datathon this year is "on creating models to classify whether patients have been diagnosed with a certain type of diabetes." You can register and participate until March 1.

Also, take a look at this blog post on the MATLAB benchmark code for this datathon.

MATLAB Benchmark Code for WiDS Datathon 2021

There are also various online challenges by MathWorks that students may be interested. Here are the winners from last year's Simulink Student Challenge. There was also a MATLAB Online Live Editor Challenge a couple of years ago.

Hello , I wonder how to determine continous or discrete time modelling.For example if I want to run my model in MCU in this case discrete model is suitable?I am a bit confused

David
David
上次活动时间: 2021-2-23

MATLAB Answers will now properly handle the use of the '*@*' character when you want to get someone's attention. This behavior is commonly referred to as 'mentioning' or 'tagging' someone and is a feature found in most communication apps.

Why we are doing this

To help with communication and potentially speed up conversations. Also, it turns out many of you have been typing the @ character in Answers already, even though the MATLAB Answers site didn't behave in the expected way.

How it works

Once you type the @ character a popup will appear listing the community members already in the Q/A thread, as you keep typing the list will expand to include members not in the thread. A mentioned user will receive a notification when the question/answer/comment is posted. Each mention in the Q/A thread will have a new visual style and link to the user profile for that community member.

If you don't want to get 'mentioned' you can turn off the setting in your communication preferences located on your profile page .

We hope you will find this feature helpful and as always please reply with any feedback you may have.

We have created a new community for users of ThingSpeak. This new community is for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.

Christopher Stapels will be moderating the new ThingSpeak community .

We encourage you to visit the new community and share best practices, examples, and ask questions.

MathWorks is please to offer a new training course, Power Electronics Control Design with Simulink and Simscape.

This one-day course focuses on modeling and controlling power electronic systems in the Simulink® environment using Simscape Electrical™. Topics include:

  • Modeling direct current (dc) power electronic components
  • Controlling the level of fidelity in a model
  • Developing controls for power electronics
  • Modeling three-phase alternating current (ac) power electronic components
  • Controlling power electronics for motor drive applications
David
David
上次活动时间: 2021-1-21

Ameer Hamza had a great 2020 and has been awarded the coveted MOST ACCEPTED answers badge for all his contributions in MATLAB Answers this past year. Ameer joins Walter Roberson and Image Analyst in receiving this award going all the way back to 2012!

There are 10 community members who have achieved the Top Downloads badge for their popular File Exchange submissions in 2020. Do you recognize any of these names? There's a good chance you've used one or more of their toolboxes or scripts in your work if you're a frequent visitor to File Exchange, if you're not you might want to check out what they've posted, it may save you a lot of time writing your own code.

--------------------- Top Downloads Badge Winners -----------------

Congratulations to all these winners and a giant THANK YOU for all they've done this past year to help everyone in the MATLAB Central community!

Hi everyone,

I am a third year BEng Energy Engineering student. I am looking at the design, modelling and peformance of an HVDC power converter for use in offshore wind for my final year dissertation. Power electronics is a new area for me and I am also new to simulink/ simscape elctrical.

Could anyone provide some useful examples of MMC (in particular rectifiers), or some advice for designing in simscape electrical. I am struggling with the design of PWM control especially. I aim to make a scaled down version of the MMC in Simulink but so far have had no luck. If anyone can help I would be really appreciative.

Thanks in advance.

Joe

Hi everybody!I've realized a DC/DC Buck Converter Model with closed loop control system. I need to limit the overshoot in the step response of the submitted system. I've already tried to tune the controller in the PID Tuner by manually adjusting the overshoot by moving the response time slider, as it is said in this article: https://it.mathworks.com/help/slcontrol/gs/automated-tuning-of-simulink-pid-controller-block.html The problem is that it is not accurate. I manage to get an overshoot of 4.77% or 5.4%, whereas i need to set the parameters in order that the overshoot is 5%. Should I use TuningGoal.Overshoot? How am I supposed to do? How should I set the input and output in my model? I've read Matlab documentation but I didn't catch that. Thanks in advance!

I am currently working on simulink online but I cannot maximize the screen

Just making sure people are aware of our new Onramp courses. These are great self-learning resources for students.

Released a few months ago:

Released this month:

How do you teach subjects like Programming and Numerical Computing hands-on in these challenging times?

Prof Chiranjoy Chattopadhyay at the Dept of Computer Science and Engineering at IIT Jodhpur shares his innovative approach to teaching at a distance in this new Technical Article on Teaching Parallel Computing Online with MATLAB.

The course utilized MATLAB Online , MATLAB Onramp and MATLAB Grader to train students in the basics of technical computing, in addition to using a Hands-on Online GPU workshop organised with the MathWorks Education Team. As a result of this approach to distance teaching, the students have reported good levels of understanding in the main learning outcomes of this course, as indicated in the survey results (below):

Please consider trying out the links above to check if your course might benefit from a similar approach, and feel free to message us if you are interested in learning more.

Jiro Doke
Jiro Doke
上次活动时间: 2020-11-30

I just highlighted an app on File Exchange for emulating an experiment. Great idea for doing lab classes with software. What I like about this app is that it incorporates statistical variance and measurement noise that comes from physical experiments.

Read more about it here:

https://blogs.mathworks.com/pick/2020/11/20/emulating-a-physical-experiment-of-measuring-mms/

I see this solution on the Cody solutions list. Solution 1949216
I am puzzled as to how this could possibly be rated as correct (size 48)
(BTW - I am pretty sure I saw this, or similar, before.)
function ans = fileread(varargin)
' ';
a=1;
b=3;
a=1;
b=3;a=1;
b=3;a=1;
b=3;a=1;
b=3; end

Hi everyone, I'm trying to estimate the Frequency Response of a buck converter. I've found this article: https://it.mathworks.com/company/newsletters/articles/estimating-the-frequency-response-of-a-power-electronics-model.html I've adapted the procedure to a buck converter and followed the instructions but something went wrong. In the last step I've performed a time-domain verification in a Simulink® simulation with the switch-mode buck converter and a Transfer Function block implementing the parametric estimation and compare the response of both systems to the same small perturbation signal but the estimated model response doesn't match the switching model response. I don't know why I've got a diverging systems. I've tried to reduce the load and modify the duty cycle but nothing changed. How can I fix it?

In the link below (File Exchange), you'll find an example with an electric motor supplied by a fuel cell stack (Simscape implementation) and a battery. When motor load is low-to-normal, the fuel cell provides excess energy, that is used to recharge the battery. At motor peak load, the battery needs to contribute in order to complete the expected duty. If you have any query or thoughts, please reach me at jsagardu@mathworks.com

https://www.mathworks.com/matlabcentral/fileexchange/59343-fuel-cell-battery-driven-electric-motor-h2-transfer

I would like to plot 2 discrete vectors on one graph created as follows: u=1; X={u,2*u,3*u,4*u,5*u,6*u,7*u,8*u,9*u}; Y={u,3*u,5*u,-u,-6*u,u-u,u^2,u^3,u^4}; stem(X,Y) unfortunately system returns error how to do it properly?

  1. Use the new exportapp function to capture an image of your app|uifigure
  2. MATLAB's getframe now supports apps & uifigures
  3. Review: How to get the handle to an app figure

Use the new exportapp function to capture an image of your app|uifigure

Imagine these scenarios:

  • Your app contains several adjustable parameters that update an embedded plot and you'd like to remember the values of each app component so that you can recreate the plot with the same dataset
  • You're constructing a manual for your app and would like to include images of your app
  • You're app contains a process that automatically updates regularly and you'd like to store periodic snapshots of your app.

As of MATLABs R2020b release , we no longer must rely on 3rd party software to record an image of an app or uifigure.

exportapp(fig,filename) saves an image (JPEG | PNG | TIFF | PDF) of a uifigure ( fig) with the specified file name or full file path ( filename). MATLAB's documentation includes an example of how to add an [Export] button to an app that allows the user to select a path, filename, and extension for their exported image.

Here's another example that merely saves the image as a PDF to the app's main folder.

1. Add a button to the app and assign a ButtonPushed callback function to the button. This one also assigns an icon to the button in the form of an svg file.

2. Define the callback function to name the image after the app's name and include a datetime stamp. The image will be saved to the app's main folder.

% Button pushed function: SnapshotButton
function SnapshotButtonPushed(app, ~) 
    % create filename containing the app's figure name (spaces removed)
    % and a datetime stamp in format yymmdd_hhmmss
    filename = sprintf('%s_%s.pdf',regexprep(app.MyApp.Name,' +',''), datestr(now(),'yymmdd_HHMMSS'));
    % Get the app's path
    filepath = fileparts(which([mfilename,'.mlapp']));
    % Store snapshot
    exportapp(app.MyApp, fullfile(filepath,filename))
end

Matlab's getframe now supports apps & uifigures

getframe(h) captures images of axes or a uifigure as a structure containing the image data which defines a movie frame. This function has been around for a while but as of r2020b , it now supports uifigures. By capturing consecutive frames, you can create a movie that can be played back within a Matlab figure (using movie ) or as an AVI file (using VideoWriter ). This is useful when demonstrating the effects of changes to app components.

The general steps to recording a process within an app as a movie are,

1. Add a button or some other event to your app that can invoke the frame recording process.

2. Animation is typically controlled by a loop with n iterations. Preallocate the structure array that will store the outputs to getframe. The example below stores the outputs within the app so that they are available by other functions within the app. That will require you to define the variable as a property in the app.

% nFrames is the number of iterations that will be recorded.
% recordedFrames is defined as a private property within the app
app.recordedFrames(1:nFrames) = struct('cdata',[],'colormap',[]);

3. Call getframe from within the loop that controls the animation. If you're using VideoWriter to create an AVI file, you'll also do that here (not shown, but see an example in the documentation ).

% app.myAppUIFigure: the app's figure handle
% getframe() also accepts axis handles
for i = 1:nFrames
      ... % code that updates the app for the next frame
      app.recordedFrames(i) = getframe(app.myAppUIFigure);
  end

4. Now the frame data are stored in app.recordedFrames and can be accessed from anywhere within the app. To play them back as a movie,

movie(app.recordedFrames) 
% or 
movie(app.recordedFrames, n) % to play the movie n-times
movie(app.recordedFrames, n, fps) % to specify the number of frames per second

To demonstrate this, I adapted a copy of Matlab's built-in PulseGenerator.mlapp by adding

  • a record button
  • a record status lamp with frame counter
  • a playback button
  • a function that animates the effects of the Edge Knob

Recording process (The GIF is a lot faster than realtime and only shows part of the recording) (Open the image in a new window or see the attached Live Script for a clearer image).

Playback process (Open the image in a new window or see the attached Live Script for a clearer image.)

Review: How to get the handle to an app figure

To use either of these functions outside of app designer, you'll need to access the App's figure handle. By default, the HandleVisibility property of uifigures is set to off preventing the use of gcf to retrieve the figure handle. Here are 4 ways to access the app's figure handle from outside of the app.

1. Store the app's handle when opening the app.

app = myApp;
% Get the figure handle
figureHandle = app.myAppUIFigure;

2. Search for the figure handle using the app's name, tag, or any other unique property value

allfigs = findall(0, 'Type', 'figure'); % handle to all existing figures
figureHandle = findall(allfigs, 'Name', 'MyApp', 'Tag', 'MyUniqueTagName');

3. Change the HandleVisibility property to on or callback so that the figure handle is accessible by gcf anywhere or from within callback functions. This can be changed programmatically or from within the app designer component browser. Note, this is not recommended since any function that uses gcf such as axes(), clf(), etc can now access your app!.

4. If the app's figure handle is needed within a callback function external to the app, you could pass the app's figure handle in as an input variable or you could use gcbf() even if the HandleVisibility is off.

See a complete list of changes to the PulseGenerator app in the attached Live Script file to recreate the app.