Category: Matlab
Category Archives: Matlab
Fletcher Reeves conjugate method
Hello,
My program is giving the right solution for the problem, but I believe it is doing unecessary steps. For a problem with initial point at [4 6], my code using conjugate method is doing more steps than when I try to solve the same problem using the steepest descent method.
-> Main function:
function [x_opt,f_opt,k] = conjugate_gradient (fob,g_fob,x0,tol_grad);
c0 = feval(g_fob,x0); % evaluate gradient at initial point
k = 0;
if norm(c0) < tol_grad
x_opt = x0; % optimum point
f_opt = feval(fob,x_opt); % cost function value
else
d0= -c0; % search direction
alfa0 = equal_interval_line_search(x0,d0,fob,0.5,1e-6); %line search (step size)
x1= x0+ alfa0*d0;
c1 = feval(g_fob,x1);
while norm(c1) > tol_grad
beta = (norm(c1)/norm(c0))^2;
d1= -c1+beta*d0;
alfa1 = equal_interval_line_search(x1,d1,fob,0.5,1e-6);
x2= x1+alfa1*d1;
c0=c1;
c1= feval(g_fob,x2);
d0=d1;
x1=x2;
k=k+1;
end
x_opt = x1;
f_opt = feval(fob,x_opt);
end
Cost function:
function f = fob_8_58(x);
f = 8*x(1)^2 + 8*x(2)^2 – 80*((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5*x(1)-5*x(2);
->Gradient fuction:
function g = grad_fob_8_58(x)
g(1) = 16*x(1) – 80*x(1)/((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*x(1)/((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5;
g(2) =16*x(2) – 80*(x(2)-10)/((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*(x(2)+10)/((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5;Hello,
My program is giving the right solution for the problem, but I believe it is doing unecessary steps. For a problem with initial point at [4 6], my code using conjugate method is doing more steps than when I try to solve the same problem using the steepest descent method.
-> Main function:
function [x_opt,f_opt,k] = conjugate_gradient (fob,g_fob,x0,tol_grad);
c0 = feval(g_fob,x0); % evaluate gradient at initial point
k = 0;
if norm(c0) < tol_grad
x_opt = x0; % optimum point
f_opt = feval(fob,x_opt); % cost function value
else
d0= -c0; % search direction
alfa0 = equal_interval_line_search(x0,d0,fob,0.5,1e-6); %line search (step size)
x1= x0+ alfa0*d0;
c1 = feval(g_fob,x1);
while norm(c1) > tol_grad
beta = (norm(c1)/norm(c0))^2;
d1= -c1+beta*d0;
alfa1 = equal_interval_line_search(x1,d1,fob,0.5,1e-6);
x2= x1+alfa1*d1;
c0=c1;
c1= feval(g_fob,x2);
d0=d1;
x1=x2;
k=k+1;
end
x_opt = x1;
f_opt = feval(fob,x_opt);
end
Cost function:
function f = fob_8_58(x);
f = 8*x(1)^2 + 8*x(2)^2 – 80*((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5*x(1)-5*x(2);
->Gradient fuction:
function g = grad_fob_8_58(x)
g(1) = 16*x(1) – 80*x(1)/((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*x(1)/((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5;
g(2) =16*x(2) – 80*(x(2)-10)/((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*(x(2)+10)/((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5; Hello,
My program is giving the right solution for the problem, but I believe it is doing unecessary steps. For a problem with initial point at [4 6], my code using conjugate method is doing more steps than when I try to solve the same problem using the steepest descent method.
-> Main function:
function [x_opt,f_opt,k] = conjugate_gradient (fob,g_fob,x0,tol_grad);
c0 = feval(g_fob,x0); % evaluate gradient at initial point
k = 0;
if norm(c0) < tol_grad
x_opt = x0; % optimum point
f_opt = feval(fob,x_opt); % cost function value
else
d0= -c0; % search direction
alfa0 = equal_interval_line_search(x0,d0,fob,0.5,1e-6); %line search (step size)
x1= x0+ alfa0*d0;
c1 = feval(g_fob,x1);
while norm(c1) > tol_grad
beta = (norm(c1)/norm(c0))^2;
d1= -c1+beta*d0;
alfa1 = equal_interval_line_search(x1,d1,fob,0.5,1e-6);
x2= x1+alfa1*d1;
c0=c1;
c1= feval(g_fob,x2);
d0=d1;
x1=x2;
k=k+1;
end
x_opt = x1;
f_opt = feval(fob,x_opt);
end
Cost function:
function f = fob_8_58(x);
f = 8*x(1)^2 + 8*x(2)^2 – 80*((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5*x(1)-5*x(2);
->Gradient fuction:
function g = grad_fob_8_58(x)
g(1) = 16*x(1) – 80*x(1)/((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*x(1)/((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5;
g(2) =16*x(2) – 80*(x(2)-10)/((x(1)^2+x(2)^2-20*x(2)+100)^0.5)- 80*(x(2)+10)/((x(1)^2+x(2)^2+20*x(2)+100)^0.5)-5; optimization, conjugate method, fletcher reeves MATLAB Answers — New Questions
What are the differences between Simscape Driveline and Simulink Powertrain Blockset?
Looking at the product pages on Mathworks’ website, Simscape Driveline and Simulink Powertrain Blockset seem be aimed at the same tasks even though, as far as I understand, the way Simscape works "under the hood" is different from Simulink systems.
What are the differences then? In which situation would I pick one over the other?Looking at the product pages on Mathworks’ website, Simscape Driveline and Simulink Powertrain Blockset seem be aimed at the same tasks even though, as far as I understand, the way Simscape works "under the hood" is different from Simulink systems.
What are the differences then? In which situation would I pick one over the other? Looking at the product pages on Mathworks’ website, Simscape Driveline and Simulink Powertrain Blockset seem be aimed at the same tasks even though, as far as I understand, the way Simscape works "under the hood" is different from Simulink systems.
What are the differences then? In which situation would I pick one over the other? simscape, simscape driveline, powertrain blockset, powertrain, simulink powertrain MATLAB Answers — New Questions
How can I use Test Manager’s results tables and format in a custom report?
I want to create a custom Simulink Test report that includes the summary and coverage tables at the end of each section as shown in the Test Manager results.
Could you advise me on how I can do this?I want to create a custom Simulink Test report that includes the summary and coverage tables at the end of each section as shown in the Test Manager results.
Could you advise me on how I can do this? I want to create a custom Simulink Test report that includes the summary and coverage tables at the end of each section as shown in the Test Manager results.
Could you advise me on how I can do this? results, coverage, report, test, manager, custom MATLAB Answers — New Questions
performance: vision.AlphaBlender is slower when image is big.
vision.AlphaBlender is a very good function that can do a lot of "image matting", but when I encounter a large image size, the speed is very slow, look forward to the official enhancement of the efficiency of this function.
blender = vision.AlphaBlender(‘Operation’,’Binary Mask’,…
‘MaskSource’,’Input port’);
% big image test performance
HH = [8000,500];
WW = [8000,500];
for i = 1:length(HH)
H = HH(i);
W = WW(i);
bottomImg = zeros(H,W,3,’single’);
topImg = rand(H,W,3,’single’);
maskImg = zeros(H,W,’logical’);
maskImg(1:100,1:100)=1;
t1 = tic;
outImg = blender(bottomImg,topImg,maskImg);
t2 = toc(t1);
fprintf(‘image size:(%d*%d) take time: %.3f secondsn’,H,W,t2)
endvision.AlphaBlender is a very good function that can do a lot of "image matting", but when I encounter a large image size, the speed is very slow, look forward to the official enhancement of the efficiency of this function.
blender = vision.AlphaBlender(‘Operation’,’Binary Mask’,…
‘MaskSource’,’Input port’);
% big image test performance
HH = [8000,500];
WW = [8000,500];
for i = 1:length(HH)
H = HH(i);
W = WW(i);
bottomImg = zeros(H,W,3,’single’);
topImg = rand(H,W,3,’single’);
maskImg = zeros(H,W,’logical’);
maskImg(1:100,1:100)=1;
t1 = tic;
outImg = blender(bottomImg,topImg,maskImg);
t2 = toc(t1);
fprintf(‘image size:(%d*%d) take time: %.3f secondsn’,H,W,t2)
end vision.AlphaBlender is a very good function that can do a lot of "image matting", but when I encounter a large image size, the speed is very slow, look forward to the official enhancement of the efficiency of this function.
blender = vision.AlphaBlender(‘Operation’,’Binary Mask’,…
‘MaskSource’,’Input port’);
% big image test performance
HH = [8000,500];
WW = [8000,500];
for i = 1:length(HH)
H = HH(i);
W = WW(i);
bottomImg = zeros(H,W,3,’single’);
topImg = rand(H,W,3,’single’);
maskImg = zeros(H,W,’logical’);
maskImg(1:100,1:100)=1;
t1 = tic;
outImg = blender(bottomImg,topImg,maskImg);
t2 = toc(t1);
fprintf(‘image size:(%d*%d) take time: %.3f secondsn’,H,W,t2)
end vision.alphablender, image processing MATLAB Answers — New Questions
How to solve this partial differential equation in simulink?
Hello , I want to simulate the following partial equation on simulink , but I dont know if what I already built is fine , I have some struggle with dc/dz ,because it gives me error when I try to build it , so I conected rate transition and discrete derivative ,but dont know it is ok . I am building a fixed bed reactor full loaded with carbon absorbed gold in which a cyanide flow is pumped into and absorbs the gold loading , depleting the carbon . Following the equations:
So i tried finite differences for dc/dz with forward difference for eactor entry , central along the reactor , and backward in the exit, and dc/dt and dq/dt use integrator blocks, I consider Co= 0 and q0=4320. The problem is that when I remove rate transition and discrete derivative in 4th reactor,gives error.
Being that said, is correct to represent dc/dz as following? :
Adjoint the simulink file down here and thanks in advance:
https://riveril123.quickconnect.to/d/s/11jhifsXc7WjjbgDgYlqicG8JX9cxHGm/1KbHfeBHUy1vF0hiTKBsPaD8Nff4HGwg-27UAduxX-QsHello , I want to simulate the following partial equation on simulink , but I dont know if what I already built is fine , I have some struggle with dc/dz ,because it gives me error when I try to build it , so I conected rate transition and discrete derivative ,but dont know it is ok . I am building a fixed bed reactor full loaded with carbon absorbed gold in which a cyanide flow is pumped into and absorbs the gold loading , depleting the carbon . Following the equations:
So i tried finite differences for dc/dz with forward difference for eactor entry , central along the reactor , and backward in the exit, and dc/dt and dq/dt use integrator blocks, I consider Co= 0 and q0=4320. The problem is that when I remove rate transition and discrete derivative in 4th reactor,gives error.
Being that said, is correct to represent dc/dz as following? :
Adjoint the simulink file down here and thanks in advance:
https://riveril123.quickconnect.to/d/s/11jhifsXc7WjjbgDgYlqicG8JX9cxHGm/1KbHfeBHUy1vF0hiTKBsPaD8Nff4HGwg-27UAduxX-Qs Hello , I want to simulate the following partial equation on simulink , but I dont know if what I already built is fine , I have some struggle with dc/dz ,because it gives me error when I try to build it , so I conected rate transition and discrete derivative ,but dont know it is ok . I am building a fixed bed reactor full loaded with carbon absorbed gold in which a cyanide flow is pumped into and absorbs the gold loading , depleting the carbon . Following the equations:
So i tried finite differences for dc/dz with forward difference for eactor entry , central along the reactor , and backward in the exit, and dc/dt and dq/dt use integrator blocks, I consider Co= 0 and q0=4320. The problem is that when I remove rate transition and discrete derivative in 4th reactor,gives error.
Being that said, is correct to represent dc/dz as following? :
Adjoint the simulink file down here and thanks in advance:
https://riveril123.quickconnect.to/d/s/11jhifsXc7WjjbgDgYlqicG8JX9cxHGm/1KbHfeBHUy1vF0hiTKBsPaD8Nff4HGwg-27UAduxX-Qs simulink, reactor, partial differential equation MATLAB Answers — New Questions
Difference between RMSE of Curve fitter and calculated RMSE in MS Excel
Dear colleagues,
I have used Curve fitter app for regression. The app calculates RMSE which is different than calculated by myself in MS Excel.
My calculation in MS Excel for RMSE is about 8 and I use the formula on the right.
I have tried to upload *.sfit file, but it is forbidden. SO I’m uploading only the excel file.Dear colleagues,
I have used Curve fitter app for regression. The app calculates RMSE which is different than calculated by myself in MS Excel.
My calculation in MS Excel for RMSE is about 8 and I use the formula on the right.
I have tried to upload *.sfit file, but it is forbidden. SO I’m uploading only the excel file. Dear colleagues,
I have used Curve fitter app for regression. The app calculates RMSE which is different than calculated by myself in MS Excel.
My calculation in MS Excel for RMSE is about 8 and I use the formula on the right.
I have tried to upload *.sfit file, but it is forbidden. SO I’m uploading only the excel file. rmse in ms excel MATLAB Answers — New Questions
PWM Generator and Boost Converter
Hi all,
I am building a PWM generator and boost converter diagram. When i vary the input (Duty Cycle) to the PWM Generator, it should control my IGBT switch that is part of my boost converter. However, i tried varying my duty cycle and the output to my boost converter remained the same.
I would appreciate if someone can help me and explain what went wrong by taking a look at the schematic attached below.
Thank you in advance!
<</matlabcentral/answers/uploaded_files/46998/Capture.PNG>>Hi all,
I am building a PWM generator and boost converter diagram. When i vary the input (Duty Cycle) to the PWM Generator, it should control my IGBT switch that is part of my boost converter. However, i tried varying my duty cycle and the output to my boost converter remained the same.
I would appreciate if someone can help me and explain what went wrong by taking a look at the schematic attached below.
Thank you in advance!
<</matlabcentral/answers/uploaded_files/46998/Capture.PNG>> Hi all,
I am building a PWM generator and boost converter diagram. When i vary the input (Duty Cycle) to the PWM Generator, it should control my IGBT switch that is part of my boost converter. However, i tried varying my duty cycle and the output to my boost converter remained the same.
I would appreciate if someone can help me and explain what went wrong by taking a look at the schematic attached below.
Thank you in advance!
<</matlabcentral/answers/uploaded_files/46998/Capture.PNG>> pwm, simulink, boost converter, power_electronics_control, electric_motor_control, power_conversion_control MATLAB Answers — New Questions
Gradient color filled bar plots.
Hello all,
I need to change the color of the barplots (attached picture below) as gradient but Matlab dos not have any function to do that, I guess. is it possible to do with patch function?Hello all,
I need to change the color of the barplots (attached picture below) as gradient but Matlab dos not have any function to do that, I guess. is it possible to do with patch function? Hello all,
I need to change the color of the barplots (attached picture below) as gradient but Matlab dos not have any function to do that, I guess. is it possible to do with patch function? barplots, gradient color MATLAB Answers — New Questions
How do I programmatically switch to Dark Mode (Dark Theme) in R2025a?
I am running R2025a pre-release. What are the commands to switch to dark mode?I am running R2025a pre-release. What are the commands to switch to dark mode? I am running R2025a pre-release. What are the commands to switch to dark mode? dark mode MATLAB Answers — New Questions
2nd Order Low-Pass Sallen Key and Multi Feedback Filter Design (Chebyshev)
I am trying to understand how to design a Sallen Key and MFB Filter that has Chebyshev characterisitcs.
Currently I am inputting the T.F (shown below) into MATLAB and using bode command to plot the T.F of various Qs to analyse the difference.
H.wo^2/S^2+(wo/Q)+wo^2
H=3.16, wo=125663, Q=varied to anaylse difference (intervals between 0.5 to 10)
When trying to utilise cheby1 and cheby2 to get the filters characteristics I am getting confused.
I input the relevant info into cheby1 below
[b,a] = cheby1(n,Rp,Wp,fType)
n=2, Rp=0.5, Wp=20000Hz, "low"
I keep getting this error "the cutoff frequencies must be within the interval of (0 1)".
I am very new to matlab and filter designs but I am struggling to understand what I am missing
Thanks,
AndyI am trying to understand how to design a Sallen Key and MFB Filter that has Chebyshev characterisitcs.
Currently I am inputting the T.F (shown below) into MATLAB and using bode command to plot the T.F of various Qs to analyse the difference.
H.wo^2/S^2+(wo/Q)+wo^2
H=3.16, wo=125663, Q=varied to anaylse difference (intervals between 0.5 to 10)
When trying to utilise cheby1 and cheby2 to get the filters characteristics I am getting confused.
I input the relevant info into cheby1 below
[b,a] = cheby1(n,Rp,Wp,fType)
n=2, Rp=0.5, Wp=20000Hz, "low"
I keep getting this error "the cutoff frequencies must be within the interval of (0 1)".
I am very new to matlab and filter designs but I am struggling to understand what I am missing
Thanks,
Andy I am trying to understand how to design a Sallen Key and MFB Filter that has Chebyshev characterisitcs.
Currently I am inputting the T.F (shown below) into MATLAB and using bode command to plot the T.F of various Qs to analyse the difference.
H.wo^2/S^2+(wo/Q)+wo^2
H=3.16, wo=125663, Q=varied to anaylse difference (intervals between 0.5 to 10)
When trying to utilise cheby1 and cheby2 to get the filters characteristics I am getting confused.
I input the relevant info into cheby1 below
[b,a] = cheby1(n,Rp,Wp,fType)
n=2, Rp=0.5, Wp=20000Hz, "low"
I keep getting this error "the cutoff frequencies must be within the interval of (0 1)".
I am very new to matlab and filter designs but I am struggling to understand what I am missing
Thanks,
Andy 2nd order filters, matlab code, sallen key, mfb, chebyshev MATLAB Answers — New Questions
Why am I prompted for admin credentials every time I launch MATLAB on Windows?
Why am I prompted to enter admin credentials every time I run MATLAB on Windows?Why am I prompted to enter admin credentials every time I run MATLAB on Windows? Why am I prompted to enter admin credentials every time I run MATLAB on Windows? MATLAB Answers — New Questions
CustomDisplay functionality for AppDesigner apps
I’m developing an AppDesigner App that I intend to interact with from the console. Right now, when I display my app at the console, my custom members get buried under all the public handles as shown below:
>> hApp
hApp =
MyApp with properties:
UIFigure: [1×1 Figure]
FileMenu: [1×1 Menu]
OpenMenu: [1×1 Menu]
SaveMenu: [1×1 Menu]
… % Many more handles omitted for brevity % …
foo: 0
bar: [1×1 struct]
baz: [1×1 struct]
I’m trying to achieve something similar to this, where the least useful public members are hidden in the properties link:
>> hApp.UIFigure
ans =
Figure (MyApp) with properties:
Number: []
Name: ‘MyApp’
Color: [940.0000e-003 940.0000e-003 940.0000e-003]
Position: [2.1360e+003 -663.0000e+000 640.0000e+000 480.0000e+000]
Units: ‘pixels’
Show all properties
The Figure class can easily achieve this due to inheritance from matlab.mixin.CustomDisplay. However, AFAIK, it is not possible to edit the inheritance of AppDesigner apps.
How do I hide visibility of particular members without reinventing the wheel?I’m developing an AppDesigner App that I intend to interact with from the console. Right now, when I display my app at the console, my custom members get buried under all the public handles as shown below:
>> hApp
hApp =
MyApp with properties:
UIFigure: [1×1 Figure]
FileMenu: [1×1 Menu]
OpenMenu: [1×1 Menu]
SaveMenu: [1×1 Menu]
… % Many more handles omitted for brevity % …
foo: 0
bar: [1×1 struct]
baz: [1×1 struct]
I’m trying to achieve something similar to this, where the least useful public members are hidden in the properties link:
>> hApp.UIFigure
ans =
Figure (MyApp) with properties:
Number: []
Name: ‘MyApp’
Color: [940.0000e-003 940.0000e-003 940.0000e-003]
Position: [2.1360e+003 -663.0000e+000 640.0000e+000 480.0000e+000]
Units: ‘pixels’
Show all properties
The Figure class can easily achieve this due to inheritance from matlab.mixin.CustomDisplay. However, AFAIK, it is not possible to edit the inheritance of AppDesigner apps.
How do I hide visibility of particular members without reinventing the wheel? I’m developing an AppDesigner App that I intend to interact with from the console. Right now, when I display my app at the console, my custom members get buried under all the public handles as shown below:
>> hApp
hApp =
MyApp with properties:
UIFigure: [1×1 Figure]
FileMenu: [1×1 Menu]
OpenMenu: [1×1 Menu]
SaveMenu: [1×1 Menu]
… % Many more handles omitted for brevity % …
foo: 0
bar: [1×1 struct]
baz: [1×1 struct]
I’m trying to achieve something similar to this, where the least useful public members are hidden in the properties link:
>> hApp.UIFigure
ans =
Figure (MyApp) with properties:
Number: []
Name: ‘MyApp’
Color: [940.0000e-003 940.0000e-003 940.0000e-003]
Position: [2.1360e+003 -663.0000e+000 640.0000e+000 480.0000e+000]
Units: ‘pixels’
Show all properties
The Figure class can easily achieve this due to inheritance from matlab.mixin.CustomDisplay. However, AFAIK, it is not possible to edit the inheritance of AppDesigner apps.
How do I hide visibility of particular members without reinventing the wheel? appdesigner, customdisplay MATLAB Answers — New Questions
How to debug and resolve SIL/MIL discrepancies when using AUTOSAR Code Replacement Library (CRL)?
I am utilizing the AUTOSAR Code Replacement Library (CRL) and have observed discrepancies between the simulation results and the Software-in-the-Loop (SIL) outcomes. What could be the root causes of these issues, and how can I implement effective workarounds?I am utilizing the AUTOSAR Code Replacement Library (CRL) and have observed discrepancies between the simulation results and the Software-in-the-Loop (SIL) outcomes. What could be the root causes of these issues, and how can I implement effective workarounds? I am utilizing the AUTOSAR Code Replacement Library (CRL) and have observed discrepancies between the simulation results and the Software-in-the-Loop (SIL) outcomes. What could be the root causes of these issues, and how can I implement effective workarounds? MATLAB Answers — New Questions
I have some issues with derivating D-Q inductance from a five-phase FEA data.
Hi folks,
I have simulated a five-phase interior PMSM on FEA software to get self and mutual inductance data. The data have been calculated according to mechanical rotor angle (half of the electrical angle in my case). Now, I want to calculate d and q inductances. As you know, there is a five-phase coordinate transformation block in Simulink and one can easily get the equations from the block help page. The equation is given below. However, when I calculate the d-q inductances by electrical rotor angle the results are not constant. The results formed a sinusoidal wave shape. Is there anyone familiar with such calculations to help me figure it out?
Thanks for your help in advance!
The code:
a=length(e_deg);
Ld=zeros(a,1);
Lq=zeros(a,1);
for ind=1:a
Ld(ind,1)=(2/5)*(sind(e_deg(ind,1))*Laa(ind,1)+sind(e_deg(ind,1)-72)*Lbb(ind,1)+sind(e_deg(ind,1)-144)*Lcc(ind,1)+sind(e_deg(ind,1)+144)*Ldd(ind,1)+sind(e_deg(ind,1)+72)*Lee(ind,1));
Lq(ind,1)=(2/5)*(cosd(e_deg(ind,1))*Laa(ind,1)+cosd(e_deg(ind,1)-72)*Lbb(ind,1)+cosd(e_deg(ind,1)-144)*Lcc(ind,1)+cosd(e_deg(ind,1)+144)*Ldd(ind,1)+cosd(e_deg(ind,1)+72)*Lee(ind,1));
end
figure
plot(e_deg,Ld)
hold on
plot(e_deg,Lq)
legend(‘Ld’,’Lq’)
The transformation matrix I have used: Implement abcde to dqxy0 transform – Simulink (mathworks.com)
The results i got:Hi folks,
I have simulated a five-phase interior PMSM on FEA software to get self and mutual inductance data. The data have been calculated according to mechanical rotor angle (half of the electrical angle in my case). Now, I want to calculate d and q inductances. As you know, there is a five-phase coordinate transformation block in Simulink and one can easily get the equations from the block help page. The equation is given below. However, when I calculate the d-q inductances by electrical rotor angle the results are not constant. The results formed a sinusoidal wave shape. Is there anyone familiar with such calculations to help me figure it out?
Thanks for your help in advance!
The code:
a=length(e_deg);
Ld=zeros(a,1);
Lq=zeros(a,1);
for ind=1:a
Ld(ind,1)=(2/5)*(sind(e_deg(ind,1))*Laa(ind,1)+sind(e_deg(ind,1)-72)*Lbb(ind,1)+sind(e_deg(ind,1)-144)*Lcc(ind,1)+sind(e_deg(ind,1)+144)*Ldd(ind,1)+sind(e_deg(ind,1)+72)*Lee(ind,1));
Lq(ind,1)=(2/5)*(cosd(e_deg(ind,1))*Laa(ind,1)+cosd(e_deg(ind,1)-72)*Lbb(ind,1)+cosd(e_deg(ind,1)-144)*Lcc(ind,1)+cosd(e_deg(ind,1)+144)*Ldd(ind,1)+cosd(e_deg(ind,1)+72)*Lee(ind,1));
end
figure
plot(e_deg,Ld)
hold on
plot(e_deg,Lq)
legend(‘Ld’,’Lq’)
The transformation matrix I have used: Implement abcde to dqxy0 transform – Simulink (mathworks.com)
The results i got: Hi folks,
I have simulated a five-phase interior PMSM on FEA software to get self and mutual inductance data. The data have been calculated according to mechanical rotor angle (half of the electrical angle in my case). Now, I want to calculate d and q inductances. As you know, there is a five-phase coordinate transformation block in Simulink and one can easily get the equations from the block help page. The equation is given below. However, when I calculate the d-q inductances by electrical rotor angle the results are not constant. The results formed a sinusoidal wave shape. Is there anyone familiar with such calculations to help me figure it out?
Thanks for your help in advance!
The code:
a=length(e_deg);
Ld=zeros(a,1);
Lq=zeros(a,1);
for ind=1:a
Ld(ind,1)=(2/5)*(sind(e_deg(ind,1))*Laa(ind,1)+sind(e_deg(ind,1)-72)*Lbb(ind,1)+sind(e_deg(ind,1)-144)*Lcc(ind,1)+sind(e_deg(ind,1)+144)*Ldd(ind,1)+sind(e_deg(ind,1)+72)*Lee(ind,1));
Lq(ind,1)=(2/5)*(cosd(e_deg(ind,1))*Laa(ind,1)+cosd(e_deg(ind,1)-72)*Lbb(ind,1)+cosd(e_deg(ind,1)-144)*Lcc(ind,1)+cosd(e_deg(ind,1)+144)*Ldd(ind,1)+cosd(e_deg(ind,1)+72)*Lee(ind,1));
end
figure
plot(e_deg,Ld)
hold on
plot(e_deg,Lq)
legend(‘Ld’,’Lq’)
The transformation matrix I have used: Implement abcde to dqxy0 transform – Simulink (mathworks.com)
The results i got: matlab, coordinate transformation, park transformation MATLAB Answers — New Questions
handle character minus character
I have two characters which contain ’18:29:42.835′ and ’18:29:49.425′. How is it possible to subtrack t2-t1 so as to find duration?I have two characters which contain ’18:29:42.835′ and ’18:29:49.425′. How is it possible to subtrack t2-t1 so as to find duration? I have two characters which contain ’18:29:42.835′ and ’18:29:49.425′. How is it possible to subtrack t2-t1 so as to find duration? characters, comma, separated, list MATLAB Answers — New Questions
flickering lamp with visual effects in simulink
Hi,
I’m trying to simulate a lamp connected to an electrical system that suffers from flickering voltage in simulink. The lamp light should show flicker in a visual manner. Any idea’s if this is possible or how to go about it?
Please, assume here that lamp is a resistor therefore when the voltage changes the energy flowing in changes as and a result the light loses or gains intensity. So a simple way to regulate the intensity of a monocolored lamp in simulink should do nicely.
If you have more knowledge regarding this topic please answer the following question as well.
In a broader sense is there a way for example to simulate a tungsten filament lighting up or any other phenomenon, assuming you have the equations governing it (supposing you can solve it with finite element or what have you), with visual effects?
Cordially,
OmidHi,
I’m trying to simulate a lamp connected to an electrical system that suffers from flickering voltage in simulink. The lamp light should show flicker in a visual manner. Any idea’s if this is possible or how to go about it?
Please, assume here that lamp is a resistor therefore when the voltage changes the energy flowing in changes as and a result the light loses or gains intensity. So a simple way to regulate the intensity of a monocolored lamp in simulink should do nicely.
If you have more knowledge regarding this topic please answer the following question as well.
In a broader sense is there a way for example to simulate a tungsten filament lighting up or any other phenomenon, assuming you have the equations governing it (supposing you can solve it with finite element or what have you), with visual effects?
Cordially,
Omid Hi,
I’m trying to simulate a lamp connected to an electrical system that suffers from flickering voltage in simulink. The lamp light should show flicker in a visual manner. Any idea’s if this is possible or how to go about it?
Please, assume here that lamp is a resistor therefore when the voltage changes the energy flowing in changes as and a result the light loses or gains intensity. So a simple way to regulate the intensity of a monocolored lamp in simulink should do nicely.
If you have more knowledge regarding this topic please answer the following question as well.
In a broader sense is there a way for example to simulate a tungsten filament lighting up or any other phenomenon, assuming you have the equations governing it (supposing you can solve it with finite element or what have you), with visual effects?
Cordially,
Omid simulink, visual effects, flicker, lamp MATLAB Answers — New Questions
Pole pair on Single Phase Asynchronous motor Cap Start-Run
Hi,
I am getting an error while trying to simulate a Single phase Asynchronous motor. When I change the pole pair from 2 which is the default to 1 I am getting negative rpm. When the pole pair is 2 or 3 or 4 it works fine with the correct speed and positive rpm.
This is the block of AC Cap-Start/Run motor:
Best regards,
Andrew.Hi,
I am getting an error while trying to simulate a Single phase Asynchronous motor. When I change the pole pair from 2 which is the default to 1 I am getting negative rpm. When the pole pair is 2 or 3 or 4 it works fine with the correct speed and positive rpm.
This is the block of AC Cap-Start/Run motor:
Best regards,
Andrew. Hi,
I am getting an error while trying to simulate a Single phase Asynchronous motor. When I change the pole pair from 2 which is the default to 1 I am getting negative rpm. When the pole pair is 2 or 3 or 4 it works fine with the correct speed and positive rpm.
This is the block of AC Cap-Start/Run motor:
Best regards,
Andrew. single phase asynchronous motor, cap-start MATLAB Answers — New Questions
The ‘matlab.mixin.Copyable’ class does not support code generation.
Recently,I`m working on transforming a matlab project code into c/c++ code. But now I have a problem like the title said "The ‘matlab.mixin.Copyable’ class does not support code generation.". this problem is becuase I writed a class inheritance the matlab.mixin.Copyable class. Who can help me to solve this problem? thank you!Recently,I`m working on transforming a matlab project code into c/c++ code. But now I have a problem like the title said "The ‘matlab.mixin.Copyable’ class does not support code generation.". this problem is becuase I writed a class inheritance the matlab.mixin.Copyable class. Who can help me to solve this problem? thank you! Recently,I`m working on transforming a matlab project code into c/c++ code. But now I have a problem like the title said "The ‘matlab.mixin.Copyable’ class does not support code generation.". this problem is becuase I writed a class inheritance the matlab.mixin.Copyable class. Who can help me to solve this problem? thank you! inheritance class matlab convert to c/c++ abstract class, oop, mixin.copyable MATLAB Answers — New Questions
Problem with ‘Patch’ graphics in 2014b – Splits in two along diagonal
I’m using ‘Patch’ to replace the boxes in box plots to change the colour etc. Code is:
h = findobj(gca,’Tag’,’Box’);
for x=1:length(h)
boxShade=patch(get(h(x),’XData’),get(h(x),’YData’), colours(x,:), ‘linestyle’, ‘none’);
uistack(boxShade,’bottom’);
end
delete(h);
This worked fine until I updated to 2014b where now the Patches appear to split in two along the diagonal, with the median in front of one half and behind the other. Example cut from exported pdf:
<</matlabcentral/answers/uploaded_files/20887/Ave_1.jpg>>
I am using the painters renderer as I’m outputting vector pdfs.
Any ideas? I’ve seen some other talk that it’s a bug from intersecting lines in a patch but there are no intersections here I believe as it’s just a simple rectangle?
Any help greatly appreciated!
DavidI’m using ‘Patch’ to replace the boxes in box plots to change the colour etc. Code is:
h = findobj(gca,’Tag’,’Box’);
for x=1:length(h)
boxShade=patch(get(h(x),’XData’),get(h(x),’YData’), colours(x,:), ‘linestyle’, ‘none’);
uistack(boxShade,’bottom’);
end
delete(h);
This worked fine until I updated to 2014b where now the Patches appear to split in two along the diagonal, with the median in front of one half and behind the other. Example cut from exported pdf:
<</matlabcentral/answers/uploaded_files/20887/Ave_1.jpg>>
I am using the painters renderer as I’m outputting vector pdfs.
Any ideas? I’ve seen some other talk that it’s a bug from intersecting lines in a patch but there are no intersections here I believe as it’s just a simple rectangle?
Any help greatly appreciated!
David I’m using ‘Patch’ to replace the boxes in box plots to change the colour etc. Code is:
h = findobj(gca,’Tag’,’Box’);
for x=1:length(h)
boxShade=patch(get(h(x),’XData’),get(h(x),’YData’), colours(x,:), ‘linestyle’, ‘none’);
uistack(boxShade,’bottom’);
end
delete(h);
This worked fine until I updated to 2014b where now the Patches appear to split in two along the diagonal, with the median in front of one half and behind the other. Example cut from exported pdf:
<</matlabcentral/answers/uploaded_files/20887/Ave_1.jpg>>
I am using the painters renderer as I’m outputting vector pdfs.
Any ideas? I’ve seen some other talk that it’s a bug from intersecting lines in a patch but there are no intersections here I believe as it’s just a simple rectangle?
Any help greatly appreciated!
David patch, r2014bgraphics MATLAB Answers — New Questions
Error when running simple voltage converter in simulink
Hi,
I got this error when when I tried to simulate the circuit: An error occurred while running the simulation and the simulation was terminated
Caused by:
Solver encountered an error while simulating model ‘Teste_Quadratic_boost’ at time 5.9442244214857332e-09 and cannot continue. Please check the model for errors.
Solver could not solve the system of algebraic equations because a singular iteration matrix was encountered. Consider providing more accurate initial conditions. If the problem persists, check the model structure and values of parameters.
Looking for the problem I found that if the mosfet is removed or its Threshold voltage is not reached, Simulink doesn’t report an errorHi,
I got this error when when I tried to simulate the circuit: An error occurred while running the simulation and the simulation was terminated
Caused by:
Solver encountered an error while simulating model ‘Teste_Quadratic_boost’ at time 5.9442244214857332e-09 and cannot continue. Please check the model for errors.
Solver could not solve the system of algebraic equations because a singular iteration matrix was encountered. Consider providing more accurate initial conditions. If the problem persists, check the model structure and values of parameters.
Looking for the problem I found that if the mosfet is removed or its Threshold voltage is not reached, Simulink doesn’t report an error Hi,
I got this error when when I tried to simulate the circuit: An error occurred while running the simulation and the simulation was terminated
Caused by:
Solver encountered an error while simulating model ‘Teste_Quadratic_boost’ at time 5.9442244214857332e-09 and cannot continue. Please check the model for errors.
Solver could not solve the system of algebraic equations because a singular iteration matrix was encountered. Consider providing more accurate initial conditions. If the problem persists, check the model structure and values of parameters.
Looking for the problem I found that if the mosfet is removed or its Threshold voltage is not reached, Simulink doesn’t report an error solver, simulink, singular iteration matrix, boost MATLAB Answers — New Questions