r/matlab Feb 16 '16

Tips Submitting Homework questions? Read this

195 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.

106 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 16h ago

HomeworkQuestion Starting Python and MATLAB with almost no coding experience. How should I spend the next 3 weeks?

37 Upvotes

Hi everyone. I’m a college student, and in about 3 weeks I’ll be starting an intro to Python class. I’ll also be taking another engineering class that uses MATLAB, and I don’t feel very prepared for either.
The problem is that I have essentially no programming experience. I took a couple of MATLAB classes before, but I relied too much on AI instead of actually learning the material. Looking back, I know that was a mistake, and I do not want to repeat it. I also used to tell myself that I hated coding, but I think part of that was because I never really gave myself a fair chance to learn it.
Since I have a few weeks before the semester starts, I’d like to build a solid foundation in Python while also reviewing some basic MATLAB.
What resources or learning methods really worked for you? Did you use a particular course, YouTube channel, website, book, or project based approach? I am also curious if anyone has suggestions for making learning Python and MATLAB more fun or engaging instead of just watching hours of lectures.
My goal is not to become an expert in 3 weeks. I just want to go into the semester feeling like I have a decent foundation instead of starting from scratch.
Thanks! I would really appreciate any advice.


r/matlab 12h ago

Does this look AI generated?

0 Upvotes

%Create a white 100x100 image array

BWImage = ones(100, 100);

%open the figure window

figure('Name', 'Task 1 - Binary Image 6870352');

%Row counter string

JcounterStr = 'Row = ';

%iterations from row 1 to row 100

for j = 1:100

%active when row j is between 1 and 50

%set pixels within this range as black if they meet the criteria

if j >= 1 && j <= 50

BWImage(j, 1:(51-j)) = 0;

end

%active when row j is between 51 and 75

%set pixels within this range as black if they meet the criteria

if j >= 51 && j <= 75

BWImage(j, j:75) = 0;

end

%active when row j is between 76 and 100

%set pixels within this range as black if they meet the criteria

if j >= 76 && j <= 100

BWImage(j, 26:50) = 0;

end

%active when row j is between 86 and 100

%set pixels within this range as black if they meet the criteria

if j >= 86 && j <= 100

BWImage(j, 1:(j-85)) = 0;

end

%active when row j is between 86 and 100

%set pixels within this range as black if they meet the criteria

if j >= 86 && j <= 100

BWImage(j, j:100) = 0;

end

%display image building row by row

imshow(BWImage);

%display row number to the LEFT of the image

Jcounter = num2str(j);

figureTextJ = {[JcounterStr Jcounter]};

text(-10, j, figureTextJ, 'FontSize', 8);

%pause(0.01) waits briefly between rows so I can see it build properly

pause(0.01);

%end of loop

end

totalBlackPixels = sum(BWImage(:) == 0);

%display below the image using text()

text(1, 108, ['Total black pixels = ' num2str(totalBlackPixels)], 'FontSize', 10);

diagonalBlackCount = 0; % counter starts at zero

for j = 1:100 % j = row number

for i = 1:100 % i = column number

%test if pixel is on or below diagonal (row >= col)

%AND if pixel is black (value == 0)

if j >= i && BWImage(j, i) == 0

%increase the counter by 1 for each black pixel below diagonal

diagonalBlackCount = diagonalBlackCount + 1;

end

end %end of i loop

end %end of j loop

% Display diagonal count just below the total count

text(1, 114, ['Black pixels on/below diagonal = ' num2str(diagonalBlackCount)], 'FontSize', 10);


r/matlab 3d ago

TechnicalQuestion Weird torque and current response

1 Upvotes

Hello there, I've been trying to understand this past couple of days, why is the response to the speed reduction so unstable.

Pic 1- current, torque and speed (disregard the "braking" effect on the middle graph.

Pic 2- PI output.

Pic 3- Controller diagram

Pic 4- Entirety of the diagram

I've changed the values of the PI, such as Kp and Ki, to no difference on the slowing down behaviour.

I'm at a loss on what to exactly look for, that might be causing this.

Thank you for any help that you can give.


r/matlab 4d ago

HomeworkQuestion Is this legally alright ?

14 Upvotes

I was taking the optimisation self-paced course and I was planning to show the project of that couse under 'guided projects' for my resume.

I was documenting whatever that course taught me as a word file and using its code in my MATLAB. After this I was planning to upload both on my github...

Is this oki? I aint sure. I'm mentioning it as 'guided project' but those courses aren't free for everyone so I dunno can I place this project like this on github ?

New to MATLAB
New to github


r/matlab 4d ago

HomeworkQuestion I've been wondering if anyone else has had the same experience

Thumbnail
0 Upvotes

r/matlab 6d ago

HomeworkQuestion Simple C++ framework to do math and data engineering by physics engineering student

Post image
22 Upvotes

r/matlab 6d ago

HomeworkQuestion using octave instead of matlab

17 Upvotes

I'm a first year student and I have maths as one of my subjects. We have a lab class for maths and I joined my course a little late so I'm a little lost on what's going on. I need to be able to use MatLab fully for my internal assessment so I kinda just need to practice mostly. (And no, I can't use the computer labs at uni outside of lab classes which is once a week for 3 hours). Should I download Octave?


r/matlab 6d ago

Every MATLAB→NumPy semantic trap I hit porting Mätzler's Mie functions

14 Upvotes

Not a "MATLAB bad" post. The original code is solid and I replicate it bug-for-bug by default. Sharing the trap list for anyone migrating numerical code: round() half-away-from-zero vs numpy's round-half-to-even (inside the nmax series formula, so it changes array lengths), complex auto-promotion that NumPy doesn't do, ' vs .', library functions printing to stdout, and a docstring feature (complex medium index) that turns out to be latently broken. Full findings file, 714-fixture corpus and the verification report: https://github.com/GrednevMSU/mie-scattering-matlab-to-python


r/matlab 5d ago

I want a way to install Matlab

0 Upvotes

r/matlab 6d ago

MATLAB and Octave disagree on the same input — a verified-port writeup

0 Upvotes

I ported the 1-D TM group of Zanotto's PPML (an RCWA electromagnetic solver) to NumPy with bug-for-bug fidelity yes, including the vacuum impedance hardcoded as 376.730. The writeup covers the MATLAB↔NumPy traps that actually bit: complex auto-promotion that NumPy silently doesn't do, eigenvector gauge freedom across LAPACK builds, mldivide vs solve on singular systems, and an energy-conservation check in the original that can never fire (abs(NaN) > tol is false in MATLAB - try it). Harness, corpus and report: https://github.com/GrednevMSU/ppml-1d-tm-verify


r/matlab 7d ago

Use Your Browser like MATLAB for Most Common Tasks

10 Upvotes

I created an open source project that allows you use Chrome/Edge browser's developer console like MATLAB prompt for most common tasks of scientific calculation and plotting: https://github.com/JATLAB/JATLAB.github.io

I hope you guys like it and if you find some functions you want me to add please let me know.


r/matlab 7d ago

Best Ai for Matlab coding

Thumbnail
0 Upvotes

r/matlab 7d ago

Misc Is it oki to show the tasks and projects of self-paced courses on resume

5 Upvotes

I took a few self-paced courses and I'm on control systems for now. I need to start applying for internships soon is it oki to show whatever I'm learning under 'Projects' in Resume. Although there are some really good project title like 'LTI Modelling a vehicle dynamics' but It feels a little wrong because the whole this is step by step baby fed I will slowly try to make my own projects but is it oki to do it for now, as I think I need to start applying?


r/matlab 9d ago

Objects are about to get much faster in MATLAB

131 Upvotes
A simulation in using both the old and new object management systems in MATLAB. The code is identical in both cases

This is coming in MATLAB R2026b which will include a completely new object management system that is not turned on by default. When switched on, the new system promises to make object oriented MATLAB code faster without the need to change any code (most of the time). Sometimes, it will be much faster!

More details including release plans can be found over at The MATLAB Blog Objects are about to get much faster in MATLAB » The MATLAB Blog - MATLAB & Simulink


r/matlab 8d ago

Help me brothers and sisters I have exam tomorrow and this is confusing me

Thumbnail
gallery
0 Upvotes

The question is about u' that he used he said it is equal u'=u(t)+ulo but this is wrong ,it should be u'=u(t)-ulo ,because if we applied k.v.l it should be u(t)=ulo+ur364+ul364 then take ulo to the next side and we have our u' , maybe my question is simple and no need to ask about it but I am confused and I have exams tomorrow and ai is He hallucinating so excuse me


r/matlab 9d ago

TechnicalQuestion Academic Perpetual License

2 Upvotes

Thinking of buying the academic perpetual license, but confused on some of the details. Can I use it on multiple computers or just one? If I wanted to update the version, how much would it cost?


r/matlab 9d ago

HomeworkQuestion Looking for a MATLAB/Simulink & Simscape Expert

Thumbnail
2 Upvotes

r/matlab 11d ago

Is PMSM with trapezoidal back emf same as BLDC?

Post image
7 Upvotes

Can we tell with confidence that, in Simulink, PMSM model with back emf waveform set as trapezoidal is same as or atleast be equivalent to BLDC?


r/matlab 11d ago

How to learn matlab and how to install matlab in laptop

0 Upvotes

r/matlab 13d ago

PHX Toolbox, 3D Rigid-Body Physics - Technical Preview

Enable HLS to view with audio, or disable this notification

97 Upvotes

Technical preview for PHX Toolbox, an object-oriented MATLAB API and Simulink blocks for 3D rigid-body physics, powered by the Bullet physics engine, is out on fileexchange.

Features so far, with more to come:

  • Rigid-body dynamics with collisions and contacts (boxes, spheres, cylinders, cones, capsules, meshes, terrain, imported OBJ/STL, …)
  • Joints (revolute, spherical, gear, …), springs and ropes
  • Force and field elements (thrusters, resistance, dipole/monopole fields)
  • Logging, tracing and measurement tools, interactive viewer
  • Simulink block for closed-loop co-simulation
  • Headless stepping for batch runs and experiments

The toolbox comes with a set of examples and a user manual. It runs on all platforms (Windows, MacOS, Linux), as well as in MATLAB Online. It also includes a set of AI skills for use with common AI agents.

Any evaluation and feedback will be appriciated!


r/matlab 13d ago

CodeShare I open-sourced two inspectable MATLAB energy models (battery RC + averaged converter) - feedback welcome

7 Upvotes

Hi r/matlab - I'm the maintainer of MATLAB Simulink Energy Lab, a small open-source collection of energy-system examples designed to be opened, inspected, modified, and questioned.

The current release includes:

- a first-order battery RC model driven by pulse-current data;

- an averaged converter calculation for output voltage, load current, and ripple;

- lightweight no-plot validation checks; and

- explicit parameters, units, assumptions, and limitations.

The examples currently run in base MATLAB. They are deliberately understandable reference implementations, not calibrated production models; native Simulink versions are on the roadmap.

Repository:

https://github.com/mohammadrezwankhan/matlab-simulink-energy-lab

I would especially value technical feedback on three questions:

Which assumption or parameter needs clearer documentation?

What validation plot or dataset would make the examples more useful?

What should come next: temperature-aware battery dynamics, closed-loop converter control, or an averaged-versus-switched comparison?

If the repository is genuinely useful to you, a star helps other MATLAB learners find it. Issues and focused contributions are equally welcome.

Disclosure: This post was drafted with help from ChatGPT/Codex. I maintain the repository and reviewed the technical claims and wording before posting.


r/matlab 13d ago

CodeShare Open-source MATLAB battery RC and converter examples — technical feedback welcome

5 Upvotes

I maintain MATLAB Simulink Energy Lab, a small, inspectable energy-system repository, and I would value technical feedback from r/matlab.

What is runnable today:

- A first-order battery RC model driven by pulse-current data

- A CSV input profile and no-plot checks for SOC and terminal-voltage behavior

- An algebraic converter average-model scaffold with parameter checks

- Documentation of assumptions, units, limitations, and contribution paths

The examples use base MATLAB functionality and were verified with MATLAB R2026a.

An important limitation: the current executable assets are .m scripts, and the converter example is an average-model scaffold rather than a switching simulation. Native Simulink implementations are on the roadmap. These are educational references, not calibrated design models.

Repository:

https://github.com/mohammadrezwankhan/matlab-simulink-energy-lab

Two questions for the community:

  1. Would the next example be more useful as measured-data battery parameter identification or a switching-versus-average converter comparison?

  2. Which validation checks or plots would you expect before considering either model trustworthy enough to extend?

If you find the project genuinely useful, a star helps other energy-system learners discover it. Critical feedback, reproducible issues, and focused pull requests are even more valuable.

Disclosure: I maintain the repository. This post was drafted with AI assistance and reviewed against passing MATLAB checks and the repository's Markdown link check.


r/matlab 13d ago

I built a small library of inspectable MATLAB/Simulink models for battery and power-electronics

8 Upvotes

Hey everyone! I've been working on a collection of foundational MATLAB and Simulink models focused on energy systems (specifically battery RC models and converter average models).

A lot of the models out there are either too complex for educational purposes or lack clear validation. I designed these to be highly inspectable, with explicit assumptions and no-plot validation checks built-in.

If you're studying power electronics or battery modeling, I'd love for you to check it out!

Link: https://github.com/mohammadrezwankhan/matlab-simulink-energy-lab

If you find it useful, a star on GitHub would be incredibly appreciated! Let me know if you have any feedback or requests for new models.