Pull up a chair!

Discussions is your place to get to know your peers, tackle the bigger challenges together, and have fun along the way.

  • Want to see the latest updates? Follow the Highlights!
  • Looking for techniques improve your MATLAB or Simulink skills? Tips & Tricks has you covered!
  • Sharing the perfect math joke, pun, or meme? Look no further than Fun!
  • Think there's a channel we need? Tell us more in Ideas


Matt J
Matt J
Last activity about 8 hours ago

Are there Matlab features which intend to satisfy your needs but fail in certain critical areas, forcing you to abandon them completely in favor of your own version or a 3rd party alternative? Perhaps these features are starting to improve with new Matlab releases, but not quickly enough? Share your own frustrations in the comments below.
Here are two of mine:
1. volumeViewier
volumeViewer is 6 years old now. It is fine when you only need to view one 3D image at a time, but I never do. In my work, I am putting several images side-by-side for visual comparison. For such work, you need to be able to programmatically change axis limits and grayscale and use @doc:linkprops to reflect these changes across all the images. With 2D image comparison, all that is possible, but volumeViewer supports none of those things. So, I resort to my own 3D viewer
2.Tomographic projection commands RADON and FANBEAM
These commands are provided in the Image Processing Toolbox seemingly for no other reason than to support homework exercises for people taking introductory tomographic imaging courses. They fail in a number of ways for people who need to do serious tomographic imaging work, producing artifacts or nonlinear effects which shouldn't be there. See for example Why isn't FANBEAM linear? or Radon Transform works unexpectedly. Moreover, the toolbox still provides tomographic projectors only for 2D imaging not 3D, even though 64-bit RAM has made volumetric imaging commonplace in Matlab for at least 10 years. Luckily, there are now freely available 3rd party alternatives like TIGRE.
Hi Everyone,
I have Experiemental Data (Bode Plot), using MATLAB I found the Transfer Function of my plant. I have attached my E7i_CSV file.
T2 = readtable('E7i_CSV.csv');
% Fill With Actual Sampling Frequency
FHz = T2.F;
Ts = 1/(2*(max(FHz)+10000))
for k = 1:size(T2,1)-1
if FHz(k+1) == FHz(k)
FHz(k+1) = FHz(k+1)+0.5; % 'Brute Force' Interpolation
end
end
Mag = T2.G;
PhDeg = T2.P;
Response = Mag.*exp(1j*deg2rad(PhDeg)); % Complex Vector
sysfr = idfrd(Response, FHz, Ts, 'FrequencyUnit','Hz')
%bode(sysfr)
%tfsys = tfest(sysfr,4,3) This is much better
tfsys = tfest(sysfr,4,3) %82.69%
%tfsys = tfest(sysfr,6,3)
figure
compare(sysfr, tfsys)
is_stable = isstable(tfsys);
disp(is_stable);
I want to convert this transfer function to statespace equations, which will be used for Model Predictive Control Design. Simple tf2ss command give me TF but it doesn't look very accrurate.
[A, B, C, D] = tf2ss(num,den)
So, I was reading a paper which i will follow, they have mentioned that they had FRF (Frequency Response Function) data and they find state space model/equations using Prediction Error Method (PEM). But I am unable to understand how I can used Bode Plot data and convert it state space using PEM. I will appreciate your help.
Secondy I verified the paper StateSpace Model by first converting it to Transfer Function and then using tf2ss command. which shows inaccurate results similiar to my results. I am looking for your help. Following is the verification code for paper i am following
%Rana Paper State Space Equations Coversion to
%Transfer Function for Validation Reason
% Define state-space matrices
Ax = [-49.3277, -980.7648, 618.2198;
567.3557, -120.2273, 651.7342;
-45.8885, -415.4194, -115.7522];
Bx = [-1.8122; 3.901370; 4.3011];
Cx = [14.9368, 16.9208, -23.6827];
Dx = 0;
% Create a state-space model
sys = ss(Ax, Bx, Cx, Dx);
% Display the state-space model
disp('State-Space Model:');
disp(sys);
% Convert the state-space model to a transfer function
tf_sys = tf(sys);
% Display the transfer function
disp('Transfer Function:');
disp(tf_sys);
%TF to StateSpace Rana Model
num_rana = [ -62.92 3.625*10^4 -1.065*10^8];
den_rana = [ 1 285.3 8.811*10^5 1.982*10^8];
tff_rana = tf(num_rana,den_rana);
tffss_rana = tf2ss(num_rana,den_rana);
[Arana,Brana,Crana,Drana] = tf2ss(num_rana,den_rana);
Shore
Shore
Last activity about 10 hours ago

Halloween Analysis of Many Aspects of Halloween Headquarters and Effects on USA
(Note to Chistopher: I used a simple ESP8266 generating random numbers for fields 1 thru 7, (0 to 100, 4000, 127, 30, 45, 200,000, 50,000) and 0 to 1 for field 8. And a couple of real sensor inputs.
goc3
goc3
Last activity about 3 hours ago

Have you ever learned that something you were doing manually in MATLAB was already possible using a built-in feature? Have you ever written a function only to later realize (or be told) that a built-in function already did what you needed?
Two such moments come to mind for me.
1. Did you realize that you can set conditional breakpoints? Neither did I, until someone showed me that feature. To do that, open or create a file in the editor, right click on a line number for any line that contains code, and select Set Conditional Breakpoint... This will bring up a dialog wherein you can type any logical condition for which execution should be paused. Before I learned about this, I would manually insert if-statements during debugging. Then, after fixing each bug, I would have to delete those statements. This built-in feature is so much better.
2. Have you ever needed to plot horizontal or vertical lines in a plot? For the longest time, I would manually code such lines. Then, I learned about xline() and yline(). Not only is less code required, these lines automatically span the entire axes while zooming, panning, or adjusting axis limits!
Share your own Aha! moments below. This will help everyone learn about MATLAB functionality that may not be obvious or front and center.
(Note: While File Exchange contains many great contributions, the intent of this thread is to focus on built-in MATLAB functionality.)
Moja
Moja
Last activity on 13 Oct 2023 at 19:09

The carot symbol on my keyboard (ˆ shift+6) doesn't work on matlab. Matlab doesn't recognize it so I can't write any equation with power symbol. I tried every possible solution on the web and it doesn't work. even in the character viewer I don't have any result when I search ''caret".
Exciting news for students! 🚀Simulink Student Challenge 2023 is live! Unleash your engineering skills and compete for exciting rewards. Submission deadline is December 12th, 2023!
In the past year, we've witnessed an exponential growth of ChatGPT and other Generative AI tools. AI has quickly become a transformative force across industries, from tech giants to small startups, and even community sites like ours. For instance, Stack Overflow announced its plan to leverage AI tools to draft a question or tag content; Quora built a ChatGPT bot to answer questions; and GitHub is piloting the AI tool for personalized content.
This trend in the community landscape makes me wonder what MATLAB Central community, especially in MATLAB Answers, can do to integrate AI and enhance the community.
Share with us your ideas in the comment session. Ideally one comment per idea, so that others can vote on a secific idea or have deeper discussions about it.
Adam and Heather will be discussing new features in R2023b and answering your questions in a few hours - visit the link below to check out the preview and sign up for notification.
We launched the Discussions area with 6 channels, based on the existing types of content we see today in the MATLAB Central community.
I'm curious which channels you are most interested in participating, or which channels are missing.
Tell us your thoughts here!
Adam Danz just launched a new blog about MATLAB Graphics and App Building.
As you know, He has been a prolific contributor to MATLAB Answers and one of his answers recently won the Editor's Choice Award.
If there are any topics or questions you are interested in, please share with Adam, and I am sure he will get those into his blog.
Adam Danz
Adam Danz
Last activity on 13 Oct 2023 at 22:04

Over the weekend I came across a pi approximation using durations of years and weeks (image below, Wolfram, eq. 89), accurate to 6 digits using the average Gregorian year (365.2425 days).
Here it is in MATLAB. I divided by 1 week at the end rather than multiplying by its reciprocal because you can’t divide a numeric by a duration in MATLAB (1/week).
weeks = @(n)n*days(7);
piApprox = ((years(13)-weeks(6))/years(13) + weeks(3)) / weeks(1)
% piApprox = 3.141593493469302
Here’s a breakdown
  • The first argument becomes 12.885 yrs / 13 yrs or 0.99115
  • Add three weeks: 0.99115 + 3 weeks = 21.991 days
  • The reduced fraction becomes 21.991 days / 7 days
Now it looks a lot closer to the more familiar approximation for pi 22/7 but with greater precision!
This person used computer version to build a keyboard input, and used standard flag semaphore for the positions.
Flag semaphore is used mostly by sailors to be able to communicate optically over a distance; it does not need anything more than make-shift flags (but binoculars or telescopes can help.) Trained users can go faster than you might guess.
Hans Scharler
Hans Scharler
Last activity on 10 Oct 2023 at 17:42

Chen, Rena, and I are at a community management event. It's great to be with others talking about relationships, trust, and co-creation.
Chen Lin
Chen Lin
Last activity on 10 Oct 2023 at 17:41

I'm in a community conference in Boston today and see what snacks we get! The organizer said it's a coincidence, but it's definitly a good idea to have them in our MathWorks community meetings.
Walter Roberson
Walter Roberson
Last activity on 7 Oct 2023 at 3:54

A research team found a way to trick a number of AI systems by injecting carefully placed nonsense -- for example being able able to beat DeepMind's Go game.
This video discusses the "Cody" bridge, which is a pedestrian bridge over a canal that has been designed to move up and out of the way when ships need to travel through. The mathematics of the bridge movement are discussed and diagrammed. It is unique and educational.
Walter Roberson
Walter Roberson
Last activity on 5 Oct 2023 at 2:27

Recently developed: a "microscope" based on touch and stereo vision.
Using touch removes the possibility of optical confusion -- for example, black on touch is only due to shape, not due to the possibility that the object has a black patch.
Sorry, you might need a Facebook account to watch the video.
Image Analyst
Image Analyst
Last activity on 3 Oct 2023 at 21:38

(Sorry - it should be 2023b by now.)
Mike Croucher
Mike Croucher
Last activity on 4 Oct 2023 at 21:22

Adam Danz
Adam Danz
Last activity on 12 Oct 2023 at 23:47

I'm curious how the community uses the hold command when creating charts and graphics in MATLAB. In short, hold on sets up the axes to add new objects to the axes while hold off sets up the axes to reset when new objects are added.
When you use hold on do you always follow up with hold off? What's your reasoning on this decision?
Can't wait to discuss this here! I'd love to hear from newbies and experts alike!