r/matlab Feb 16 '16

Tips Submitting Homework questions? Read this

190 Upvotes

A lot of people ask for help with homework here. This is is fine and good. There are plenty of people here who are willing to help. That being said, a lot of people are asking questions poorly. First, I would like to direct you to the sidebar:

We are here to help, but won't do your homework

We mean it. We will push you in the right direction, help you find an error, etc- but we won't do it for you. Starting today, if you simply ask the homework question without offering any other context, your question will be removed.

You might be saying "I don't even know where to start!" and that's OK. You can still offer something. Maybe you have no clue how to start the program, but you can at least tell us the math you're trying to use. And you must ask a question other than "how to do it." Ask yourself "if I knew how to do 'what?' then I could do this." Then ask that 'what.'

As a follow up, if you post code (and this is very recommended), please do something to make it readable. Either do the code markup in Reddit (leading 4 spaces) or put it in pastebin and link us to there. If your code is completely unformatted, your post will be removed, with a message from a mod on why. Once you fix it, your post will be re-instated.

One final thing: if you are asking a homework question, it must be tagged as 'Homework Help' Granted, sometimes people mis-click or are confused. Mods will re-tag posts which are homework with the tag. However, if you are caught purposefully attempting to trick people with your tags (AKA- saying 'Code Share' or 'Technical Help') your post will be removed and after a warning, you will be banned.

As for the people offering help- if you see someone breaking these rules, the mods as two things from you.

  1. Don't answer their question

  2. Report it

Thank you


r/matlab May 07 '23

ModPost If you paste ChatGPT output into posts or comments, please say it's from ChatGPT.

88 Upvotes

Historically we find that posts requesting help tend to receive greater community support when the author has demonstrated some level of personal effort invested in solving the problem. This can be gleaned in a number of ways, including a review of the code you've included in the post. With the advent of ChatGPT this is more difficult because users can simply paste ChatGPT output that has failed them for whatever reason, into subreddit posts, looking for help debugging. If you do this please say so. If you really want to piss off community members, let them find out on their own they've been debugging ChatGPT output without knowing it. And then get banned.

edit: to clarify, it's ok to integrate ChatGPT stuff into posts and comments, just be transparent about it.


r/matlab 1h ago

Camara DSRL with Matlab

Upvotes

At university, I am required to use a webcam to identify patterns using MATLAB. However, I don't have one, but I do have a Nikon DSLR camera. Is there a way to connect it without using a video capture device or a mobile phone? And which libraries can I use?


r/matlab 5h ago

Please help me understand this output

Post image
1 Upvotes

I’m really new to matlab and struggling with While loops. Could anyone help walk me through how this code spits out Q = [16 32 64 128]. I have to solve this type of problem on paper for my next exam, so any help is perfect!

Thank you.


r/matlab 10h ago

links between satellite and ground stations and device don’t appear

Thumbnail
youtu.be
1 Upvotes

i followed this tutorial but instead of the second ground station i added a device and deleted the second satellite, and wanted to connect links just as shown in the tutorial between the three of them yet the links don’t seem to appear no matter how hard i tried even when the satellite is above both the device and the ground station


r/matlab 1d ago

Acausal Modeling Libraries (Simscape) compared to Dymola / Simcenter Amesim

4 Upvotes

It seems that the trend is to move towards acausal modeling for all levels of modeling. This trend is being embraced by many 0D/1D modeling and simulation software, such as Dymola/Modelica, Simcenter Amesim, Modelon Impact, and GT-Suite. However, Simulink appears to be lagging a bit behind with its Simscape solution. Many of the libraries seem less advanced compared to those in GT-Suite or Simcenter Amesim. For instance, these two platforms offer apps for block parametrization, very detailed blocks for specific applications, and numerous almost ready-to-use demos/examples, all integrated within the same acausal environment.

Is this the case or just an impression? Does MathWorks have plans to enhance Simscape's libraries to match the detail and progress seen in other 0D/1D modeling software?


r/matlab 16h ago

Why does it say “Access Expires?”

Post image
0 Upvotes

r/matlab 15h ago

chat gpt code error

Thumbnail
gallery
0 Upvotes

i'm trying to run this code yet everytime this message appears, does anyone know why is it an error in the first place?


r/matlab 1d ago

The icons cannot be displaed in Simulink library browser, why?

1 Upvotes

Dear all, I installed a third-party toolbox (SDtoolbox), and it can be correctly opened in matlab command window, however, the icons are missing in simulink library browser, why?


r/matlab 1d ago

Integrating Multiple Simscape Models (on Subsystem Reference)

3 Upvotes

So I am working with this group of people on creating a model of a system. We decomposed it into multiple components groups that are developing the single component's models. We are using the Subsystem Reference approach to then integrate all the models. Since they are all Simscape based. They need a Solver Configuration block to run. These run-tests are done by importing a subsystem reference model model_subsys_1.slx into a unit_test_subsys_1.slx file in which the inputs for the component are provided to test its runtime. In that unit test file, the Solver Configuration block for the component is inserted.

Then we use another file, .slx -> system_integration.slx, to import all the subsystem references to the components (many repeated multiple times). The thing is:
I must use only TWO Solver Configuration blocks to run the system integration model.
However, each owner developed its component model with a different Solver Configuration block.

The integrated model is really slow. Currently, it is not even running because of Solver Configuration issues.

Does MathWorks suggest any workflow to solve this?


r/matlab 3d ago

Goodbye to Matlab

244 Upvotes

Despite having a rare limited edition MATLAB sticker, I must say goodbye forever to MATLAB as I transition from my math undergrad to an engineering PhD. I used MATLAB for 1 class, 1 research project, and my senior thesis. However:

  1. The app itself takes up a ton of storage space on my Mac
  2. It constantly crashes and freezes
  3. I have found suitable Python replacements for almost everything except for signal processing tools, which are somewhat lacking

I've reached my last straw—Matlab r2023b is constantly crashing and freezing. I appreciate the loyalty that MATLAB shows to the math community and I admit that its built-in functions have enabled my laziness but it's time for us to part ways.


r/matlab 1d ago

HomeworkQuestion Need Help Obtaining Coefficient values from PI controller (Simulink).

1 Upvotes

I have a model that uses a PI controller. I want to obtain the PID coefficients for various reference inputs (Constant, Ramp, Sine, Step).

Here is what I have done so far:

  1. Change the reference input type and value.
  2. Open the PI controller box.
  3. Use the Auto Tune function to find the coefficient value for that particular input reference.

Now, I have got one set of values. I want to obtain a large dataset that will be used for machine learning.

Any help will be appreciated.


r/matlab 2d ago

TechnicalQuestion Advice on UI implementation?

1 Upvotes

I've been working on a program called ThreadFinder for ~10 weeks now (my first personal project!!!). It's meant to calculate and display gradients of DMC embroidery thread colors. The base code works great, but I want to update it so rather than typing input into the command window it uses the uicontrol feature to have, like, buttons and drop-downs and such.

I understand how to insert a uicontrol element into a figure, but I'm having difficulties making it not look like a bad powerpoint. So I figured I'd ask what the typical workflow is for making a UI like this. Specs for what I want below:

- a segment that can display a color gradient based on an array containing titles for each color and rgb values for each (currently using a bar graph for this)

current output segment

- three menus that let you select a thread for start/end/ctrl of the gradient, ideally in some kind of dropdown menu that will show you a sample of the color you're selecting, and will let you type in a thread's 'name' (see the 20, 58, 96, etc along the bottom of the image) and shows you autocompletes for that.

- a toggle switch for linear /bezier calculation mode-- if linear is selected, ctrl thread menu should be greyed out and uneditable

- a toggle for color mode (cmyk or lch)

- a slider for how many threads you want as output

I want all of these elements in one figure / window, and I want to have access to some matlab tool that will let me finely configure the look of the ui panel elements. A friend of mine told me the uifigure tool gets you better control of ui look and feel, but I worry putting a bar graph in a user interface wouldn't work so well... any ideas as for what combo of tools I should use for this?


r/matlab 1d ago

CodeShare Rate my schizo code

Post image
0 Upvotes

Screenshot good


r/matlab 3d ago

News MATLAB R2025a Prerelease Update 5 is available - Give feedback

12 Upvotes

I was on vacation and didn't see this until now. It is not new news but the Update 5 of R2025a Prerelease is available. Try it and give feedback!

https://blogs.mathworks.com/matlab/2025/03/20/weve-been-listening-matlab-r2025a-prerelease-update-5-now-available/

Use the feedback button to give feedback

If you get a notification that your prerelease license is expired, you can extend it using the "Update Current License".


r/matlab 2d ago

Root Locus Graph with K in the denomenator

2 Upvotes

Hello,

I'm trying to graph the root locus of the transfer function 1/(2s^2 + 5Ks). I've written:

k=linspace(0,500,50);

sys = tf(1,[2 5*k 0]);

rlocus(sys)

And I get a pretty crazy output (attached here). Is this correct, a glitch, or a failure in how I've set it up?


r/matlab 2d ago

HomeworkQuestion Need help with my hydraulic simulation for automated Turning operation.

0 Upvotes

Hello, I have a task that needs me to make a working hydraulic circuit using simscape. The basic layout is feeding-clamping-cutting-declamping-feeder out. I have added sequence valves for clamp and cutter for extension and for clamp and feeder during retraction. After I ran the simulation, the output graph shows that all my sequence valves open at the same time (eg. feeder,clamp and cut start together). I can’t quite understand why this is happening and would love to hear your thoughts. Thank you for any suggestions.


r/matlab 3d ago

TechnicalQuestion Making "fzero" faster?

12 Upvotes

I have a script that finds the zeros of a function with fzero thousands or millions of times, which makes it pretty slow. Is there a way to make it any faster at the expense of precision? I've tried changing "XTol" as an option to reduce the tolerance, but no matter how I change it, including making the tolerance much bigger, it takes twice as long if I feed it tolerance options.

edit: turns out I don't actually need the fzero function, I gave up on the exact solution too soon.


r/matlab 4d ago

How do I call an app created using app designer in matlab 2024a?

2 Upvotes

I've used matlab app designer to create a 3D environment using the peaks function I've also packaged this app and installed it. How then do I call this app into my matlab scanning radar code in the editor so that it can interact with the 3D environment.


r/matlab 4d ago

TechnicalQuestion Simulink Arduino - Generated code exceeds available memory

3 Upvotes

Hello everyone. I'm trying to learn the Arduino package on Simulink. I was following the tutorial "Transmit and Receive Data Using Arduino CAN Blocks" on Mathworks when this error happened. I am using Arduino Uno R3 board.

So far I have tried:

- Changing Hardware Module to another board, upload to receive fail message then change back to Uno and upload.

- Run in I/O mode instead of on-board.

Neither of these worked and I still get the same error message.

Does anyone know how to fix this? Please let me know if you have any suggestions. Thanks for the help!


r/matlab 4d ago

Simulink not working?

Thumbnail
gallery
2 Upvotes

I'm working on some rocket GNC stuff and I launched simulink today to find -much to my dismay- that the scope blocks are not working. When i plug a step block into a scope block directly, the scope displays nothing. Any suggestions?


r/matlab 5d ago

TechnicalQuestion need to cheaply check if a matrix is invertible in a running algorithm

3 Upvotes

Lets say we have a matrix C that is of size d by d, and we want to invert it.

If C is full rank, there is no problem.

But if C is essentially low-rank, even though the zero eigenvalues are very close to machine epsilon, inverting C will return something like:

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.167957e-17.

I want to have an if statement that determines if this condition was met, as efficiently as possible. It shouldn't just check if this statement was made, since the matlab user may disable all warning statements like this. Then if the matrix is ill conditioned, I use pseudoinverse instead. I want this if loop because I always want to use inv instead of pseudoinverse when possible to save computations.

If inv just failed to work and gave an error when the matrix was singular, I could just use a "try" and "catch" to perform this, but the issue is that matlab will generally still return a matrix, albeit badly conditioned, and give the warning, so I need another way to check if this was singular.


r/matlab 4d ago

HomeworkQuestion Sum function not producing desired output

0 Upvotes

Working on a homework question and am having trouble with the sum function. I have a 3*2 matrix however when I use the sum function it does not add down the column. Here is my code:

r1 = [0 1]

r2 = [ (cos(pi/4)) (sin(pi/4))

]r3 = [ (3/5) (4/5) ]

F1 = 300 * r1

F2 = 450 * r2

F3 = 600 * r3

F = [ F1; F2; F3]

Fr = sum(F,1)

The output I continue to get is:

Fr =

1.0e+03 *

0.6782 1.0982

If anyone knows what could be causing this and help me out I would greatly appreciate it!


r/matlab 5d ago

HomeworkQuestion Fixing incompatible array sizes

0 Upvotes

Hey everyone. I am struggling desperately with a homework assignment. I keep getting an error code for these lines:

% Distribute the life-stages so that each subpopulation starts at 75% its

% carrying capacity

nt = repmat((0.75 * K) * stable_stage(:), 1, site_numbers);

% Apply to all subpopulations

% Simulation loop

for t = 1:time_steps nt = L * nt; for site = 1:site_numbers

% Apply Lefkovitch matrix to each site separately nt(:, site) = L * nt(:, site);

end

% Incorporate Ricker model

nt = nt .* exp(beta * (1 - sum(nt, 1) ./ K));

for s = 1:life_stages

nt(s, :) = nt(s,:) * M; % Migration applied to each life stage

end

record_individuals(t, :, :) = nt;

end

"Arrays have incompatible sizes for this operation.

Error in FreemanMCDermott_Tutorial10 (line 79)

nt(s, :) = nt(s, :) .* M'; % Element-wise multiplication (note the transpose on M)"


r/matlab 5d ago

TechnicalQuestion How do I add new data (from a table) into an existing table?

1 Upvotes

Let’s say I have a main table, with rows named A, B, and C, and columns named X,Y,Z. The data is a bunch of numbers. And say I have another table with new data that only has columns named X and Y and rows named A and C. How can I add the data from this new table into the existing, larger table? For example, cell {A, Y} from the smaller table should be added into the larger table’s cell {A, Y}.


r/matlab 5d ago

Need help i havr to do ocr using matlab of engraved text i Have an kind of manifolds i have to detect the tet but the code i am getting not working for me. If anyone suggest the method or any other technique would be helpful Thank you

1 Upvotes

#ocr


r/matlab 6d ago

Made a Pringle chips on MATLAB

30 Upvotes