Tag Archives: matlab
OPTIMIZED OVER CURRENT RELAY CO-ORDINATION
can you please provide matlab code for optimal coordination of overcurrent relays using linear programming?can you please provide matlab code for optimal coordination of overcurrent relays using linear programming? can you please provide matlab code for optimal coordination of overcurrent relays using linear programming? optimization MATLAB Answers — New Questions
How to find the neighbors of each element in a matrix
Hi,
how I can find the neighbors of each element in a given matrix? Does such a method exist in Matlab?
Here is an example :
A=[3 4 8 6;
1 6 9 0;
2 5 7 1]
The neighbors of A(1,1) are {1, 4, 6}; The neighbors of A(1,2) are {3, 1, 6, 8, 9}; The neighbors of A(2, 1) are {3, 2, 4, 6, 5}; The neighbors of A(2, 2) are {3, 1, 2, 4, 5, 8, 9, 7}
Thanks.Hi,
how I can find the neighbors of each element in a given matrix? Does such a method exist in Matlab?
Here is an example :
A=[3 4 8 6;
1 6 9 0;
2 5 7 1]
The neighbors of A(1,1) are {1, 4, 6}; The neighbors of A(1,2) are {3, 1, 6, 8, 9}; The neighbors of A(2, 1) are {3, 2, 4, 6, 5}; The neighbors of A(2, 2) are {3, 1, 2, 4, 5, 8, 9, 7}
Thanks. Hi,
how I can find the neighbors of each element in a given matrix? Does such a method exist in Matlab?
Here is an example :
A=[3 4 8 6;
1 6 9 0;
2 5 7 1]
The neighbors of A(1,1) are {1, 4, 6}; The neighbors of A(1,2) are {3, 1, 6, 8, 9}; The neighbors of A(2, 1) are {3, 2, 4, 6, 5}; The neighbors of A(2, 2) are {3, 1, 2, 4, 5, 8, 9, 7}
Thanks. neighbors of each element in a matrix MATLAB Answers — New Questions
Alzheimer disease dataset using deep learning technologies
Can anyone please respond that I’m working on an m.tech project which is of Alzheimer disease prediction using deep learning technologies and I’m using i5 processor having 16gb and 512gb causing my code to run very slow In some cases days for an single program very dissatisfied for this reason so I’m trying to improve the performance of my laptop and decided to buy an new one which works very faster especially for project use. So can anyone prefer which is best for my project and the price is not at problem.Can anyone please respond that I’m working on an m.tech project which is of Alzheimer disease prediction using deep learning technologies and I’m using i5 processor having 16gb and 512gb causing my code to run very slow In some cases days for an single program very dissatisfied for this reason so I’m trying to improve the performance of my laptop and decided to buy an new one which works very faster especially for project use. So can anyone prefer which is best for my project and the price is not at problem. Can anyone please respond that I’m working on an m.tech project which is of Alzheimer disease prediction using deep learning technologies and I’m using i5 processor having 16gb and 512gb causing my code to run very slow In some cases days for an single program very dissatisfied for this reason so I’m trying to improve the performance of my laptop and decided to buy an new one which works very faster especially for project use. So can anyone prefer which is best for my project and the price is not at problem. alzheimer’s disease, matlab, deep learning MATLAB Answers — New Questions
I have missile and target data in.txt format and f-16.mat and missile.mat models for 3d animating missile and target . According to my data set missile path is in trajectory.
But when I want to 3d models for animating they are not animating only plotting is animating .I don’t what’s the issue . Can you correct the code if it’s possible
Here is my .mat files data """>> load(‘enemy.mat’);
whos
Name Size Bytes Class Attributes
data_aam 1559×6 76947 table
data_enemy 2129×6 104305 table
end_idx 1×1 8 double
n_rows_aam 1×1 8 double
n_rows_enemy 1×1 8 double
n_steps 1×1 8 double
pAlpha 1×1 8 double
pEdge 1×3 24 double
pFace 1×3 24 double
pMatrix 1559×6 74832 double
pModel 1×8 16 char
pPath 1×2 4 char
pPathColor 1×3 24 double
pPathWidth 1×1 8 double
pScale 1×1 8 double
start_idx 1×1 8 double
trajectory_aam 1559×6 74832 double
trajectory_enemy 1559×6 74832 double
>> load(‘aam.mat’);
whos
Name Size Bytes Class Attributes
data_aam 1559×6 76947 table
data_enemy 2129×6 104305 table
end_idx 1×1 8 double
n_rows_aam 1×1 8 double
n_rows_enemy 1×1 8 double
n_steps 1×1 8 double
pAlpha 1×1 8 double
pEdge 1×3 24 double
pFace 1×3 24 double
pMatrix 1559×6 74832 double
pModel 1×11 22 char
pPath 1×2 4 char
pPathColor 1×3 24 double
pPathWidth 1×1 8 double
pScale 1×1 8 double
start_idx 1×1 8 double
trajectory_aam 1559×6 74832 double
trajectory_enemy 1559×6 74832 double
>> % Check the contents of f-16.mat
matFileF16 = load(‘f-16.mat’);
disp(matFileF16);
% Check the contents of missile.mat
matFileMissile = load(‘missile.mat’);
disp(matFileMissile);
V: [2537×3 double]
F: [4428×3 double]
C: [2537×1 double]
V: [3902×3 double]
F: [7426×3 double]
C: [3902×1 double]"""
*
# * bold*% Load and process the .txt files
data_enemy = readtable(‘target_2.txt’, ‘VariableNamingRule’, ‘preserve’); % Target data
data_aam = readtable(‘missile_2.txt’, ‘VariableNamingRule’, ‘preserve’); % Missile data
% Extract relevant columns: position (x, y, z) and angular data (phi, theta, psi)
trajectory_enemy = [data_enemy.tgtpos_x, data_enemy.tgt_pos_y, data_enemy.tgt_pos_z, …
data_enemy.tgt_phi, data_enemy.tgt_theta, data_enemy.tgt_psi];
% Time vector for the enemy (target) data
time_enemy = 1:size(trajectory_enemy, 1);
% Time vector for the missile data
time_aam = linspace(1, size(trajectory_enemy, 1), size(data_aam, 1));
% Interpolate missile data to match the target data size
trajectory_aam_interp = interp1(time_aam, [data_aam.Msl_pos_x, data_aam.Msl_pos_y, data_aam.Msl_pos_z, …
data_aam.Msl_phi, data_aam.Msl_theta, data_aam.Msl_psi], …
time_enemy);
% Verify data array sizes
disp(‘Size of target trajectory:’);
disp(size(trajectory_enemy));
disp(‘Size of interpolated missile trajectory:’);
disp(size(trajectory_aam_interp));
% Save interpolated data to .mat files for use in flypath
save(‘enemy_trajectory.mat’, ‘trajectory_enemy’);
save(‘aam_trajectory.mat’, ‘trajectory_aam_interp’);
% Create 3D models with appropriate scaling
new_object(‘enemy.mat’, trajectory_enemy, …
‘model’, ‘f-16.mat’, ‘edge’, [.4 .4 .4], ‘face’, [.6 .6 .6], …
‘path’, ‘on’, ‘pathcolor’, [.3 .3 .3], ‘pathwidth’, 1, ‘scale’, 0.0005);
new_object(‘aam.mat’, trajectory_aam_interp, …
‘model’, ‘missile.mat’, ‘edge’, [.2 .2 .2], ‘face’, [.3 .3 .3], …
‘path’, ‘on’, ‘pathcolor’, [.89 .47 .0], ‘pathwidth’, 1, ‘scale’, 0.0005);
disp(‘Checking dimensions of loaded matrices…’);
load(‘enemy.mat’);
disp(size(trajectory_enemy));
load(‘aam.mat’);
disp(size(trajectory_aam_interp));
flypath(‘enemy.mat’, ‘aam.mat’, …
‘animate’, ‘on’, ‘step’, 10, …
‘font’, ‘Arial’, ‘fontsize’, 12, …
‘view’, [45, 30], ‘window’, [800, 600], …
‘output’, ‘trajectory_animation.mp4’, …
‘xlim’, [-10000, 10000], …
‘ylim’, [-10000, 15000], …
‘zlim’, [-1500, 2000]);
Here is flypath function code *****%
% FLYPATH (flypath.m)
%
% Displays static and animated trajectories of missiles and air targets
%
% SYNTAX:
%
% flypath(object_1,object_2,…,object_n,varargin)
%
% PARAMETERS:
%
% object_x : object data set produced by ‘new_object’ function,
% use command ‘help new_object’ to get more information
%
% OPTIONAL ARGUMENTS:
%
% ‘animate’ : animation on/off (‘on’,’off’ – default ‘off’)
% ‘axis’ : axes visibility (‘on’,’off’ – default ‘on’)
% ‘axiscolor’ : axes and axes font color ([R G B] – default [0 0 0])
% ‘color’ : display area color ([R G B] – default [1 1 1])
% ‘dpi’ : dpi value (75,150,300,600 – default 150)
% ‘font’ : font name (string – default ‘Times New Roman’)
% ‘fontsize’ : font size (default 12)
% ‘output’ : output file name (string – default ‘none’)
% ‘step’ : model repetition density (default 10)
% ‘view’ : camera view angles ([azimuth elevation] – default [15 30])
% ‘window’ : display area size ([width height] – default [800 600])
% ‘xlim’ : x axes limits ([min max] or ‘off’ – default ‘off’)
% ‘ylim’ : y axes limits ([min max] or ‘off’ – default ‘off’)
% ‘zlim’ : x axes limits ([min max] or ‘off’ – default ‘off’)
%
% EXAMPLES OF USE:
%
% trajectory = load(‘trajectory_tbm.mat’);
% new_object(‘ballistic_missile.mat’,trajectory,…
% ‘model’,’scud.mat’,’scale’,5,…
% ‘path’,’on’,’pathcolor’,[.89 .0 .27]);
% flypath(‘ballistic_missile.mat’,…
% ‘animate’,’off’,’step’,30,…
% ‘axis’,’on’,’axiscolor’,[0 0 0],’color’,[1 1 1],…
% ‘font’,’Georgia’,’fontsize’,6,…
% ‘view’,[0 0],’window’,[1800 600],…
% ‘xlim’,[-2e4 16e4],’ylim’,[-10 10],’zlim’,[0 4e4],…
% ‘output’,’tbm_example.png’,’dpi’,600);
%
function flypath(varargin)
objCount = 0;
% — check input parameters —
if nargin < 1
error(‘Not enough input parameters!’);
end;
% — default input parameters —
pAnimate = ‘off’; % animation: ‘on’,’off’
pAxis = ‘on’; % axes visibility: ‘on’,’off’
pAxisColor = [ 0 0 0 ]; % axes and axes font color: [ R G B ]
pColor = [ 1 1 1 ]; % display area color: [ R G B ]
pDpi = 150; % dpi value: 75, 150, 300, 600
pFont = ‘Times New Roman’; % font name
pFontSize = 12; % font size
pOutput = ‘none’; % output filename or ‘none’
pStep = 10; % model repetition density
pView = [ 15 30 ]; % camera view angles: [ azimuth elevation ]
pWindow = [ 800 600 ]; % display area size (in pixels)
pXLim = ‘off’; % x axes limits ([min max] or ‘off’ – default ‘off’)
pYLim = ‘off’; % y axes limits ([min max] or ‘off’ – default ‘off’)
pZLim = ‘off’; % z axes limits ([min max] or ‘off’ – default ‘off’)
% — read input parameters —
i = 1;
while i <= length(varargin)
switch lower(varargin{i})
case ‘animate’
pAnimate = varargin{i+1};
i = i + 2;
case ‘axis’
pAxis = varargin{i+1};
i = i + 2;
case ‘axiscolor’
pAxisColor = varargin{i+1};
i = i + 2;
case ‘color’
pColor = varargin{i+1};
i = i + 2;
case ‘dpi’
pDpi = varargin{i+1};
i = i + 2;
case ‘font’
pFont = varargin{i+1};
i = i + 2;
case ‘fontsize’
pFontSize = varargin{i+1};
i = i + 2;
case ‘output’
pOutput = varargin{i+1};
i = i + 2;
case ‘step’
pStep = varargin{i+1};
i = i + 2;
case ‘view’
pView = varargin{i+1};
i = i + 2;
case ‘window’
pWindow = varargin{i+1};
i = i + 2;
case ‘xlim’
pXLim = varargin{i+1};
i = i + 2;
case ‘ylim’
pYLim = varargin{i+1};
i = i + 2;
case ‘zlim’
pZLim = varargin{i+1};
i = i + 2;
otherwise
if exist(varargin{i},’file’) == 2
objCount = objCount + 1;
else
error(‘file %s does not exist!’,varargin{i});
end
i = i + 1;
end
end;
% — object loader —
i = 1;
while i <= objCount
% — load data to tmp variable —
tmp = load(varargin{i});
% — add data to obj structure —
if size(tmp.pMatrix,1) < size(tmp.pMatrix,2)
obj(i).matrix = tmp.pMatrix’;
else
obj(i).matrix = tmp.pMatrix;
end;
obj(i).face = tmp.pFace;
obj(i).edge = tmp.pEdge;
obj(i).alpha = tmp.pAlpha;
obj(i).path = tmp.pPath;
obj(i).pathcolor = tmp.pPathColor;
obj(i).pathwidth = tmp.pPathWidth;
obj(i).scale = tmp.pScale;
% — add 3d model to the structure —
tmp = load(tmp.pModel);
obj(i).v(:,1) = -1 * obj(i).scale * tmp.V(:,1);
obj(i).v(:,2) = 1 * obj(i).scale * tmp.V(:,2);
obj(i).v(:,3) = 1 * obj(i).scale * tmp.V(:,3);
obj(i).f = tmp.F;
% — increment counter —
i = i + 1;
end;
% — check matrix sizes —
sizeCounter = 0;
maxLength = size(obj(1).matrix,1);
if objCount > 1
i = 2;
while i <= objCount
if size(obj(i).matrix,1) ~= maxLength
sizeCounter = sizeCounter + 1;
end;
i = i + 1;
end;
if sizeCounter > 0
warning(‘data array sizes are different!’);
warning(‘data cutted to the smallest matrix dimension’);
i = 1;
maxLength = 9e100;
while i <= objCount
if size(obj(i).matrix,1) < maxLength
maxLength = size(obj(i).matrix,1);
end
i = i + 1;
end;
end;
end
% — check step size —
if pStep >= maxLength
warning(‘step size is equal or greather than max length of data array!’);
warning(‘default step value used’);
pStep = 10;
end;
% — prepare display area —
fig = figure(1);
set(fig,…
‘Name’,’flypath3d’,…
‘NumberTitle’,’off’,…
‘MenuBar’,’none’,…
‘ToolBar’,’figure’,…
‘Pointer’,’crosshair’,…
‘Position’,[50 50 pWindow(1) pWindow(2)],…
‘Color’,pColor);
set(gca,…
‘FontName’,pFont,…
‘Color’,pColor,…
‘XColor’,pAxisColor,…
‘YColor’,pAxisColor,…
‘ZColor’,pAxisColor,…
‘FontSize’,pFontSize);
clf(fig);
hold on;
% — animate —
for i = 1:pStep:maxLength
% — prepare new frame for animation —
if strcmp(pAnimate,’on’) == 1
clf(fig);
hold on;
end;
set(gca,…
‘FontName’,pFont,…
‘Color’,pColor,…
‘XColor’,pAxisColor,…
‘YColor’,pAxisColor,…
‘ZColor’,pAxisColor,…
‘FontSize’,pFontSize);
% — draw scene —
for j = 1:1:objCount
theta = obj(j).matrix(i,4);
psi = obj(j).matrix(i,5) – pi/2;
phi = -1 * obj(j).matrix(i,6);
% — transformation matrix —
sinTheta = sin(theta);
cosTheta = cos(theta);
sinPsi = sin(psi);
cosPsi = cos(psi);
sinPhi = sin(phi);
cosPhi = cos(phi);
transformMatrix = [ …
cosPsi * cosTheta …
-sinPsi * cosTheta …
sinTheta; …
cosPsi * sinTheta * sinPhi + sinPsi * cosPhi …
-sinPsi * sinTheta * sinPhi + cosPsi * cosPhi …
-cosTheta * sinPhi; …
-cosPsi * sinTheta * cosPhi + sinPsi * sinPhi …
sinPsi * sinTheta * cosPhi + cosPsi * sinPhi …
cosTheta * cosPhi ];
vertices = obj(j).v * transformMatrix;
objectSet = [ obj(j).matrix(i,1) obj(j).matrix(i,2) obj(j).matrix(i,3) ];
delta = repmat( objectSet, size( vertices, 1 ), 1 );
vertices = vertices + delta;
objPath = patch( ‘faces’, obj(j).f, ‘vertices’, vertices );
set(objPath, …
‘FaceColor’,obj(j).face,…
‘FaceAlpha’,obj(j).alpha,…
‘EdgeColor’,obj(j).edge );
if strcmp(obj(j).path,’on’) == 1
plot3(obj(j).matrix(1:i,1),…
obj(j).matrix(1:i,2),…
obj(j).matrix(1:i,3),…
‘Color’, obj(j).pathcolor, …
‘LineWidth’, obj(j).pathwidth, …
‘LineStyle’, ‘-‘);
end;
end;
% — display parameters —
if strcmp(pXLim,’off’) ~= 1
xlim( pXLim );
end
if strcmp(pYLim,’off’) ~= 1
ylim( pYLim );
end
if strcmp(pZLim,’off’) ~= 1
zlim( pZLim );
end
xlabel(‘x [m]’);
ylabel(‘y [m]’);
zlabel(‘z [m]’);
if strcmp(pAxis,’on’) == 1
axis on;
axis square;
grid on;
else
axis off;
axis square;
grid off;
end;
lighting phong;
daspect([1 1 1]);
view( pView );
if strcmp(pAnimate,’on’) == 1
drawnow;
end;
% — save the results to the gif file —
if strcmp(pAnimate,’on’) == 1
if strcmp(pOutput,’none’) ~= 1
frame = getframe(1);
im = frame2im(frame);
[A,map] = rgb2ind(im,256);
if i == 1;
imwrite(A,map,pOutput,’gif’,’LoopCount’,Inf,’DelayTime’,.04);
else
imwrite(A,map,pOutput,’gif’,’WriteMode’,’append’,’DelayTime’,.04);
end;
end;
end;
end;
if strcmp(pAnimate,’off’) == 1
if strcmp(pOutput,’none’) ~= 1
switch(pDpi)
case 75
eval(sprintf(‘print -dpng -r75 %s;’, pOutput));
case 150
eval(sprintf(‘print -dpng -r150 %s;’, pOutput));
case 300
eval(sprintf(‘print -dpng -r300 %s;’, pOutput));
case 600
eval(sprintf(‘print -dpng -r600 %s;’, pOutput));
otherwise
eval(sprintf(‘print -dpng -r600 %s;’, pOutput));
end;
end;
end;
end**** Where I’m getting wrong please suggest me and I have given all .matfiles data . Where I’m getting issue I want 3d models animationBut when I want to 3d models for animating they are not animating only plotting is animating .I don’t what’s the issue . Can you correct the code if it’s possible
Here is my .mat files data """>> load(‘enemy.mat’);
whos
Name Size Bytes Class Attributes
data_aam 1559×6 76947 table
data_enemy 2129×6 104305 table
end_idx 1×1 8 double
n_rows_aam 1×1 8 double
n_rows_enemy 1×1 8 double
n_steps 1×1 8 double
pAlpha 1×1 8 double
pEdge 1×3 24 double
pFace 1×3 24 double
pMatrix 1559×6 74832 double
pModel 1×8 16 char
pPath 1×2 4 char
pPathColor 1×3 24 double
pPathWidth 1×1 8 double
pScale 1×1 8 double
start_idx 1×1 8 double
trajectory_aam 1559×6 74832 double
trajectory_enemy 1559×6 74832 double
>> load(‘aam.mat’);
whos
Name Size Bytes Class Attributes
data_aam 1559×6 76947 table
data_enemy 2129×6 104305 table
end_idx 1×1 8 double
n_rows_aam 1×1 8 double
n_rows_enemy 1×1 8 double
n_steps 1×1 8 double
pAlpha 1×1 8 double
pEdge 1×3 24 double
pFace 1×3 24 double
pMatrix 1559×6 74832 double
pModel 1×11 22 char
pPath 1×2 4 char
pPathColor 1×3 24 double
pPathWidth 1×1 8 double
pScale 1×1 8 double
start_idx 1×1 8 double
trajectory_aam 1559×6 74832 double
trajectory_enemy 1559×6 74832 double
>> % Check the contents of f-16.mat
matFileF16 = load(‘f-16.mat’);
disp(matFileF16);
% Check the contents of missile.mat
matFileMissile = load(‘missile.mat’);
disp(matFileMissile);
V: [2537×3 double]
F: [4428×3 double]
C: [2537×1 double]
V: [3902×3 double]
F: [7426×3 double]
C: [3902×1 double]"""
*
# * bold*% Load and process the .txt files
data_enemy = readtable(‘target_2.txt’, ‘VariableNamingRule’, ‘preserve’); % Target data
data_aam = readtable(‘missile_2.txt’, ‘VariableNamingRule’, ‘preserve’); % Missile data
% Extract relevant columns: position (x, y, z) and angular data (phi, theta, psi)
trajectory_enemy = [data_enemy.tgtpos_x, data_enemy.tgt_pos_y, data_enemy.tgt_pos_z, …
data_enemy.tgt_phi, data_enemy.tgt_theta, data_enemy.tgt_psi];
% Time vector for the enemy (target) data
time_enemy = 1:size(trajectory_enemy, 1);
% Time vector for the missile data
time_aam = linspace(1, size(trajectory_enemy, 1), size(data_aam, 1));
% Interpolate missile data to match the target data size
trajectory_aam_interp = interp1(time_aam, [data_aam.Msl_pos_x, data_aam.Msl_pos_y, data_aam.Msl_pos_z, …
data_aam.Msl_phi, data_aam.Msl_theta, data_aam.Msl_psi], …
time_enemy);
% Verify data array sizes
disp(‘Size of target trajectory:’);
disp(size(trajectory_enemy));
disp(‘Size of interpolated missile trajectory:’);
disp(size(trajectory_aam_interp));
% Save interpolated data to .mat files for use in flypath
save(‘enemy_trajectory.mat’, ‘trajectory_enemy’);
save(‘aam_trajectory.mat’, ‘trajectory_aam_interp’);
% Create 3D models with appropriate scaling
new_object(‘enemy.mat’, trajectory_enemy, …
‘model’, ‘f-16.mat’, ‘edge’, [.4 .4 .4], ‘face’, [.6 .6 .6], …
‘path’, ‘on’, ‘pathcolor’, [.3 .3 .3], ‘pathwidth’, 1, ‘scale’, 0.0005);
new_object(‘aam.mat’, trajectory_aam_interp, …
‘model’, ‘missile.mat’, ‘edge’, [.2 .2 .2], ‘face’, [.3 .3 .3], …
‘path’, ‘on’, ‘pathcolor’, [.89 .47 .0], ‘pathwidth’, 1, ‘scale’, 0.0005);
disp(‘Checking dimensions of loaded matrices…’);
load(‘enemy.mat’);
disp(size(trajectory_enemy));
load(‘aam.mat’);
disp(size(trajectory_aam_interp));
flypath(‘enemy.mat’, ‘aam.mat’, …
‘animate’, ‘on’, ‘step’, 10, …
‘font’, ‘Arial’, ‘fontsize’, 12, …
‘view’, [45, 30], ‘window’, [800, 600], …
‘output’, ‘trajectory_animation.mp4’, …
‘xlim’, [-10000, 10000], …
‘ylim’, [-10000, 15000], …
‘zlim’, [-1500, 2000]);
Here is flypath function code *****%
% FLYPATH (flypath.m)
%
% Displays static and animated trajectories of missiles and air targets
%
% SYNTAX:
%
% flypath(object_1,object_2,…,object_n,varargin)
%
% PARAMETERS:
%
% object_x : object data set produced by ‘new_object’ function,
% use command ‘help new_object’ to get more information
%
% OPTIONAL ARGUMENTS:
%
% ‘animate’ : animation on/off (‘on’,’off’ – default ‘off’)
% ‘axis’ : axes visibility (‘on’,’off’ – default ‘on’)
% ‘axiscolor’ : axes and axes font color ([R G B] – default [0 0 0])
% ‘color’ : display area color ([R G B] – default [1 1 1])
% ‘dpi’ : dpi value (75,150,300,600 – default 150)
% ‘font’ : font name (string – default ‘Times New Roman’)
% ‘fontsize’ : font size (default 12)
% ‘output’ : output file name (string – default ‘none’)
% ‘step’ : model repetition density (default 10)
% ‘view’ : camera view angles ([azimuth elevation] – default [15 30])
% ‘window’ : display area size ([width height] – default [800 600])
% ‘xlim’ : x axes limits ([min max] or ‘off’ – default ‘off’)
% ‘ylim’ : y axes limits ([min max] or ‘off’ – default ‘off’)
% ‘zlim’ : x axes limits ([min max] or ‘off’ – default ‘off’)
%
% EXAMPLES OF USE:
%
% trajectory = load(‘trajectory_tbm.mat’);
% new_object(‘ballistic_missile.mat’,trajectory,…
% ‘model’,’scud.mat’,’scale’,5,…
% ‘path’,’on’,’pathcolor’,[.89 .0 .27]);
% flypath(‘ballistic_missile.mat’,…
% ‘animate’,’off’,’step’,30,…
% ‘axis’,’on’,’axiscolor’,[0 0 0],’color’,[1 1 1],…
% ‘font’,’Georgia’,’fontsize’,6,…
% ‘view’,[0 0],’window’,[1800 600],…
% ‘xlim’,[-2e4 16e4],’ylim’,[-10 10],’zlim’,[0 4e4],…
% ‘output’,’tbm_example.png’,’dpi’,600);
%
function flypath(varargin)
objCount = 0;
% — check input parameters —
if nargin < 1
error(‘Not enough input parameters!’);
end;
% — default input parameters —
pAnimate = ‘off’; % animation: ‘on’,’off’
pAxis = ‘on’; % axes visibility: ‘on’,’off’
pAxisColor = [ 0 0 0 ]; % axes and axes font color: [ R G B ]
pColor = [ 1 1 1 ]; % display area color: [ R G B ]
pDpi = 150; % dpi value: 75, 150, 300, 600
pFont = ‘Times New Roman’; % font name
pFontSize = 12; % font size
pOutput = ‘none’; % output filename or ‘none’
pStep = 10; % model repetition density
pView = [ 15 30 ]; % camera view angles: [ azimuth elevation ]
pWindow = [ 800 600 ]; % display area size (in pixels)
pXLim = ‘off’; % x axes limits ([min max] or ‘off’ – default ‘off’)
pYLim = ‘off’; % y axes limits ([min max] or ‘off’ – default ‘off’)
pZLim = ‘off’; % z axes limits ([min max] or ‘off’ – default ‘off’)
% — read input parameters —
i = 1;
while i <= length(varargin)
switch lower(varargin{i})
case ‘animate’
pAnimate = varargin{i+1};
i = i + 2;
case ‘axis’
pAxis = varargin{i+1};
i = i + 2;
case ‘axiscolor’
pAxisColor = varargin{i+1};
i = i + 2;
case ‘color’
pColor = varargin{i+1};
i = i + 2;
case ‘dpi’
pDpi = varargin{i+1};
i = i + 2;
case ‘font’
pFont = varargin{i+1};
i = i + 2;
case ‘fontsize’
pFontSize = varargin{i+1};
i = i + 2;
case ‘output’
pOutput = varargin{i+1};
i = i + 2;
case ‘step’
pStep = varargin{i+1};
i = i + 2;
case ‘view’
pView = varargin{i+1};
i = i + 2;
case ‘window’
pWindow = varargin{i+1};
i = i + 2;
case ‘xlim’
pXLim = varargin{i+1};
i = i + 2;
case ‘ylim’
pYLim = varargin{i+1};
i = i + 2;
case ‘zlim’
pZLim = varargin{i+1};
i = i + 2;
otherwise
if exist(varargin{i},’file’) == 2
objCount = objCount + 1;
else
error(‘file %s does not exist!’,varargin{i});
end
i = i + 1;
end
end;
% — object loader —
i = 1;
while i <= objCount
% — load data to tmp variable —
tmp = load(varargin{i});
% — add data to obj structure —
if size(tmp.pMatrix,1) < size(tmp.pMatrix,2)
obj(i).matrix = tmp.pMatrix’;
else
obj(i).matrix = tmp.pMatrix;
end;
obj(i).face = tmp.pFace;
obj(i).edge = tmp.pEdge;
obj(i).alpha = tmp.pAlpha;
obj(i).path = tmp.pPath;
obj(i).pathcolor = tmp.pPathColor;
obj(i).pathwidth = tmp.pPathWidth;
obj(i).scale = tmp.pScale;
% — add 3d model to the structure —
tmp = load(tmp.pModel);
obj(i).v(:,1) = -1 * obj(i).scale * tmp.V(:,1);
obj(i).v(:,2) = 1 * obj(i).scale * tmp.V(:,2);
obj(i).v(:,3) = 1 * obj(i).scale * tmp.V(:,3);
obj(i).f = tmp.F;
% — increment counter —
i = i + 1;
end;
% — check matrix sizes —
sizeCounter = 0;
maxLength = size(obj(1).matrix,1);
if objCount > 1
i = 2;
while i <= objCount
if size(obj(i).matrix,1) ~= maxLength
sizeCounter = sizeCounter + 1;
end;
i = i + 1;
end;
if sizeCounter > 0
warning(‘data array sizes are different!’);
warning(‘data cutted to the smallest matrix dimension’);
i = 1;
maxLength = 9e100;
while i <= objCount
if size(obj(i).matrix,1) < maxLength
maxLength = size(obj(i).matrix,1);
end
i = i + 1;
end;
end;
end
% — check step size —
if pStep >= maxLength
warning(‘step size is equal or greather than max length of data array!’);
warning(‘default step value used’);
pStep = 10;
end;
% — prepare display area —
fig = figure(1);
set(fig,…
‘Name’,’flypath3d’,…
‘NumberTitle’,’off’,…
‘MenuBar’,’none’,…
‘ToolBar’,’figure’,…
‘Pointer’,’crosshair’,…
‘Position’,[50 50 pWindow(1) pWindow(2)],…
‘Color’,pColor);
set(gca,…
‘FontName’,pFont,…
‘Color’,pColor,…
‘XColor’,pAxisColor,…
‘YColor’,pAxisColor,…
‘ZColor’,pAxisColor,…
‘FontSize’,pFontSize);
clf(fig);
hold on;
% — animate —
for i = 1:pStep:maxLength
% — prepare new frame for animation —
if strcmp(pAnimate,’on’) == 1
clf(fig);
hold on;
end;
set(gca,…
‘FontName’,pFont,…
‘Color’,pColor,…
‘XColor’,pAxisColor,…
‘YColor’,pAxisColor,…
‘ZColor’,pAxisColor,…
‘FontSize’,pFontSize);
% — draw scene —
for j = 1:1:objCount
theta = obj(j).matrix(i,4);
psi = obj(j).matrix(i,5) – pi/2;
phi = -1 * obj(j).matrix(i,6);
% — transformation matrix —
sinTheta = sin(theta);
cosTheta = cos(theta);
sinPsi = sin(psi);
cosPsi = cos(psi);
sinPhi = sin(phi);
cosPhi = cos(phi);
transformMatrix = [ …
cosPsi * cosTheta …
-sinPsi * cosTheta …
sinTheta; …
cosPsi * sinTheta * sinPhi + sinPsi * cosPhi …
-sinPsi * sinTheta * sinPhi + cosPsi * cosPhi …
-cosTheta * sinPhi; …
-cosPsi * sinTheta * cosPhi + sinPsi * sinPhi …
sinPsi * sinTheta * cosPhi + cosPsi * sinPhi …
cosTheta * cosPhi ];
vertices = obj(j).v * transformMatrix;
objectSet = [ obj(j).matrix(i,1) obj(j).matrix(i,2) obj(j).matrix(i,3) ];
delta = repmat( objectSet, size( vertices, 1 ), 1 );
vertices = vertices + delta;
objPath = patch( ‘faces’, obj(j).f, ‘vertices’, vertices );
set(objPath, …
‘FaceColor’,obj(j).face,…
‘FaceAlpha’,obj(j).alpha,…
‘EdgeColor’,obj(j).edge );
if strcmp(obj(j).path,’on’) == 1
plot3(obj(j).matrix(1:i,1),…
obj(j).matrix(1:i,2),…
obj(j).matrix(1:i,3),…
‘Color’, obj(j).pathcolor, …
‘LineWidth’, obj(j).pathwidth, …
‘LineStyle’, ‘-‘);
end;
end;
% — display parameters —
if strcmp(pXLim,’off’) ~= 1
xlim( pXLim );
end
if strcmp(pYLim,’off’) ~= 1
ylim( pYLim );
end
if strcmp(pZLim,’off’) ~= 1
zlim( pZLim );
end
xlabel(‘x [m]’);
ylabel(‘y [m]’);
zlabel(‘z [m]’);
if strcmp(pAxis,’on’) == 1
axis on;
axis square;
grid on;
else
axis off;
axis square;
grid off;
end;
lighting phong;
daspect([1 1 1]);
view( pView );
if strcmp(pAnimate,’on’) == 1
drawnow;
end;
% — save the results to the gif file —
if strcmp(pAnimate,’on’) == 1
if strcmp(pOutput,’none’) ~= 1
frame = getframe(1);
im = frame2im(frame);
[A,map] = rgb2ind(im,256);
if i == 1;
imwrite(A,map,pOutput,’gif’,’LoopCount’,Inf,’DelayTime’,.04);
else
imwrite(A,map,pOutput,’gif’,’WriteMode’,’append’,’DelayTime’,.04);
end;
end;
end;
end;
if strcmp(pAnimate,’off’) == 1
if strcmp(pOutput,’none’) ~= 1
switch(pDpi)
case 75
eval(sprintf(‘print -dpng -r75 %s;’, pOutput));
case 150
eval(sprintf(‘print -dpng -r150 %s;’, pOutput));
case 300
eval(sprintf(‘print -dpng -r300 %s;’, pOutput));
case 600
eval(sprintf(‘print -dpng -r600 %s;’, pOutput));
otherwise
eval(sprintf(‘print -dpng -r600 %s;’, pOutput));
end;
end;
end;
end**** Where I’m getting wrong please suggest me and I have given all .matfiles data . Where I’m getting issue I want 3d models animation But when I want to 3d models for animating they are not animating only plotting is animating .I don’t what’s the issue . Can you correct the code if it’s possible
Here is my .mat files data """>> load(‘enemy.mat’);
whos
Name Size Bytes Class Attributes
data_aam 1559×6 76947 table
data_enemy 2129×6 104305 table
end_idx 1×1 8 double
n_rows_aam 1×1 8 double
n_rows_enemy 1×1 8 double
n_steps 1×1 8 double
pAlpha 1×1 8 double
pEdge 1×3 24 double
pFace 1×3 24 double
pMatrix 1559×6 74832 double
pModel 1×8 16 char
pPath 1×2 4 char
pPathColor 1×3 24 double
pPathWidth 1×1 8 double
pScale 1×1 8 double
start_idx 1×1 8 double
trajectory_aam 1559×6 74832 double
trajectory_enemy 1559×6 74832 double
>> load(‘aam.mat’);
whos
Name Size Bytes Class Attributes
data_aam 1559×6 76947 table
data_enemy 2129×6 104305 table
end_idx 1×1 8 double
n_rows_aam 1×1 8 double
n_rows_enemy 1×1 8 double
n_steps 1×1 8 double
pAlpha 1×1 8 double
pEdge 1×3 24 double
pFace 1×3 24 double
pMatrix 1559×6 74832 double
pModel 1×11 22 char
pPath 1×2 4 char
pPathColor 1×3 24 double
pPathWidth 1×1 8 double
pScale 1×1 8 double
start_idx 1×1 8 double
trajectory_aam 1559×6 74832 double
trajectory_enemy 1559×6 74832 double
>> % Check the contents of f-16.mat
matFileF16 = load(‘f-16.mat’);
disp(matFileF16);
% Check the contents of missile.mat
matFileMissile = load(‘missile.mat’);
disp(matFileMissile);
V: [2537×3 double]
F: [4428×3 double]
C: [2537×1 double]
V: [3902×3 double]
F: [7426×3 double]
C: [3902×1 double]"""
*
# * bold*% Load and process the .txt files
data_enemy = readtable(‘target_2.txt’, ‘VariableNamingRule’, ‘preserve’); % Target data
data_aam = readtable(‘missile_2.txt’, ‘VariableNamingRule’, ‘preserve’); % Missile data
% Extract relevant columns: position (x, y, z) and angular data (phi, theta, psi)
trajectory_enemy = [data_enemy.tgtpos_x, data_enemy.tgt_pos_y, data_enemy.tgt_pos_z, …
data_enemy.tgt_phi, data_enemy.tgt_theta, data_enemy.tgt_psi];
% Time vector for the enemy (target) data
time_enemy = 1:size(trajectory_enemy, 1);
% Time vector for the missile data
time_aam = linspace(1, size(trajectory_enemy, 1), size(data_aam, 1));
% Interpolate missile data to match the target data size
trajectory_aam_interp = interp1(time_aam, [data_aam.Msl_pos_x, data_aam.Msl_pos_y, data_aam.Msl_pos_z, …
data_aam.Msl_phi, data_aam.Msl_theta, data_aam.Msl_psi], …
time_enemy);
% Verify data array sizes
disp(‘Size of target trajectory:’);
disp(size(trajectory_enemy));
disp(‘Size of interpolated missile trajectory:’);
disp(size(trajectory_aam_interp));
% Save interpolated data to .mat files for use in flypath
save(‘enemy_trajectory.mat’, ‘trajectory_enemy’);
save(‘aam_trajectory.mat’, ‘trajectory_aam_interp’);
% Create 3D models with appropriate scaling
new_object(‘enemy.mat’, trajectory_enemy, …
‘model’, ‘f-16.mat’, ‘edge’, [.4 .4 .4], ‘face’, [.6 .6 .6], …
‘path’, ‘on’, ‘pathcolor’, [.3 .3 .3], ‘pathwidth’, 1, ‘scale’, 0.0005);
new_object(‘aam.mat’, trajectory_aam_interp, …
‘model’, ‘missile.mat’, ‘edge’, [.2 .2 .2], ‘face’, [.3 .3 .3], …
‘path’, ‘on’, ‘pathcolor’, [.89 .47 .0], ‘pathwidth’, 1, ‘scale’, 0.0005);
disp(‘Checking dimensions of loaded matrices…’);
load(‘enemy.mat’);
disp(size(trajectory_enemy));
load(‘aam.mat’);
disp(size(trajectory_aam_interp));
flypath(‘enemy.mat’, ‘aam.mat’, …
‘animate’, ‘on’, ‘step’, 10, …
‘font’, ‘Arial’, ‘fontsize’, 12, …
‘view’, [45, 30], ‘window’, [800, 600], …
‘output’, ‘trajectory_animation.mp4’, …
‘xlim’, [-10000, 10000], …
‘ylim’, [-10000, 15000], …
‘zlim’, [-1500, 2000]);
Here is flypath function code *****%
% FLYPATH (flypath.m)
%
% Displays static and animated trajectories of missiles and air targets
%
% SYNTAX:
%
% flypath(object_1,object_2,…,object_n,varargin)
%
% PARAMETERS:
%
% object_x : object data set produced by ‘new_object’ function,
% use command ‘help new_object’ to get more information
%
% OPTIONAL ARGUMENTS:
%
% ‘animate’ : animation on/off (‘on’,’off’ – default ‘off’)
% ‘axis’ : axes visibility (‘on’,’off’ – default ‘on’)
% ‘axiscolor’ : axes and axes font color ([R G B] – default [0 0 0])
% ‘color’ : display area color ([R G B] – default [1 1 1])
% ‘dpi’ : dpi value (75,150,300,600 – default 150)
% ‘font’ : font name (string – default ‘Times New Roman’)
% ‘fontsize’ : font size (default 12)
% ‘output’ : output file name (string – default ‘none’)
% ‘step’ : model repetition density (default 10)
% ‘view’ : camera view angles ([azimuth elevation] – default [15 30])
% ‘window’ : display area size ([width height] – default [800 600])
% ‘xlim’ : x axes limits ([min max] or ‘off’ – default ‘off’)
% ‘ylim’ : y axes limits ([min max] or ‘off’ – default ‘off’)
% ‘zlim’ : x axes limits ([min max] or ‘off’ – default ‘off’)
%
% EXAMPLES OF USE:
%
% trajectory = load(‘trajectory_tbm.mat’);
% new_object(‘ballistic_missile.mat’,trajectory,…
% ‘model’,’scud.mat’,’scale’,5,…
% ‘path’,’on’,’pathcolor’,[.89 .0 .27]);
% flypath(‘ballistic_missile.mat’,…
% ‘animate’,’off’,’step’,30,…
% ‘axis’,’on’,’axiscolor’,[0 0 0],’color’,[1 1 1],…
% ‘font’,’Georgia’,’fontsize’,6,…
% ‘view’,[0 0],’window’,[1800 600],…
% ‘xlim’,[-2e4 16e4],’ylim’,[-10 10],’zlim’,[0 4e4],…
% ‘output’,’tbm_example.png’,’dpi’,600);
%
function flypath(varargin)
objCount = 0;
% — check input parameters —
if nargin < 1
error(‘Not enough input parameters!’);
end;
% — default input parameters —
pAnimate = ‘off’; % animation: ‘on’,’off’
pAxis = ‘on’; % axes visibility: ‘on’,’off’
pAxisColor = [ 0 0 0 ]; % axes and axes font color: [ R G B ]
pColor = [ 1 1 1 ]; % display area color: [ R G B ]
pDpi = 150; % dpi value: 75, 150, 300, 600
pFont = ‘Times New Roman’; % font name
pFontSize = 12; % font size
pOutput = ‘none’; % output filename or ‘none’
pStep = 10; % model repetition density
pView = [ 15 30 ]; % camera view angles: [ azimuth elevation ]
pWindow = [ 800 600 ]; % display area size (in pixels)
pXLim = ‘off’; % x axes limits ([min max] or ‘off’ – default ‘off’)
pYLim = ‘off’; % y axes limits ([min max] or ‘off’ – default ‘off’)
pZLim = ‘off’; % z axes limits ([min max] or ‘off’ – default ‘off’)
% — read input parameters —
i = 1;
while i <= length(varargin)
switch lower(varargin{i})
case ‘animate’
pAnimate = varargin{i+1};
i = i + 2;
case ‘axis’
pAxis = varargin{i+1};
i = i + 2;
case ‘axiscolor’
pAxisColor = varargin{i+1};
i = i + 2;
case ‘color’
pColor = varargin{i+1};
i = i + 2;
case ‘dpi’
pDpi = varargin{i+1};
i = i + 2;
case ‘font’
pFont = varargin{i+1};
i = i + 2;
case ‘fontsize’
pFontSize = varargin{i+1};
i = i + 2;
case ‘output’
pOutput = varargin{i+1};
i = i + 2;
case ‘step’
pStep = varargin{i+1};
i = i + 2;
case ‘view’
pView = varargin{i+1};
i = i + 2;
case ‘window’
pWindow = varargin{i+1};
i = i + 2;
case ‘xlim’
pXLim = varargin{i+1};
i = i + 2;
case ‘ylim’
pYLim = varargin{i+1};
i = i + 2;
case ‘zlim’
pZLim = varargin{i+1};
i = i + 2;
otherwise
if exist(varargin{i},’file’) == 2
objCount = objCount + 1;
else
error(‘file %s does not exist!’,varargin{i});
end
i = i + 1;
end
end;
% — object loader —
i = 1;
while i <= objCount
% — load data to tmp variable —
tmp = load(varargin{i});
% — add data to obj structure —
if size(tmp.pMatrix,1) < size(tmp.pMatrix,2)
obj(i).matrix = tmp.pMatrix’;
else
obj(i).matrix = tmp.pMatrix;
end;
obj(i).face = tmp.pFace;
obj(i).edge = tmp.pEdge;
obj(i).alpha = tmp.pAlpha;
obj(i).path = tmp.pPath;
obj(i).pathcolor = tmp.pPathColor;
obj(i).pathwidth = tmp.pPathWidth;
obj(i).scale = tmp.pScale;
% — add 3d model to the structure —
tmp = load(tmp.pModel);
obj(i).v(:,1) = -1 * obj(i).scale * tmp.V(:,1);
obj(i).v(:,2) = 1 * obj(i).scale * tmp.V(:,2);
obj(i).v(:,3) = 1 * obj(i).scale * tmp.V(:,3);
obj(i).f = tmp.F;
% — increment counter —
i = i + 1;
end;
% — check matrix sizes —
sizeCounter = 0;
maxLength = size(obj(1).matrix,1);
if objCount > 1
i = 2;
while i <= objCount
if size(obj(i).matrix,1) ~= maxLength
sizeCounter = sizeCounter + 1;
end;
i = i + 1;
end;
if sizeCounter > 0
warning(‘data array sizes are different!’);
warning(‘data cutted to the smallest matrix dimension’);
i = 1;
maxLength = 9e100;
while i <= objCount
if size(obj(i).matrix,1) < maxLength
maxLength = size(obj(i).matrix,1);
end
i = i + 1;
end;
end;
end
% — check step size —
if pStep >= maxLength
warning(‘step size is equal or greather than max length of data array!’);
warning(‘default step value used’);
pStep = 10;
end;
% — prepare display area —
fig = figure(1);
set(fig,…
‘Name’,’flypath3d’,…
‘NumberTitle’,’off’,…
‘MenuBar’,’none’,…
‘ToolBar’,’figure’,…
‘Pointer’,’crosshair’,…
‘Position’,[50 50 pWindow(1) pWindow(2)],…
‘Color’,pColor);
set(gca,…
‘FontName’,pFont,…
‘Color’,pColor,…
‘XColor’,pAxisColor,…
‘YColor’,pAxisColor,…
‘ZColor’,pAxisColor,…
‘FontSize’,pFontSize);
clf(fig);
hold on;
% — animate —
for i = 1:pStep:maxLength
% — prepare new frame for animation —
if strcmp(pAnimate,’on’) == 1
clf(fig);
hold on;
end;
set(gca,…
‘FontName’,pFont,…
‘Color’,pColor,…
‘XColor’,pAxisColor,…
‘YColor’,pAxisColor,…
‘ZColor’,pAxisColor,…
‘FontSize’,pFontSize);
% — draw scene —
for j = 1:1:objCount
theta = obj(j).matrix(i,4);
psi = obj(j).matrix(i,5) – pi/2;
phi = -1 * obj(j).matrix(i,6);
% — transformation matrix —
sinTheta = sin(theta);
cosTheta = cos(theta);
sinPsi = sin(psi);
cosPsi = cos(psi);
sinPhi = sin(phi);
cosPhi = cos(phi);
transformMatrix = [ …
cosPsi * cosTheta …
-sinPsi * cosTheta …
sinTheta; …
cosPsi * sinTheta * sinPhi + sinPsi * cosPhi …
-sinPsi * sinTheta * sinPhi + cosPsi * cosPhi …
-cosTheta * sinPhi; …
-cosPsi * sinTheta * cosPhi + sinPsi * sinPhi …
sinPsi * sinTheta * cosPhi + cosPsi * sinPhi …
cosTheta * cosPhi ];
vertices = obj(j).v * transformMatrix;
objectSet = [ obj(j).matrix(i,1) obj(j).matrix(i,2) obj(j).matrix(i,3) ];
delta = repmat( objectSet, size( vertices, 1 ), 1 );
vertices = vertices + delta;
objPath = patch( ‘faces’, obj(j).f, ‘vertices’, vertices );
set(objPath, …
‘FaceColor’,obj(j).face,…
‘FaceAlpha’,obj(j).alpha,…
‘EdgeColor’,obj(j).edge );
if strcmp(obj(j).path,’on’) == 1
plot3(obj(j).matrix(1:i,1),…
obj(j).matrix(1:i,2),…
obj(j).matrix(1:i,3),…
‘Color’, obj(j).pathcolor, …
‘LineWidth’, obj(j).pathwidth, …
‘LineStyle’, ‘-‘);
end;
end;
% — display parameters —
if strcmp(pXLim,’off’) ~= 1
xlim( pXLim );
end
if strcmp(pYLim,’off’) ~= 1
ylim( pYLim );
end
if strcmp(pZLim,’off’) ~= 1
zlim( pZLim );
end
xlabel(‘x [m]’);
ylabel(‘y [m]’);
zlabel(‘z [m]’);
if strcmp(pAxis,’on’) == 1
axis on;
axis square;
grid on;
else
axis off;
axis square;
grid off;
end;
lighting phong;
daspect([1 1 1]);
view( pView );
if strcmp(pAnimate,’on’) == 1
drawnow;
end;
% — save the results to the gif file —
if strcmp(pAnimate,’on’) == 1
if strcmp(pOutput,’none’) ~= 1
frame = getframe(1);
im = frame2im(frame);
[A,map] = rgb2ind(im,256);
if i == 1;
imwrite(A,map,pOutput,’gif’,’LoopCount’,Inf,’DelayTime’,.04);
else
imwrite(A,map,pOutput,’gif’,’WriteMode’,’append’,’DelayTime’,.04);
end;
end;
end;
end;
if strcmp(pAnimate,’off’) == 1
if strcmp(pOutput,’none’) ~= 1
switch(pDpi)
case 75
eval(sprintf(‘print -dpng -r75 %s;’, pOutput));
case 150
eval(sprintf(‘print -dpng -r150 %s;’, pOutput));
case 300
eval(sprintf(‘print -dpng -r300 %s;’, pOutput));
case 600
eval(sprintf(‘print -dpng -r600 %s;’, pOutput));
otherwise
eval(sprintf(‘print -dpng -r600 %s;’, pOutput));
end;
end;
end;
end**** Where I’m getting wrong please suggest me and I have given all .matfiles data . Where I’m getting issue I want 3d models animation @matlab MATLAB Answers — New Questions
Click disp() in the Icon Drawing Commands palette to add the command to the editable region.
Open the Mask Editor dialog and navigate to the Icon tab.
Click disp() in the Icon Drawing Commands palette to add the command to the editable region.
Replace the sample text with the variable from the previous task, label.
In the Property Editor at right, Change Run initialization to On.
Save the mask.Open the Mask Editor dialog and navigate to the Icon tab.
Click disp() in the Icon Drawing Commands palette to add the command to the editable region.
Replace the sample text with the variable from the previous task, label.
In the Property Editor at right, Change Run initialization to On.
Save the mask. Open the Mask Editor dialog and navigate to the Icon tab.
Click disp() in the Icon Drawing Commands palette to add the command to the editable region.
Replace the sample text with the variable from the previous task, label.
In the Property Editor at right, Change Run initialization to On.
Save the mask. display MATLAB Answers — New Questions
Rejected stereo image pairs in Stereo Camera Calibrator App
Hello all,
I’m trying to use the “Stereo Camera Calibrator App”.
I’m trying to import four pairs of images, but it only accepts one pair and rejects the other three. I followed the advice from the camera preparation page, but it didn’t do any good. I have no clue why it rejects most of the image pairs.
Please see the attached four images of each camera (left and right). The checkerboard size is 3 mm.
Thank you.Hello all,
I’m trying to use the “Stereo Camera Calibrator App”.
I’m trying to import four pairs of images, but it only accepts one pair and rejects the other three. I followed the advice from the camera preparation page, but it didn’t do any good. I have no clue why it rejects most of the image pairs.
Please see the attached four images of each camera (left and right). The checkerboard size is 3 mm.
Thank you. Hello all,
I’m trying to use the “Stereo Camera Calibrator App”.
I’m trying to import four pairs of images, but it only accepts one pair and rejects the other three. I followed the advice from the camera preparation page, but it didn’t do any good. I have no clue why it rejects most of the image pairs.
Please see the attached four images of each camera (left and right). The checkerboard size is 3 mm.
Thank you. image processing, stereo camera calibrator app MATLAB Answers — New Questions
Calculate the normal vector between two nodes in the space
Hi! I have two nodes A and B. These are positioned in space with the same value of X and Y but different Z. The normal in this case would be n=[0 0 1] (red plane parallel to the XY plane).
I would like to calculate the normal n ‘green’ in the case of nodes A and C. Is this possible?
A = [-33.24 -10.70 7.41];
B = [A(1,1), A(1,2), A(1,3)+5];
N = [A;B];
C = [A(1,1), A(1,2)+7, A(1,3)+5];
NN = [A;C];
figure
plot3(A(1,1),A(1,2),A(1,3),’k.’,’Markersize’,30);
hold on
plot3(B(1,1),B(1,2),B(1,3),’r.’,’Markersize’,30);
plot3(C(1,1),C(1,2),C(1,3),’g.’,’Markersize’,30);
plot3(N(:,1),N(:,2),N(:,3),’-k’,’LineWidth’,1);
plot3(NN(:,1),NN(:,2),NN(:,3),’-k’,’LineWidth’,1);
hold off
axis equal
(YZ view)Hi! I have two nodes A and B. These are positioned in space with the same value of X and Y but different Z. The normal in this case would be n=[0 0 1] (red plane parallel to the XY plane).
I would like to calculate the normal n ‘green’ in the case of nodes A and C. Is this possible?
A = [-33.24 -10.70 7.41];
B = [A(1,1), A(1,2), A(1,3)+5];
N = [A;B];
C = [A(1,1), A(1,2)+7, A(1,3)+5];
NN = [A;C];
figure
plot3(A(1,1),A(1,2),A(1,3),’k.’,’Markersize’,30);
hold on
plot3(B(1,1),B(1,2),B(1,3),’r.’,’Markersize’,30);
plot3(C(1,1),C(1,2),C(1,3),’g.’,’Markersize’,30);
plot3(N(:,1),N(:,2),N(:,3),’-k’,’LineWidth’,1);
plot3(NN(:,1),NN(:,2),NN(:,3),’-k’,’LineWidth’,1);
hold off
axis equal
(YZ view) Hi! I have two nodes A and B. These are positioned in space with the same value of X and Y but different Z. The normal in this case would be n=[0 0 1] (red plane parallel to the XY plane).
I would like to calculate the normal n ‘green’ in the case of nodes A and C. Is this possible?
A = [-33.24 -10.70 7.41];
B = [A(1,1), A(1,2), A(1,3)+5];
N = [A;B];
C = [A(1,1), A(1,2)+7, A(1,3)+5];
NN = [A;C];
figure
plot3(A(1,1),A(1,2),A(1,3),’k.’,’Markersize’,30);
hold on
plot3(B(1,1),B(1,2),B(1,3),’r.’,’Markersize’,30);
plot3(C(1,1),C(1,2),C(1,3),’g.’,’Markersize’,30);
plot3(N(:,1),N(:,2),N(:,3),’-k’,’LineWidth’,1);
plot3(NN(:,1),NN(:,2),NN(:,3),’-k’,’LineWidth’,1);
hold off
axis equal
(YZ view) normal, vector MATLAB Answers — New Questions
my Simcape Electrical model does not want to wire the reference (earth ) block
As you see below the reference block desnot want to connect to the volatge source or any other block. I am using MATLAB R2023b academic version. Can someone give me a clue what I have to look atAs you see below the reference block desnot want to connect to the volatge source or any other block. I am using MATLAB R2023b academic version. Can someone give me a clue what I have to look at As you see below the reference block desnot want to connect to the volatge source or any other block. I am using MATLAB R2023b academic version. Can someone give me a clue what I have to look at r2023b MATLAB Answers — New Questions
libstdc++.so.6: version `GLIBCXX_3.4.29′ not found
When I run the MATLAB on my arch linux computer, I met the following issue. I am using R2021b, it works fine on this arch linux computer before. This problems happens when I change the font of matlab and reboot.
MATLAB is selecting SOFTWARE OPENGL rendering.
MESA-LOADER: failed to open radeonsi: /home/deck/matlab/bin/glnxa64/../../sys/os/g
lnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/dr
i/radeonsi_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load driver: radeonsi
MESA-LOADER: failed to open kms_swrast: /home/deck/matlab/bin/glnxa64/../../sys/os
/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/
dri/kms_swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: /home/deck/matlab/bin/glnxa64/../../sys/os/gln
xa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/dri/
swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load swrast driver
Gtk-Message: 00:00:13.007: Failed to load module "canberra-gtk-module"When I run the MATLAB on my arch linux computer, I met the following issue. I am using R2021b, it works fine on this arch linux computer before. This problems happens when I change the font of matlab and reboot.
MATLAB is selecting SOFTWARE OPENGL rendering.
MESA-LOADER: failed to open radeonsi: /home/deck/matlab/bin/glnxa64/../../sys/os/g
lnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/dr
i/radeonsi_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load driver: radeonsi
MESA-LOADER: failed to open kms_swrast: /home/deck/matlab/bin/glnxa64/../../sys/os
/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/
dri/kms_swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: /home/deck/matlab/bin/glnxa64/../../sys/os/gln
xa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/dri/
swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load swrast driver
Gtk-Message: 00:00:13.007: Failed to load module "canberra-gtk-module" When I run the MATLAB on my arch linux computer, I met the following issue. I am using R2021b, it works fine on this arch linux computer before. This problems happens when I change the font of matlab and reboot.
MATLAB is selecting SOFTWARE OPENGL rendering.
MESA-LOADER: failed to open radeonsi: /home/deck/matlab/bin/glnxa64/../../sys/os/g
lnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/dr
i/radeonsi_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load driver: radeonsi
MESA-LOADER: failed to open kms_swrast: /home/deck/matlab/bin/glnxa64/../../sys/os
/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/
dri/kms_swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: /home/deck/matlab/bin/glnxa64/../../sys/os/gln
xa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /usr/lib/dri/
swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)
failed to load swrast driver
Gtk-Message: 00:00:13.007: Failed to load module "canberra-gtk-module" installation, linux MATLAB Answers — New Questions
How to enable “Snap to Tick” for a slider in App Designer?
Hi, I want to know how to make a slider move discretely rather than continuously. As an example, I want the slider to jump from 1 to 2 when I move it. In other words, I need to enable the "Snap to Tick" feature.
Thanks in advance.Hi, I want to know how to make a slider move discretely rather than continuously. As an example, I want the slider to jump from 1 to 2 when I move it. In other words, I need to enable the "Snap to Tick" feature.
Thanks in advance. Hi, I want to know how to make a slider move discretely rather than continuously. As an example, I want the slider to jump from 1 to 2 when I move it. In other words, I need to enable the "Snap to Tick" feature.
Thanks in advance. app designer, snap to tick, slider MATLAB Answers — New Questions
bifurcation for Fractional order
I need an example matlab code to draw a bifurcation diagram for a fractional orde system. (for parametre varying or FO q varying, as seen in figures)
I’ve done some research on the subject and found The code by @Marius-F. Danca (2023) can be found at this File Exchange link:
Matlab code for FO logistic map, MATLAB Central File Exchange. Retrieved October 24, 2023.
However, I can’t plot the bifurcation diagram for the FO case.
code for the graphical representation of the bifurcation proposed by Sam Chak
interval = [2.8 4.0];
accuracy = 0.001;
reps = 100; % number of repetitions
numtoplot = 50;
initidx = reps – (numtoplot – 1);
for r = interval(1):accuracy:interval(2)
x = 0.4;
xo = x;
for n = 2:reps
xn = r*xo*(1 – xo);
x = [x xn];
xo = xn;
end
plot(r*ones(numtoplot), x(initidx:reps), ‘.’, ‘MarkerSize’, 1, ‘Color’, ‘#be4d25’),
hold on
end
hold off
xlim([2.8 4])
title(‘Logistic Map’)
xlabel(‘itr’, ‘FontSize’, 14)
ylabel(‘itx’, ‘FontSize’, 14)
However, the fractional order need a workaround, i fond the code by @Marius-F. Danca
but I don’t know how it works, Can anyone kindly share *.m file
function [u]=FO_discrete(q,p,u0,n_max)
% Author: Marius-F. Danca 2021
u=zeros(n_max,1); % memory alocation
u(1)=u0+f(u0); % u(1) outside of the loops
for n=2:n_max; % $u(2),u(3),…,n(n_max)$
s=exp(gammaln(n-1+q)-gammaln(n))*f(u0);
for j=2:n;
s=s+exp(gammaln(n-j+q)-gammaln(n-j+1))*f(u(j-1));
end
u(n)=u0+s/gamma(q);
end
function ff=f(x); % logistic map
ff=p*x*(1-x);
end
endI need an example matlab code to draw a bifurcation diagram for a fractional orde system. (for parametre varying or FO q varying, as seen in figures)
I’ve done some research on the subject and found The code by @Marius-F. Danca (2023) can be found at this File Exchange link:
Matlab code for FO logistic map, MATLAB Central File Exchange. Retrieved October 24, 2023.
However, I can’t plot the bifurcation diagram for the FO case.
code for the graphical representation of the bifurcation proposed by Sam Chak
interval = [2.8 4.0];
accuracy = 0.001;
reps = 100; % number of repetitions
numtoplot = 50;
initidx = reps – (numtoplot – 1);
for r = interval(1):accuracy:interval(2)
x = 0.4;
xo = x;
for n = 2:reps
xn = r*xo*(1 – xo);
x = [x xn];
xo = xn;
end
plot(r*ones(numtoplot), x(initidx:reps), ‘.’, ‘MarkerSize’, 1, ‘Color’, ‘#be4d25’),
hold on
end
hold off
xlim([2.8 4])
title(‘Logistic Map’)
xlabel(‘itr’, ‘FontSize’, 14)
ylabel(‘itx’, ‘FontSize’, 14)
However, the fractional order need a workaround, i fond the code by @Marius-F. Danca
but I don’t know how it works, Can anyone kindly share *.m file
function [u]=FO_discrete(q,p,u0,n_max)
% Author: Marius-F. Danca 2021
u=zeros(n_max,1); % memory alocation
u(1)=u0+f(u0); % u(1) outside of the loops
for n=2:n_max; % $u(2),u(3),…,n(n_max)$
s=exp(gammaln(n-1+q)-gammaln(n))*f(u0);
for j=2:n;
s=s+exp(gammaln(n-j+q)-gammaln(n-j+1))*f(u(j-1));
end
u(n)=u0+s/gamma(q);
end
function ff=f(x); % logistic map
ff=p*x*(1-x);
end
end I need an example matlab code to draw a bifurcation diagram for a fractional orde system. (for parametre varying or FO q varying, as seen in figures)
I’ve done some research on the subject and found The code by @Marius-F. Danca (2023) can be found at this File Exchange link:
Matlab code for FO logistic map, MATLAB Central File Exchange. Retrieved October 24, 2023.
However, I can’t plot the bifurcation diagram for the FO case.
code for the graphical representation of the bifurcation proposed by Sam Chak
interval = [2.8 4.0];
accuracy = 0.001;
reps = 100; % number of repetitions
numtoplot = 50;
initidx = reps – (numtoplot – 1);
for r = interval(1):accuracy:interval(2)
x = 0.4;
xo = x;
for n = 2:reps
xn = r*xo*(1 – xo);
x = [x xn];
xo = xn;
end
plot(r*ones(numtoplot), x(initidx:reps), ‘.’, ‘MarkerSize’, 1, ‘Color’, ‘#be4d25’),
hold on
end
hold off
xlim([2.8 4])
title(‘Logistic Map’)
xlabel(‘itr’, ‘FontSize’, 14)
ylabel(‘itx’, ‘FontSize’, 14)
However, the fractional order need a workaround, i fond the code by @Marius-F. Danca
but I don’t know how it works, Can anyone kindly share *.m file
function [u]=FO_discrete(q,p,u0,n_max)
% Author: Marius-F. Danca 2021
u=zeros(n_max,1); % memory alocation
u(1)=u0+f(u0); % u(1) outside of the loops
for n=2:n_max; % $u(2),u(3),…,n(n_max)$
s=exp(gammaln(n-1+q)-gammaln(n))*f(u0);
for j=2:n;
s=s+exp(gammaln(n-j+q)-gammaln(n-j+1))*f(u(j-1));
end
u(n)=u0+s/gamma(q);
end
function ff=f(x); % logistic map
ff=p*x*(1-x);
end
end mar MATLAB Answers — New Questions
How can i print at app designer on a Text Area box, text with hyperlinks?
Hi,
How can i print in Text area box (with app designer), hyperlinks for files that located in local PC?
when im using the sprintf function rom conslue window i can see the print with hypelink, for example:
sprintf(‘<a href="matlab: winopen(”%s”)">%s</a>nn’, filepath, CurrentFileName),
but when im trying to print the same inside the text area its printing me the whole string:
How can i print hyperlink inside the text area?Hi,
How can i print in Text area box (with app designer), hyperlinks for files that located in local PC?
when im using the sprintf function rom conslue window i can see the print with hypelink, for example:
sprintf(‘<a href="matlab: winopen(”%s”)">%s</a>nn’, filepath, CurrentFileName),
but when im trying to print the same inside the text area its printing me the whole string:
How can i print hyperlink inside the text area? Hi,
How can i print in Text area box (with app designer), hyperlinks for files that located in local PC?
when im using the sprintf function rom conslue window i can see the print with hypelink, for example:
sprintf(‘<a href="matlab: winopen(”%s”)">%s</a>nn’, filepath, CurrentFileName),
but when im trying to print the same inside the text area its printing me the whole string:
How can i print hyperlink inside the text area? appdesigner, hyperlink MATLAB Answers — New Questions
Live Script opening in new window please help
When I open a new live script it opens it in a new window instead of splitting the screen in half vertically! Its drivng me crazy but I cant figure out what option in the toolbar editer it is.When I open a new live script it opens it in a new window instead of splitting the screen in half vertically! Its drivng me crazy but I cant figure out what option in the toolbar editer it is. When I open a new live script it opens it in a new window instead of splitting the screen in half vertically! Its drivng me crazy but I cant figure out what option in the toolbar editer it is. workspace layout MATLAB Answers — New Questions
how to azimuthally average a N*N data ?
I have a 291*291 velocity data from LES . I want to azimuthally average the data so that for any angle from the origin at a particular radial distance i get the same value of velocity.
please suggest the way to do it.
Following figure shows the pictorial reperesentation of velocity data in yz plane
here is the attached file for the dataI have a 291*291 velocity data from LES . I want to azimuthally average the data so that for any angle from the origin at a particular radial distance i get the same value of velocity.
please suggest the way to do it.
Following figure shows the pictorial reperesentation of velocity data in yz plane
here is the attached file for the data I have a 291*291 velocity data from LES . I want to azimuthally average the data so that for any angle from the origin at a particular radial distance i get the same value of velocity.
please suggest the way to do it.
Following figure shows the pictorial reperesentation of velocity data in yz plane
here is the attached file for the data azimuthally-average data MATLAB Answers — New Questions
How matlab reads ansys files
I used ansys_aas toolbox to link between ansys workbench and matlab but i’m confused of how can the matlab reads the chart in ansys and make optimization to get minimum error between desired and actual curvesI used ansys_aas toolbox to link between ansys workbench and matlab but i’m confused of how can the matlab reads the chart in ansys and make optimization to get minimum error between desired and actual curves I used ansys_aas toolbox to link between ansys workbench and matlab but i’m confused of how can the matlab reads the chart in ansys and make optimization to get minimum error between desired and actual curves ansys workbench, matlab MATLAB Answers — New Questions
problem with loops and conditional statements
I am writing a simple program with if loop inside a for loop but the program gets stopped in middle with error:
Index exceeds the number of array elements. Index must not exceed 1.
Error in newtrial (line 19)
Y(i) = Y(i) + 1;
and the plot is not generated as well even for values generated.
the code is:
clc
clear
x1 = 5
y1 = 3
x0 = 0
y0 = 0
dx = x1-x0
dy = y1-y0
e = dy-dx
X = x0
Y = y0
for i = 1:1:5;
X(i+1) = X(i) + 1
if e(i) >= 0
Y(i+1) = Y(i) + 1;
e(i+1) = e(i) – dx;
else
e(i+1) = e(i) + dy;
end
end
Y
plot(X,Y,’bo’)
axis([0 6 0 6])
I am new to this, so any help or correction in code is appreciated, thanks in advance.I am writing a simple program with if loop inside a for loop but the program gets stopped in middle with error:
Index exceeds the number of array elements. Index must not exceed 1.
Error in newtrial (line 19)
Y(i) = Y(i) + 1;
and the plot is not generated as well even for values generated.
the code is:
clc
clear
x1 = 5
y1 = 3
x0 = 0
y0 = 0
dx = x1-x0
dy = y1-y0
e = dy-dx
X = x0
Y = y0
for i = 1:1:5;
X(i+1) = X(i) + 1
if e(i) >= 0
Y(i+1) = Y(i) + 1;
e(i+1) = e(i) – dx;
else
e(i+1) = e(i) + dy;
end
end
Y
plot(X,Y,’bo’)
axis([0 6 0 6])
I am new to this, so any help or correction in code is appreciated, thanks in advance. I am writing a simple program with if loop inside a for loop but the program gets stopped in middle with error:
Index exceeds the number of array elements. Index must not exceed 1.
Error in newtrial (line 19)
Y(i) = Y(i) + 1;
and the plot is not generated as well even for values generated.
the code is:
clc
clear
x1 = 5
y1 = 3
x0 = 0
y0 = 0
dx = x1-x0
dy = y1-y0
e = dy-dx
X = x0
Y = y0
for i = 1:1:5;
X(i+1) = X(i) + 1
if e(i) >= 0
Y(i+1) = Y(i) + 1;
e(i+1) = e(i) – dx;
else
e(i+1) = e(i) + dy;
end
end
Y
plot(X,Y,’bo’)
axis([0 6 0 6])
I am new to this, so any help or correction in code is appreciated, thanks in advance. index error, loops MATLAB Answers — New Questions
Processing EMG data in MATLAB?
Hi all,
I am VERY new to MATLAB, so please excuse my ignorance if this is a very novice problem. I am analysing EMG signals, I have imported from my data from xlsx as time (X) and voltage (y).
After extracting data;
set(0, ‘defaultFigureToolbar’, ‘none’)
% RAW_DATA_EXTRACTION
%% BACK_SQUAT
%%% VISIT_ONE
T1_10rm_BS_1 = xlsread(‘T1_70%_10rm_BS_1.xlsx’,’Sheet3′,’A5:E77494′);
time = T1_10rm_BS_1(:,1);
BS_RF_1 = T1_10rm_BS_1(:,4);
BS_BF_1 = T1_10rm_BS_1(:,5);
T1_10rm_BS_2 = xlsread(‘T1_70%_10rm_BS_2.xlsx’, ‘Sheet4′,’A5:E78394’);
time = T1_10rm_BS_2(:,1);
BS_RF_2 = T1_10rm_BS_2(:,4);
BS_BF_2 = T1_10rm_BS_2(:,5);
running filters;
%FILTER
% Lowpass filter 500Hz
Freq = 1500;
NyqFreq = Freq/2;
Lowpass = 500;
Wn = Lowpass/NyqFreq;
[B,A] = butter (4,Wn,’low’);
% run filter
BS_RF_1_low_filtered = filtfilt(B,A,BS_RF_1);
BS_BF_1_low_filtered = filtfilt(B,A,BS_BF_1);
BS_RF_2_low_filtered = filtfilt(B,A,BS_RF_2);
BS_BF_2_low_filtered = filtfilt(B,A,BS_BF_2);
% Highpass filter 10Hz
Highpass = 10;
Wo = Highpass/NyqFreq;
[D,C] = butter (4,Wo,’high’);
% run filter
high_pass_BS_RF_1_filtdata = filtfilt(D,C,BS_RF_1_low_filtered);
high_pass_BS_BF_1_filtdata = filtfilt(D,C,BS_BF_1_low_filtered);
high_pass_BS_RF_2_filtdata = filtfilt(D,C,BS_RF_2_low_filtered);
high_pass_BS_BF_2_filtdata = filtfilt(D,C,BS_BF_2_low_filtered);
% Full wave rectification of EMG
filtered_BS_RF_1 = abs(high_pass_BS_RF_1_filtdata);
filtered_BS_BF_1 = abs(high_pass_BS_BF_1_filtdata);
filtered_BS_RF_2 = abs(high_pass_BS_RF_2_filtdata);
filtered_BS_BF_2 = abs(high_pass_BS_BF_2_filtdata);
% Linear envelope (2Hz lowpass)
LP = 2;
Wp = LP/NyqFreq;
[F,E] = butter (4,Wp,’low’);
linear_BS_RF_1 = filtfilt(F,E,filtered_BS_RF_1);
linear_BS_BF_1 = filtfilt(F,E,filtered_BS_BF_1);
linear_BS_RF_2 = filtfilt(F,E,filtered_BS_RF_2);
linear_BS_BF_2 = filtfilt(F,E,filtered_BS_BF_2);
and generating my plot (for BS_RF_1);
I am now struggling to try and find the area under the curve for my set of 10 repetitions.
I am looking to define mean activation and peak activation.
All constructive help welcome,
Cheers.Hi all,
I am VERY new to MATLAB, so please excuse my ignorance if this is a very novice problem. I am analysing EMG signals, I have imported from my data from xlsx as time (X) and voltage (y).
After extracting data;
set(0, ‘defaultFigureToolbar’, ‘none’)
% RAW_DATA_EXTRACTION
%% BACK_SQUAT
%%% VISIT_ONE
T1_10rm_BS_1 = xlsread(‘T1_70%_10rm_BS_1.xlsx’,’Sheet3′,’A5:E77494′);
time = T1_10rm_BS_1(:,1);
BS_RF_1 = T1_10rm_BS_1(:,4);
BS_BF_1 = T1_10rm_BS_1(:,5);
T1_10rm_BS_2 = xlsread(‘T1_70%_10rm_BS_2.xlsx’, ‘Sheet4′,’A5:E78394’);
time = T1_10rm_BS_2(:,1);
BS_RF_2 = T1_10rm_BS_2(:,4);
BS_BF_2 = T1_10rm_BS_2(:,5);
running filters;
%FILTER
% Lowpass filter 500Hz
Freq = 1500;
NyqFreq = Freq/2;
Lowpass = 500;
Wn = Lowpass/NyqFreq;
[B,A] = butter (4,Wn,’low’);
% run filter
BS_RF_1_low_filtered = filtfilt(B,A,BS_RF_1);
BS_BF_1_low_filtered = filtfilt(B,A,BS_BF_1);
BS_RF_2_low_filtered = filtfilt(B,A,BS_RF_2);
BS_BF_2_low_filtered = filtfilt(B,A,BS_BF_2);
% Highpass filter 10Hz
Highpass = 10;
Wo = Highpass/NyqFreq;
[D,C] = butter (4,Wo,’high’);
% run filter
high_pass_BS_RF_1_filtdata = filtfilt(D,C,BS_RF_1_low_filtered);
high_pass_BS_BF_1_filtdata = filtfilt(D,C,BS_BF_1_low_filtered);
high_pass_BS_RF_2_filtdata = filtfilt(D,C,BS_RF_2_low_filtered);
high_pass_BS_BF_2_filtdata = filtfilt(D,C,BS_BF_2_low_filtered);
% Full wave rectification of EMG
filtered_BS_RF_1 = abs(high_pass_BS_RF_1_filtdata);
filtered_BS_BF_1 = abs(high_pass_BS_BF_1_filtdata);
filtered_BS_RF_2 = abs(high_pass_BS_RF_2_filtdata);
filtered_BS_BF_2 = abs(high_pass_BS_BF_2_filtdata);
% Linear envelope (2Hz lowpass)
LP = 2;
Wp = LP/NyqFreq;
[F,E] = butter (4,Wp,’low’);
linear_BS_RF_1 = filtfilt(F,E,filtered_BS_RF_1);
linear_BS_BF_1 = filtfilt(F,E,filtered_BS_BF_1);
linear_BS_RF_2 = filtfilt(F,E,filtered_BS_RF_2);
linear_BS_BF_2 = filtfilt(F,E,filtered_BS_BF_2);
and generating my plot (for BS_RF_1);
I am now struggling to try and find the area under the curve for my set of 10 repetitions.
I am looking to define mean activation and peak activation.
All constructive help welcome,
Cheers. Hi all,
I am VERY new to MATLAB, so please excuse my ignorance if this is a very novice problem. I am analysing EMG signals, I have imported from my data from xlsx as time (X) and voltage (y).
After extracting data;
set(0, ‘defaultFigureToolbar’, ‘none’)
% RAW_DATA_EXTRACTION
%% BACK_SQUAT
%%% VISIT_ONE
T1_10rm_BS_1 = xlsread(‘T1_70%_10rm_BS_1.xlsx’,’Sheet3′,’A5:E77494′);
time = T1_10rm_BS_1(:,1);
BS_RF_1 = T1_10rm_BS_1(:,4);
BS_BF_1 = T1_10rm_BS_1(:,5);
T1_10rm_BS_2 = xlsread(‘T1_70%_10rm_BS_2.xlsx’, ‘Sheet4′,’A5:E78394’);
time = T1_10rm_BS_2(:,1);
BS_RF_2 = T1_10rm_BS_2(:,4);
BS_BF_2 = T1_10rm_BS_2(:,5);
running filters;
%FILTER
% Lowpass filter 500Hz
Freq = 1500;
NyqFreq = Freq/2;
Lowpass = 500;
Wn = Lowpass/NyqFreq;
[B,A] = butter (4,Wn,’low’);
% run filter
BS_RF_1_low_filtered = filtfilt(B,A,BS_RF_1);
BS_BF_1_low_filtered = filtfilt(B,A,BS_BF_1);
BS_RF_2_low_filtered = filtfilt(B,A,BS_RF_2);
BS_BF_2_low_filtered = filtfilt(B,A,BS_BF_2);
% Highpass filter 10Hz
Highpass = 10;
Wo = Highpass/NyqFreq;
[D,C] = butter (4,Wo,’high’);
% run filter
high_pass_BS_RF_1_filtdata = filtfilt(D,C,BS_RF_1_low_filtered);
high_pass_BS_BF_1_filtdata = filtfilt(D,C,BS_BF_1_low_filtered);
high_pass_BS_RF_2_filtdata = filtfilt(D,C,BS_RF_2_low_filtered);
high_pass_BS_BF_2_filtdata = filtfilt(D,C,BS_BF_2_low_filtered);
% Full wave rectification of EMG
filtered_BS_RF_1 = abs(high_pass_BS_RF_1_filtdata);
filtered_BS_BF_1 = abs(high_pass_BS_BF_1_filtdata);
filtered_BS_RF_2 = abs(high_pass_BS_RF_2_filtdata);
filtered_BS_BF_2 = abs(high_pass_BS_BF_2_filtdata);
% Linear envelope (2Hz lowpass)
LP = 2;
Wp = LP/NyqFreq;
[F,E] = butter (4,Wp,’low’);
linear_BS_RF_1 = filtfilt(F,E,filtered_BS_RF_1);
linear_BS_BF_1 = filtfilt(F,E,filtered_BS_BF_1);
linear_BS_RF_2 = filtfilt(F,E,filtered_BS_RF_2);
linear_BS_BF_2 = filtfilt(F,E,filtered_BS_BF_2);
and generating my plot (for BS_RF_1);
I am now struggling to try and find the area under the curve for my set of 10 repetitions.
I am looking to define mean activation and peak activation.
All constructive help welcome,
Cheers. onset, offset, emg, novice MATLAB Answers — New Questions
How to draw a semi-circular heat map?(怎么画半圆形的热力图)
How to draw such a heatmap, should I use ‘polaroplot’ or ‘colormap’?
怎么画出这样的热力图,应该使用polarplot还是colormap?How to draw such a heatmap, should I use ‘polaroplot’ or ‘colormap’?
怎么画出这样的热力图,应该使用polarplot还是colormap? How to draw such a heatmap, should I use ‘polaroplot’ or ‘colormap’?
怎么画出这样的热力图,应该使用polarplot还是colormap? polarplot, colormap MATLAB Answers — New Questions
Is it possible to have a string constant (output datatype: string) generated in UTF-8?
"Simulink strings support 256 characters of the ISO/IEC 8859-1 character set" according to Simulink Strings in the Help Center.
I’ve created a "string constant" block called "String ãºç" in a simulink model where I’ve inserted the value "exampleàñçº".
The block’s name is exported correctly in UTF-8 ("String ãºç"), but what I get in the exported file for the value is "example340361347272" (octal values for extended characters in ISO/IEC 8859-1).
I was wondering if there was a way to export the string value in UTF-8."Simulink strings support 256 characters of the ISO/IEC 8859-1 character set" according to Simulink Strings in the Help Center.
I’ve created a "string constant" block called "String ãºç" in a simulink model where I’ve inserted the value "exampleàñçº".
The block’s name is exported correctly in UTF-8 ("String ãºç"), but what I get in the exported file for the value is "example340361347272" (octal values for extended characters in ISO/IEC 8859-1).
I was wondering if there was a way to export the string value in UTF-8. "Simulink strings support 256 characters of the ISO/IEC 8859-1 character set" according to Simulink Strings in the Help Center.
I’ve created a "string constant" block called "String ãºç" in a simulink model where I’ve inserted the value "exampleàñçº".
The block’s name is exported correctly in UTF-8 ("String ãºç"), but what I get in the exported file for the value is "example340361347272" (octal values for extended characters in ISO/IEC 8859-1).
I was wondering if there was a way to export the string value in UTF-8. block parameters, simulink, simulink coder, matlab coder, embedded coder, string, datatype, string constant, model configuration, encoding, latin-1, iso/iec 8859-1, utf-8, unicode MATLAB Answers — New Questions
How to create the 3D mesh plot in Simulink
I am having simple m-code ..
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
figure(1)
mesh(Z)
and it displays
I want to do it in Simulink – Is it possible to do 3D mesh in SImulink – how?I am having simple m-code ..
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
figure(1)
mesh(Z)
and it displays
I want to do it in Simulink – Is it possible to do 3D mesh in SImulink – how? I am having simple m-code ..
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
figure(1)
mesh(Z)
and it displays
I want to do it in Simulink – Is it possible to do 3D mesh in SImulink – how? 3d mesh in simulink MATLAB Answers — New Questions