Main Content

Results for


Hi Fellow Users,
I am Muthuserpi From A begginer of Optics studio Please anyone help me how to add two diffeaction reflective grating and How to tilt and decenter in matlab simulation
Thanks And Regards
S.Muthuserpi
Just in case, I have my license of MATLAB. I just have this question and I didn't find any information. I wouldn't like to create another account, for this reason I prefer to ask here.
Hello Community,
For E vehicle application to control the speed and torque of PMSM motor I am implementing FOC algorithm. We know that to arrive at Speed set point we have speed control loop which is outer loop, Further PI CONTROLLER of speed loop will give reference for Iq current which regulates the current using current loop. My question is 1.How to arrive at Torque set point?
2. Is speed control using FOC is enough or we should implement Torque control algorithm also?
3. should we have speed mode and Torque mode selection in case of constant speed requirement during cruise mode and high torque requirement during uphill situation respectively
4. To arrive at Torque set point what is the relation or transfer function to tune PI controller for Torque loop?
Please give your valuable inputs and answers, thanks in advance
Hello Academia,
I've been trying to get information regarding these configuraitons in a 3 phase transformer. The first is a dual secondary consisting of a wye output and delta output. Both feed separate 3 phase bridges, which outputs are connected in parallel.
The second is a Wye output, which each leg feeds 3 more series windings, which are located on the adjacent core (phase shifted) on the same transformer, with only one 3 phase bridge for the output
I see there is a zigzag simulink but can't seem to get that loaded...
My question is, are these essentially identical in operation, or is the dual secondary what I should be using? (due to better harmonic rejection)
Thanks,
Bryan
Hello,
I am designing a battery model and its control to undergo cyclic charge and discharge.
The battery model is created by using a simscape electrical battery block (Table-based).
The control is modeled using Stateflow. The statflow chart takes SOC values as inputs and provide current values as outputs. By default, the battery will be at rest and no current is drawn at that state (I=0A). And then based on the SOC % of the battery, it goes to charge (3A current) or discharge (-3A current) state. I have defined the controls as follows.
  • If the battery has SOC >= 50%, it has to discharge. If the battery has SOC < 50%, it has to charge.
  • While discharging, if the battery reaches 0% SOC, it goes to rest.
  • While charging, if the battery reaches 100% SOC, it goes to rest.
I have defined initial SOC as 50%.
When I run the simulation, the battery started to discharge as per the condition provided in the stateflow chart.
I = -3
But the battery has not come to rest state after reaching 0% S0C.
I am getting a warning that,
At time 1944.017100, one or more assertions are triggered. State of charge must be greater than or equal to zero. The assertion comes from: Block path: Example_cell_model/Battery (Table-Based)1Assert location: o (location information is protected)
I don't understand why the battery has not came back to rest state.
Do anyone has any idea for the cause of this problem and how to resolve it?
Thanks in advance.
I need to model temperature rise of a resistor due to joule heating with a variable supply or a variable resistor. Is there a simulink component that can be used for this or it has to be implemented with the physical equations fed into block diagrams?
Can someone help give an idea of how this can be modeled?
I'm trying to simulate EV drive system using FEM PMSM and IGBT block of simscape electrical.
The simulation results (magnitude of the current in time domain) is quite similar with the experimental results.
But in frequency domain analysis using FFT (fast fourier transform), amplitude of current harmonics(specially 5, 7 th of fundamental frequency) are way to different.
Is there any way that I could increase my simulation accuracy?
I am trying to simulate a single phase H-bridge inverter connected to a load in Simulink using Simscape Electrical (blue wire). The simulation does not work. I tested the same circuit (with black wire). And everything works fine. I looked hard, I can't see any reason. Does anyone know why or have any examples?
You can find the simulation files in the attachment.
My goal with this is to start with a basic inverter scheme before testing multilevel converters. I had started with that but I had problems from the beginning...
Thanks in advance

hello can some body help me regarding designing a project in simulink to estimate the state of health of a battery ?... including kalman filter .... at least i need the battery cell equivalent circuit in simulink and the idea of the estimation method

many thanks

I am trying to simulate a 3 phase induction motor on Simulink by using its dynamic model. This is the information in its datasheet:
It also has 4 poles and J = 0.0117 kgm², star connection. After calculate parameters, I get these values:
Lm = 0.176 H; Rr=Rs = 0.613Ω; Llr=Lls = 0.00669 H.
Also in the datasheet, they said that the output torque = 705 Nm at speed 35 rpm, but the model cannot reach that value. The simulation motor run backward if applied torque greater than 70 Nm ( at about 1200 rpm). But in reality, this motor can withstand 705 Nm, I have seen it run.
Can someone help me with this problem? Thank you
Hi,
I have two DGs and I want a secondary control between these two DGs using mpc toolbox. I don't know where I am going wrong with it. it is not working. when I am trying to change the load the frequency is still the same. Can anyone please help?
Thanks
Hullo Everyone. I have published a video on the MathWorks YouTube channel that explains active, reactive and apparent power. It is less than 9 minutes and so can be viewed over a coffee break. Here's the link https://www.youtube.com/watch?v=DCUwK6AfzcM
Hi,
I am using matlab fuction block to calculate duty ratio for a MOSFET . How do I incorporate time delay in the calculated duty cycle. Duty cycle of S3 should be delayed by d1 in the picture.Kindly help

I have a datasheet of an induction motor (as figure below). I want to simulate it on matlab/simulink, but I don't know it's parameters (Lls, Llr, Lm, Rr, Rs).

I tried to search about open circuit test and blocked rotor test to determine these parameters, but some of information doesn't appear on datasheet and I don't have the real motor to test on it (datasheet is only think I have).

Could someone help me with this?

Assignments, quizzes, midterms, finals, grades, joys of success, the anxiety of low grades. Sounds like a typical cycle that students go through, right? Sometimes, all that hustle and bustle makes students forget that coding could be fun! Dr. Amin Rahman teaches AMATH 301 at the University of Washington. Many engineering students take this course and learn MATLAB in the course. He was looking for ways to keep students engaged and remind them that coding is fun. To achieve this goal Dr. Rahman and I set up a small competition in MATLAB Grader. Dr. Rahman selected several problems from MATLAB Grader problem collections. Students competed in this optional competition without the pressure of grades. They submitted their solutions; their submissions were automatically graded using MATLAB Grader and they got instant feedback. Green checkmarks for the correct answers empowered students and gamified coding. With the feedback they got, they continuously improved their code.

Prizes? Aside from the joys of coding in MATLAB, students won MathWorks-branded items like t-shirts, hats, and bags and proudly wore them as you can see in Dr. Rahman’s tweet.

Interested in using MATLAB Grader? Interested in accessing MATLAB Grader problem collections? Like to brainstorm ideas to make coding more fun? Reach out to us! We are here to help. Any creative ideas to make courses more engaging? Please share your ideas with this community!

I have submitted a problem in cody some days back. Now it is not showing in my profile. Initially it was accepted and some people submitted the solutions also, however It has been removed after that, are there some guidelines which I am not following?
Antonello Zito
Antonello Zito
Last activity on 13 Jan 2025 at 22:38

This is not a question, but a point of discussion for the entire community. I am aware that every 1/2 months this theme comes out, but until this is not fixed it is totally necessary that this comes, indeed, out. And I said "fix" because Mathworks has to understand that a dark theme is not only a visual/aesthetic matter, it is a substantial part of the game. Most of the OS, GUIs, programs are actually in dark mode, and a vast majority of the users makes indeed use of a global dark mode. How much one does like it is personal, but the benefits to power savings and eye health is instead a fact. Mathworks being ignoring this for years is nothing but ridiculous. Of course it is not an easy task, but every minute of committment for it is worthy. And nope, Schemer is not helpful because it does not provide a real fix to this question.
I feel free to suggest something similar to the Spyder's dark theme, which came out like 2 years ago if I remember correctly.
Of course, my point is not being disrespectful (I am instead very respectful to the huge efforts of Mathworks for making this wonderful program run). But, form a user's point of view, the fact that not a single word has so far come out from Mathworks about a dark theme (meaning that for sure we will not see it in a timing of months) requires us to put a strong pressure on this.
Mathworks, please: it's time for a dark theme.
Hi everyone
I am a new of this community and I very interested in this forum and Matlab.I am trying to submit a soultion but as tiltle my code has a built-in function so the test systerm dont reconisie it.It run completely ok on my computer.
This is problem
This is my solution
function [boOut] = BoIfPointInPoly(PolyMatrix,p_test)
%Summary of this function goes here
%{
if we draw a line from test point to a central point of a side of The polygon
then we extend that line to the furthest point of the polygon ensure that
line go through all side of Polygon in 1 direction.I call that line is line_test
Next find number of intersert of line test and all sides w polyxpoly
function
num interset point is odd mean p_test inside
num interset point is even mean p_test outside
this solution go from the concept that if a line go in from a side it has go out
from other side.So if it go in but not go out that mean it start from
inside.
%}
% Detailed explanation goes here
%line from p test throuh central of a side to furthest point of polygon
%find vector
V = ((PolyMatrix(1,:) + PolyMatrix(2,:)) /2) - p_test ;
%draw that vector to furtest point
pend = p_test + V * max(PolyMatrix(:));
%with multi of V and biggest element I assume that line will go all out the
%polygon which ensure out logic will right
line_test = [p_test ; pend];
disp('Our line test\n');
disp(line_test);
%find interst point
p_inter = polyxpoly(PolyMatrix(:,1),PolyMatrix(:,2),line_test(:,1),line_test(:,2));
%find number of interset (row)
[numIntere,trash] = size(p_inter);
disp('Number of interest point:');
disp(numIntere);
%determine in or out
if (rem(numIntere,2) == 0)
boOut = 0;
else
boOut = 1;
end
end
Can anyone has solution.
Introduction
Comma-separated lists are really very simple. You use them all the time. Here is one:
a,b,c,d
That is a comma-separated list containing four variables, the variables a, b, c, and d. Every time you write a list separated by commas then you are writing a comma-separated list. Most commonly you would write a comma-separated list as inputs when calling a function:
fun(a,b,c,d)
or as arguments to the concatenation operator or cell construction operator:
[a,b,c,d]
{a,b,c,d}
or as function outputs:
[a,b,c,d] = fun();
It is very important to understand that in general a comma-separated list is NOT one variable (but it could be). However, sometimes it is useful to create a comma-separated list from one variable (or define one variable from a comma-separated list), and MATLAB has several ways of doing this from various container array types:
1) from a field of a structure array using dot-indexing:
struct_array.field % all elements
struct_array(idx).field % selected elements
2) from a cell array using curly-braces:
cell_array{:} % all elements
cell_array{idx} % selected elements
3) from a string array using curly-braces:
string_array{:} % all elements
string_array{idx} % selected elements
Note that in all cases, the comma-separated list consists of the content of the container array, not subsets (or "slices") of the container array itself (use parentheses to "slice" any array). In other words, they will be equivalent to writing this comma-separated list of the container array content:
content1, content2, content3, .. , contentN
and will return as many content arrays as the original container array has elements (or that you select using indexing, in the requested order). A comma-separated list of one element is just one array, but in general there can be any number of separate arrays in the comma-separated list (zero, one, two, three, four, or more). Here is an example showing that a comma-separated list generated from the content of a cell array is the same as a comma-separated list written explicitly:
>> C = {1,0,Inf};
>> C{:}
ans =
1
ans =
0
ans =
Inf
>> 1,0,Inf
ans =
1
ans =
0
ans =
Inf
How to Use Comma-Separated Lists
Function Inputs: Remember that every time you call a function with multiple input arguments you are using a comma-separated list:
fun(a,b,c,d)
and this is exactly why they are useful: because you can specify the arguments for a function or operator without knowing anything about the arguments (even how many there are). Using the example cell array from above:
>> vertcat(C{:})
ans =
1
0
Inf
which, as we should know by now, is exactly equivalent to writing the same comma-separated list directly into the function call:
>> vertcat(1,0,Inf)
ans =
1
0
Inf
How can we use this? Commonly these are used to generate vectors of values from a structure or cell array, e.g. to concatenate the filenames which are in the output structure of dir:
S = dir(..);
F = {S.name}
which is simply equivalent to
F = {S(1).name, S(2).name, S(3).name, .. , S(end).name}
Or, consider a function with multiple optional input arguments:
opt = {'HeaderLines',2, 'Delimiter',',', 'CollectOutputs',true);
fid = fopen(..);
C = textscan(fid,'%f%f',opt{:});
fclose(fid);
Note how we can pass the optional arguments as a comma-separated list. Remember how a comma-separated list is equivalent to writing var1,var2,var3,..., then the above example is really just this:
C = textscan(fid,'%f%f', 'HeaderLines',2, 'Delimiter',',', 'CollectOutputs',true)
with the added advantage that we can specify all of the optional arguments elsewhere and handle them as one cell array (e.g. as a function input, or at the top of the file). Or we could select which options we want simply by using indexing on that cell array. Note that varargin and varargout can also be useful here.
Function Outputs: In much the same way that the input arguments can be specified, so can an arbitrary number of output arguments. This is commonly used for functions which return a variable number of output arguments, specifically ind2sub and gradient and ndgrid. For example we can easily get all outputs of ndgrid, for any number of inputs (in this example three inputs and three outputs, determined by the number of elements in the cell array):
C = {1:3,4:7,8:9};
[C{:}] = ndgrid(C{:});
which is thus equivalent to:
[C{1},C{2},C{3}] = ndgrid(C{1},C{2},C{3});
Further Topics:
MATLAB documentation:
Click on these links to jump to relevant comments below:
Dynamic Indexing (indexing into arrays with arbitrary numbers of dimensions)
Nested Structures (why you get an error trying to index into a comma-separated list)
Summary
Just remember that in general a comma-separated list is not one variable (although they can be), and that they are exactly what they say: a list (of arrays) separated with commas. You use them all the time without even realizing it, every time you write this:
fun(a,b,c,d)

If you are interested in live script lecture notes in the following areas, take a look at the short course ( Advanced MATLAB for Scientific Computing ) developed at Stanford. You can also download the required data for the examples from the course GitHub page.

  • MATLAB Fundamentals
  • Graphics and Data Visualization
  • Efficient Code Writing
  • System and File Manipulation
  • Big Data Handling
  • Numerical Linear Algebra
  • Numerical Optimization
  • Symbolic Toolbox, ODE, and PDE
  • Statistical and Machine Learning
  • Deep Learning
  • Object-Oriented Programming
  • Using MATLAB with Other Programming Languages
  • Image Processing, Computer Vision, and Image Acquisition
  • Signal Processing, Audio, and DSP System