Category: Matlab
Category Archives: Matlab
4D spherical shell heat map
I have written a code (attached) to plot particles striking a sphere of radius r – I can produce the image in example_1. I divide the shell into segments and calculate the number of particles falling within each.
I would like to represent the data as a smooth 3d heatmap over the spherical shell. I can produce the image shown in example_2 using scatter3 and a color bar, but I would like a smooth surface. I have tried to follow the example of my previous question using an isosurface –
however ux != uy != uz and I have the "Number of elements must not change" error.
I have also tried meshgrid(), but the size of photons results in an array that excedes maximum size preference.
Is there an easier way to smooth this data?
photons = readmatrix(‘input.txt’);
r = 70; % in unit mm
prop = zeros(length(photons),3);
for i = 1:length(photons)
c(i) = ((photons(i,1)*photons(i,1)) + (photons(i,2)*photons(i,2)) + (photons(i,3)*photons(i,3)) – (r*r));
b(i) = 2*((photons(i,1)*photons(i,7)) + (photons(i,2)*photons(i,8)) + (photons(i,3)*photons(i,9)));
a(i) = ((photons(i,7)*photons(i,7)) + (photons(i,8)*photons(i,8)) + (photons(i,9)*photons(i,9)));
t(i) = (-b(i) + sqrt(b(i).^2 – 4*a(i)*c(i)))/(2*a(i));
prop(i,1) = photons(i,1) + t(i)*photons(i,7);
prop(i,2) = photons(i,2) + t(i)*photons(i,8);
prop(i,3) = photons(i,3) + t(i)*photons(i,9);
prop_sph(i,3) = sqrt(prop(i,1).^2 + prop(i,2).^2 + prop(i,3).^2); % calculate spherical radius (should be r)
prop_sph(i,1) = acos((prop(i,3))/(prop_sph(i,3))); % calculate spherical theta (elevation)
if prop(i,1) > 0 && prop(i,2) >= 0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)); % calculate spherical phi (azimuth)
end
if prop(i,1) > 0 && prop(i,2) < 0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + 2*pi;
end
if prop(i,1) < 0 && prop(i,2) >=0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + pi;
end
if prop(i,1) < 0 && prop(i,2) >=0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + pi;
end
if prop(i,1) < 0 && prop(i,2) < 0
prop_sph(i,2) = (atan(prop(i,2)/prop(i,1)) – pi) + 2*pi ;
end
if prop(i,1) == 0 && prop(i,2) > 0
prop_sph(i,2) = pi / 2;
end
if prop(i,1) == 0 && prop(i,2) < 0
prop_sph(i,2) = (-pi / 2) + 2*pi;
end
if prop(i,1) == 0 && prop(i,2) == 0
prop_sph(i,2) = NaN;
end
end
% plot the photon distribution in Cartesian coordinates.
% scatter3(prop(:,1),prop(:,2),prop(:,3), 10,’k’,’filled’,’MarkerFaceAlpha’,.9);
% sort photons into bins of size d_th*d_phi in spherical coordinates
max_th = pi;
max_phi = 2*pi;
d_th = max_th / 100;
d_phi = max_phi / 100;
l_th = round((max_th / d_th) * (max_phi / d_phi));
theta = (0:d_th:max_th)’;
phi = (0:d_phi:max_phi)’;
mat = [zeros(l_th,1)’; zeros(l_th,1)’; zeros(l_th,1)’;]’;
n = 1;
for j = 1:length(phi)
for i = 1:length(theta)
mat(n,1) = theta(i);
mat(n,2) = phi(j);
n = n+1;
end
end
for w = 1:length(mat)
for k = 1:length(prop_sph)
if (((prop_sph(k,1) >= mat(w,1)) && (prop_sph(k,1) < mat(w,1) + d_th)) && ((prop_sph(k,2) >= mat(w,2)) && (prop_sph(k,2) < mat(w,2) + d_phi)))
mat(w,3) = mat(w,3) + 1;
end
end
end
% ——- convert back to cartesian coordinates and include color data
for i = 1:length(mat)
prop_map_fin(i,1) = prop_sph(i,3)*sin(mat(i,1) + d_th/2)*cos(mat(i,2) + d_phi/2);
prop_map_fin(i,2) = prop_sph(i,3)*sin(mat(i,1) + d_th/2)*sin(mat(i,2) + d_phi/2);
prop_map_fin(i,3) = prop_sph(i,3)*cos(mat(i,1) + d_th/2);
prop_map_fin(i,4) = mat(i,3);
% X = prop_sph(:,3).*sin(prop_sph(:,1)).*cos(prop_sph(:,2));
% Y = prop_sph(:,3).*sin(prop_sph(:,1)).*sin(prop_sph(:,2));
% Z = prop_sph(:,3).*cos(prop_sph(:,1));
end
% — visualize ——————————————————–
%surf(prop_map_fin(:,1),prop_map_fin(:,2),prop_map_fin(:,3),prop_map_fin(:,4))
scatter3(prop_map_fin(:,1),prop_map_fin(:,2),prop_map_fin(:,3), 10,prop_map_fin(:,4), ‘filled’);
cb = colorbar; % create and label the colorbar
cb.Label.String = ”;
% xslice = [5 9.9]; % define the cross sections to view
% yslice = 3;
% zslice = ([-3 0]);
%slice(prop_map_fin(:,1), prop_map_fin(:,2), prop_map_fin(:,3), prop_map_fin(:,4), xslice, yslice, zslice)
%
T = array2table(prop_map_fin);
x = T{:, 1}; y = T{:, 2}; z = T{:, 3}; c2 = T{:, 4};
ux = unique(x); uy = unique(y); uz = unique(z);
data_sorted = sortrows(T, 1:4);
v = reshape(data_sorted{:, 4}, length(ux),length(uy),length(uz));
isosurface(uz, uy, ux, v, 0);
%[X2,Y2,Z2] = meshgrid(prop_map_fin(:,1), prop_map_fin(:,2), prop_map_fin(:,3));
function [x y] = GetCircle(r, h, k, a, b)
t = linspace(a, b, 40);
x = r*cos(t) + h;
y = r*sin(t) + k;
endI have written a code (attached) to plot particles striking a sphere of radius r – I can produce the image in example_1. I divide the shell into segments and calculate the number of particles falling within each.
I would like to represent the data as a smooth 3d heatmap over the spherical shell. I can produce the image shown in example_2 using scatter3 and a color bar, but I would like a smooth surface. I have tried to follow the example of my previous question using an isosurface –
however ux != uy != uz and I have the "Number of elements must not change" error.
I have also tried meshgrid(), but the size of photons results in an array that excedes maximum size preference.
Is there an easier way to smooth this data?
photons = readmatrix(‘input.txt’);
r = 70; % in unit mm
prop = zeros(length(photons),3);
for i = 1:length(photons)
c(i) = ((photons(i,1)*photons(i,1)) + (photons(i,2)*photons(i,2)) + (photons(i,3)*photons(i,3)) – (r*r));
b(i) = 2*((photons(i,1)*photons(i,7)) + (photons(i,2)*photons(i,8)) + (photons(i,3)*photons(i,9)));
a(i) = ((photons(i,7)*photons(i,7)) + (photons(i,8)*photons(i,8)) + (photons(i,9)*photons(i,9)));
t(i) = (-b(i) + sqrt(b(i).^2 – 4*a(i)*c(i)))/(2*a(i));
prop(i,1) = photons(i,1) + t(i)*photons(i,7);
prop(i,2) = photons(i,2) + t(i)*photons(i,8);
prop(i,3) = photons(i,3) + t(i)*photons(i,9);
prop_sph(i,3) = sqrt(prop(i,1).^2 + prop(i,2).^2 + prop(i,3).^2); % calculate spherical radius (should be r)
prop_sph(i,1) = acos((prop(i,3))/(prop_sph(i,3))); % calculate spherical theta (elevation)
if prop(i,1) > 0 && prop(i,2) >= 0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)); % calculate spherical phi (azimuth)
end
if prop(i,1) > 0 && prop(i,2) < 0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + 2*pi;
end
if prop(i,1) < 0 && prop(i,2) >=0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + pi;
end
if prop(i,1) < 0 && prop(i,2) >=0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + pi;
end
if prop(i,1) < 0 && prop(i,2) < 0
prop_sph(i,2) = (atan(prop(i,2)/prop(i,1)) – pi) + 2*pi ;
end
if prop(i,1) == 0 && prop(i,2) > 0
prop_sph(i,2) = pi / 2;
end
if prop(i,1) == 0 && prop(i,2) < 0
prop_sph(i,2) = (-pi / 2) + 2*pi;
end
if prop(i,1) == 0 && prop(i,2) == 0
prop_sph(i,2) = NaN;
end
end
% plot the photon distribution in Cartesian coordinates.
% scatter3(prop(:,1),prop(:,2),prop(:,3), 10,’k’,’filled’,’MarkerFaceAlpha’,.9);
% sort photons into bins of size d_th*d_phi in spherical coordinates
max_th = pi;
max_phi = 2*pi;
d_th = max_th / 100;
d_phi = max_phi / 100;
l_th = round((max_th / d_th) * (max_phi / d_phi));
theta = (0:d_th:max_th)’;
phi = (0:d_phi:max_phi)’;
mat = [zeros(l_th,1)’; zeros(l_th,1)’; zeros(l_th,1)’;]’;
n = 1;
for j = 1:length(phi)
for i = 1:length(theta)
mat(n,1) = theta(i);
mat(n,2) = phi(j);
n = n+1;
end
end
for w = 1:length(mat)
for k = 1:length(prop_sph)
if (((prop_sph(k,1) >= mat(w,1)) && (prop_sph(k,1) < mat(w,1) + d_th)) && ((prop_sph(k,2) >= mat(w,2)) && (prop_sph(k,2) < mat(w,2) + d_phi)))
mat(w,3) = mat(w,3) + 1;
end
end
end
% ——- convert back to cartesian coordinates and include color data
for i = 1:length(mat)
prop_map_fin(i,1) = prop_sph(i,3)*sin(mat(i,1) + d_th/2)*cos(mat(i,2) + d_phi/2);
prop_map_fin(i,2) = prop_sph(i,3)*sin(mat(i,1) + d_th/2)*sin(mat(i,2) + d_phi/2);
prop_map_fin(i,3) = prop_sph(i,3)*cos(mat(i,1) + d_th/2);
prop_map_fin(i,4) = mat(i,3);
% X = prop_sph(:,3).*sin(prop_sph(:,1)).*cos(prop_sph(:,2));
% Y = prop_sph(:,3).*sin(prop_sph(:,1)).*sin(prop_sph(:,2));
% Z = prop_sph(:,3).*cos(prop_sph(:,1));
end
% — visualize ——————————————————–
%surf(prop_map_fin(:,1),prop_map_fin(:,2),prop_map_fin(:,3),prop_map_fin(:,4))
scatter3(prop_map_fin(:,1),prop_map_fin(:,2),prop_map_fin(:,3), 10,prop_map_fin(:,4), ‘filled’);
cb = colorbar; % create and label the colorbar
cb.Label.String = ”;
% xslice = [5 9.9]; % define the cross sections to view
% yslice = 3;
% zslice = ([-3 0]);
%slice(prop_map_fin(:,1), prop_map_fin(:,2), prop_map_fin(:,3), prop_map_fin(:,4), xslice, yslice, zslice)
%
T = array2table(prop_map_fin);
x = T{:, 1}; y = T{:, 2}; z = T{:, 3}; c2 = T{:, 4};
ux = unique(x); uy = unique(y); uz = unique(z);
data_sorted = sortrows(T, 1:4);
v = reshape(data_sorted{:, 4}, length(ux),length(uy),length(uz));
isosurface(uz, uy, ux, v, 0);
%[X2,Y2,Z2] = meshgrid(prop_map_fin(:,1), prop_map_fin(:,2), prop_map_fin(:,3));
function [x y] = GetCircle(r, h, k, a, b)
t = linspace(a, b, 40);
x = r*cos(t) + h;
y = r*sin(t) + k;
end I have written a code (attached) to plot particles striking a sphere of radius r – I can produce the image in example_1. I divide the shell into segments and calculate the number of particles falling within each.
I would like to represent the data as a smooth 3d heatmap over the spherical shell. I can produce the image shown in example_2 using scatter3 and a color bar, but I would like a smooth surface. I have tried to follow the example of my previous question using an isosurface –
however ux != uy != uz and I have the "Number of elements must not change" error.
I have also tried meshgrid(), but the size of photons results in an array that excedes maximum size preference.
Is there an easier way to smooth this data?
photons = readmatrix(‘input.txt’);
r = 70; % in unit mm
prop = zeros(length(photons),3);
for i = 1:length(photons)
c(i) = ((photons(i,1)*photons(i,1)) + (photons(i,2)*photons(i,2)) + (photons(i,3)*photons(i,3)) – (r*r));
b(i) = 2*((photons(i,1)*photons(i,7)) + (photons(i,2)*photons(i,8)) + (photons(i,3)*photons(i,9)));
a(i) = ((photons(i,7)*photons(i,7)) + (photons(i,8)*photons(i,8)) + (photons(i,9)*photons(i,9)));
t(i) = (-b(i) + sqrt(b(i).^2 – 4*a(i)*c(i)))/(2*a(i));
prop(i,1) = photons(i,1) + t(i)*photons(i,7);
prop(i,2) = photons(i,2) + t(i)*photons(i,8);
prop(i,3) = photons(i,3) + t(i)*photons(i,9);
prop_sph(i,3) = sqrt(prop(i,1).^2 + prop(i,2).^2 + prop(i,3).^2); % calculate spherical radius (should be r)
prop_sph(i,1) = acos((prop(i,3))/(prop_sph(i,3))); % calculate spherical theta (elevation)
if prop(i,1) > 0 && prop(i,2) >= 0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)); % calculate spherical phi (azimuth)
end
if prop(i,1) > 0 && prop(i,2) < 0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + 2*pi;
end
if prop(i,1) < 0 && prop(i,2) >=0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + pi;
end
if prop(i,1) < 0 && prop(i,2) >=0
prop_sph(i,2) = atan(prop(i,2)/prop(i,1)) + pi;
end
if prop(i,1) < 0 && prop(i,2) < 0
prop_sph(i,2) = (atan(prop(i,2)/prop(i,1)) – pi) + 2*pi ;
end
if prop(i,1) == 0 && prop(i,2) > 0
prop_sph(i,2) = pi / 2;
end
if prop(i,1) == 0 && prop(i,2) < 0
prop_sph(i,2) = (-pi / 2) + 2*pi;
end
if prop(i,1) == 0 && prop(i,2) == 0
prop_sph(i,2) = NaN;
end
end
% plot the photon distribution in Cartesian coordinates.
% scatter3(prop(:,1),prop(:,2),prop(:,3), 10,’k’,’filled’,’MarkerFaceAlpha’,.9);
% sort photons into bins of size d_th*d_phi in spherical coordinates
max_th = pi;
max_phi = 2*pi;
d_th = max_th / 100;
d_phi = max_phi / 100;
l_th = round((max_th / d_th) * (max_phi / d_phi));
theta = (0:d_th:max_th)’;
phi = (0:d_phi:max_phi)’;
mat = [zeros(l_th,1)’; zeros(l_th,1)’; zeros(l_th,1)’;]’;
n = 1;
for j = 1:length(phi)
for i = 1:length(theta)
mat(n,1) = theta(i);
mat(n,2) = phi(j);
n = n+1;
end
end
for w = 1:length(mat)
for k = 1:length(prop_sph)
if (((prop_sph(k,1) >= mat(w,1)) && (prop_sph(k,1) < mat(w,1) + d_th)) && ((prop_sph(k,2) >= mat(w,2)) && (prop_sph(k,2) < mat(w,2) + d_phi)))
mat(w,3) = mat(w,3) + 1;
end
end
end
% ——- convert back to cartesian coordinates and include color data
for i = 1:length(mat)
prop_map_fin(i,1) = prop_sph(i,3)*sin(mat(i,1) + d_th/2)*cos(mat(i,2) + d_phi/2);
prop_map_fin(i,2) = prop_sph(i,3)*sin(mat(i,1) + d_th/2)*sin(mat(i,2) + d_phi/2);
prop_map_fin(i,3) = prop_sph(i,3)*cos(mat(i,1) + d_th/2);
prop_map_fin(i,4) = mat(i,3);
% X = prop_sph(:,3).*sin(prop_sph(:,1)).*cos(prop_sph(:,2));
% Y = prop_sph(:,3).*sin(prop_sph(:,1)).*sin(prop_sph(:,2));
% Z = prop_sph(:,3).*cos(prop_sph(:,1));
end
% — visualize ——————————————————–
%surf(prop_map_fin(:,1),prop_map_fin(:,2),prop_map_fin(:,3),prop_map_fin(:,4))
scatter3(prop_map_fin(:,1),prop_map_fin(:,2),prop_map_fin(:,3), 10,prop_map_fin(:,4), ‘filled’);
cb = colorbar; % create and label the colorbar
cb.Label.String = ”;
% xslice = [5 9.9]; % define the cross sections to view
% yslice = 3;
% zslice = ([-3 0]);
%slice(prop_map_fin(:,1), prop_map_fin(:,2), prop_map_fin(:,3), prop_map_fin(:,4), xslice, yslice, zslice)
%
T = array2table(prop_map_fin);
x = T{:, 1}; y = T{:, 2}; z = T{:, 3}; c2 = T{:, 4};
ux = unique(x); uy = unique(y); uz = unique(z);
data_sorted = sortrows(T, 1:4);
v = reshape(data_sorted{:, 4}, length(ux),length(uy),length(uz));
isosurface(uz, uy, ux, v, 0);
%[X2,Y2,Z2] = meshgrid(prop_map_fin(:,1), prop_map_fin(:,2), prop_map_fin(:,3));
function [x y] = GetCircle(r, h, k, a, b)
t = linspace(a, b, 40);
x = r*cos(t) + h;
y = r*sin(t) + k;
end heatmap, contour, scatter, spherical shell, 4d MATLAB Answers — New Questions
Simscape 4-Way 3-Position Directional Valve (IL) No “Fluids/Plot Valve Characteristics” Option
Per the help documentation for this block, there should be a plotting option to help visualize the orifice opening. The instructions are to right click the block and select "Fluids > Plot Valve Characteristics"; however, no Fluids option appears upon right clicking the block. I am using MATLAB R2024a.
The option also does not exist under any of the Format, Mask, or Library Link submenus.
Block documentation: https://www.mathworks.com/help/hydro/ref/4way3positiondirectionalvalveil.htmlPer the help documentation for this block, there should be a plotting option to help visualize the orifice opening. The instructions are to right click the block and select "Fluids > Plot Valve Characteristics"; however, no Fluids option appears upon right clicking the block. I am using MATLAB R2024a.
The option also does not exist under any of the Format, Mask, or Library Link submenus.
Block documentation: https://www.mathworks.com/help/hydro/ref/4way3positiondirectionalvalveil.html Per the help documentation for this block, there should be a plotting option to help visualize the orifice opening. The instructions are to right click the block and select "Fluids > Plot Valve Characteristics"; however, no Fluids option appears upon right clicking the block. I am using MATLAB R2024a.
The option also does not exist under any of the Format, Mask, or Library Link submenus.
Block documentation: https://www.mathworks.com/help/hydro/ref/4way3positiondirectionalvalveil.html simscape, fluids, directinal-valve, r2024a MATLAB Answers — New Questions
Setting Boundary Conditions & Using bvp4c
Hi, I’m having trouble understanding how to use bvp4c. For my assignment, I have created a game that shoots a cannonball at a certain velocity and angle (which are the game inputs), it an attempt to hit a castle (the location is generated by the game).
Now, I need to make a cheat script using bvp4c that when given the position of the castle, outputs a set of velocity and angle values that would make the cannonball hit the castle. The castle is the red square in the image.
sol = = bvp4c(@gamePhysics,@bcfun,solinit)
Here are the two second order ODE’s that describe projectile’s motion:
From there I converted them to these four first order ODE’s:
function dydt = gamePhysics(t,y)
m = 5; % kg
D = 0.013; % N*s^2/m^2
g = 9.81; % m/s^2
dydt = zeros(4,1);
dydt(1) = y(2)
dydt(2) = ((-D/m)*y(2)*(y(2)^2+y(4)^2)^(0.5));
dydt(3) = y(4);
dydt(4) = ((-g)-(D/m)*y(4)*(y(2)^2+y(4)^2)^(0.5));
end
I’m now stuck on making a function that describes the boundary conditions. At the origin, y(0) = 0 and at the castle, y(0) = x_castle.
Also, I’m confused on what the solinit function in bvp4c means. Am I guessing a random velocity and angle?
Thank you! Sorry, I’m pretty lost on how to use this function.Hi, I’m having trouble understanding how to use bvp4c. For my assignment, I have created a game that shoots a cannonball at a certain velocity and angle (which are the game inputs), it an attempt to hit a castle (the location is generated by the game).
Now, I need to make a cheat script using bvp4c that when given the position of the castle, outputs a set of velocity and angle values that would make the cannonball hit the castle. The castle is the red square in the image.
sol = = bvp4c(@gamePhysics,@bcfun,solinit)
Here are the two second order ODE’s that describe projectile’s motion:
From there I converted them to these four first order ODE’s:
function dydt = gamePhysics(t,y)
m = 5; % kg
D = 0.013; % N*s^2/m^2
g = 9.81; % m/s^2
dydt = zeros(4,1);
dydt(1) = y(2)
dydt(2) = ((-D/m)*y(2)*(y(2)^2+y(4)^2)^(0.5));
dydt(3) = y(4);
dydt(4) = ((-g)-(D/m)*y(4)*(y(2)^2+y(4)^2)^(0.5));
end
I’m now stuck on making a function that describes the boundary conditions. At the origin, y(0) = 0 and at the castle, y(0) = x_castle.
Also, I’m confused on what the solinit function in bvp4c means. Am I guessing a random velocity and angle?
Thank you! Sorry, I’m pretty lost on how to use this function. Hi, I’m having trouble understanding how to use bvp4c. For my assignment, I have created a game that shoots a cannonball at a certain velocity and angle (which are the game inputs), it an attempt to hit a castle (the location is generated by the game).
Now, I need to make a cheat script using bvp4c that when given the position of the castle, outputs a set of velocity and angle values that would make the cannonball hit the castle. The castle is the red square in the image.
sol = = bvp4c(@gamePhysics,@bcfun,solinit)
Here are the two second order ODE’s that describe projectile’s motion:
From there I converted them to these four first order ODE’s:
function dydt = gamePhysics(t,y)
m = 5; % kg
D = 0.013; % N*s^2/m^2
g = 9.81; % m/s^2
dydt = zeros(4,1);
dydt(1) = y(2)
dydt(2) = ((-D/m)*y(2)*(y(2)^2+y(4)^2)^(0.5));
dydt(3) = y(4);
dydt(4) = ((-g)-(D/m)*y(4)*(y(2)^2+y(4)^2)^(0.5));
end
I’m now stuck on making a function that describes the boundary conditions. At the origin, y(0) = 0 and at the castle, y(0) = x_castle.
Also, I’m confused on what the solinit function in bvp4c means. Am I guessing a random velocity and angle?
Thank you! Sorry, I’m pretty lost on how to use this function. bvp4c, boundary conditions, ode45 MATLAB Answers — New Questions
inverse kinematics of 7 dof robot using newton raphson method anyone can help. i am not getting desired position of end effector
main()
function main
% Desired end-effector position and orientation
T = [0 1 0 -5;-0.0008 0 1 0.0191;1 0 0.0008 -24; 0 0 0 1];
I = eye(4);
% Initial guess for the joint angles
thetha = [0;0;0;0;0;0;0];
% Tolerance and maximum number of iterations
tolerance = 1e-4;
max_iters = 10000;
alpha = 0.05;
% Main IK loop using Newton-Raphson
for i = 1:max_iters
g = gmatrix(thetha);
G = inv(g);
d = G*T -I ;
% Compute the error between current and desired pose
D = [d(1,4);d(2,4);d(3,4);d(3,2);d(1,3);d(2,1)];
% Check if the solution is within the tolerance
if norm(D) < tolerance
fprintf(‘Converged to a solution after %d iterations.n’, i);
disp(‘Joint angles (radians):’);
disp(thetha);
return;
end
% Compute the Jacobian matrix at the current joint angles
j = jac(thetha);
% Calculate the pseudoinverse of the Jacobian
J_pinv = pinv(j); % Moore-Penrose pseudoinverse
% Update the joint angles
thetha = thetha + alpha*J_pinv * D;
thetha = round(thetha,3);
end
display(thetha)
fprintf(‘Maximum iterations reached without convergence.n’);
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
th = thetha;
T1=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T1=T1*A;
end
result = T1
end
function g1 = gmatrix(th)
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
T=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T=T*A;
end
g1 = T;
end
function J = jac(th)
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
T=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T=T*A;
z(1:3,i)=T(1:3,3);
p(1:3,i)=T(1:3,4);
end
ro = [0; 0; 1;];
J=[cross(ro,p(:,7)) cross(z(:,1),(p(:,7)-p(:,1))) cross(z(:,2),(p(:,7)-p(:,2))) cross(z(:,3),(p(:,7)-p(:,3))) cross(z(:,4),(p(:,7)-p(:,4))) cross(z(:,5),(p(:,7)-p(:,5))) cross(z(:,6),(p(:,7)-p(:,6))) ;ro z(:,1) z(:,2) z(:,3) z(:,4) z(:,5) z(:,6)];
endmain()
function main
% Desired end-effector position and orientation
T = [0 1 0 -5;-0.0008 0 1 0.0191;1 0 0.0008 -24; 0 0 0 1];
I = eye(4);
% Initial guess for the joint angles
thetha = [0;0;0;0;0;0;0];
% Tolerance and maximum number of iterations
tolerance = 1e-4;
max_iters = 10000;
alpha = 0.05;
% Main IK loop using Newton-Raphson
for i = 1:max_iters
g = gmatrix(thetha);
G = inv(g);
d = G*T -I ;
% Compute the error between current and desired pose
D = [d(1,4);d(2,4);d(3,4);d(3,2);d(1,3);d(2,1)];
% Check if the solution is within the tolerance
if norm(D) < tolerance
fprintf(‘Converged to a solution after %d iterations.n’, i);
disp(‘Joint angles (radians):’);
disp(thetha);
return;
end
% Compute the Jacobian matrix at the current joint angles
j = jac(thetha);
% Calculate the pseudoinverse of the Jacobian
J_pinv = pinv(j); % Moore-Penrose pseudoinverse
% Update the joint angles
thetha = thetha + alpha*J_pinv * D;
thetha = round(thetha,3);
end
display(thetha)
fprintf(‘Maximum iterations reached without convergence.n’);
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
th = thetha;
T1=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T1=T1*A;
end
result = T1
end
function g1 = gmatrix(th)
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
T=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T=T*A;
end
g1 = T;
end
function J = jac(th)
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
T=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T=T*A;
z(1:3,i)=T(1:3,3);
p(1:3,i)=T(1:3,4);
end
ro = [0; 0; 1;];
J=[cross(ro,p(:,7)) cross(z(:,1),(p(:,7)-p(:,1))) cross(z(:,2),(p(:,7)-p(:,2))) cross(z(:,3),(p(:,7)-p(:,3))) cross(z(:,4),(p(:,7)-p(:,4))) cross(z(:,5),(p(:,7)-p(:,5))) cross(z(:,6),(p(:,7)-p(:,6))) ;ro z(:,1) z(:,2) z(:,3) z(:,4) z(:,5) z(:,6)];
end main()
function main
% Desired end-effector position and orientation
T = [0 1 0 -5;-0.0008 0 1 0.0191;1 0 0.0008 -24; 0 0 0 1];
I = eye(4);
% Initial guess for the joint angles
thetha = [0;0;0;0;0;0;0];
% Tolerance and maximum number of iterations
tolerance = 1e-4;
max_iters = 10000;
alpha = 0.05;
% Main IK loop using Newton-Raphson
for i = 1:max_iters
g = gmatrix(thetha);
G = inv(g);
d = G*T -I ;
% Compute the error between current and desired pose
D = [d(1,4);d(2,4);d(3,4);d(3,2);d(1,3);d(2,1)];
% Check if the solution is within the tolerance
if norm(D) < tolerance
fprintf(‘Converged to a solution after %d iterations.n’, i);
disp(‘Joint angles (radians):’);
disp(thetha);
return;
end
% Compute the Jacobian matrix at the current joint angles
j = jac(thetha);
% Calculate the pseudoinverse of the Jacobian
J_pinv = pinv(j); % Moore-Penrose pseudoinverse
% Update the joint angles
thetha = thetha + alpha*J_pinv * D;
thetha = round(thetha,3);
end
display(thetha)
fprintf(‘Maximum iterations reached without convergence.n’);
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
th = thetha;
T1=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T1=T1*A;
end
result = T1
end
function g1 = gmatrix(th)
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
T=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T=T*A;
end
g1 = T;
end
function J = jac(th)
a = [0 2 25 3 2 2 1];
a1 = [-1.57 1.57 -1.57 1.57 -1.57 0 0];
d = [0 0 0 0 0 0 0];
T=eye(4);
for i=1:7
A=[cos(th(i)) -sin(th(i)) 0 a(i); sin(th(i))*cos(a1(i)) cos(th(i))*cos(a1(i)) -sin(a1(i)) -sin(a1(i))*d(i); sin(th(i))*sin(a1(i)) cos(th(i))*sin(a1(i)) cos(a1(i)) cos(a1(i))*d(i); 0 0 0 1];
T=T*A;
z(1:3,i)=T(1:3,3);
p(1:3,i)=T(1:3,4);
end
ro = [0; 0; 1;];
J=[cross(ro,p(:,7)) cross(z(:,1),(p(:,7)-p(:,1))) cross(z(:,2),(p(:,7)-p(:,2))) cross(z(:,3),(p(:,7)-p(:,3))) cross(z(:,4),(p(:,7)-p(:,4))) cross(z(:,5),(p(:,7)-p(:,5))) cross(z(:,6),(p(:,7)-p(:,6))) ;ro z(:,1) z(:,2) z(:,3) z(:,4) z(:,5) z(:,6)];
end matlab, inverse kinematics, 7 dof robot, jacobian matrix MATLAB Answers — New Questions
Why two ENVI header files are different?
I have generated ENVI header file using MATLAB code is as follows;
map_info = sprintf(‘UTM, %f, %f, %f, %f, %f, %f, %s, %s, units=Meters’, …
R.XIntrinsicLimits(1), R.YIntrinsicLimits(1), …
R.XWorldLimits(1), R.YWorldLimits(2), …
R.CellExtentInWorldX, R.CellExtentInWorldY, …
R.ColumnsStartFrom, R.CoordinateSystemType);
This is giving following map info
{UTM, 0.500000, 0.500000, 699960.000000, 3300000.000000, 10.000000, 10.000000, north, planar, units=Meters}
While ENVI software generated map info is as follows
map info = {UTM, 1.000, 1.000, 699960.000, 3300000.000, 2.0000000000e+001, 2.0000000000e+001, 43, North, WGS-84, units=Meters}
I request you to please suggest me why this difference has occured and how to get map info generated by ENVI software by using MATLAB.
DevendraI have generated ENVI header file using MATLAB code is as follows;
map_info = sprintf(‘UTM, %f, %f, %f, %f, %f, %f, %s, %s, units=Meters’, …
R.XIntrinsicLimits(1), R.YIntrinsicLimits(1), …
R.XWorldLimits(1), R.YWorldLimits(2), …
R.CellExtentInWorldX, R.CellExtentInWorldY, …
R.ColumnsStartFrom, R.CoordinateSystemType);
This is giving following map info
{UTM, 0.500000, 0.500000, 699960.000000, 3300000.000000, 10.000000, 10.000000, north, planar, units=Meters}
While ENVI software generated map info is as follows
map info = {UTM, 1.000, 1.000, 699960.000, 3300000.000, 2.0000000000e+001, 2.0000000000e+001, 43, North, WGS-84, units=Meters}
I request you to please suggest me why this difference has occured and how to get map info generated by ENVI software by using MATLAB.
Devendra I have generated ENVI header file using MATLAB code is as follows;
map_info = sprintf(‘UTM, %f, %f, %f, %f, %f, %f, %s, %s, units=Meters’, …
R.XIntrinsicLimits(1), R.YIntrinsicLimits(1), …
R.XWorldLimits(1), R.YWorldLimits(2), …
R.CellExtentInWorldX, R.CellExtentInWorldY, …
R.ColumnsStartFrom, R.CoordinateSystemType);
This is giving following map info
{UTM, 0.500000, 0.500000, 699960.000000, 3300000.000000, 10.000000, 10.000000, north, planar, units=Meters}
While ENVI software generated map info is as follows
map info = {UTM, 1.000, 1.000, 699960.000, 3300000.000, 2.0000000000e+001, 2.0000000000e+001, 43, North, WGS-84, units=Meters}
I request you to please suggest me why this difference has occured and how to get map info generated by ENVI software by using MATLAB.
Devendra why two envi header files are different? MATLAB Answers — New Questions
How to save a figure as a geotiff
Im only seeing examples online of saving images as geotifs, I plotted a surface which is bounded by lat and longs. The surface is interpolated from a bunch of singlebeam points, and I can save it as a text file but it only saves the data for the actual points, not the entire surface. What I want to do is save the entire surface so it could be quickly thrown into GIS. Any ideas on where to start with this? Thanks again!Im only seeing examples online of saving images as geotifs, I plotted a surface which is bounded by lat and longs. The surface is interpolated from a bunch of singlebeam points, and I can save it as a text file but it only saves the data for the actual points, not the entire surface. What I want to do is save the entire surface so it could be quickly thrown into GIS. Any ideas on where to start with this? Thanks again! Im only seeing examples online of saving images as geotifs, I plotted a surface which is bounded by lat and longs. The surface is interpolated from a bunch of singlebeam points, and I can save it as a text file but it only saves the data for the actual points, not the entire surface. What I want to do is save the entire surface so it could be quickly thrown into GIS. Any ideas on where to start with this? Thanks again! geotif MATLAB Answers — New Questions
how to load multiple eeg dataset files into matlab?
i have 88 eeg data files, their extension is ‘.set’
they are all in the same folder titled ‘all_data’, i am really new at MATLAB, i am unable to figure out how to load all of them at once in my workspace.
i used the line below to load one file, but doing the same for 88 files is a lot of hassle
eegdata= pop_loadset(‘C:UsersParulDocumentsMATLABsecondary_dataall datasub-01_task-40HzAuditoryEntrainment_eeg.set’)
Please helpi have 88 eeg data files, their extension is ‘.set’
they are all in the same folder titled ‘all_data’, i am really new at MATLAB, i am unable to figure out how to load all of them at once in my workspace.
i used the line below to load one file, but doing the same for 88 files is a lot of hassle
eegdata= pop_loadset(‘C:UsersParulDocumentsMATLABsecondary_dataall datasub-01_task-40HzAuditoryEntrainment_eeg.set’)
Please help i have 88 eeg data files, their extension is ‘.set’
they are all in the same folder titled ‘all_data’, i am really new at MATLAB, i am unable to figure out how to load all of them at once in my workspace.
i used the line below to load one file, but doing the same for 88 files is a lot of hassle
eegdata= pop_loadset(‘C:UsersParulDocumentsMATLABsecondary_dataall datasub-01_task-40HzAuditoryEntrainment_eeg.set’)
Please help load, for loop, code MATLAB Answers — New Questions
I get the illegal instruction error while running an iterative matricial method on the Matlab code in PC
————————————————————————
Illegal instruction detected at Thu Apr 25 13:48:52 2024
————————————————————————
Configuration:
Crash Decoding : Disabled
Default Encoding : windows-1252
MATLAB Architecture: win64
MATLAB Root : D:matlab programa
MATLAB Version : 8.3.0.532 (R2014a)
Operating System : Microsoft Windows 11 Pro
Processor ID : x86 Family 143 Model 113 Stepping 0, AuthenticAMD
Virtual Machine : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
Illegal instruction
Register State (from fault):
RAX = 00000000ecdf9000 RBX = 00000000ecdfd000
RCX = 00000000043f1190 RDX = 00000000ecf51620
RSP = 00000000043f0fa0 RBP = 00000000043f1cc8
RSI = 000000012ecbacb8 RDI = 00000000043f1cc8
R8 = 0000000000000100 R9 = 00000000ecdfd000
R10 = 0000000000001518 R11 = 0000000000000708
R12 = 0000000000000008 R13 = 00000000000000d8
R14 = 0000000000000008 R15 = 0000000000000008
RIP = 000000012db62162 EFL = 00010216
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x000000012db62162 D:matlab programabinwin64mkl.dll+25108834 xerbla+23000914
[ 1] 0x000000012d160694 D:matlab programabinwin64mkl.dll+14616212 xerbla+12508292
[ 2] 0x000000012d1522e8 D:matlab programabinwin64mkl.dll+14557928 xerbla+12450008
[ 3] 0x000000012c44a7b1 D:matlab programabinwin64mkl.dll+00894897 mkl_cbwr_set+00506561
[ 4] 0x000000012caf38e1 D:matlab programabinwin64mkl.dll+07878881 xerbla+05770961
[ 5] 0x000000012c4515aa D:matlab programabinwin64mkl.dll+00923050 mkl_cbwr_set+00534714
[ 6] 0x000000007fb011d0 D:matlab programabinwin64libmwmathlinalg.dll+00135632 FactorObject::create+00069744
[ 7] 0x000000007fb016aa D:matlab programabinwin64libmwmathlinalg.dll+00136874 FactorObject::create+00070986
[ 8] 0x000000001097c07f D:matlab programabinwin64m_dispatcher.dll+00049279 Mfh_file::dispatch_fh+00001247
[ 9] 0x000000001097c637 D:matlab programabinwin64m_dispatcher.dll+00050743 Mfunction_handle::dispatch+00000487
[ 10] 0x0000000010d1cf97 D:matlab programabinwin64m_interpreter.dll+00511895 MathWorks::MException::MExceptionEnvelope::GetID+00306695
[ 11] 0x0000000010d201c8 D:matlab programabinwin64m_interpreter.dll+00524744 MathWorks::MException::MExceptionEnvelope::GetID+00319544
[ 12] 0x0000000010d1cc38 D:matlab programabinwin64m_interpreter.dll+00511032 MathWorks::MException::MExceptionEnvelope::GetID+00305832
[ 13] 0x0000000010d2644f D:matlab programabinwin64m_interpreter.dll+00549967 MathWorks::MException::MExceptionEnvelope::GetID+00344767
[ 14] 0x0000000010d34962 D:matlab programabinwin64m_interpreter.dll+00608610 MathWorks::MException::MExceptionEnvelope::GetID+00403410
[ 15] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 16] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 17] 0x000000001097be4f D:matlab programabinwin64m_dispatcher.dll+00048719 Mfh_file::dispatch_fh+00000687
[ 18] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 19] 0x0000000010d55e04 D:matlab programabinwin64m_interpreter.dll+00744964 MathWorks::MException::MExceptionEnvelope::GetID+00539764
[ 20] 0x0000000010d40782 D:matlab programabinwin64m_interpreter.dll+00657282 MathWorks::MException::MExceptionEnvelope::GetID+00452082
[ 21] 0x0000000010d33f6f D:matlab programabinwin64m_interpreter.dll+00606063 MathWorks::MException::MExceptionEnvelope::GetID+00400863
[ 22] 0x0000000010d1cd43 D:matlab programabinwin64m_interpreter.dll+00511299 MathWorks::MException::MExceptionEnvelope::GetID+00306099
[ 23] 0x0000000010d2644f D:matlab programabinwin64m_interpreter.dll+00549967 MathWorks::MException::MExceptionEnvelope::GetID+00344767
[ 24] 0x0000000010d29350 D:matlab programabinwin64m_interpreter.dll+00562000 MathWorks::MException::MExceptionEnvelope::GetID+00356800
[ 25] 0x0000000010d4446f D:matlab programabinwin64m_interpreter.dll+00672879 MathWorks::MException::MExceptionEnvelope::GetID+00467679
[ 26] 0x0000000010d445b8 D:matlab programabinwin64m_interpreter.dll+00673208 MathWorks::MException::MExceptionEnvelope::GetID+00468008
[ 27] 0x0000000010d34a2d D:matlab programabinwin64m_interpreter.dll+00608813 MathWorks::MException::MExceptionEnvelope::GetID+00403613
[ 28] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 29] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 30] 0x000000001097c00e D:matlab programabinwin64m_dispatcher.dll+00049166 Mfh_file::dispatch_fh+00001134
[ 31] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 32] 0x0000000010d2cdfe D:matlab programabinwin64m_interpreter.dll+00577022 MathWorks::MException::MExceptionEnvelope::GetID+00371822
[ 33] 0x0000000010da68a7 D:matlab programabinwin64m_interpreter.dll+01075367 inEachVisibleName+00016119
[ 34] 0x0000000010d2ab1a D:matlab programabinwin64m_interpreter.dll+00568090 MathWorks::MException::MExceptionEnvelope::GetID+00362890
[ 35] 0x0000000010d4446f D:matlab programabinwin64m_interpreter.dll+00672879 MathWorks::MException::MExceptionEnvelope::GetID+00467679
[ 36] 0x0000000010d445b8 D:matlab programabinwin64m_interpreter.dll+00673208 MathWorks::MException::MExceptionEnvelope::GetID+00468008
[ 37] 0x0000000010d34a2d D:matlab programabinwin64m_interpreter.dll+00608813 MathWorks::MException::MExceptionEnvelope::GetID+00403613
[ 38] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 39] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 40] 0x000000001097c00e D:matlab programabinwin64m_dispatcher.dll+00049166 Mfh_file::dispatch_fh+00001134
[ 41] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 42] 0x0000000010db4a0e D:matlab programabinwin64m_interpreter.dll+01133070 inValidateLoadedObject+00003486
[ 43] 0x0000000010dbbd95 D:matlab programabinwin64m_interpreter.dll+01162645 inResetInterpreter+00005029
[ 44] 0x0000000010dc0a05 D:matlab programabinwin64m_interpreter.dll+01182213 MathWorks::MException::MExceptionEnvelope::Copy+00010997
[ 45] 0x0000000010dc09d2 D:matlab programabinwin64m_interpreter.dll+01182162 MathWorks::MException::MExceptionEnvelope::Copy+00010946
[ 46] 0x0000000010dc0997 D:matlab programabinwin64m_interpreter.dll+01182103 MathWorks::MException::MExceptionEnvelope::Copy+00010887
[ 47] 0x00000000111ae89c D:matlab programabinwin64m_interpreter.dll+05302428 inMexPutVariable+00004204
[ 48] 0x00000000111aebf6 D:matlab programabinwin64m_interpreter.dll+05303286 inMexPutVariable+00005062
[ 49] 0x00000000111af02e D:matlab programabinwin64m_interpreter.dll+05304366 inMexPutVariable+00006142
[ 50] 0x00000000111af36c D:matlab programabinwin64m_interpreter.dll+05305196 inMexPutVariable+00006972
[ 51] 0x00000000110c0161 D:matlab programabinwin64m_interpreter.dll+04325729 inEvalCmdWithLocalReturn+00000065
[ 52] 0x00000000fb5fbecd D:matlab programabinwin64libmwbridge.dll+00048845 mnDebugPrompt+00000109
[ 53] 0x00000000fb5fcfaf D:matlab programabinwin64libmwbridge.dll+00053167 mnParser+00000735
[ 54] 0x00000000fd0afae4 D:matlab programabinwin64mcr.dll+00195300 mcrInstance::mnParser_on_interpreter_thread+00000036
[ 55] 0x00000000fd093af0 D:matlab programabinwin64mcr.dll+00080624 mcr::runtime::setInterpreterThreadToCurrent+00029488
[ 56] 0x00000000fd093b50 D:matlab programabinwin64mcr.dll+00080720 mcr::runtime::setInterpreterThreadToCurrent+00029584
[ 57] 0x00000000fab6e026 D:matlab programabinwin64uiw.dll+00581670 UIW_IsUserMessage+00000086
[ 58] 0x00000000fab6e705 D:matlab programabinwin64uiw.dll+00583429 UIW_SetGLIMUserMsg+00000117
[ 59] 0x00000000fab6e789 D:matlab programabinwin64uiw.dll+00583561 UIW_SetGLIMUserMsg+00000249
[ 60] 0x00007ff952af5362 C:WindowsSystem32USER32.dll+00217954 GetTopWindow+00000578
[ 61] 0x00007ff952ae547f C:WindowsSystem32USER32.dll+00152703 GetDpiForWindow+00001551
[ 62] 0x00007ff952ae53c6 C:WindowsSystem32USER32.dll+00152518 GetDpiForWindow+00001366
[ 63] 0x00007ff952d533a4 C:WindowsSYSTEM32ntdll.dll+00668580 KiUserCallbackDispatcher+00000036
[ 64] 0x00007ff9500f14d4 C:WindowsSystem32win32u.dll+00005332 NtUserPeekMessage+00000020
[ 65] 0x00007ff952ae267f C:WindowsSystem32USER32.dll+00140927 PeekMessageW+00000463
[ 66] 0x00007ff952ae2399 C:WindowsSystem32USER32.dll+00140185 PeekMessageA+00000105
[ 67] 0x00000000fab1bd4b D:matlab programabinwin64uiw.dll+00245067 UIW_SetCurrentDialog+00000731
[ 68] 0x00000000fab6fbe2 D:matlab programabinwin64uiw.dll+00588770 ws_FreeSystemFont+00000482
[ 69] 0x00000001000e2ed0 D:matlab programabinwin64libmwservices.dll+00995024 services::system_events::PpeDispatchHook::~PpeDispatchHook+00053488
[ 70] 0x00000001000e36a5 D:matlab programabinwin64libmwservices.dll+00997029 services::system_events::PpeDispatchHook::~PpeDispatchHook+00055493
[ 71] 0x00000001000e4330 D:matlab programabinwin64libmwservices.dll+01000240 services::system_events::PpeDispatchHook::~PpeDispatchHook+00058704
[ 72] 0x00000001000ed4c6 D:matlab programabinwin64libmwservices.dll+01037510 sysq::removeProcessPendingEventsHook+00011030
[ 73] 0x00000001000ed7ca D:matlab programabinwin64libmwservices.dll+01038282 svWS_ProcessPendingEvents+00000138
[ 74] 0x00000000fd094b6d D:matlab programabinwin64mcr.dll+00084845 mcr::runtime::setInterpreterThreadToCurrent+00033709
[ 75] 0x00000000fd094e3b D:matlab programabinwin64mcr.dll+00085563 mcr::runtime::setInterpreterThreadToCurrent+00034427
[ 76] 0x00000000fd088b75 D:matlab programabinwin64mcr.dll+00035701 mcrInstantiationError::operator=+00003221
[ 77] 0x00000000fd08bea2 D:matlab programabinwin64mcr.dll+00048802 mcr_invoke_on_interpreter_thread+00001602
[ 78] 0x00000000fa7e6e5d D:matlab programabinwin64MVMLocal.dll+00159325 mvm_server::inproc::LocalFactory::createMVM+00040653
[ 79] 0x00000000fa8bafaa D:matlab programabinwin64mvm.dll+00569258 mvm::detail::SessionImpl::privateSession+00001754
[ 80] 0x00000000fa8bd32a D:matlab programabinwin64mvm.dll+00578346 mvm::detail::SessionImpl::privateSession+00010842
[ 81] 0x00000000fa8bce85 D:matlab programabinwin64mvm.dll+00577157 mvm::detail::SessionImpl::privateSession+00009653
[ 82] 0x0000000140004f79 D:matlab programabinwin64matlab.exe+00020345
[ 83] 0x0000000140006a07 D:matlab programabinwin64matlab.exe+00027143
[ 84] 0x00007ff950e5257d C:WindowsSystem32KERNEL32.DLL+00075133 BaseThreadInitThunk+00000029
[ 85] 0x00007ff952d0aa48 C:WindowsSYSTEM32ntdll.dll+00371272 RtlUserThreadStart+00000040
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help.————————————————————————
Illegal instruction detected at Thu Apr 25 13:48:52 2024
————————————————————————
Configuration:
Crash Decoding : Disabled
Default Encoding : windows-1252
MATLAB Architecture: win64
MATLAB Root : D:matlab programa
MATLAB Version : 8.3.0.532 (R2014a)
Operating System : Microsoft Windows 11 Pro
Processor ID : x86 Family 143 Model 113 Stepping 0, AuthenticAMD
Virtual Machine : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
Illegal instruction
Register State (from fault):
RAX = 00000000ecdf9000 RBX = 00000000ecdfd000
RCX = 00000000043f1190 RDX = 00000000ecf51620
RSP = 00000000043f0fa0 RBP = 00000000043f1cc8
RSI = 000000012ecbacb8 RDI = 00000000043f1cc8
R8 = 0000000000000100 R9 = 00000000ecdfd000
R10 = 0000000000001518 R11 = 0000000000000708
R12 = 0000000000000008 R13 = 00000000000000d8
R14 = 0000000000000008 R15 = 0000000000000008
RIP = 000000012db62162 EFL = 00010216
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x000000012db62162 D:matlab programabinwin64mkl.dll+25108834 xerbla+23000914
[ 1] 0x000000012d160694 D:matlab programabinwin64mkl.dll+14616212 xerbla+12508292
[ 2] 0x000000012d1522e8 D:matlab programabinwin64mkl.dll+14557928 xerbla+12450008
[ 3] 0x000000012c44a7b1 D:matlab programabinwin64mkl.dll+00894897 mkl_cbwr_set+00506561
[ 4] 0x000000012caf38e1 D:matlab programabinwin64mkl.dll+07878881 xerbla+05770961
[ 5] 0x000000012c4515aa D:matlab programabinwin64mkl.dll+00923050 mkl_cbwr_set+00534714
[ 6] 0x000000007fb011d0 D:matlab programabinwin64libmwmathlinalg.dll+00135632 FactorObject::create+00069744
[ 7] 0x000000007fb016aa D:matlab programabinwin64libmwmathlinalg.dll+00136874 FactorObject::create+00070986
[ 8] 0x000000001097c07f D:matlab programabinwin64m_dispatcher.dll+00049279 Mfh_file::dispatch_fh+00001247
[ 9] 0x000000001097c637 D:matlab programabinwin64m_dispatcher.dll+00050743 Mfunction_handle::dispatch+00000487
[ 10] 0x0000000010d1cf97 D:matlab programabinwin64m_interpreter.dll+00511895 MathWorks::MException::MExceptionEnvelope::GetID+00306695
[ 11] 0x0000000010d201c8 D:matlab programabinwin64m_interpreter.dll+00524744 MathWorks::MException::MExceptionEnvelope::GetID+00319544
[ 12] 0x0000000010d1cc38 D:matlab programabinwin64m_interpreter.dll+00511032 MathWorks::MException::MExceptionEnvelope::GetID+00305832
[ 13] 0x0000000010d2644f D:matlab programabinwin64m_interpreter.dll+00549967 MathWorks::MException::MExceptionEnvelope::GetID+00344767
[ 14] 0x0000000010d34962 D:matlab programabinwin64m_interpreter.dll+00608610 MathWorks::MException::MExceptionEnvelope::GetID+00403410
[ 15] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 16] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 17] 0x000000001097be4f D:matlab programabinwin64m_dispatcher.dll+00048719 Mfh_file::dispatch_fh+00000687
[ 18] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 19] 0x0000000010d55e04 D:matlab programabinwin64m_interpreter.dll+00744964 MathWorks::MException::MExceptionEnvelope::GetID+00539764
[ 20] 0x0000000010d40782 D:matlab programabinwin64m_interpreter.dll+00657282 MathWorks::MException::MExceptionEnvelope::GetID+00452082
[ 21] 0x0000000010d33f6f D:matlab programabinwin64m_interpreter.dll+00606063 MathWorks::MException::MExceptionEnvelope::GetID+00400863
[ 22] 0x0000000010d1cd43 D:matlab programabinwin64m_interpreter.dll+00511299 MathWorks::MException::MExceptionEnvelope::GetID+00306099
[ 23] 0x0000000010d2644f D:matlab programabinwin64m_interpreter.dll+00549967 MathWorks::MException::MExceptionEnvelope::GetID+00344767
[ 24] 0x0000000010d29350 D:matlab programabinwin64m_interpreter.dll+00562000 MathWorks::MException::MExceptionEnvelope::GetID+00356800
[ 25] 0x0000000010d4446f D:matlab programabinwin64m_interpreter.dll+00672879 MathWorks::MException::MExceptionEnvelope::GetID+00467679
[ 26] 0x0000000010d445b8 D:matlab programabinwin64m_interpreter.dll+00673208 MathWorks::MException::MExceptionEnvelope::GetID+00468008
[ 27] 0x0000000010d34a2d D:matlab programabinwin64m_interpreter.dll+00608813 MathWorks::MException::MExceptionEnvelope::GetID+00403613
[ 28] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 29] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 30] 0x000000001097c00e D:matlab programabinwin64m_dispatcher.dll+00049166 Mfh_file::dispatch_fh+00001134
[ 31] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 32] 0x0000000010d2cdfe D:matlab programabinwin64m_interpreter.dll+00577022 MathWorks::MException::MExceptionEnvelope::GetID+00371822
[ 33] 0x0000000010da68a7 D:matlab programabinwin64m_interpreter.dll+01075367 inEachVisibleName+00016119
[ 34] 0x0000000010d2ab1a D:matlab programabinwin64m_interpreter.dll+00568090 MathWorks::MException::MExceptionEnvelope::GetID+00362890
[ 35] 0x0000000010d4446f D:matlab programabinwin64m_interpreter.dll+00672879 MathWorks::MException::MExceptionEnvelope::GetID+00467679
[ 36] 0x0000000010d445b8 D:matlab programabinwin64m_interpreter.dll+00673208 MathWorks::MException::MExceptionEnvelope::GetID+00468008
[ 37] 0x0000000010d34a2d D:matlab programabinwin64m_interpreter.dll+00608813 MathWorks::MException::MExceptionEnvelope::GetID+00403613
[ 38] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 39] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 40] 0x000000001097c00e D:matlab programabinwin64m_dispatcher.dll+00049166 Mfh_file::dispatch_fh+00001134
[ 41] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 42] 0x0000000010db4a0e D:matlab programabinwin64m_interpreter.dll+01133070 inValidateLoadedObject+00003486
[ 43] 0x0000000010dbbd95 D:matlab programabinwin64m_interpreter.dll+01162645 inResetInterpreter+00005029
[ 44] 0x0000000010dc0a05 D:matlab programabinwin64m_interpreter.dll+01182213 MathWorks::MException::MExceptionEnvelope::Copy+00010997
[ 45] 0x0000000010dc09d2 D:matlab programabinwin64m_interpreter.dll+01182162 MathWorks::MException::MExceptionEnvelope::Copy+00010946
[ 46] 0x0000000010dc0997 D:matlab programabinwin64m_interpreter.dll+01182103 MathWorks::MException::MExceptionEnvelope::Copy+00010887
[ 47] 0x00000000111ae89c D:matlab programabinwin64m_interpreter.dll+05302428 inMexPutVariable+00004204
[ 48] 0x00000000111aebf6 D:matlab programabinwin64m_interpreter.dll+05303286 inMexPutVariable+00005062
[ 49] 0x00000000111af02e D:matlab programabinwin64m_interpreter.dll+05304366 inMexPutVariable+00006142
[ 50] 0x00000000111af36c D:matlab programabinwin64m_interpreter.dll+05305196 inMexPutVariable+00006972
[ 51] 0x00000000110c0161 D:matlab programabinwin64m_interpreter.dll+04325729 inEvalCmdWithLocalReturn+00000065
[ 52] 0x00000000fb5fbecd D:matlab programabinwin64libmwbridge.dll+00048845 mnDebugPrompt+00000109
[ 53] 0x00000000fb5fcfaf D:matlab programabinwin64libmwbridge.dll+00053167 mnParser+00000735
[ 54] 0x00000000fd0afae4 D:matlab programabinwin64mcr.dll+00195300 mcrInstance::mnParser_on_interpreter_thread+00000036
[ 55] 0x00000000fd093af0 D:matlab programabinwin64mcr.dll+00080624 mcr::runtime::setInterpreterThreadToCurrent+00029488
[ 56] 0x00000000fd093b50 D:matlab programabinwin64mcr.dll+00080720 mcr::runtime::setInterpreterThreadToCurrent+00029584
[ 57] 0x00000000fab6e026 D:matlab programabinwin64uiw.dll+00581670 UIW_IsUserMessage+00000086
[ 58] 0x00000000fab6e705 D:matlab programabinwin64uiw.dll+00583429 UIW_SetGLIMUserMsg+00000117
[ 59] 0x00000000fab6e789 D:matlab programabinwin64uiw.dll+00583561 UIW_SetGLIMUserMsg+00000249
[ 60] 0x00007ff952af5362 C:WindowsSystem32USER32.dll+00217954 GetTopWindow+00000578
[ 61] 0x00007ff952ae547f C:WindowsSystem32USER32.dll+00152703 GetDpiForWindow+00001551
[ 62] 0x00007ff952ae53c6 C:WindowsSystem32USER32.dll+00152518 GetDpiForWindow+00001366
[ 63] 0x00007ff952d533a4 C:WindowsSYSTEM32ntdll.dll+00668580 KiUserCallbackDispatcher+00000036
[ 64] 0x00007ff9500f14d4 C:WindowsSystem32win32u.dll+00005332 NtUserPeekMessage+00000020
[ 65] 0x00007ff952ae267f C:WindowsSystem32USER32.dll+00140927 PeekMessageW+00000463
[ 66] 0x00007ff952ae2399 C:WindowsSystem32USER32.dll+00140185 PeekMessageA+00000105
[ 67] 0x00000000fab1bd4b D:matlab programabinwin64uiw.dll+00245067 UIW_SetCurrentDialog+00000731
[ 68] 0x00000000fab6fbe2 D:matlab programabinwin64uiw.dll+00588770 ws_FreeSystemFont+00000482
[ 69] 0x00000001000e2ed0 D:matlab programabinwin64libmwservices.dll+00995024 services::system_events::PpeDispatchHook::~PpeDispatchHook+00053488
[ 70] 0x00000001000e36a5 D:matlab programabinwin64libmwservices.dll+00997029 services::system_events::PpeDispatchHook::~PpeDispatchHook+00055493
[ 71] 0x00000001000e4330 D:matlab programabinwin64libmwservices.dll+01000240 services::system_events::PpeDispatchHook::~PpeDispatchHook+00058704
[ 72] 0x00000001000ed4c6 D:matlab programabinwin64libmwservices.dll+01037510 sysq::removeProcessPendingEventsHook+00011030
[ 73] 0x00000001000ed7ca D:matlab programabinwin64libmwservices.dll+01038282 svWS_ProcessPendingEvents+00000138
[ 74] 0x00000000fd094b6d D:matlab programabinwin64mcr.dll+00084845 mcr::runtime::setInterpreterThreadToCurrent+00033709
[ 75] 0x00000000fd094e3b D:matlab programabinwin64mcr.dll+00085563 mcr::runtime::setInterpreterThreadToCurrent+00034427
[ 76] 0x00000000fd088b75 D:matlab programabinwin64mcr.dll+00035701 mcrInstantiationError::operator=+00003221
[ 77] 0x00000000fd08bea2 D:matlab programabinwin64mcr.dll+00048802 mcr_invoke_on_interpreter_thread+00001602
[ 78] 0x00000000fa7e6e5d D:matlab programabinwin64MVMLocal.dll+00159325 mvm_server::inproc::LocalFactory::createMVM+00040653
[ 79] 0x00000000fa8bafaa D:matlab programabinwin64mvm.dll+00569258 mvm::detail::SessionImpl::privateSession+00001754
[ 80] 0x00000000fa8bd32a D:matlab programabinwin64mvm.dll+00578346 mvm::detail::SessionImpl::privateSession+00010842
[ 81] 0x00000000fa8bce85 D:matlab programabinwin64mvm.dll+00577157 mvm::detail::SessionImpl::privateSession+00009653
[ 82] 0x0000000140004f79 D:matlab programabinwin64matlab.exe+00020345
[ 83] 0x0000000140006a07 D:matlab programabinwin64matlab.exe+00027143
[ 84] 0x00007ff950e5257d C:WindowsSystem32KERNEL32.DLL+00075133 BaseThreadInitThunk+00000029
[ 85] 0x00007ff952d0aa48 C:WindowsSYSTEM32ntdll.dll+00371272 RtlUserThreadStart+00000040
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help. ————————————————————————
Illegal instruction detected at Thu Apr 25 13:48:52 2024
————————————————————————
Configuration:
Crash Decoding : Disabled
Default Encoding : windows-1252
MATLAB Architecture: win64
MATLAB Root : D:matlab programa
MATLAB Version : 8.3.0.532 (R2014a)
Operating System : Microsoft Windows 11 Pro
Processor ID : x86 Family 143 Model 113 Stepping 0, AuthenticAMD
Virtual Machine : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
Illegal instruction
Register State (from fault):
RAX = 00000000ecdf9000 RBX = 00000000ecdfd000
RCX = 00000000043f1190 RDX = 00000000ecf51620
RSP = 00000000043f0fa0 RBP = 00000000043f1cc8
RSI = 000000012ecbacb8 RDI = 00000000043f1cc8
R8 = 0000000000000100 R9 = 00000000ecdfd000
R10 = 0000000000001518 R11 = 0000000000000708
R12 = 0000000000000008 R13 = 00000000000000d8
R14 = 0000000000000008 R15 = 0000000000000008
RIP = 000000012db62162 EFL = 00010216
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x000000012db62162 D:matlab programabinwin64mkl.dll+25108834 xerbla+23000914
[ 1] 0x000000012d160694 D:matlab programabinwin64mkl.dll+14616212 xerbla+12508292
[ 2] 0x000000012d1522e8 D:matlab programabinwin64mkl.dll+14557928 xerbla+12450008
[ 3] 0x000000012c44a7b1 D:matlab programabinwin64mkl.dll+00894897 mkl_cbwr_set+00506561
[ 4] 0x000000012caf38e1 D:matlab programabinwin64mkl.dll+07878881 xerbla+05770961
[ 5] 0x000000012c4515aa D:matlab programabinwin64mkl.dll+00923050 mkl_cbwr_set+00534714
[ 6] 0x000000007fb011d0 D:matlab programabinwin64libmwmathlinalg.dll+00135632 FactorObject::create+00069744
[ 7] 0x000000007fb016aa D:matlab programabinwin64libmwmathlinalg.dll+00136874 FactorObject::create+00070986
[ 8] 0x000000001097c07f D:matlab programabinwin64m_dispatcher.dll+00049279 Mfh_file::dispatch_fh+00001247
[ 9] 0x000000001097c637 D:matlab programabinwin64m_dispatcher.dll+00050743 Mfunction_handle::dispatch+00000487
[ 10] 0x0000000010d1cf97 D:matlab programabinwin64m_interpreter.dll+00511895 MathWorks::MException::MExceptionEnvelope::GetID+00306695
[ 11] 0x0000000010d201c8 D:matlab programabinwin64m_interpreter.dll+00524744 MathWorks::MException::MExceptionEnvelope::GetID+00319544
[ 12] 0x0000000010d1cc38 D:matlab programabinwin64m_interpreter.dll+00511032 MathWorks::MException::MExceptionEnvelope::GetID+00305832
[ 13] 0x0000000010d2644f D:matlab programabinwin64m_interpreter.dll+00549967 MathWorks::MException::MExceptionEnvelope::GetID+00344767
[ 14] 0x0000000010d34962 D:matlab programabinwin64m_interpreter.dll+00608610 MathWorks::MException::MExceptionEnvelope::GetID+00403410
[ 15] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 16] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 17] 0x000000001097be4f D:matlab programabinwin64m_dispatcher.dll+00048719 Mfh_file::dispatch_fh+00000687
[ 18] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 19] 0x0000000010d55e04 D:matlab programabinwin64m_interpreter.dll+00744964 MathWorks::MException::MExceptionEnvelope::GetID+00539764
[ 20] 0x0000000010d40782 D:matlab programabinwin64m_interpreter.dll+00657282 MathWorks::MException::MExceptionEnvelope::GetID+00452082
[ 21] 0x0000000010d33f6f D:matlab programabinwin64m_interpreter.dll+00606063 MathWorks::MException::MExceptionEnvelope::GetID+00400863
[ 22] 0x0000000010d1cd43 D:matlab programabinwin64m_interpreter.dll+00511299 MathWorks::MException::MExceptionEnvelope::GetID+00306099
[ 23] 0x0000000010d2644f D:matlab programabinwin64m_interpreter.dll+00549967 MathWorks::MException::MExceptionEnvelope::GetID+00344767
[ 24] 0x0000000010d29350 D:matlab programabinwin64m_interpreter.dll+00562000 MathWorks::MException::MExceptionEnvelope::GetID+00356800
[ 25] 0x0000000010d4446f D:matlab programabinwin64m_interpreter.dll+00672879 MathWorks::MException::MExceptionEnvelope::GetID+00467679
[ 26] 0x0000000010d445b8 D:matlab programabinwin64m_interpreter.dll+00673208 MathWorks::MException::MExceptionEnvelope::GetID+00468008
[ 27] 0x0000000010d34a2d D:matlab programabinwin64m_interpreter.dll+00608813 MathWorks::MException::MExceptionEnvelope::GetID+00403613
[ 28] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 29] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 30] 0x000000001097c00e D:matlab programabinwin64m_dispatcher.dll+00049166 Mfh_file::dispatch_fh+00001134
[ 31] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 32] 0x0000000010d2cdfe D:matlab programabinwin64m_interpreter.dll+00577022 MathWorks::MException::MExceptionEnvelope::GetID+00371822
[ 33] 0x0000000010da68a7 D:matlab programabinwin64m_interpreter.dll+01075367 inEachVisibleName+00016119
[ 34] 0x0000000010d2ab1a D:matlab programabinwin64m_interpreter.dll+00568090 MathWorks::MException::MExceptionEnvelope::GetID+00362890
[ 35] 0x0000000010d4446f D:matlab programabinwin64m_interpreter.dll+00672879 MathWorks::MException::MExceptionEnvelope::GetID+00467679
[ 36] 0x0000000010d445b8 D:matlab programabinwin64m_interpreter.dll+00673208 MathWorks::MException::MExceptionEnvelope::GetID+00468008
[ 37] 0x0000000010d34a2d D:matlab programabinwin64m_interpreter.dll+00608813 MathWorks::MException::MExceptionEnvelope::GetID+00403613
[ 38] 0x0000000010d3192c D:matlab programabinwin64m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 39] 0x0000000010d411c9 D:matlab programabinwin64m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 40] 0x000000001097c00e D:matlab programabinwin64m_dispatcher.dll+00049166 Mfh_file::dispatch_fh+00001134
[ 41] 0x000000001097c77a D:matlab programabinwin64m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 42] 0x0000000010db4a0e D:matlab programabinwin64m_interpreter.dll+01133070 inValidateLoadedObject+00003486
[ 43] 0x0000000010dbbd95 D:matlab programabinwin64m_interpreter.dll+01162645 inResetInterpreter+00005029
[ 44] 0x0000000010dc0a05 D:matlab programabinwin64m_interpreter.dll+01182213 MathWorks::MException::MExceptionEnvelope::Copy+00010997
[ 45] 0x0000000010dc09d2 D:matlab programabinwin64m_interpreter.dll+01182162 MathWorks::MException::MExceptionEnvelope::Copy+00010946
[ 46] 0x0000000010dc0997 D:matlab programabinwin64m_interpreter.dll+01182103 MathWorks::MException::MExceptionEnvelope::Copy+00010887
[ 47] 0x00000000111ae89c D:matlab programabinwin64m_interpreter.dll+05302428 inMexPutVariable+00004204
[ 48] 0x00000000111aebf6 D:matlab programabinwin64m_interpreter.dll+05303286 inMexPutVariable+00005062
[ 49] 0x00000000111af02e D:matlab programabinwin64m_interpreter.dll+05304366 inMexPutVariable+00006142
[ 50] 0x00000000111af36c D:matlab programabinwin64m_interpreter.dll+05305196 inMexPutVariable+00006972
[ 51] 0x00000000110c0161 D:matlab programabinwin64m_interpreter.dll+04325729 inEvalCmdWithLocalReturn+00000065
[ 52] 0x00000000fb5fbecd D:matlab programabinwin64libmwbridge.dll+00048845 mnDebugPrompt+00000109
[ 53] 0x00000000fb5fcfaf D:matlab programabinwin64libmwbridge.dll+00053167 mnParser+00000735
[ 54] 0x00000000fd0afae4 D:matlab programabinwin64mcr.dll+00195300 mcrInstance::mnParser_on_interpreter_thread+00000036
[ 55] 0x00000000fd093af0 D:matlab programabinwin64mcr.dll+00080624 mcr::runtime::setInterpreterThreadToCurrent+00029488
[ 56] 0x00000000fd093b50 D:matlab programabinwin64mcr.dll+00080720 mcr::runtime::setInterpreterThreadToCurrent+00029584
[ 57] 0x00000000fab6e026 D:matlab programabinwin64uiw.dll+00581670 UIW_IsUserMessage+00000086
[ 58] 0x00000000fab6e705 D:matlab programabinwin64uiw.dll+00583429 UIW_SetGLIMUserMsg+00000117
[ 59] 0x00000000fab6e789 D:matlab programabinwin64uiw.dll+00583561 UIW_SetGLIMUserMsg+00000249
[ 60] 0x00007ff952af5362 C:WindowsSystem32USER32.dll+00217954 GetTopWindow+00000578
[ 61] 0x00007ff952ae547f C:WindowsSystem32USER32.dll+00152703 GetDpiForWindow+00001551
[ 62] 0x00007ff952ae53c6 C:WindowsSystem32USER32.dll+00152518 GetDpiForWindow+00001366
[ 63] 0x00007ff952d533a4 C:WindowsSYSTEM32ntdll.dll+00668580 KiUserCallbackDispatcher+00000036
[ 64] 0x00007ff9500f14d4 C:WindowsSystem32win32u.dll+00005332 NtUserPeekMessage+00000020
[ 65] 0x00007ff952ae267f C:WindowsSystem32USER32.dll+00140927 PeekMessageW+00000463
[ 66] 0x00007ff952ae2399 C:WindowsSystem32USER32.dll+00140185 PeekMessageA+00000105
[ 67] 0x00000000fab1bd4b D:matlab programabinwin64uiw.dll+00245067 UIW_SetCurrentDialog+00000731
[ 68] 0x00000000fab6fbe2 D:matlab programabinwin64uiw.dll+00588770 ws_FreeSystemFont+00000482
[ 69] 0x00000001000e2ed0 D:matlab programabinwin64libmwservices.dll+00995024 services::system_events::PpeDispatchHook::~PpeDispatchHook+00053488
[ 70] 0x00000001000e36a5 D:matlab programabinwin64libmwservices.dll+00997029 services::system_events::PpeDispatchHook::~PpeDispatchHook+00055493
[ 71] 0x00000001000e4330 D:matlab programabinwin64libmwservices.dll+01000240 services::system_events::PpeDispatchHook::~PpeDispatchHook+00058704
[ 72] 0x00000001000ed4c6 D:matlab programabinwin64libmwservices.dll+01037510 sysq::removeProcessPendingEventsHook+00011030
[ 73] 0x00000001000ed7ca D:matlab programabinwin64libmwservices.dll+01038282 svWS_ProcessPendingEvents+00000138
[ 74] 0x00000000fd094b6d D:matlab programabinwin64mcr.dll+00084845 mcr::runtime::setInterpreterThreadToCurrent+00033709
[ 75] 0x00000000fd094e3b D:matlab programabinwin64mcr.dll+00085563 mcr::runtime::setInterpreterThreadToCurrent+00034427
[ 76] 0x00000000fd088b75 D:matlab programabinwin64mcr.dll+00035701 mcrInstantiationError::operator=+00003221
[ 77] 0x00000000fd08bea2 D:matlab programabinwin64mcr.dll+00048802 mcr_invoke_on_interpreter_thread+00001602
[ 78] 0x00000000fa7e6e5d D:matlab programabinwin64MVMLocal.dll+00159325 mvm_server::inproc::LocalFactory::createMVM+00040653
[ 79] 0x00000000fa8bafaa D:matlab programabinwin64mvm.dll+00569258 mvm::detail::SessionImpl::privateSession+00001754
[ 80] 0x00000000fa8bd32a D:matlab programabinwin64mvm.dll+00578346 mvm::detail::SessionImpl::privateSession+00010842
[ 81] 0x00000000fa8bce85 D:matlab programabinwin64mvm.dll+00577157 mvm::detail::SessionImpl::privateSession+00009653
[ 82] 0x0000000140004f79 D:matlab programabinwin64matlab.exe+00020345
[ 83] 0x0000000140006a07 D:matlab programabinwin64matlab.exe+00027143
[ 84] 0x00007ff950e5257d C:WindowsSystem32KERNEL32.DLL+00075133 BaseThreadInitThunk+00000029
[ 85] 0x00007ff952d0aa48 C:WindowsSYSTEM32ntdll.dll+00371272 RtlUserThreadStart+00000040
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help. matrix, matlab, iteration MATLAB Answers — New Questions
Error using fmincon function
% Define constants for Antoine’s equation
A = 8.07131;
B = 1730.63;
C = 233.426;
% Define the operating temperature at the outlet of the evaporator (in Celsius)
T = 70; % You can adjust this value based on the actual temperature
% Define the partial pressure of water at the outlet of the evaporator (kPa)
Pi = 30;
% Define the mass flow rate of seawater entering the evaporator (in kg/s)
Fseawater = 0.020; % kg/s
% Define the objective function to maximize water recovery
objective = @(x_vap) -calculate_water_recovery(x_vap, A, B, C, T, Pi, Fseawater);
% Define lower and upper bounds for the decision variable (mole fraction of water in vapor phase)
lb = 0; % Lower bound
ub = 1; % Upper bound
constraint = @(x) 20 – calculate_water_recovery(x, A, B, C, T, Pi, Fseawater);
% Perform optimization
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’);
[x_vap_opt, ~, exitflag] = fmincon(objective, 0.5, [], [], [], [], lb, ub, [], [], options);
if exitflag > 0
% Calculate water recovery and display results
[Lwater, Vwater] = calculate_water_recovery(x_vap_opt, A, B, C, T, Pi, Fseawater);
disp([‘Optimal mole fraction of water in vapor phase: ‘, num2str(x_vap_opt)]);
disp([‘Optimal mass flow rate of freshwater product: ‘, num2str(Vwater), ‘ kg/s’]);
disp([‘Optimal percent water recovered: ‘, num2str(Lwater), ‘%’]);
else
disp(‘Optimization failed to converge.’);
end
function [Lwater, Vwater] = calculate_water_recovery(xi_vap, A, B, C, T, Pi, Fseawater)
% Calculate the saturation vapor pressure using Antoine’s equation
Pisat = exp(A – B / (C + T));
% Calculate the mole fraction of water in the liquid phase using Raoult’s law
xi_liq = Pi / Pisat;
% Calculate the mole fraction of water in the vapor phase
xi_vap = 1 – xi_liq;
% Calculate the mass flow rate of freshwater product
Vwater = xi_vap * (0.0180153); % kg/s
% Calculate the percent water recovered
Lwater = (1 – (Fseawater – Vwater) / Fseawater) * 100;
end% Define constants for Antoine’s equation
A = 8.07131;
B = 1730.63;
C = 233.426;
% Define the operating temperature at the outlet of the evaporator (in Celsius)
T = 70; % You can adjust this value based on the actual temperature
% Define the partial pressure of water at the outlet of the evaporator (kPa)
Pi = 30;
% Define the mass flow rate of seawater entering the evaporator (in kg/s)
Fseawater = 0.020; % kg/s
% Define the objective function to maximize water recovery
objective = @(x_vap) -calculate_water_recovery(x_vap, A, B, C, T, Pi, Fseawater);
% Define lower and upper bounds for the decision variable (mole fraction of water in vapor phase)
lb = 0; % Lower bound
ub = 1; % Upper bound
constraint = @(x) 20 – calculate_water_recovery(x, A, B, C, T, Pi, Fseawater);
% Perform optimization
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’);
[x_vap_opt, ~, exitflag] = fmincon(objective, 0.5, [], [], [], [], lb, ub, [], [], options);
if exitflag > 0
% Calculate water recovery and display results
[Lwater, Vwater] = calculate_water_recovery(x_vap_opt, A, B, C, T, Pi, Fseawater);
disp([‘Optimal mole fraction of water in vapor phase: ‘, num2str(x_vap_opt)]);
disp([‘Optimal mass flow rate of freshwater product: ‘, num2str(Vwater), ‘ kg/s’]);
disp([‘Optimal percent water recovered: ‘, num2str(Lwater), ‘%’]);
else
disp(‘Optimization failed to converge.’);
end
function [Lwater, Vwater] = calculate_water_recovery(xi_vap, A, B, C, T, Pi, Fseawater)
% Calculate the saturation vapor pressure using Antoine’s equation
Pisat = exp(A – B / (C + T));
% Calculate the mole fraction of water in the liquid phase using Raoult’s law
xi_liq = Pi / Pisat;
% Calculate the mole fraction of water in the vapor phase
xi_vap = 1 – xi_liq;
% Calculate the mass flow rate of freshwater product
Vwater = xi_vap * (0.0180153); % kg/s
% Calculate the percent water recovered
Lwater = (1 – (Fseawater – Vwater) / Fseawater) * 100;
end % Define constants for Antoine’s equation
A = 8.07131;
B = 1730.63;
C = 233.426;
% Define the operating temperature at the outlet of the evaporator (in Celsius)
T = 70; % You can adjust this value based on the actual temperature
% Define the partial pressure of water at the outlet of the evaporator (kPa)
Pi = 30;
% Define the mass flow rate of seawater entering the evaporator (in kg/s)
Fseawater = 0.020; % kg/s
% Define the objective function to maximize water recovery
objective = @(x_vap) -calculate_water_recovery(x_vap, A, B, C, T, Pi, Fseawater);
% Define lower and upper bounds for the decision variable (mole fraction of water in vapor phase)
lb = 0; % Lower bound
ub = 1; % Upper bound
constraint = @(x) 20 – calculate_water_recovery(x, A, B, C, T, Pi, Fseawater);
% Perform optimization
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’);
[x_vap_opt, ~, exitflag] = fmincon(objective, 0.5, [], [], [], [], lb, ub, [], [], options);
if exitflag > 0
% Calculate water recovery and display results
[Lwater, Vwater] = calculate_water_recovery(x_vap_opt, A, B, C, T, Pi, Fseawater);
disp([‘Optimal mole fraction of water in vapor phase: ‘, num2str(x_vap_opt)]);
disp([‘Optimal mass flow rate of freshwater product: ‘, num2str(Vwater), ‘ kg/s’]);
disp([‘Optimal percent water recovered: ‘, num2str(Lwater), ‘%’]);
else
disp(‘Optimization failed to converge.’);
end
function [Lwater, Vwater] = calculate_water_recovery(xi_vap, A, B, C, T, Pi, Fseawater)
% Calculate the saturation vapor pressure using Antoine’s equation
Pisat = exp(A – B / (C + T));
% Calculate the mole fraction of water in the liquid phase using Raoult’s law
xi_liq = Pi / Pisat;
% Calculate the mole fraction of water in the vapor phase
xi_vap = 1 – xi_liq;
% Calculate the mass flow rate of freshwater product
Vwater = xi_vap * (0.0180153); % kg/s
% Calculate the percent water recovered
Lwater = (1 – (Fseawater – Vwater) / Fseawater) * 100;
end fmincon, constraints MATLAB Answers — New Questions
All Widget Gauges are blank
Was just checking in on our ThingSpeak channels and all our Public Widgets are blank.
Don’t know when this started.
Anyone else seeing this?Was just checking in on our ThingSpeak channels and all our Public Widgets are blank.
Don’t know when this started.
Anyone else seeing this? Was just checking in on our ThingSpeak channels and all our Public Widgets are blank.
Don’t know when this started.
Anyone else seeing this? thingspeak MATLAB Answers — New Questions
Cannot refresh variables when exporting Simulink to FMU file
I am trying to create a simple FMU file from a SimuLink model. I made this many times before. Now, suddenly, I am getting the following error when I try to refresh the settings (using R2024a):
Unable to resolve the name ‘internal.getWSLDockerSettings’
I have no idea what that means. A reseach on google resulted in nothing.
I thank for any help.I am trying to create a simple FMU file from a SimuLink model. I made this many times before. Now, suddenly, I am getting the following error when I try to refresh the settings (using R2024a):
Unable to resolve the name ‘internal.getWSLDockerSettings’
I have no idea what that means. A reseach on google resulted in nothing.
I thank for any help. I am trying to create a simple FMU file from a SimuLink model. I made this many times before. Now, suddenly, I am getting the following error when I try to refresh the settings (using R2024a):
Unable to resolve the name ‘internal.getWSLDockerSettings’
I have no idea what that means. A reseach on google resulted in nothing.
I thank for any help. fmu, simulink MATLAB Answers — New Questions
INDEX EXCEEDS THE NUMBER OF ARRAY ELEMENTS.
% Load the signal data from the text file using the load command with the -ascii option
x = load(‘Lab7data1.txt’, ‘-ascii’);
% Plot the signal
%figure;
%plot(x);
%xlabel(‘Sample’);
%ylabel(‘Amplitude’);
%title(‘Original Signal’);
%grid on;
% Calculate the length of the signal in samples
signal_length = length(x);
num_periods = 100;
% Estimate the number of samples per period
samples_per_period = signal_length / num_periods;
% Check Nyquist condition
if samples_per_period >= 2
disp(‘Nyquist sampling rate is satisfied.’);
else
disp(‘Nyquist sampling rate is not satisfied.’);
end
% Calculate the current sampling rate
current_sampling_rate = 1 / samples_per_period;
% Estimate the down-sampling factor needed to reduce the sampling rate to
% the Nyquist
downsampling_factor = ceil(current_sampling_rate / 2);
% Down-sample the signal
downsampled_signal = x(1:downsampling_factor:end);
% Define the x-values for the down-sampled signal
downsampled_indices = 1:downsampling_factor:signal_length;
% Make sure the lengths match
if length(downsampled_indices) ~= length(downsampled_signal)
downsampled_indices = downsampled_indices(1:length(downsampled_signal));
end
% Interpolate the down-sampled signal to up-sample it
up_sampled_signal = interp1(downsampled_indices, downsampled_signal, 1:signal_length,’linear’);
% Plot both the original and down-sampled signals
figure;
plot(1:signal_length, x, ‘b’, ‘DisplayName’, ‘Original Signal’);
hold on;
plot(downsampled_signal, ‘ro’, ‘DisplayName’, ‘Down-sampled Signal’);
plot(up_sampled_signal, ‘g’, ‘DisplayName’, ‘Up-sampled Signal (Linear Interpolation)’);
hold off;
xlabel(‘Sample’);
ylabel(‘Amplitude’);
title(‘Original vs Down-sampled Signal vs Up-sampled Signal’);
legend(‘Location’, ‘best’);
grid on;% Load the signal data from the text file using the load command with the -ascii option
x = load(‘Lab7data1.txt’, ‘-ascii’);
% Plot the signal
%figure;
%plot(x);
%xlabel(‘Sample’);
%ylabel(‘Amplitude’);
%title(‘Original Signal’);
%grid on;
% Calculate the length of the signal in samples
signal_length = length(x);
num_periods = 100;
% Estimate the number of samples per period
samples_per_period = signal_length / num_periods;
% Check Nyquist condition
if samples_per_period >= 2
disp(‘Nyquist sampling rate is satisfied.’);
else
disp(‘Nyquist sampling rate is not satisfied.’);
end
% Calculate the current sampling rate
current_sampling_rate = 1 / samples_per_period;
% Estimate the down-sampling factor needed to reduce the sampling rate to
% the Nyquist
downsampling_factor = ceil(current_sampling_rate / 2);
% Down-sample the signal
downsampled_signal = x(1:downsampling_factor:end);
% Define the x-values for the down-sampled signal
downsampled_indices = 1:downsampling_factor:signal_length;
% Make sure the lengths match
if length(downsampled_indices) ~= length(downsampled_signal)
downsampled_indices = downsampled_indices(1:length(downsampled_signal));
end
% Interpolate the down-sampled signal to up-sample it
up_sampled_signal = interp1(downsampled_indices, downsampled_signal, 1:signal_length,’linear’);
% Plot both the original and down-sampled signals
figure;
plot(1:signal_length, x, ‘b’, ‘DisplayName’, ‘Original Signal’);
hold on;
plot(downsampled_signal, ‘ro’, ‘DisplayName’, ‘Down-sampled Signal’);
plot(up_sampled_signal, ‘g’, ‘DisplayName’, ‘Up-sampled Signal (Linear Interpolation)’);
hold off;
xlabel(‘Sample’);
ylabel(‘Amplitude’);
title(‘Original vs Down-sampled Signal vs Up-sampled Signal’);
legend(‘Location’, ‘best’);
grid on; % Load the signal data from the text file using the load command with the -ascii option
x = load(‘Lab7data1.txt’, ‘-ascii’);
% Plot the signal
%figure;
%plot(x);
%xlabel(‘Sample’);
%ylabel(‘Amplitude’);
%title(‘Original Signal’);
%grid on;
% Calculate the length of the signal in samples
signal_length = length(x);
num_periods = 100;
% Estimate the number of samples per period
samples_per_period = signal_length / num_periods;
% Check Nyquist condition
if samples_per_period >= 2
disp(‘Nyquist sampling rate is satisfied.’);
else
disp(‘Nyquist sampling rate is not satisfied.’);
end
% Calculate the current sampling rate
current_sampling_rate = 1 / samples_per_period;
% Estimate the down-sampling factor needed to reduce the sampling rate to
% the Nyquist
downsampling_factor = ceil(current_sampling_rate / 2);
% Down-sample the signal
downsampled_signal = x(1:downsampling_factor:end);
% Define the x-values for the down-sampled signal
downsampled_indices = 1:downsampling_factor:signal_length;
% Make sure the lengths match
if length(downsampled_indices) ~= length(downsampled_signal)
downsampled_indices = downsampled_indices(1:length(downsampled_signal));
end
% Interpolate the down-sampled signal to up-sample it
up_sampled_signal = interp1(downsampled_indices, downsampled_signal, 1:signal_length,’linear’);
% Plot both the original and down-sampled signals
figure;
plot(1:signal_length, x, ‘b’, ‘DisplayName’, ‘Original Signal’);
hold on;
plot(downsampled_signal, ‘ro’, ‘DisplayName’, ‘Down-sampled Signal’);
plot(up_sampled_signal, ‘g’, ‘DisplayName’, ‘Up-sampled Signal (Linear Interpolation)’);
hold off;
xlabel(‘Sample’);
ylabel(‘Amplitude’);
title(‘Original vs Down-sampled Signal vs Up-sampled Signal’);
legend(‘Location’, ‘best’);
grid on; array element MATLAB Answers — New Questions
Index exceeds matrix dimensions.
clc;
clear;
%Исходные данные
F=100; %частота следования импульсов, Гц
alpha=0.5; %Коэффициент скругления
U0=1; % Амплитуда несущего колебания, В
f0=100000; %частота несущего колебания, Гц
Fs=10*f0; %частота дискретизации, Гц
T=1/F; %Период следования импульсов, с
Ts=1/Fs; %Период дискретизации, с
f=140:0.1:160; % массив частот
M=length(f);
j=complex(0, 1);
%Добавление шума
SNR=-15; % добавление шума, дБ
% 1. Расчёт импульса приподнятого косинуса
delay=3; %задержка
g=rcosine(F, 200*F, ‘sqrt’, alpha, delay); %импульс приподнятого косинуса
g=g/max(g);
N1=length(g);
t1=0:(1/(200*F)):(N1-1)*(1/(200*F));
% 2. Синтез случайного кода
Nsym=100; %число символов
p=ceil(2.*rand(1,Nsym));
p=p-1;
%———————————-Модуляция DQPSK————
% 3. Расчёт символов a
a=zeros(1, Nsym);
for n=1:Nsym %Вычисление A и B
if p(n)==0
a(n)=-1;
end
if p(n)==1
a(n)=1;
end
end
n=1:Nsym;
figure(1)
stem(n, a);
%xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘n’);
ylabel(‘a’);
grid on
% 4. Синтез модулирующего сигнала
N=Nsym*N1;
t=0:Ts:(N-1)*Ts;
Sa=zeros(1,N);
for n=1:Nsym
for k=1:N1
Sa(k+(n-1)*200*F)=a(n).*g(k)+Sa(k+(n-1)*200*F);
end
end
figure(2)
plot(t, Sa);
title(‘График модулирующего сигнала символов a’);
xlim([0, 10]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on
% 5. Балансная модуляция
Ug=U0*cos(2*pi*f0*t); %несущее колебание
Uw=Sa.*Ug; %радиосигнал
P=mean(Uw.*Uw); % мощность в Вт
PF=10*log10((max(Uw.*Uw))/P); %пик-фактор
Ps=10*log10(P); % мощность в дБ
Noise=wgn(1, N, Ps-SNR);
Uw=Uw+Noise; % добавление шума
figure(3)
plot(t, Uw);
xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Uw(t), В’);
grid on
%———————————-Демодуляция BPSK————
% 6. Балансная демодуляция
t=0:Ts:(N-1)*Ts;
Uda=Uw.*cos(2*pi*f0*t);
Sfa=filter(g, 1, Uda);
Sfa=Sfa/max(Sfa)*max(Sa);
t=0:(1/(200*F)):(N-1)*(1/(200*F));
figure(4)
subplot(2, 1, 1);
plot(t, Sfa);
title(‘График демодулированного сигнала a’);
xlim([0, 0.23]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid onclc;
clear;
%Исходные данные
F=100; %частота следования импульсов, Гц
alpha=0.5; %Коэффициент скругления
U0=1; % Амплитуда несущего колебания, В
f0=100000; %частота несущего колебания, Гц
Fs=10*f0; %частота дискретизации, Гц
T=1/F; %Период следования импульсов, с
Ts=1/Fs; %Период дискретизации, с
f=140:0.1:160; % массив частот
M=length(f);
j=complex(0, 1);
%Добавление шума
SNR=-15; % добавление шума, дБ
% 1. Расчёт импульса приподнятого косинуса
delay=3; %задержка
g=rcosine(F, 200*F, ‘sqrt’, alpha, delay); %импульс приподнятого косинуса
g=g/max(g);
N1=length(g);
t1=0:(1/(200*F)):(N1-1)*(1/(200*F));
% 2. Синтез случайного кода
Nsym=100; %число символов
p=ceil(2.*rand(1,Nsym));
p=p-1;
%———————————-Модуляция DQPSK————
% 3. Расчёт символов a
a=zeros(1, Nsym);
for n=1:Nsym %Вычисление A и B
if p(n)==0
a(n)=-1;
end
if p(n)==1
a(n)=1;
end
end
n=1:Nsym;
figure(1)
stem(n, a);
%xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘n’);
ylabel(‘a’);
grid on
% 4. Синтез модулирующего сигнала
N=Nsym*N1;
t=0:Ts:(N-1)*Ts;
Sa=zeros(1,N);
for n=1:Nsym
for k=1:N1
Sa(k+(n-1)*200*F)=a(n).*g(k)+Sa(k+(n-1)*200*F);
end
end
figure(2)
plot(t, Sa);
title(‘График модулирующего сигнала символов a’);
xlim([0, 10]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on
% 5. Балансная модуляция
Ug=U0*cos(2*pi*f0*t); %несущее колебание
Uw=Sa.*Ug; %радиосигнал
P=mean(Uw.*Uw); % мощность в Вт
PF=10*log10((max(Uw.*Uw))/P); %пик-фактор
Ps=10*log10(P); % мощность в дБ
Noise=wgn(1, N, Ps-SNR);
Uw=Uw+Noise; % добавление шума
figure(3)
plot(t, Uw);
xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Uw(t), В’);
grid on
%———————————-Демодуляция BPSK————
% 6. Балансная демодуляция
t=0:Ts:(N-1)*Ts;
Uda=Uw.*cos(2*pi*f0*t);
Sfa=filter(g, 1, Uda);
Sfa=Sfa/max(Sfa)*max(Sa);
t=0:(1/(200*F)):(N-1)*(1/(200*F));
figure(4)
subplot(2, 1, 1);
plot(t, Sfa);
title(‘График демодулированного сигнала a’);
xlim([0, 0.23]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on clc;
clear;
%Исходные данные
F=100; %частота следования импульсов, Гц
alpha=0.5; %Коэффициент скругления
U0=1; % Амплитуда несущего колебания, В
f0=100000; %частота несущего колебания, Гц
Fs=10*f0; %частота дискретизации, Гц
T=1/F; %Период следования импульсов, с
Ts=1/Fs; %Период дискретизации, с
f=140:0.1:160; % массив частот
M=length(f);
j=complex(0, 1);
%Добавление шума
SNR=-15; % добавление шума, дБ
% 1. Расчёт импульса приподнятого косинуса
delay=3; %задержка
g=rcosine(F, 200*F, ‘sqrt’, alpha, delay); %импульс приподнятого косинуса
g=g/max(g);
N1=length(g);
t1=0:(1/(200*F)):(N1-1)*(1/(200*F));
% 2. Синтез случайного кода
Nsym=100; %число символов
p=ceil(2.*rand(1,Nsym));
p=p-1;
%———————————-Модуляция DQPSK————
% 3. Расчёт символов a
a=zeros(1, Nsym);
for n=1:Nsym %Вычисление A и B
if p(n)==0
a(n)=-1;
end
if p(n)==1
a(n)=1;
end
end
n=1:Nsym;
figure(1)
stem(n, a);
%xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘n’);
ylabel(‘a’);
grid on
% 4. Синтез модулирующего сигнала
N=Nsym*N1;
t=0:Ts:(N-1)*Ts;
Sa=zeros(1,N);
for n=1:Nsym
for k=1:N1
Sa(k+(n-1)*200*F)=a(n).*g(k)+Sa(k+(n-1)*200*F);
end
end
figure(2)
plot(t, Sa);
title(‘График модулирующего сигнала символов a’);
xlim([0, 10]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on
% 5. Балансная модуляция
Ug=U0*cos(2*pi*f0*t); %несущее колебание
Uw=Sa.*Ug; %радиосигнал
P=mean(Uw.*Uw); % мощность в Вт
PF=10*log10((max(Uw.*Uw))/P); %пик-фактор
Ps=10*log10(P); % мощность в дБ
Noise=wgn(1, N, Ps-SNR);
Uw=Uw+Noise; % добавление шума
figure(3)
plot(t, Uw);
xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Uw(t), В’);
grid on
%———————————-Демодуляция BPSK————
% 6. Балансная демодуляция
t=0:Ts:(N-1)*Ts;
Uda=Uw.*cos(2*pi*f0*t);
Sfa=filter(g, 1, Uda);
Sfa=Sfa/max(Sfa)*max(Sa);
t=0:(1/(200*F)):(N-1)*(1/(200*F));
figure(4)
subplot(2, 1, 1);
plot(t, Sfa);
title(‘График демодулированного сигнала a’);
xlim([0, 0.23]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on matlab MATLAB Answers — New Questions
phase diagram of 3D Anderson model
L = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
endL = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
end L = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
end colormap MATLAB Answers — New Questions
Pipe (TL) fluid compressibility problem
Hello whenever I uncheck the compressibility box my model can’t run anymore can anyone help please.Hello whenever I uncheck the compressibility box my model can’t run anymore can anyone help please. Hello whenever I uncheck the compressibility box my model can’t run anymore can anyone help please. simscape, simulink, simulation, problem MATLAB Answers — New Questions
How to avoid the overshoot in Jiles Atherton hysteresis loop
Trying to plot a hysteresis model using jiles atherton hysteresis model in matlab. All the parameters are defined in the beginning.
Here is the code I have written,
clear
%% Given parameters
a = 512;
c = 0.75;
k = 570;
M_s = 1.7*10^6;
i_s = 10^-6;
alpha = 0.032;
u_0 = 4*pi*10^-7;
f = 1;
h_max = 8000;
%% Generate time vector
t_start = 0; %start time
t_end = 60; %end time
dt = 0.001; %time steps
t = t_start:dt:t_end;
%% Initial values
M_irev(1) = 0; %Initial irreversible magnetization
h = h_max*sin(2*pi*f*t); % Sinusoidal magnetic field strength
%% Time stepping loop
for i=2:length(t)
% Compute effective field
h_e = h(i); % Applied field and effective field considered equal
% Compute anhysteric magnetization
M_an = M_s*(coth(h_e/a) – (a/(h_e))); % Langevin function
% Compute derivative of magnetic field with respect to time
dh_e = (h(i) – h(i-1)) / dt;
delta = sign(dh_e);
% Compute irreversible magnetization using Euler method
M_irev(i) = ((M_an – M_irev(i-1)) / ((k * delta) – (alpha * (M_an – M_irev(i-1))))) * dh_e;
% Update magnetization
M(i) = c*M_an + (1-c)*M_irev(i);
end
%% Magnetic flux density
B = u_0 * (h + M);
%% Plot results
figure;
plot(h, B);
xlabel(‘Magnetic Field Strength’);
ylabel(‘Magnetic Flux Density’);
title(‘HB Graph’);
grid on;
The problem I am facing is when it plots the curve, it shows overshoot at three points. Suspecting the problem is in the ‘Langevin function’. Lower values of h at the end part creates bigger values thus it shows overshoot at those points. I think I need to use approximation (Taylor series or similar method) at those points so that when overshoot happens the code will avoid those overshoots and take the approximation. Can anyone show me how can I do that approximation?Trying to plot a hysteresis model using jiles atherton hysteresis model in matlab. All the parameters are defined in the beginning.
Here is the code I have written,
clear
%% Given parameters
a = 512;
c = 0.75;
k = 570;
M_s = 1.7*10^6;
i_s = 10^-6;
alpha = 0.032;
u_0 = 4*pi*10^-7;
f = 1;
h_max = 8000;
%% Generate time vector
t_start = 0; %start time
t_end = 60; %end time
dt = 0.001; %time steps
t = t_start:dt:t_end;
%% Initial values
M_irev(1) = 0; %Initial irreversible magnetization
h = h_max*sin(2*pi*f*t); % Sinusoidal magnetic field strength
%% Time stepping loop
for i=2:length(t)
% Compute effective field
h_e = h(i); % Applied field and effective field considered equal
% Compute anhysteric magnetization
M_an = M_s*(coth(h_e/a) – (a/(h_e))); % Langevin function
% Compute derivative of magnetic field with respect to time
dh_e = (h(i) – h(i-1)) / dt;
delta = sign(dh_e);
% Compute irreversible magnetization using Euler method
M_irev(i) = ((M_an – M_irev(i-1)) / ((k * delta) – (alpha * (M_an – M_irev(i-1))))) * dh_e;
% Update magnetization
M(i) = c*M_an + (1-c)*M_irev(i);
end
%% Magnetic flux density
B = u_0 * (h + M);
%% Plot results
figure;
plot(h, B);
xlabel(‘Magnetic Field Strength’);
ylabel(‘Magnetic Flux Density’);
title(‘HB Graph’);
grid on;
The problem I am facing is when it plots the curve, it shows overshoot at three points. Suspecting the problem is in the ‘Langevin function’. Lower values of h at the end part creates bigger values thus it shows overshoot at those points. I think I need to use approximation (Taylor series or similar method) at those points so that when overshoot happens the code will avoid those overshoots and take the approximation. Can anyone show me how can I do that approximation? Trying to plot a hysteresis model using jiles atherton hysteresis model in matlab. All the parameters are defined in the beginning.
Here is the code I have written,
clear
%% Given parameters
a = 512;
c = 0.75;
k = 570;
M_s = 1.7*10^6;
i_s = 10^-6;
alpha = 0.032;
u_0 = 4*pi*10^-7;
f = 1;
h_max = 8000;
%% Generate time vector
t_start = 0; %start time
t_end = 60; %end time
dt = 0.001; %time steps
t = t_start:dt:t_end;
%% Initial values
M_irev(1) = 0; %Initial irreversible magnetization
h = h_max*sin(2*pi*f*t); % Sinusoidal magnetic field strength
%% Time stepping loop
for i=2:length(t)
% Compute effective field
h_e = h(i); % Applied field and effective field considered equal
% Compute anhysteric magnetization
M_an = M_s*(coth(h_e/a) – (a/(h_e))); % Langevin function
% Compute derivative of magnetic field with respect to time
dh_e = (h(i) – h(i-1)) / dt;
delta = sign(dh_e);
% Compute irreversible magnetization using Euler method
M_irev(i) = ((M_an – M_irev(i-1)) / ((k * delta) – (alpha * (M_an – M_irev(i-1))))) * dh_e;
% Update magnetization
M(i) = c*M_an + (1-c)*M_irev(i);
end
%% Magnetic flux density
B = u_0 * (h + M);
%% Plot results
figure;
plot(h, B);
xlabel(‘Magnetic Field Strength’);
ylabel(‘Magnetic Flux Density’);
title(‘HB Graph’);
grid on;
The problem I am facing is when it plots the curve, it shows overshoot at three points. Suspecting the problem is in the ‘Langevin function’. Lower values of h at the end part creates bigger values thus it shows overshoot at those points. I think I need to use approximation (Taylor series or similar method) at those points so that when overshoot happens the code will avoid those overshoots and take the approximation. Can anyone show me how can I do that approximation? jiles-atherton, hysteresis, approximation, taylor series MATLAB Answers — New Questions
Property set method for structure-like property
Hello, I’m implementing a class (used to control an instrument through a USB interface).
Due to the structure of the instrument, I’d like to store properies as structures.
I wonder if there is a good way to implement property set method which would only update the field that was changed.
Here is what I have know:
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function input = get.input(obj)
range = obj.get(‘input_range’);
ac = obj.get(‘input_ac’);
impedance_50ohm = obj.get(‘input_impedance_50’);
input = struct(‘range’, range, ‘ac’, ac, ‘impedance_50ohm’, impedance_50ohm);
end
function output = get.output(obj)
on = obj.get(‘output_on’);
range = obj.get(‘output_range’);
amplitude = obj.get(‘output_amplitude’);
mixer = obj.get(‘output_mixer’);
output = struct(‘on’, on, ‘range’, range, ‘amplitude’, amplitude, ‘mixer’, mixer);
end
% Setters
function set.input(obj, input)
obj.set(‘input_range’, input.range);
obj.set(‘input_ac’, input.ac);
obj.set(‘input_impedance_50’, input.impedance_50ohm);
end
function set.output(obj, output)
obj.set(‘output_on’, output.on);
obj.set(‘output_range’, output.range);
obj.set(‘output_amplitude’, output.amplitude);
obj.set(‘output_mixer’, output.mixer);
end
end
end
However, I do not want to update all the field each time one field is changed. I want to do something like (obviously this not a proper code):
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function range = get.input.range(obj)
range = obj.get(‘input_range’);
end
function ac = get.input.ac(obj)
ac = obj.get(‘input_ac’);
end
%etc…
% Setters
function set.input.range(obj, input.range)
obj.set(‘input_range’, input.range);
end
function set.input.ac(obj, input.ac)
obj.set(‘input_ac’, input.ac);
end
%etc…
end
end
I understand that I could just make them separate properties, but this would be not a pleasing solution.
classdef Driver < handle
properties
%Input Parameters
input_range; % Input ranges of all signal inputs
input_ac; % Input couplings of all signal inputs
input_impedance_50; % Input impedances of all signal inputs
%Output Parameters
output_on; % Output status of all signal outputs
output_range; % Output ranges of all signal outputs
output_amplitude; % Output amplitudes of all signal outputs
output_mixer; % Output mixer channels of all signal outputs
end
end
Thank you.Hello, I’m implementing a class (used to control an instrument through a USB interface).
Due to the structure of the instrument, I’d like to store properies as structures.
I wonder if there is a good way to implement property set method which would only update the field that was changed.
Here is what I have know:
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function input = get.input(obj)
range = obj.get(‘input_range’);
ac = obj.get(‘input_ac’);
impedance_50ohm = obj.get(‘input_impedance_50’);
input = struct(‘range’, range, ‘ac’, ac, ‘impedance_50ohm’, impedance_50ohm);
end
function output = get.output(obj)
on = obj.get(‘output_on’);
range = obj.get(‘output_range’);
amplitude = obj.get(‘output_amplitude’);
mixer = obj.get(‘output_mixer’);
output = struct(‘on’, on, ‘range’, range, ‘amplitude’, amplitude, ‘mixer’, mixer);
end
% Setters
function set.input(obj, input)
obj.set(‘input_range’, input.range);
obj.set(‘input_ac’, input.ac);
obj.set(‘input_impedance_50’, input.impedance_50ohm);
end
function set.output(obj, output)
obj.set(‘output_on’, output.on);
obj.set(‘output_range’, output.range);
obj.set(‘output_amplitude’, output.amplitude);
obj.set(‘output_mixer’, output.mixer);
end
end
end
However, I do not want to update all the field each time one field is changed. I want to do something like (obviously this not a proper code):
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function range = get.input.range(obj)
range = obj.get(‘input_range’);
end
function ac = get.input.ac(obj)
ac = obj.get(‘input_ac’);
end
%etc…
% Setters
function set.input.range(obj, input.range)
obj.set(‘input_range’, input.range);
end
function set.input.ac(obj, input.ac)
obj.set(‘input_ac’, input.ac);
end
%etc…
end
end
I understand that I could just make them separate properties, but this would be not a pleasing solution.
classdef Driver < handle
properties
%Input Parameters
input_range; % Input ranges of all signal inputs
input_ac; % Input couplings of all signal inputs
input_impedance_50; % Input impedances of all signal inputs
%Output Parameters
output_on; % Output status of all signal outputs
output_range; % Output ranges of all signal outputs
output_amplitude; % Output amplitudes of all signal outputs
output_mixer; % Output mixer channels of all signal outputs
end
end
Thank you. Hello, I’m implementing a class (used to control an instrument through a USB interface).
Due to the structure of the instrument, I’d like to store properies as structures.
I wonder if there is a good way to implement property set method which would only update the field that was changed.
Here is what I have know:
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function input = get.input(obj)
range = obj.get(‘input_range’);
ac = obj.get(‘input_ac’);
impedance_50ohm = obj.get(‘input_impedance_50’);
input = struct(‘range’, range, ‘ac’, ac, ‘impedance_50ohm’, impedance_50ohm);
end
function output = get.output(obj)
on = obj.get(‘output_on’);
range = obj.get(‘output_range’);
amplitude = obj.get(‘output_amplitude’);
mixer = obj.get(‘output_mixer’);
output = struct(‘on’, on, ‘range’, range, ‘amplitude’, amplitude, ‘mixer’, mixer);
end
% Setters
function set.input(obj, input)
obj.set(‘input_range’, input.range);
obj.set(‘input_ac’, input.ac);
obj.set(‘input_impedance_50’, input.impedance_50ohm);
end
function set.output(obj, output)
obj.set(‘output_on’, output.on);
obj.set(‘output_range’, output.range);
obj.set(‘output_amplitude’, output.amplitude);
obj.set(‘output_mixer’, output.mixer);
end
end
end
However, I do not want to update all the field each time one field is changed. I want to do something like (obviously this not a proper code):
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function range = get.input.range(obj)
range = obj.get(‘input_range’);
end
function ac = get.input.ac(obj)
ac = obj.get(‘input_ac’);
end
%etc…
% Setters
function set.input.range(obj, input.range)
obj.set(‘input_range’, input.range);
end
function set.input.ac(obj, input.ac)
obj.set(‘input_ac’, input.ac);
end
%etc…
end
end
I understand that I could just make them separate properties, but this would be not a pleasing solution.
classdef Driver < handle
properties
%Input Parameters
input_range; % Input ranges of all signal inputs
input_ac; % Input couplings of all signal inputs
input_impedance_50; % Input impedances of all signal inputs
%Output Parameters
output_on; % Output status of all signal outputs
output_range; % Output ranges of all signal outputs
output_amplitude; % Output amplitudes of all signal outputs
output_mixer; % Output mixer channels of all signal outputs
end
end
Thank you. setter, getter, class, property, structures MATLAB Answers — New Questions
Trying to adjust weighting on PART of a sigmoid fit
I included a picture of the current fit that I am getting, what is in black is the actual data. So far the fit is pretty good but my PI would like it to fit a bit better and he suggested weighting the first part of the fit less than the later parts since we really only care from about 500 seconds onwards. Any suggestions on how to do this? I can include the actual matlab file for the fit if that would be helpful for anyone
Thanks!I included a picture of the current fit that I am getting, what is in black is the actual data. So far the fit is pretty good but my PI would like it to fit a bit better and he suggested weighting the first part of the fit less than the later parts since we really only care from about 500 seconds onwards. Any suggestions on how to do this? I can include the actual matlab file for the fit if that would be helpful for anyone
Thanks! I included a picture of the current fit that I am getting, what is in black is the actual data. So far the fit is pretty good but my PI would like it to fit a bit better and he suggested weighting the first part of the fit less than the later parts since we really only care from about 500 seconds onwards. Any suggestions on how to do this? I can include the actual matlab file for the fit if that would be helpful for anyone
Thanks! sigmoid, image processing, curve fitting MATLAB Answers — New Questions
Get the Isocline from a know levelset plot (Contours) and the function output (Height)
I was checking the function fcontour that we can use to get the contours like the following one.
I took the given example:
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f)
Now, I would like to see the heights of each contour.
Suppose I have the height value, how do I get the points that belong the contour that corresponds to the height.
Regards…I was checking the function fcontour that we can use to get the contours like the following one.
I took the given example:
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f)
Now, I would like to see the heights of each contour.
Suppose I have the height value, how do I get the points that belong the contour that corresponds to the height.
Regards… I was checking the function fcontour that we can use to get the contours like the following one.
I took the given example:
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f)
Now, I would like to see the heights of each contour.
Suppose I have the height value, how do I get the points that belong the contour that corresponds to the height.
Regards… fcontour, levelset, isoclines MATLAB Answers — New Questions
Creating a loop for repeated vector values
Hi,
I am attempting to setup a massive vector made up of Current values for a battery model. Before this piece of code I have included, the PosAccelReqCurrent already has 15 values. Is it possible to make a loop to repeat the values below for x amount of times rather than just copy and pasting it x times? It would make my code a lot of more efficient rather than having thousands of lines of the same code.
As further context, this code is to create many repeated current cycles to test battery degredation over time. Apologies if I have not added enough explanation.
Thank you.
%%%%%%%%%%%%%%%
maxPARC = length(PosAccelReqCurrent);
for x=1:6500
PosAccelReqCurrent(maxPARC+x)=PosAccelReqCurrent(15);
end
for x=1:6500
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:100
PosAccelReqCurrent(maxPARC+x)=0;
end
for x=1:100
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:3470
PosAccelReqCurrent(maxPARC+x)=15;
end
for x=1:3470
ActVel(maxPARC+x)=0;
end
%%%%%%%%%%%%%%%%%%%%Hi,
I am attempting to setup a massive vector made up of Current values for a battery model. Before this piece of code I have included, the PosAccelReqCurrent already has 15 values. Is it possible to make a loop to repeat the values below for x amount of times rather than just copy and pasting it x times? It would make my code a lot of more efficient rather than having thousands of lines of the same code.
As further context, this code is to create many repeated current cycles to test battery degredation over time. Apologies if I have not added enough explanation.
Thank you.
%%%%%%%%%%%%%%%
maxPARC = length(PosAccelReqCurrent);
for x=1:6500
PosAccelReqCurrent(maxPARC+x)=PosAccelReqCurrent(15);
end
for x=1:6500
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:100
PosAccelReqCurrent(maxPARC+x)=0;
end
for x=1:100
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:3470
PosAccelReqCurrent(maxPARC+x)=15;
end
for x=1:3470
ActVel(maxPARC+x)=0;
end
%%%%%%%%%%%%%%%%%%%% Hi,
I am attempting to setup a massive vector made up of Current values for a battery model. Before this piece of code I have included, the PosAccelReqCurrent already has 15 values. Is it possible to make a loop to repeat the values below for x amount of times rather than just copy and pasting it x times? It would make my code a lot of more efficient rather than having thousands of lines of the same code.
As further context, this code is to create many repeated current cycles to test battery degredation over time. Apologies if I have not added enough explanation.
Thank you.
%%%%%%%%%%%%%%%
maxPARC = length(PosAccelReqCurrent);
for x=1:6500
PosAccelReqCurrent(maxPARC+x)=PosAccelReqCurrent(15);
end
for x=1:6500
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:100
PosAccelReqCurrent(maxPARC+x)=0;
end
for x=1:100
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:3470
PosAccelReqCurrent(maxPARC+x)=15;
end
for x=1:3470
ActVel(maxPARC+x)=0;
end
%%%%%%%%%%%%%%%%%%%% loops, batterymodel MATLAB Answers — New Questions