Tag Archives: matlab
inv(A)*B or AB, which is more accurate for a full rank A and half rank B
My matrix is
>> A_2stepblock
A_2stepblock =
1.0e+06 *
Columns 1 through 6
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0.000024000000000
1.953050781823359 0.390611805629631 0.078122690980311 0.015624604167218 0.003124934027730 0.000624989444415
3.515506250666680 0.624981527842487 0.109372229170523 0.018749604166382 0.003124947222073 0.000499993666635
5.624833750582380 0.874977833364188 0.131247229164674 0.018749683332437 0.002499968333177 0.000299997466649
7.874800500277688 1.049977833317391 0.131247783327059 0.014999809999061 0.001499987333244 0.000119999493329
9.449800499856519 1.049982266616475 0.104998669993428 0.008999923999464 0.000599997466643 0.000024000000000
Columns 7 through 10
0 0 0 0.000001000000000
0 0 0.000001000000000 0
0 0.000002000000000 0 0
0.000006000000000 0 0 0
0 0 0 0
0.000124998416659 0.000024999788887 0.000004999978889 0.000001000000000
0.000074999366662 0.000009999957777 0.000001000000000 0
0.000029999873332 0.000002000000000 0 0
0.000006000000000 0 0 0
0 0 0 0
K>> rank(A_2stepblock)
ans =
10
and I need to calculate
A_2stepblock dA_2stepblock_dt / A_2stepblock
where
K>> dA_2stepblock_dt
dA_2stepblock_dt =
1.0e+06 *
Columns 1 through 7
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
3.515506250666680 0.624981527842487 0.109372229170523 0.018749604166382 0.003124947222073 0.000499993666635 0.000074999366662
5.624833750582380 0.874977833364188 0.131247229164674 0.018749683332437 0.002499968333177 0.000299997466649 0.000029999873332
7.874800500277688 1.049977833317391 0.131247783327059 0.014999809999061 0.001499987333244 0.000119999493329 0.000006000000000
9.449800499856519 1.049982266616475 0.104998669993428 0.008999923999464 0.000599997466643 0.000024000000000 0
9.449840399548277 0.839989359947423 0.062999467996248 0.003599984799861 0.000120000000000 0 0
Columns 8 through 10
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0.000009999957777 0.000001000000000 0
0.000002000000000 0 0
0 0 0
0 0 0
0 0 0
has a rank of 5.
I tried both inv() and /, resulting in very different results for a gradient descent algorithm.
So, which is more accurate?My matrix is
>> A_2stepblock
A_2stepblock =
1.0e+06 *
Columns 1 through 6
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0.000024000000000
1.953050781823359 0.390611805629631 0.078122690980311 0.015624604167218 0.003124934027730 0.000624989444415
3.515506250666680 0.624981527842487 0.109372229170523 0.018749604166382 0.003124947222073 0.000499993666635
5.624833750582380 0.874977833364188 0.131247229164674 0.018749683332437 0.002499968333177 0.000299997466649
7.874800500277688 1.049977833317391 0.131247783327059 0.014999809999061 0.001499987333244 0.000119999493329
9.449800499856519 1.049982266616475 0.104998669993428 0.008999923999464 0.000599997466643 0.000024000000000
Columns 7 through 10
0 0 0 0.000001000000000
0 0 0.000001000000000 0
0 0.000002000000000 0 0
0.000006000000000 0 0 0
0 0 0 0
0.000124998416659 0.000024999788887 0.000004999978889 0.000001000000000
0.000074999366662 0.000009999957777 0.000001000000000 0
0.000029999873332 0.000002000000000 0 0
0.000006000000000 0 0 0
0 0 0 0
K>> rank(A_2stepblock)
ans =
10
and I need to calculate
A_2stepblock dA_2stepblock_dt / A_2stepblock
where
K>> dA_2stepblock_dt
dA_2stepblock_dt =
1.0e+06 *
Columns 1 through 7
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
3.515506250666680 0.624981527842487 0.109372229170523 0.018749604166382 0.003124947222073 0.000499993666635 0.000074999366662
5.624833750582380 0.874977833364188 0.131247229164674 0.018749683332437 0.002499968333177 0.000299997466649 0.000029999873332
7.874800500277688 1.049977833317391 0.131247783327059 0.014999809999061 0.001499987333244 0.000119999493329 0.000006000000000
9.449800499856519 1.049982266616475 0.104998669993428 0.008999923999464 0.000599997466643 0.000024000000000 0
9.449840399548277 0.839989359947423 0.062999467996248 0.003599984799861 0.000120000000000 0 0
Columns 8 through 10
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0.000009999957777 0.000001000000000 0
0.000002000000000 0 0
0 0 0
0 0 0
0 0 0
has a rank of 5.
I tried both inv() and /, resulting in very different results for a gradient descent algorithm.
So, which is more accurate? My matrix is
>> A_2stepblock
A_2stepblock =
1.0e+06 *
Columns 1 through 6
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0.000024000000000
1.953050781823359 0.390611805629631 0.078122690980311 0.015624604167218 0.003124934027730 0.000624989444415
3.515506250666680 0.624981527842487 0.109372229170523 0.018749604166382 0.003124947222073 0.000499993666635
5.624833750582380 0.874977833364188 0.131247229164674 0.018749683332437 0.002499968333177 0.000299997466649
7.874800500277688 1.049977833317391 0.131247783327059 0.014999809999061 0.001499987333244 0.000119999493329
9.449800499856519 1.049982266616475 0.104998669993428 0.008999923999464 0.000599997466643 0.000024000000000
Columns 7 through 10
0 0 0 0.000001000000000
0 0 0.000001000000000 0
0 0.000002000000000 0 0
0.000006000000000 0 0 0
0 0 0 0
0.000124998416659 0.000024999788887 0.000004999978889 0.000001000000000
0.000074999366662 0.000009999957777 0.000001000000000 0
0.000029999873332 0.000002000000000 0 0
0.000006000000000 0 0 0
0 0 0 0
K>> rank(A_2stepblock)
ans =
10
and I need to calculate
A_2stepblock dA_2stepblock_dt / A_2stepblock
where
K>> dA_2stepblock_dt
dA_2stepblock_dt =
1.0e+06 *
Columns 1 through 7
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
3.515506250666680 0.624981527842487 0.109372229170523 0.018749604166382 0.003124947222073 0.000499993666635 0.000074999366662
5.624833750582380 0.874977833364188 0.131247229164674 0.018749683332437 0.002499968333177 0.000299997466649 0.000029999873332
7.874800500277688 1.049977833317391 0.131247783327059 0.014999809999061 0.001499987333244 0.000119999493329 0.000006000000000
9.449800499856519 1.049982266616475 0.104998669993428 0.008999923999464 0.000599997466643 0.000024000000000 0
9.449840399548277 0.839989359947423 0.062999467996248 0.003599984799861 0.000120000000000 0 0
Columns 8 through 10
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0.000009999957777 0.000001000000000 0
0.000002000000000 0 0
0 0 0
0 0 0
0 0 0
has a rank of 5.
I tried both inv() and /, resulting in very different results for a gradient descent algorithm.
So, which is more accurate? matrix inverse, linear algebra MATLAB Answers — New Questions
How do I get LDAP user information for logged in user into my MATLAB WebApp?
I have a WebApp server (Windows, R2022a) running a couple of apps, and it is behind LDAP authentication. When a user logs in, I can see that the user information is stored somewhere within the server because the correct username appears in the upper right corner of the main MATLAB WebApp server screen. What I would like to do is access that information inside my app. Is there a MATLAB command within the app that can access the logged in user? I tried:
user = compiler.UserInfo()
but all the fields were empty.
Thank you!
-GregI have a WebApp server (Windows, R2022a) running a couple of apps, and it is behind LDAP authentication. When a user logs in, I can see that the user information is stored somewhere within the server because the correct username appears in the upper right corner of the main MATLAB WebApp server screen. What I would like to do is access that information inside my app. Is there a MATLAB command within the app that can access the logged in user? I tried:
user = compiler.UserInfo()
but all the fields were empty.
Thank you!
-Greg I have a WebApp server (Windows, R2022a) running a couple of apps, and it is behind LDAP authentication. When a user logs in, I can see that the user information is stored somewhere within the server because the correct username appears in the upper right corner of the main MATLAB WebApp server screen. What I would like to do is access that information inside my app. Is there a MATLAB command within the app that can access the logged in user? I tried:
user = compiler.UserInfo()
but all the fields were empty.
Thank you!
-Greg ldap, webapp server MATLAB Answers — New Questions
Does Matlab support system objects for X410 USRP?
Does Matlab R2024a support system objects such as comm.SDRuTransmitter or comm.SDRuReceiver with the X410 USRP when using Wireless TestBench? If not, is this something that will be available in future updates?Does Matlab R2024a support system objects such as comm.SDRuTransmitter or comm.SDRuReceiver with the X410 USRP when using Wireless TestBench? If not, is this something that will be available in future updates? Does Matlab R2024a support system objects such as comm.SDRuTransmitter or comm.SDRuReceiver with the X410 USRP when using Wireless TestBench? If not, is this something that will be available in future updates? usrp, matlab, sdr MATLAB Answers — New Questions
UIFigure appearance (scaling) change between 2023b and 2024a
I wrote an app in 2023b, but after installing 2024a the figure doesn’t appear the same, and some of my UI controls actually fall off the figure in 2024a. Below is a simplified example of the issue.
Here is the code I ran in both versions:
fig = uifigure(Name="This is in 2023b");
% fig = uifigure(Name="This is in 2024a");
lbl = uilabel(fig);
lbl.Text = "This is a label";
lbl.Position = [20 200 100 60];
Here is a screenshot of the outputs side-by-side:
As you can see the font and the spacing in 2024a is slightly larger, as if it is scaled differently. And it’s not just with UILables, the size and spacing is larger for all objects in 2024a compared to 2023b.
I reset all default groot settings with reset(groot, "default")
I recursivly cleared all personal settings with [setting].clearPersonalValue
But I still get this result.
It’s a fairly large and complex app with a lot of ui controls and I don’t want to rewrite it because if this.
Is there a setting somewhere I’m overlooking, or something else I’m missing?I wrote an app in 2023b, but after installing 2024a the figure doesn’t appear the same, and some of my UI controls actually fall off the figure in 2024a. Below is a simplified example of the issue.
Here is the code I ran in both versions:
fig = uifigure(Name="This is in 2023b");
% fig = uifigure(Name="This is in 2024a");
lbl = uilabel(fig);
lbl.Text = "This is a label";
lbl.Position = [20 200 100 60];
Here is a screenshot of the outputs side-by-side:
As you can see the font and the spacing in 2024a is slightly larger, as if it is scaled differently. And it’s not just with UILables, the size and spacing is larger for all objects in 2024a compared to 2023b.
I reset all default groot settings with reset(groot, "default")
I recursivly cleared all personal settings with [setting].clearPersonalValue
But I still get this result.
It’s a fairly large and complex app with a lot of ui controls and I don’t want to rewrite it because if this.
Is there a setting somewhere I’m overlooking, or something else I’m missing? I wrote an app in 2023b, but after installing 2024a the figure doesn’t appear the same, and some of my UI controls actually fall off the figure in 2024a. Below is a simplified example of the issue.
Here is the code I ran in both versions:
fig = uifigure(Name="This is in 2023b");
% fig = uifigure(Name="This is in 2024a");
lbl = uilabel(fig);
lbl.Text = "This is a label";
lbl.Position = [20 200 100 60];
Here is a screenshot of the outputs side-by-side:
As you can see the font and the spacing in 2024a is slightly larger, as if it is scaled differently. And it’s not just with UILables, the size and spacing is larger for all objects in 2024a compared to 2023b.
I reset all default groot settings with reset(groot, "default")
I recursivly cleared all personal settings with [setting].clearPersonalValue
But I still get this result.
It’s a fairly large and complex app with a lot of ui controls and I don’t want to rewrite it because if this.
Is there a setting somewhere I’m overlooking, or something else I’m missing? uifigure, settings, groot, uifigure font, uifigure scaling MATLAB Answers — New Questions
How to save the values of data tips of a plot
What function to use to save the data tip values of a plot to some variables in my app designerWhat function to use to save the data tip values of a plot to some variables in my app designer What function to use to save the data tip values of a plot to some variables in my app designer datatips MATLAB Answers — New Questions
Multivariate Newthon’s Method
Dear All,
I am trying to solve a multivariate function by using the Newthon’s Method. However, I get an error message in the lwhen I run my code (exactly in newtons_method file), and I could not figure out what is going on. Here is the files that I am using:
%This file is the one that appears here: Multivariate Newton’s Method (newtons_method_n)
function [x,k,x_all] = newtons_method_n(f,J,x0,opts)
if (nargin < 4) || isempty(opts) || ~isfield(opts,’k_max’)
k_max = 200;
else
k_max = opts.k_max;
end
if (nargin < 4) || isempty(opts) || ~isfield(opts,’return_all’)
return_all = false;
else
return_all = opts.return_all;
end
if (nargin < 4) || isempty(opts) || ~isfield(opts,’TOL’)
TOL = 1e-10;
else
TOL = opts.TOL;
end
n = length(x0);
if f(x0) == zeros(n,1)
x = x0;
return
end
x_curr = x0;
x_next = zeros(n,1);
if return_all
x_all = zeros(n,k_max+1);
end
for k = 1:k_max
if return_all
x_all(:,k) = x_curr;
end
y = J(x_curr)(-f(x_curr));
x_next = x_curr+y;
if (norm(y) < TOL)
break;
end
x_curr = x_next;
end
x = x_next;
if return_all
x_all(:,k+1) = x;
x_all = x_all(:,1:(k+1));
end
end
This is the main.n file:
clear all
clc
% Global variables are only parameters which do not change
global a b theta t d n L Y g
load DATA
n = 19; % Number of countries
a = 0.134813590592666;
b = 0.21221;
theta = 8.28; % Shape of Pareto dist
relaw = aw./aw(n,1); % Relative wage to US
t = exp( b*(S+theta*(log(relaw))) ); % Technology: see Table VI
d = D; % Geographic barriers dni^(-theta)
L = l; % Labor
Y = y; % Income
elast = 0.1; % Elasticity of wage adjustment
% Gamma constant (as in the original code)
g = (b^(-b))*((1-b)^(-(1-b)));
g = g^(theta);
disp(‘Newton iterative procedure starts here’)
w = aw; % Set initial wages at data
% Set bounds (implied by the model) for prices
pbounds = bounds(w);
p0 = 0.5*(pbounds(:,1)+pbounds(:,2)); % Half way between min and max
[pval,fval] = newtons_method(@(p) prices(p,w),p0);
And finally the prices.m file:
function [fval,fjac] = prices(p,w)
global b theta t d n g
aux1 = g*t.*(w.^(-theta*b));
aux2 = repmat(aux1,1,n)’;
G = d.*aux2;
fval = Gp -p.^(1-b);
fjac = inv(G) – (1-b)*diag(p.^(-b));
With all this on hand, any idea about why is there an error?
Thank you in advanced!Dear All,
I am trying to solve a multivariate function by using the Newthon’s Method. However, I get an error message in the lwhen I run my code (exactly in newtons_method file), and I could not figure out what is going on. Here is the files that I am using:
%This file is the one that appears here: Multivariate Newton’s Method (newtons_method_n)
function [x,k,x_all] = newtons_method_n(f,J,x0,opts)
if (nargin < 4) || isempty(opts) || ~isfield(opts,’k_max’)
k_max = 200;
else
k_max = opts.k_max;
end
if (nargin < 4) || isempty(opts) || ~isfield(opts,’return_all’)
return_all = false;
else
return_all = opts.return_all;
end
if (nargin < 4) || isempty(opts) || ~isfield(opts,’TOL’)
TOL = 1e-10;
else
TOL = opts.TOL;
end
n = length(x0);
if f(x0) == zeros(n,1)
x = x0;
return
end
x_curr = x0;
x_next = zeros(n,1);
if return_all
x_all = zeros(n,k_max+1);
end
for k = 1:k_max
if return_all
x_all(:,k) = x_curr;
end
y = J(x_curr)(-f(x_curr));
x_next = x_curr+y;
if (norm(y) < TOL)
break;
end
x_curr = x_next;
end
x = x_next;
if return_all
x_all(:,k+1) = x;
x_all = x_all(:,1:(k+1));
end
end
This is the main.n file:
clear all
clc
% Global variables are only parameters which do not change
global a b theta t d n L Y g
load DATA
n = 19; % Number of countries
a = 0.134813590592666;
b = 0.21221;
theta = 8.28; % Shape of Pareto dist
relaw = aw./aw(n,1); % Relative wage to US
t = exp( b*(S+theta*(log(relaw))) ); % Technology: see Table VI
d = D; % Geographic barriers dni^(-theta)
L = l; % Labor
Y = y; % Income
elast = 0.1; % Elasticity of wage adjustment
% Gamma constant (as in the original code)
g = (b^(-b))*((1-b)^(-(1-b)));
g = g^(theta);
disp(‘Newton iterative procedure starts here’)
w = aw; % Set initial wages at data
% Set bounds (implied by the model) for prices
pbounds = bounds(w);
p0 = 0.5*(pbounds(:,1)+pbounds(:,2)); % Half way between min and max
[pval,fval] = newtons_method(@(p) prices(p,w),p0);
And finally the prices.m file:
function [fval,fjac] = prices(p,w)
global b theta t d n g
aux1 = g*t.*(w.^(-theta*b));
aux2 = repmat(aux1,1,n)’;
G = d.*aux2;
fval = Gp -p.^(1-b);
fjac = inv(G) – (1-b)*diag(p.^(-b));
With all this on hand, any idea about why is there an error?
Thank you in advanced! Dear All,
I am trying to solve a multivariate function by using the Newthon’s Method. However, I get an error message in the lwhen I run my code (exactly in newtons_method file), and I could not figure out what is going on. Here is the files that I am using:
%This file is the one that appears here: Multivariate Newton’s Method (newtons_method_n)
function [x,k,x_all] = newtons_method_n(f,J,x0,opts)
if (nargin < 4) || isempty(opts) || ~isfield(opts,’k_max’)
k_max = 200;
else
k_max = opts.k_max;
end
if (nargin < 4) || isempty(opts) || ~isfield(opts,’return_all’)
return_all = false;
else
return_all = opts.return_all;
end
if (nargin < 4) || isempty(opts) || ~isfield(opts,’TOL’)
TOL = 1e-10;
else
TOL = opts.TOL;
end
n = length(x0);
if f(x0) == zeros(n,1)
x = x0;
return
end
x_curr = x0;
x_next = zeros(n,1);
if return_all
x_all = zeros(n,k_max+1);
end
for k = 1:k_max
if return_all
x_all(:,k) = x_curr;
end
y = J(x_curr)(-f(x_curr));
x_next = x_curr+y;
if (norm(y) < TOL)
break;
end
x_curr = x_next;
end
x = x_next;
if return_all
x_all(:,k+1) = x;
x_all = x_all(:,1:(k+1));
end
end
This is the main.n file:
clear all
clc
% Global variables are only parameters which do not change
global a b theta t d n L Y g
load DATA
n = 19; % Number of countries
a = 0.134813590592666;
b = 0.21221;
theta = 8.28; % Shape of Pareto dist
relaw = aw./aw(n,1); % Relative wage to US
t = exp( b*(S+theta*(log(relaw))) ); % Technology: see Table VI
d = D; % Geographic barriers dni^(-theta)
L = l; % Labor
Y = y; % Income
elast = 0.1; % Elasticity of wage adjustment
% Gamma constant (as in the original code)
g = (b^(-b))*((1-b)^(-(1-b)));
g = g^(theta);
disp(‘Newton iterative procedure starts here’)
w = aw; % Set initial wages at data
% Set bounds (implied by the model) for prices
pbounds = bounds(w);
p0 = 0.5*(pbounds(:,1)+pbounds(:,2)); % Half way between min and max
[pval,fval] = newtons_method(@(p) prices(p,w),p0);
And finally the prices.m file:
function [fval,fjac] = prices(p,w)
global b theta t d n g
aux1 = g*t.*(w.^(-theta*b));
aux2 = repmat(aux1,1,n)’;
G = d.*aux2;
fval = Gp -p.^(1-b);
fjac = inv(G) – (1-b)*diag(p.^(-b));
With all this on hand, any idea about why is there an error?
Thank you in advanced! optimization, functions MATLAB Answers — New Questions
How do I mesh a matlab model
I am trying to mesh a geometry. The geometry was modelled on matlab. Most meshing examples on matlab involve importing of the geometry. How do I mesh a model that was made in matlab. The model code as well as the mesh code has been given below.
rect1=[3
4
-530
530
530
-530
0
0
-530
-530];
C1=[1
0
0
228.6];
C2=[1
0
0
520.5];
C1 = [C1;zeros(length(rect1) – length(C1),1)];
C2 = [C2;zeros(length(rect1) – length(C2),1)];
gd = [C1,C2,rect1];
ns = (char(‘C1′,’C2′,’rect1’));
ns = ns’;
sf='(C2)-(C1+rect1)’;
dl = decsg(gd,sf,ns);
model = createpde("thermal","transient");
ge = geometryFromEdges(model,dl);
% 2D -> 3D extrusion
gd1 = extrude(ge,96);
figure
pdegplot(gd1,"FaceLabels","on")
model = femodel(Geometry="gd1");
model = generateMesh(model,Hmax=5,Hmin=1);
pdemesh(model)I am trying to mesh a geometry. The geometry was modelled on matlab. Most meshing examples on matlab involve importing of the geometry. How do I mesh a model that was made in matlab. The model code as well as the mesh code has been given below.
rect1=[3
4
-530
530
530
-530
0
0
-530
-530];
C1=[1
0
0
228.6];
C2=[1
0
0
520.5];
C1 = [C1;zeros(length(rect1) – length(C1),1)];
C2 = [C2;zeros(length(rect1) – length(C2),1)];
gd = [C1,C2,rect1];
ns = (char(‘C1′,’C2′,’rect1’));
ns = ns’;
sf='(C2)-(C1+rect1)’;
dl = decsg(gd,sf,ns);
model = createpde("thermal","transient");
ge = geometryFromEdges(model,dl);
% 2D -> 3D extrusion
gd1 = extrude(ge,96);
figure
pdegplot(gd1,"FaceLabels","on")
model = femodel(Geometry="gd1");
model = generateMesh(model,Hmax=5,Hmin=1);
pdemesh(model) I am trying to mesh a geometry. The geometry was modelled on matlab. Most meshing examples on matlab involve importing of the geometry. How do I mesh a model that was made in matlab. The model code as well as the mesh code has been given below.
rect1=[3
4
-530
530
530
-530
0
0
-530
-530];
C1=[1
0
0
228.6];
C2=[1
0
0
520.5];
C1 = [C1;zeros(length(rect1) – length(C1),1)];
C2 = [C2;zeros(length(rect1) – length(C2),1)];
gd = [C1,C2,rect1];
ns = (char(‘C1′,’C2′,’rect1’));
ns = ns’;
sf='(C2)-(C1+rect1)’;
dl = decsg(gd,sf,ns);
model = createpde("thermal","transient");
ge = geometryFromEdges(model,dl);
% 2D -> 3D extrusion
gd1 = extrude(ge,96);
figure
pdegplot(gd1,"FaceLabels","on")
model = femodel(Geometry="gd1");
model = generateMesh(model,Hmax=5,Hmin=1);
pdemesh(model) mesh MATLAB Answers — New Questions
Collision over-simplification in RST
Hello,
I am working with MATLAB to visualize the collision meshes of a robot I’ve designed. When using the show(robot) function, I notice that the collision meshes appear less detailed, I guess, the idea is to optimize execution time and reduce CPU load.
Could you please provide information on the maximum number of triangles allowed per STL file for collision meshes? I aim to achieve a balance between having detailed collision meshes and maintaining computational efficiency.
How it’s supposed to look like :
meshTri = stlread("concept_c-bras5_col.stl");
trisurf(meshTri)
axis equal
How it actually looks like :
rbt = importrobot("concept.urdf");
show(rbt,Collisions="on");
As you can see it’s really ugly. Do you know how to improve the collision meshes make them more accurate ?Hello,
I am working with MATLAB to visualize the collision meshes of a robot I’ve designed. When using the show(robot) function, I notice that the collision meshes appear less detailed, I guess, the idea is to optimize execution time and reduce CPU load.
Could you please provide information on the maximum number of triangles allowed per STL file for collision meshes? I aim to achieve a balance between having detailed collision meshes and maintaining computational efficiency.
How it’s supposed to look like :
meshTri = stlread("concept_c-bras5_col.stl");
trisurf(meshTri)
axis equal
How it actually looks like :
rbt = importrobot("concept.urdf");
show(rbt,Collisions="on");
As you can see it’s really ugly. Do you know how to improve the collision meshes make them more accurate ? Hello,
I am working with MATLAB to visualize the collision meshes of a robot I’ve designed. When using the show(robot) function, I notice that the collision meshes appear less detailed, I guess, the idea is to optimize execution time and reduce CPU load.
Could you please provide information on the maximum number of triangles allowed per STL file for collision meshes? I aim to achieve a balance between having detailed collision meshes and maintaining computational efficiency.
How it’s supposed to look like :
meshTri = stlread("concept_c-bras5_col.stl");
trisurf(meshTri)
axis equal
How it actually looks like :
rbt = importrobot("concept.urdf");
show(rbt,Collisions="on");
As you can see it’s really ugly. Do you know how to improve the collision meshes make them more accurate ? matlab MATLAB Answers — New Questions
vastly different optimization results from different matlab versions (r2023b,2021b,2020b)
[I just came across the problem and want to put down what I have for now. Will come back to improve the question once I narrow it down. THX]
I was solving a high-dimensional nonlinear optimization problem with self written gradient descent method. Running the exact same code (literally the same file, with no workspace or command window inputs), version 2023b gave me very different results from 2021b. I then compared with 2020b, which produced the same result as 2021b. Comparing the outputs, I found that 2023b calculated the gradient differently.
2020b and 2021b gave the following and converged after 18 iterations.
direction = [4.33783e-06 2.33596e-06 -5.33992e-06 -8.36479e-06 -9.19797e-05 1 ]
2023b gave the following and didn’t converge after 44 iterations.
direction = [4.17191e-06 2.24661e-06 -5.13617e-06 -7.53861e-06 -5.19154e-05 1 ]
The code is very slow, so I can’t let it run forever and find out when it will converge.
As far as I know, my code doesn’t involve any randomness. It does use a lot of matrices and high-order polynomials, as well as conditions.
I went through the release notes from r2021b onwards, and noticed a change to the round function, which I don’t use explicitly but can affect the conditions I suppose?round function change
There’re also some performance improvements on matrix calculations.[I just came across the problem and want to put down what I have for now. Will come back to improve the question once I narrow it down. THX]
I was solving a high-dimensional nonlinear optimization problem with self written gradient descent method. Running the exact same code (literally the same file, with no workspace or command window inputs), version 2023b gave me very different results from 2021b. I then compared with 2020b, which produced the same result as 2021b. Comparing the outputs, I found that 2023b calculated the gradient differently.
2020b and 2021b gave the following and converged after 18 iterations.
direction = [4.33783e-06 2.33596e-06 -5.33992e-06 -8.36479e-06 -9.19797e-05 1 ]
2023b gave the following and didn’t converge after 44 iterations.
direction = [4.17191e-06 2.24661e-06 -5.13617e-06 -7.53861e-06 -5.19154e-05 1 ]
The code is very slow, so I can’t let it run forever and find out when it will converge.
As far as I know, my code doesn’t involve any randomness. It does use a lot of matrices and high-order polynomials, as well as conditions.
I went through the release notes from r2021b onwards, and noticed a change to the round function, which I don’t use explicitly but can affect the conditions I suppose?round function change
There’re also some performance improvements on matrix calculations. [I just came across the problem and want to put down what I have for now. Will come back to improve the question once I narrow it down. THX]
I was solving a high-dimensional nonlinear optimization problem with self written gradient descent method. Running the exact same code (literally the same file, with no workspace or command window inputs), version 2023b gave me very different results from 2021b. I then compared with 2020b, which produced the same result as 2021b. Comparing the outputs, I found that 2023b calculated the gradient differently.
2020b and 2021b gave the following and converged after 18 iterations.
direction = [4.33783e-06 2.33596e-06 -5.33992e-06 -8.36479e-06 -9.19797e-05 1 ]
2023b gave the following and didn’t converge after 44 iterations.
direction = [4.17191e-06 2.24661e-06 -5.13617e-06 -7.53861e-06 -5.19154e-05 1 ]
The code is very slow, so I can’t let it run forever and find out when it will converge.
As far as I know, my code doesn’t involve any randomness. It does use a lot of matrices and high-order polynomials, as well as conditions.
I went through the release notes from r2021b onwards, and noticed a change to the round function, which I don’t use explicitly but can affect the conditions I suppose?round function change
There’re also some performance improvements on matrix calculations. version changes, different results MATLAB Answers — New Questions
Removing the grey margin of a plot (follow up question)
This is a follow-up question to Removing the grey margin of a plot. If I use the same code proposed by @KSSV within a subplot environment, the picture goes out the left margin (and probably the right margin as well):
subplot(1,2,1) % <– If I use subplotm the picture goes out the left (and maybe right) margin
plot(peaks)
title(‘Plot of Peaks Function’)
axis off
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) – ti(1) – ti(3);
ax_height = outerpos(4) – ti(2) – ti(4);
ax.Position = [left bottom ax_width ax_height];
Is there a way to correctly adjust the left (and maybe the right) margin, in such a way that the entire figure lies inside the subplot?This is a follow-up question to Removing the grey margin of a plot. If I use the same code proposed by @KSSV within a subplot environment, the picture goes out the left margin (and probably the right margin as well):
subplot(1,2,1) % <– If I use subplotm the picture goes out the left (and maybe right) margin
plot(peaks)
title(‘Plot of Peaks Function’)
axis off
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) – ti(1) – ti(3);
ax_height = outerpos(4) – ti(2) – ti(4);
ax.Position = [left bottom ax_width ax_height];
Is there a way to correctly adjust the left (and maybe the right) margin, in such a way that the entire figure lies inside the subplot? This is a follow-up question to Removing the grey margin of a plot. If I use the same code proposed by @KSSV within a subplot environment, the picture goes out the left margin (and probably the right margin as well):
subplot(1,2,1) % <– If I use subplotm the picture goes out the left (and maybe right) margin
plot(peaks)
title(‘Plot of Peaks Function’)
axis off
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) – ti(1) – ti(3);
ax_height = outerpos(4) – ti(2) – ti(4);
ax.Position = [left bottom ax_width ax_height];
Is there a way to correctly adjust the left (and maybe the right) margin, in such a way that the entire figure lies inside the subplot? margin, subplot, outerposition, tightinset, margins MATLAB Answers — New Questions
Plot shows in legend but not in graph?
subplot(2,2,1);
plot(x1,y1,’bs’)
hold on
p1 = polyfit(x1,y1,35);
f1 = polyval(p1,x1);
plot(x1,f1,’–r’)
hold off
legend
title(‘Data Set 1’)
xlabel(‘X1 Values’)
ylabel(‘Y1 Values’)
subplot(2,2,2);
plot(x2,y2,’g*’)
hold on
p2 = polyfit(x2,y2,35);
f2 = polyval(p2,x2);
plot(x2,f2,’–b’)
hold off
legend
title(‘Data Set 2’)
xlabel(‘X2 Values’)
ylabel(‘Y2 Values’)subplot(2,2,1);
plot(x1,y1,’bs’)
hold on
p1 = polyfit(x1,y1,35);
f1 = polyval(p1,x1);
plot(x1,f1,’–r’)
hold off
legend
title(‘Data Set 1’)
xlabel(‘X1 Values’)
ylabel(‘Y1 Values’)
subplot(2,2,2);
plot(x2,y2,’g*’)
hold on
p2 = polyfit(x2,y2,35);
f2 = polyval(p2,x2);
plot(x2,f2,’–b’)
hold off
legend
title(‘Data Set 2’)
xlabel(‘X2 Values’)
ylabel(‘Y2 Values’) subplot(2,2,1);
plot(x1,y1,’bs’)
hold on
p1 = polyfit(x1,y1,35);
f1 = polyval(p1,x1);
plot(x1,f1,’–r’)
hold off
legend
title(‘Data Set 1’)
xlabel(‘X1 Values’)
ylabel(‘Y1 Values’)
subplot(2,2,2);
plot(x2,y2,’g*’)
hold on
p2 = polyfit(x2,y2,35);
f2 = polyval(p2,x2);
plot(x2,f2,’–b’)
hold off
legend
title(‘Data Set 2’)
xlabel(‘X2 Values’)
ylabel(‘Y2 Values’) subplot, multiple MATLAB Answers — New Questions
Linear Neural Network add another linear layer
I have written a program for training a linear neural network for classification. Both the input and the output are 3 row vectors and I need a each node to have a linear transfer function. I have used the linearlayer type as you can see in the code below;
function trainLNN(P, T)
%P = [1.7300 1.9500 2.3800; 1.4400 5.0000 4.7500; 3.4000 3.2000 3.3000];
%T = [ 0 1 0; 1 0 0; 0 0 1];
net = linearlayer;
net.trainParam.epochs = 1000;
net.trainParam.goal = 0.1;
net.trainParam.lr = 0.001;
net.trainParam.lr = maxlinlr(P,’bias’);
net = train(net,P, T);
What I get is a neural network with just an input and an output layer (see the photo below).
How can I extend that to add a hidden layer between the input and the output layers to have a network like the one in the photo with all nodes having a linear transfer function? I have tried net = linearlayer(P,T, 3, {‘purelin’, ‘purelin’}); but I get an error ("Too many parameter arguments");I have written a program for training a linear neural network for classification. Both the input and the output are 3 row vectors and I need a each node to have a linear transfer function. I have used the linearlayer type as you can see in the code below;
function trainLNN(P, T)
%P = [1.7300 1.9500 2.3800; 1.4400 5.0000 4.7500; 3.4000 3.2000 3.3000];
%T = [ 0 1 0; 1 0 0; 0 0 1];
net = linearlayer;
net.trainParam.epochs = 1000;
net.trainParam.goal = 0.1;
net.trainParam.lr = 0.001;
net.trainParam.lr = maxlinlr(P,’bias’);
net = train(net,P, T);
What I get is a neural network with just an input and an output layer (see the photo below).
How can I extend that to add a hidden layer between the input and the output layers to have a network like the one in the photo with all nodes having a linear transfer function? I have tried net = linearlayer(P,T, 3, {‘purelin’, ‘purelin’}); but I get an error ("Too many parameter arguments"); I have written a program for training a linear neural network for classification. Both the input and the output are 3 row vectors and I need a each node to have a linear transfer function. I have used the linearlayer type as you can see in the code below;
function trainLNN(P, T)
%P = [1.7300 1.9500 2.3800; 1.4400 5.0000 4.7500; 3.4000 3.2000 3.3000];
%T = [ 0 1 0; 1 0 0; 0 0 1];
net = linearlayer;
net.trainParam.epochs = 1000;
net.trainParam.goal = 0.1;
net.trainParam.lr = 0.001;
net.trainParam.lr = maxlinlr(P,’bias’);
net = train(net,P, T);
What I get is a neural network with just an input and an output layer (see the photo below).
How can I extend that to add a hidden layer between the input and the output layers to have a network like the one in the photo with all nodes having a linear transfer function? I have tried net = linearlayer(P,T, 3, {‘purelin’, ‘purelin’}); but I get an error ("Too many parameter arguments"); linear neural network, matlab, linearlayer MATLAB Answers — New Questions
MATLAB getMATFilesFromPixhawk Function Fails to Retrieve SD Card Data from Pixhawk PID Controller Simulation
I have been working on a PID controller for Pixhawk and encountered an issue when trying to retrieve MAT files from the SD card after optimizing and building the model in Simulink. Initially, I successfully logged signals to the SD card using the example px4-log and following the documentation. However, when applying the same steps to my PID controller project, I encountered an error when attempting to extract the MAT files using the getMATFilesFromPixhawk function. Despite running MATLAB as an administrator to avoid permission problems, the issue persists. I have tried various solutions without success. Do you have any ideas on how to resolve this?I have been working on a PID controller for Pixhawk and encountered an issue when trying to retrieve MAT files from the SD card after optimizing and building the model in Simulink. Initially, I successfully logged signals to the SD card using the example px4-log and following the documentation. However, when applying the same steps to my PID controller project, I encountered an error when attempting to extract the MAT files using the getMATFilesFromPixhawk function. Despite running MATLAB as an administrator to avoid permission problems, the issue persists. I have tried various solutions without success. Do you have any ideas on how to resolve this? I have been working on a PID controller for Pixhawk and encountered an issue when trying to retrieve MAT files from the SD card after optimizing and building the model in Simulink. Initially, I successfully logged signals to the SD card using the example px4-log and following the documentation. However, when applying the same steps to my PID controller project, I encountered an error when attempting to extract the MAT files using the getMATFilesFromPixhawk function. Despite running MATLAB as an administrator to avoid permission problems, the issue persists. I have tried various solutions without success. Do you have any ideas on how to resolve this? getmatfilesfrompixhawk, simulink, pixhawk, matlab function, simulation, export MATLAB Answers — New Questions
How to correct the recording of a daamaged accelerometer in earthquake analysis
Hello everyone,
I have the recording of two accelerometers but it turned out that one of them did not work properly and the recording is messed up (See photo, The two recordings should be the same). However I think if processed well I can recover the lost acclerogram. Does anyone have an idea how I can proceed. I have attached the recordings.
Thank you in advanceHello everyone,
I have the recording of two accelerometers but it turned out that one of them did not work properly and the recording is messed up (See photo, The two recordings should be the same). However I think if processed well I can recover the lost acclerogram. Does anyone have an idea how I can proceed. I have attached the recordings.
Thank you in advance Hello everyone,
I have the recording of two accelerometers but it turned out that one of them did not work properly and the recording is messed up (See photo, The two recordings should be the same). However I think if processed well I can recover the lost acclerogram. Does anyone have an idea how I can proceed. I have attached the recordings.
Thank you in advance accelerogram, earthquake, dynamic, engineering MATLAB Answers — New Questions
“library initialization failed – unable to allocate file descriptor table – out of memory MATLAB is exiting because of fatal error”
Hi!
I’m a Linux user and today I started receiving the following error message when launching MATLAB:
MATLAB is selecting SOFTWARE OPENGL rendering.
library initialization failed – unable to allocate file descriptor table – out of memory
MATLAB is exiting because of fatal error
[1] 10520 killed matlab
It was working correctly until now, not sure it could have something to do with a software update. However, if I execute matlab with the -nojvm flag it opens the console properly.
I’m using MATLAB R2023a in Debian trixie kernel version 6.7.12.
Thanks for your help!Hi!
I’m a Linux user and today I started receiving the following error message when launching MATLAB:
MATLAB is selecting SOFTWARE OPENGL rendering.
library initialization failed – unable to allocate file descriptor table – out of memory
MATLAB is exiting because of fatal error
[1] 10520 killed matlab
It was working correctly until now, not sure it could have something to do with a software update. However, if I execute matlab with the -nojvm flag it opens the console properly.
I’m using MATLAB R2023a in Debian trixie kernel version 6.7.12.
Thanks for your help! Hi!
I’m a Linux user and today I started receiving the following error message when launching MATLAB:
MATLAB is selecting SOFTWARE OPENGL rendering.
library initialization failed – unable to allocate file descriptor table – out of memory
MATLAB is exiting because of fatal error
[1] 10520 killed matlab
It was working correctly until now, not sure it could have something to do with a software update. However, if I execute matlab with the -nojvm flag it opens the console properly.
I’m using MATLAB R2023a in Debian trixie kernel version 6.7.12.
Thanks for your help! error, launch MATLAB Answers — New Questions
Data Extraction from SimBiology Simulations
What is the BEST way to get the simulation data out of simbiology and into excel or some other program?
I have found a brief explanation on how to export to Matlab area and then convert to XLS but its not working terrible wellWhat is the BEST way to get the simulation data out of simbiology and into excel or some other program?
I have found a brief explanation on how to export to Matlab area and then convert to XLS but its not working terrible well What is the BEST way to get the simulation data out of simbiology and into excel or some other program?
I have found a brief explanation on how to export to Matlab area and then convert to XLS but its not working terrible well simbiology, simulation MATLAB Answers — New Questions
What is the reason for error in HDL Coder and Cadence Stratus HLS tutorial?
Hi all,
I’m trying to complete this tutorial https://se.mathworks.com/help/hdlcoder/ug/get-started-with-matlab-to-hls-workflow-using-hdl-coder-app.html, but I get stuck in the Verification step in Workflow Advisor. I get this output in the Workflow Advisor window in Verification step (Verify with HLS Test Bench):
## Begin TestBench generation.
Code generation successful.
### Collecting data…
### Begin HDL test bench file generation with logged samples
### Generating test bench data file: x_in.dat.
### Generating test bench data file: y_out_expected.dat.
### Generating test bench data file: delayed_xout_expected.dat.
### Generating test bench file: mlhdlc_sfir_fixptClass_tb.hpp
### Running Stratus Importer on the generated testbench.
### Working on mlhdlc_sfir_fixpt_bdw_import_log.txt as mlhdlc_sfir_fixpt_bdw_import_log.txt.
Stratus Importer failed. See ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ for details.
Error in CadenceStratus>>generateBDWImportScripts at 0
Error in CadenceStratus>>postTBGen at 0
Error in HLSPostCodegenDriver>>postTBGen at 0
Error in Manager>>wfa_runHLSSimulation at 0
And following error message to Matlab Command window:
Error using emlhdlcoder.HLSDriver.Tools.CadenceStratus/generateBDWImportScripts
Stratus Importer failed. See ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ for
details.
Error in emlhdlcoder.HLSDriver.Tools.CadenceStratus/postTBGen
Error in emlhdlcoder.HLSDriver.HLSPostCodegenDriver/postTBGen
Error in emlhdlcoder.WorkFlow.Manager/wfa_runHLSSimulation
And here is the content of the ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ file is:
INFO: Searching /sw/rhel7/cadence/STRATUS2301 for template
WARNING: BDW_IMPORT_ML_CLOCK_FREQ = 0, using default 5.0.
INFO: Processing template tb.cc
FATAL ERROR: Unable to process template tb.cc
I’m using Matlab version R2024a and Cadence Stratus 23.01, but tested also with 22.01 which gave same error. What are the software versions that this tutorial is verified to work?Hi all,
I’m trying to complete this tutorial https://se.mathworks.com/help/hdlcoder/ug/get-started-with-matlab-to-hls-workflow-using-hdl-coder-app.html, but I get stuck in the Verification step in Workflow Advisor. I get this output in the Workflow Advisor window in Verification step (Verify with HLS Test Bench):
## Begin TestBench generation.
Code generation successful.
### Collecting data…
### Begin HDL test bench file generation with logged samples
### Generating test bench data file: x_in.dat.
### Generating test bench data file: y_out_expected.dat.
### Generating test bench data file: delayed_xout_expected.dat.
### Generating test bench file: mlhdlc_sfir_fixptClass_tb.hpp
### Running Stratus Importer on the generated testbench.
### Working on mlhdlc_sfir_fixpt_bdw_import_log.txt as mlhdlc_sfir_fixpt_bdw_import_log.txt.
Stratus Importer failed. See ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ for details.
Error in CadenceStratus>>generateBDWImportScripts at 0
Error in CadenceStratus>>postTBGen at 0
Error in HLSPostCodegenDriver>>postTBGen at 0
Error in Manager>>wfa_runHLSSimulation at 0
And following error message to Matlab Command window:
Error using emlhdlcoder.HLSDriver.Tools.CadenceStratus/generateBDWImportScripts
Stratus Importer failed. See ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ for
details.
Error in emlhdlcoder.HLSDriver.Tools.CadenceStratus/postTBGen
Error in emlhdlcoder.HLSDriver.HLSPostCodegenDriver/postTBGen
Error in emlhdlcoder.WorkFlow.Manager/wfa_runHLSSimulation
And here is the content of the ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ file is:
INFO: Searching /sw/rhel7/cadence/STRATUS2301 for template
WARNING: BDW_IMPORT_ML_CLOCK_FREQ = 0, using default 5.0.
INFO: Processing template tb.cc
FATAL ERROR: Unable to process template tb.cc
I’m using Matlab version R2024a and Cadence Stratus 23.01, but tested also with 22.01 which gave same error. What are the software versions that this tutorial is verified to work? Hi all,
I’m trying to complete this tutorial https://se.mathworks.com/help/hdlcoder/ug/get-started-with-matlab-to-hls-workflow-using-hdl-coder-app.html, but I get stuck in the Verification step in Workflow Advisor. I get this output in the Workflow Advisor window in Verification step (Verify with HLS Test Bench):
## Begin TestBench generation.
Code generation successful.
### Collecting data…
### Begin HDL test bench file generation with logged samples
### Generating test bench data file: x_in.dat.
### Generating test bench data file: y_out_expected.dat.
### Generating test bench data file: delayed_xout_expected.dat.
### Generating test bench file: mlhdlc_sfir_fixptClass_tb.hpp
### Running Stratus Importer on the generated testbench.
### Working on mlhdlc_sfir_fixpt_bdw_import_log.txt as mlhdlc_sfir_fixpt_bdw_import_log.txt.
Stratus Importer failed. See ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ for details.
Error in CadenceStratus>>generateBDWImportScripts at 0
Error in CadenceStratus>>postTBGen at 0
Error in HLSPostCodegenDriver>>postTBGen at 0
Error in Manager>>wfa_runHLSSimulation at 0
And following error message to Matlab Command window:
Error using emlhdlcoder.HLSDriver.Tools.CadenceStratus/generateBDWImportScripts
Stratus Importer failed. See ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ for
details.
Error in emlhdlcoder.HLSDriver.Tools.CadenceStratus/postTBGen
Error in emlhdlcoder.HLSDriver.HLSPostCodegenDriver/postTBGen
Error in emlhdlcoder.WorkFlow.Manager/wfa_runHLSSimulation
And here is the content of the ‘mlhdlc_sfir_fixpt_bdw_import_log.txt’ file is:
INFO: Searching /sw/rhel7/cadence/STRATUS2301 for template
WARNING: BDW_IMPORT_ML_CLOCK_FREQ = 0, using default 5.0.
INFO: Processing template tb.cc
FATAL ERROR: Unable to process template tb.cc
I’m using Matlab version R2024a and Cadence Stratus 23.01, but tested also with 22.01 which gave same error. What are the software versions that this tutorial is verified to work? cadence, stratus, hls MATLAB Answers — New Questions
Error using symengine First argument must not contain functionals.
Dear MathWorks-Community,
I recived the following error message:
Error using symengine
First argument must not contain functionals.
Error in mupadengine/evalin_internal
Error in mupadengine/fevalHelper
Error in mupadengine/feval_internal
Error in sym/diff (line 107)
R = feval_internal(symengine, ‘symobj::diff’, S, x, n);
When I wanted to run my code it appeard for line 10 where I am calculating diffL_over_theta1dot. Can someone please explain me why it worked for diffL_over_alpha1 in line 4 but not for line 10?
L is a symfun.
Can anyone help me with resolving this issue?
Thanks a lot in advance!
syms tau_1
syms theta_1(t) alpha_1(t)
diffL_over_alpha1=diff(L,alpha_1);
alpha_1dot=diff(alpha_1,t);
tau_1==diff(diffL_over_alpha1dot,t)-diff(L,alpha_1dot);
theta_1_dot=diff(theta_1,t);
diffL_over_theta1dot=diff(L,theta_1_dot)
0==diff(diffL_over_theta1dot,t)-diff(L,theta_1);Dear MathWorks-Community,
I recived the following error message:
Error using symengine
First argument must not contain functionals.
Error in mupadengine/evalin_internal
Error in mupadengine/fevalHelper
Error in mupadengine/feval_internal
Error in sym/diff (line 107)
R = feval_internal(symengine, ‘symobj::diff’, S, x, n);
When I wanted to run my code it appeard for line 10 where I am calculating diffL_over_theta1dot. Can someone please explain me why it worked for diffL_over_alpha1 in line 4 but not for line 10?
L is a symfun.
Can anyone help me with resolving this issue?
Thanks a lot in advance!
syms tau_1
syms theta_1(t) alpha_1(t)
diffL_over_alpha1=diff(L,alpha_1);
alpha_1dot=diff(alpha_1,t);
tau_1==diff(diffL_over_alpha1dot,t)-diff(L,alpha_1dot);
theta_1_dot=diff(theta_1,t);
diffL_over_theta1dot=diff(L,theta_1_dot)
0==diff(diffL_over_theta1dot,t)-diff(L,theta_1); Dear MathWorks-Community,
I recived the following error message:
Error using symengine
First argument must not contain functionals.
Error in mupadengine/evalin_internal
Error in mupadengine/fevalHelper
Error in mupadengine/feval_internal
Error in sym/diff (line 107)
R = feval_internal(symengine, ‘symobj::diff’, S, x, n);
When I wanted to run my code it appeard for line 10 where I am calculating diffL_over_theta1dot. Can someone please explain me why it worked for diffL_over_alpha1 in line 4 but not for line 10?
L is a symfun.
Can anyone help me with resolving this issue?
Thanks a lot in advance!
syms tau_1
syms theta_1(t) alpha_1(t)
diffL_over_alpha1=diff(L,alpha_1);
alpha_1dot=diff(alpha_1,t);
tau_1==diff(diffL_over_alpha1dot,t)-diff(L,alpha_1dot);
theta_1_dot=diff(theta_1,t);
diffL_over_theta1dot=diff(L,theta_1_dot)
0==diff(diffL_over_theta1dot,t)-diff(L,theta_1); symbolic MATLAB Answers — New Questions
Simulink model doesn’t oscillate
Hi,
I’m trying to model an reaction wheel inverted pendulum and I find this article: https://www.mdpi.com/2079-9292/13/3/514#B1-electronics-13-00514. And now I have to identify the friction coefficient, b_theta. They mesure the natural oscillation of the pendulum by swinging. And then implement this formula in simulink to estimate b_theta by comparing the results:
On the right is my model and on the left is the model present in the article. The probleme is that my simulation doesn’t oscillate, the result is always 0. And i don’t know what the probleme is. I’m using a fixed step of 1e-3 and the solver is on auto (I try multiple solvers but the result is the same).Hi,
I’m trying to model an reaction wheel inverted pendulum and I find this article: https://www.mdpi.com/2079-9292/13/3/514#B1-electronics-13-00514. And now I have to identify the friction coefficient, b_theta. They mesure the natural oscillation of the pendulum by swinging. And then implement this formula in simulink to estimate b_theta by comparing the results:
On the right is my model and on the left is the model present in the article. The probleme is that my simulation doesn’t oscillate, the result is always 0. And i don’t know what the probleme is. I’m using a fixed step of 1e-3 and the solver is on auto (I try multiple solvers but the result is the same). Hi,
I’m trying to model an reaction wheel inverted pendulum and I find this article: https://www.mdpi.com/2079-9292/13/3/514#B1-electronics-13-00514. And now I have to identify the friction coefficient, b_theta. They mesure the natural oscillation of the pendulum by swinging. And then implement this formula in simulink to estimate b_theta by comparing the results:
On the right is my model and on the left is the model present in the article. The probleme is that my simulation doesn’t oscillate, the result is always 0. And i don’t know what the probleme is. I’m using a fixed step of 1e-3 and the solver is on auto (I try multiple solvers but the result is the same). model MATLAB Answers — New Questions
Dynamic matrix columns combinations
Hello,
I would like to find all possible combinations of a matrix columns, with each column contribute a value, in each itteration of a loop. The matrix size changes in each itteration. For example:
A = [1 2 3
4 5 6
7 8 9].
should produce:
1 2 3
1 2 6
1 5 3 etc.
but should not produce:
1 4 2 for example.
My problems:
When insert the matrix to combvec function nothing happens. The function accept vectors – and since I do it with different matrix size in each Itteration of a loop I can’t write it manually.
ndgrid also requires vectors – and since I need to choose a combination index in other variable – I’m not clear how this happens.
I don’t have combination function in my Matlab version.
Is there a way to define vectors dynamically in a loop? any idea on to how overcome this? Do I need to write a combination function myself?Hello,
I would like to find all possible combinations of a matrix columns, with each column contribute a value, in each itteration of a loop. The matrix size changes in each itteration. For example:
A = [1 2 3
4 5 6
7 8 9].
should produce:
1 2 3
1 2 6
1 5 3 etc.
but should not produce:
1 4 2 for example.
My problems:
When insert the matrix to combvec function nothing happens. The function accept vectors – and since I do it with different matrix size in each Itteration of a loop I can’t write it manually.
ndgrid also requires vectors – and since I need to choose a combination index in other variable – I’m not clear how this happens.
I don’t have combination function in my Matlab version.
Is there a way to define vectors dynamically in a loop? any idea on to how overcome this? Do I need to write a combination function myself? Hello,
I would like to find all possible combinations of a matrix columns, with each column contribute a value, in each itteration of a loop. The matrix size changes in each itteration. For example:
A = [1 2 3
4 5 6
7 8 9].
should produce:
1 2 3
1 2 6
1 5 3 etc.
but should not produce:
1 4 2 for example.
My problems:
When insert the matrix to combvec function nothing happens. The function accept vectors – and since I do it with different matrix size in each Itteration of a loop I can’t write it manually.
ndgrid also requires vectors – and since I need to choose a combination index in other variable – I’m not clear how this happens.
I don’t have combination function in my Matlab version.
Is there a way to define vectors dynamically in a loop? any idea on to how overcome this? Do I need to write a combination function myself? combination MATLAB Answers — New Questions