Category: Matlab
Category Archives: Matlab
How do I start or stop the Network License Manager?
I would like to start or stop the Network License Manager for my MathWorks products.I would like to start or stop the Network License Manager for my MathWorks products. I would like to start or stop the Network License Manager for my MathWorks products. MATLAB Answers — New Questions
Error while installing RoadRunner: “error while loading shared libraries: libidn.so.11: cannot open shared object file: No such file or directory”
After installing RoadRunner, I get the following error trying to run the installer
"error while loading shared libraries: libidn.so.11: cannot open shared object file: No such file or directory"
how do I resolve this?After installing RoadRunner, I get the following error trying to run the installer
"error while loading shared libraries: libidn.so.11: cannot open shared object file: No such file or directory"
how do I resolve this? After installing RoadRunner, I get the following error trying to run the installer
"error while loading shared libraries: libidn.so.11: cannot open shared object file: No such file or directory"
how do I resolve this? libidn.so, shared, objects, roadrunner, installation MATLAB Answers — New Questions
I need to learn how to use this code. I’m trying to implement it in MATLAB. I’m having trouble getting the plane to assume a higher altitude.
I’m having trouble getting the plane to assume a higher altitude. Can anyone please look for the comment in the top section that is associated with assigning a variable a value, remove the comment, and see what the software does? Thank you. I have never dealt with "handles" before, and I need a quick course on the subject.
pn=0;
pe=0;
pd=0;
phi=0;
theta=0;
psi=0;
handle=[];
%Simulation parameters
dpn=0.5; %Change in position.
dpsi=0.01; %Change in yaw angle.
simlength=150;%Number of Sim Steps
%Draw and update the plane’s position.
for k = 1:simlength
pn = pn+dpn;
pe = pe+dpn;
%THE CODE THAT PRODUCES A PROBLEM IS BELOW
%pd = pd +.1;
psi = psi+dpsi;
%Draw or update the plane.
handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle);
pause(0.1); %Pause to visualize the movement
end
function handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle)
%define points on plane in local NED coordintates
NED = airplanepoints;
%rotate plane by (phi; theta; psi)
NED = rotate(NED, phi, theta, psi);
%translate plane to [pn; pe; pd]
NED = translate(NED, pn, pe, pd);
%transform vertices from NED to XYZ
R = […
0, 1, 0;…
1, 0 , 0;…
0, 0, -1;…
];
XYZ = R* NED’;
%plot plane
if isempty(handle)
handle = plot3(XYZ(1,:),XYZ(2,:),XYZ(3,:),’b’);
xlim([-100 100]);
ylim([-100 100]);
zlim([0 100]);
grid on;%show grid
xlabel(‘X’);ylabel(‘Y’);zlabel(‘Z’);%label axes
else
set(handle, ‘XData’, XYZ(1,:), ‘YData’,XYZ(2,:), ‘ZData’,XYZ(3,:));
drawnow
end
end
function XYZ = airplanepoints
%define points on the aircraft in local NED
XYZ = […
0 0 0;%point1
-2 1 1;%point2
-2 1 -1;%point3
0 0 0;%point1
-2 -1 1;%point4
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-2 -1 1;%point4
0 0 0;%point1
-2 1 -1;%point3
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-18 0 0;%point6
-2 1 -1;%point3
-18 0 0;%point6
-2 -1 -1;%point5
-18 0 0;%point6
-2 -1 1;%point4
-18 0 0;%point6
-2 1 1;%point2
0 0 0;%point1
-5 0 0;%point7
-5 -10 0;%point8
-8 -10 0;%point9
-8 10 0;%point10
-5 10 0;%point11
-5 0 0;%point7
-15.5 0 0;%point12
-15.5 2 0;%point13
-17.5 2 0;%point14
-17.5 -2 0;%point15
-15.5 -2 0;%point16
-15.5 0 0;%point12
-18 0 0;%point6
-18 0 -3;%point17
-15.5 0 0;%point15
-18 0 0;%point16
];
end
function XYZ=rotate(XYZ,phi,theta,psi)
%define rotation matrix
R_roll = [
1, 0, 0;
0, cos(phi), -sin(phi);
0, sin(phi), cos(phi)];
R_pitch = [
cos(theta), 0, sin(theta);
0, 1, 0;
-sin(theta), 0, cos(theta)];
R_yaw = [
cos(psi), -sin(psi), 0;
sin(psi), cos(psi), 0;
0, 0, 1];
R = R_roll*R_pitch*R_yaw;
%rotate vertices
XYZ =R*XYZ’;
XYZ = XYZ’;
end
function XYZ = translate(XYZ, pn, pe, pd)
XYZ = XYZ’ + repmat([pn;pe;pd],1,size(XYZ,1));
XYZ=XYZ’;
endI’m having trouble getting the plane to assume a higher altitude. Can anyone please look for the comment in the top section that is associated with assigning a variable a value, remove the comment, and see what the software does? Thank you. I have never dealt with "handles" before, and I need a quick course on the subject.
pn=0;
pe=0;
pd=0;
phi=0;
theta=0;
psi=0;
handle=[];
%Simulation parameters
dpn=0.5; %Change in position.
dpsi=0.01; %Change in yaw angle.
simlength=150;%Number of Sim Steps
%Draw and update the plane’s position.
for k = 1:simlength
pn = pn+dpn;
pe = pe+dpn;
%THE CODE THAT PRODUCES A PROBLEM IS BELOW
%pd = pd +.1;
psi = psi+dpsi;
%Draw or update the plane.
handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle);
pause(0.1); %Pause to visualize the movement
end
function handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle)
%define points on plane in local NED coordintates
NED = airplanepoints;
%rotate plane by (phi; theta; psi)
NED = rotate(NED, phi, theta, psi);
%translate plane to [pn; pe; pd]
NED = translate(NED, pn, pe, pd);
%transform vertices from NED to XYZ
R = […
0, 1, 0;…
1, 0 , 0;…
0, 0, -1;…
];
XYZ = R* NED’;
%plot plane
if isempty(handle)
handle = plot3(XYZ(1,:),XYZ(2,:),XYZ(3,:),’b’);
xlim([-100 100]);
ylim([-100 100]);
zlim([0 100]);
grid on;%show grid
xlabel(‘X’);ylabel(‘Y’);zlabel(‘Z’);%label axes
else
set(handle, ‘XData’, XYZ(1,:), ‘YData’,XYZ(2,:), ‘ZData’,XYZ(3,:));
drawnow
end
end
function XYZ = airplanepoints
%define points on the aircraft in local NED
XYZ = […
0 0 0;%point1
-2 1 1;%point2
-2 1 -1;%point3
0 0 0;%point1
-2 -1 1;%point4
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-2 -1 1;%point4
0 0 0;%point1
-2 1 -1;%point3
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-18 0 0;%point6
-2 1 -1;%point3
-18 0 0;%point6
-2 -1 -1;%point5
-18 0 0;%point6
-2 -1 1;%point4
-18 0 0;%point6
-2 1 1;%point2
0 0 0;%point1
-5 0 0;%point7
-5 -10 0;%point8
-8 -10 0;%point9
-8 10 0;%point10
-5 10 0;%point11
-5 0 0;%point7
-15.5 0 0;%point12
-15.5 2 0;%point13
-17.5 2 0;%point14
-17.5 -2 0;%point15
-15.5 -2 0;%point16
-15.5 0 0;%point12
-18 0 0;%point6
-18 0 -3;%point17
-15.5 0 0;%point15
-18 0 0;%point16
];
end
function XYZ=rotate(XYZ,phi,theta,psi)
%define rotation matrix
R_roll = [
1, 0, 0;
0, cos(phi), -sin(phi);
0, sin(phi), cos(phi)];
R_pitch = [
cos(theta), 0, sin(theta);
0, 1, 0;
-sin(theta), 0, cos(theta)];
R_yaw = [
cos(psi), -sin(psi), 0;
sin(psi), cos(psi), 0;
0, 0, 1];
R = R_roll*R_pitch*R_yaw;
%rotate vertices
XYZ =R*XYZ’;
XYZ = XYZ’;
end
function XYZ = translate(XYZ, pn, pe, pd)
XYZ = XYZ’ + repmat([pn;pe;pd],1,size(XYZ,1));
XYZ=XYZ’;
end I’m having trouble getting the plane to assume a higher altitude. Can anyone please look for the comment in the top section that is associated with assigning a variable a value, remove the comment, and see what the software does? Thank you. I have never dealt with "handles" before, and I need a quick course on the subject.
pn=0;
pe=0;
pd=0;
phi=0;
theta=0;
psi=0;
handle=[];
%Simulation parameters
dpn=0.5; %Change in position.
dpsi=0.01; %Change in yaw angle.
simlength=150;%Number of Sim Steps
%Draw and update the plane’s position.
for k = 1:simlength
pn = pn+dpn;
pe = pe+dpn;
%THE CODE THAT PRODUCES A PROBLEM IS BELOW
%pd = pd +.1;
psi = psi+dpsi;
%Draw or update the plane.
handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle);
pause(0.1); %Pause to visualize the movement
end
function handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle)
%define points on plane in local NED coordintates
NED = airplanepoints;
%rotate plane by (phi; theta; psi)
NED = rotate(NED, phi, theta, psi);
%translate plane to [pn; pe; pd]
NED = translate(NED, pn, pe, pd);
%transform vertices from NED to XYZ
R = […
0, 1, 0;…
1, 0 , 0;…
0, 0, -1;…
];
XYZ = R* NED’;
%plot plane
if isempty(handle)
handle = plot3(XYZ(1,:),XYZ(2,:),XYZ(3,:),’b’);
xlim([-100 100]);
ylim([-100 100]);
zlim([0 100]);
grid on;%show grid
xlabel(‘X’);ylabel(‘Y’);zlabel(‘Z’);%label axes
else
set(handle, ‘XData’, XYZ(1,:), ‘YData’,XYZ(2,:), ‘ZData’,XYZ(3,:));
drawnow
end
end
function XYZ = airplanepoints
%define points on the aircraft in local NED
XYZ = […
0 0 0;%point1
-2 1 1;%point2
-2 1 -1;%point3
0 0 0;%point1
-2 -1 1;%point4
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-2 -1 1;%point4
0 0 0;%point1
-2 1 -1;%point3
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-18 0 0;%point6
-2 1 -1;%point3
-18 0 0;%point6
-2 -1 -1;%point5
-18 0 0;%point6
-2 -1 1;%point4
-18 0 0;%point6
-2 1 1;%point2
0 0 0;%point1
-5 0 0;%point7
-5 -10 0;%point8
-8 -10 0;%point9
-8 10 0;%point10
-5 10 0;%point11
-5 0 0;%point7
-15.5 0 0;%point12
-15.5 2 0;%point13
-17.5 2 0;%point14
-17.5 -2 0;%point15
-15.5 -2 0;%point16
-15.5 0 0;%point12
-18 0 0;%point6
-18 0 -3;%point17
-15.5 0 0;%point15
-18 0 0;%point16
];
end
function XYZ=rotate(XYZ,phi,theta,psi)
%define rotation matrix
R_roll = [
1, 0, 0;
0, cos(phi), -sin(phi);
0, sin(phi), cos(phi)];
R_pitch = [
cos(theta), 0, sin(theta);
0, 1, 0;
-sin(theta), 0, cos(theta)];
R_yaw = [
cos(psi), -sin(psi), 0;
sin(psi), cos(psi), 0;
0, 0, 1];
R = R_roll*R_pitch*R_yaw;
%rotate vertices
XYZ =R*XYZ’;
XYZ = XYZ’;
end
function XYZ = translate(XYZ, pn, pe, pd)
XYZ = XYZ’ + repmat([pn;pe;pd],1,size(XYZ,1));
XYZ=XYZ’;
end #animation, #handle, #plot, #boom1 MATLAB Answers — New Questions
Error in Matlab Data Filtering from an Excel FiIe
I have an Excel file that I want Matlab to read, import, then filter (find code below). My problem is, the RowsToKeep variable outputs as an empty array, even though I know there are rows within the data that match the criteria of MLAT between 72 and 82.
Unfortunately, the Excel file I’m using is too large to upload here, even as a zip file. However, I’ve attached a snippet of the file here:
Also, after I run the code below, this is the output from Matlab:
Does anyone know why RowsToKeep gets filtered as an empty array, and how I can fix it? My Matlab code is as follows:
clc;
clear all;
close all;
% Read data from Excel file
data = readtable(‘MLAT_Sat2.xlsx’);
% Convert table to array
data = table2array(data);
% Remove rows with any NaN values
data = data(~any(isnan(data), 2), :);
% Extract columns
%NOTE: column extraction begins at row 2 to ignore the column headings.
time = data(2:end, 1);
angle = data(2:end, 2); % degrees
inclination = data(2:end, 3); % degrees
lat = data(2:end, 4); % degrees
lon = data(2:end, 5); % degrees
alt = data(2:end, 6); % kilometers
MLAT = data(2:end, 7); % degrees
MLON = data(2:end, 8); % degrees
r = data(2:end, 9);
% Find rows to keep with MLAT between 72 and 82
RowsToKeep = find(MLAT >= 72 & MLAT <= 82);
% Filter the data based on RowsToKeep
Filter = data(RowsToKeep +1 , :);
filteredTime = Filter(:, 1);
filteredAngle = Filter(:, 2);
filteredInc = Filter(:, 3);
filteredLat = Filter(:, 4);
filteredLon = Filter(:, 5);
filteredAlt = Filter(:, 6);
filteredMlat = Filter(:, 7);
filteredMlon = Filter(:, 8);
filteredr = Filter(:, 9);I have an Excel file that I want Matlab to read, import, then filter (find code below). My problem is, the RowsToKeep variable outputs as an empty array, even though I know there are rows within the data that match the criteria of MLAT between 72 and 82.
Unfortunately, the Excel file I’m using is too large to upload here, even as a zip file. However, I’ve attached a snippet of the file here:
Also, after I run the code below, this is the output from Matlab:
Does anyone know why RowsToKeep gets filtered as an empty array, and how I can fix it? My Matlab code is as follows:
clc;
clear all;
close all;
% Read data from Excel file
data = readtable(‘MLAT_Sat2.xlsx’);
% Convert table to array
data = table2array(data);
% Remove rows with any NaN values
data = data(~any(isnan(data), 2), :);
% Extract columns
%NOTE: column extraction begins at row 2 to ignore the column headings.
time = data(2:end, 1);
angle = data(2:end, 2); % degrees
inclination = data(2:end, 3); % degrees
lat = data(2:end, 4); % degrees
lon = data(2:end, 5); % degrees
alt = data(2:end, 6); % kilometers
MLAT = data(2:end, 7); % degrees
MLON = data(2:end, 8); % degrees
r = data(2:end, 9);
% Find rows to keep with MLAT between 72 and 82
RowsToKeep = find(MLAT >= 72 & MLAT <= 82);
% Filter the data based on RowsToKeep
Filter = data(RowsToKeep +1 , :);
filteredTime = Filter(:, 1);
filteredAngle = Filter(:, 2);
filteredInc = Filter(:, 3);
filteredLat = Filter(:, 4);
filteredLon = Filter(:, 5);
filteredAlt = Filter(:, 6);
filteredMlat = Filter(:, 7);
filteredMlon = Filter(:, 8);
filteredr = Filter(:, 9); I have an Excel file that I want Matlab to read, import, then filter (find code below). My problem is, the RowsToKeep variable outputs as an empty array, even though I know there are rows within the data that match the criteria of MLAT between 72 and 82.
Unfortunately, the Excel file I’m using is too large to upload here, even as a zip file. However, I’ve attached a snippet of the file here:
Also, after I run the code below, this is the output from Matlab:
Does anyone know why RowsToKeep gets filtered as an empty array, and how I can fix it? My Matlab code is as follows:
clc;
clear all;
close all;
% Read data from Excel file
data = readtable(‘MLAT_Sat2.xlsx’);
% Convert table to array
data = table2array(data);
% Remove rows with any NaN values
data = data(~any(isnan(data), 2), :);
% Extract columns
%NOTE: column extraction begins at row 2 to ignore the column headings.
time = data(2:end, 1);
angle = data(2:end, 2); % degrees
inclination = data(2:end, 3); % degrees
lat = data(2:end, 4); % degrees
lon = data(2:end, 5); % degrees
alt = data(2:end, 6); % kilometers
MLAT = data(2:end, 7); % degrees
MLON = data(2:end, 8); % degrees
r = data(2:end, 9);
% Find rows to keep with MLAT between 72 and 82
RowsToKeep = find(MLAT >= 72 & MLAT <= 82);
% Filter the data based on RowsToKeep
Filter = data(RowsToKeep +1 , :);
filteredTime = Filter(:, 1);
filteredAngle = Filter(:, 2);
filteredInc = Filter(:, 3);
filteredLat = Filter(:, 4);
filteredLon = Filter(:, 5);
filteredAlt = Filter(:, 6);
filteredMlat = Filter(:, 7);
filteredMlon = Filter(:, 8);
filteredr = Filter(:, 9); data import, data filtering, importing excel data MATLAB Answers — New Questions
Preparing input data for classification using LSTM
I am interested in classifying graphs (senquence) data to category labels. I saw that I could use LSTM however, I would like know how the primary sequence data is store for inputing into the LSTM, I also want to know how to attach know labels to each graph for purpose of training.
https://www.mathworks.com/help/deeplearning/ug/classify-sequence-data-using-lstm-networks.html
In this there is a variable / struture called waveform, how was it constructed?
Please assistI am interested in classifying graphs (senquence) data to category labels. I saw that I could use LSTM however, I would like know how the primary sequence data is store for inputing into the LSTM, I also want to know how to attach know labels to each graph for purpose of training.
https://www.mathworks.com/help/deeplearning/ug/classify-sequence-data-using-lstm-networks.html
In this there is a variable / struture called waveform, how was it constructed?
Please assist I am interested in classifying graphs (senquence) data to category labels. I saw that I could use LSTM however, I would like know how the primary sequence data is store for inputing into the LSTM, I also want to know how to attach know labels to each graph for purpose of training.
https://www.mathworks.com/help/deeplearning/ug/classify-sequence-data-using-lstm-networks.html
In this there is a variable / struture called waveform, how was it constructed?
Please assist lstm MATLAB Answers — New Questions
Codebeamer RMI – Matlab Simulink Integration Error
When I trying to link the model data in Simulink with Code Beamer, the following error message occurs.
I’d appreciate it if you could check how to deal with it.
<Pre-setting>
– Complete installation of codebeamer add-on (codebeamer RMI)
– Codebeamer server connection settting complete
<Link execution order>
Choose model data -> (Right-click) Requirements -> Link to Codebeamer Item -> <An error pops up as below.>When I trying to link the model data in Simulink with Code Beamer, the following error message occurs.
I’d appreciate it if you could check how to deal with it.
<Pre-setting>
– Complete installation of codebeamer add-on (codebeamer RMI)
– Codebeamer server connection settting complete
<Link execution order>
Choose model data -> (Right-click) Requirements -> Link to Codebeamer Item -> <An error pops up as below.> When I trying to link the model data in Simulink with Code Beamer, the following error message occurs.
I’d appreciate it if you could check how to deal with it.
<Pre-setting>
– Complete installation of codebeamer add-on (codebeamer RMI)
– Codebeamer server connection settting complete
<Link execution order>
Choose model data -> (Right-click) Requirements -> Link to Codebeamer Item -> <An error pops up as below.> codebeamer, rmi, integration MATLAB Answers — New Questions
Where are the logs files located for installation, activation, Network License Manager, and the Service Host?
Where are the logs files located for installation, activation, Network License Manager, and the Service Host?Where are the logs files located for installation, activation, Network License Manager, and the Service Host? Where are the logs files located for installation, activation, Network License Manager, and the Service Host? MATLAB Answers — New Questions
Why do I receive License Manager Error -16?
When starting the network license manager or starting MATLAB I receive the following error:
Cannot read data from license server. License Manager Error -16.When starting the network license manager or starting MATLAB I receive the following error:
Cannot read data from license server. License Manager Error -16. When starting the network license manager or starting MATLAB I receive the following error:
Cannot read data from license server. License Manager Error -16. MATLAB Answers — New Questions
AppDesigner’s Compare Tool does not appear to work.
I have two different versions of a .mlapp file that I’d like to compare in order to merge my changes. Per the MATLAB documentation, the Compare Tool should work for this. This is, I can’t get it to work for the life of me. Nothing actually happens once I close the file selection window. I’ve tried restarting AppDesigner, restarting MATLAB, and restarting my machine. Am I missing something here?
See attached gif for a demonstration.I have two different versions of a .mlapp file that I’d like to compare in order to merge my changes. Per the MATLAB documentation, the Compare Tool should work for this. This is, I can’t get it to work for the life of me. Nothing actually happens once I close the file selection window. I’ve tried restarting AppDesigner, restarting MATLAB, and restarting my machine. Am I missing something here?
See attached gif for a demonstration. I have two different versions of a .mlapp file that I’d like to compare in order to merge my changes. Per the MATLAB documentation, the Compare Tool should work for this. This is, I can’t get it to work for the life of me. Nothing actually happens once I close the file selection window. I’ve tried restarting AppDesigner, restarting MATLAB, and restarting my machine. Am I missing something here?
See attached gif for a demonstration. appdesigner, compare tool MATLAB Answers — New Questions
Why do I receive License Manager Error -7?
When performing a status enquiry of my License Manager, I see the following error:
MLM: No socket connection to license server manager.
License path: 27000@hostname;
FlexNet Licensing error:-7,10015
Why do I receive "License Manager Error -7"?When performing a status enquiry of my License Manager, I see the following error:
MLM: No socket connection to license server manager.
License path: 27000@hostname;
FlexNet Licensing error:-7,10015
Why do I receive "License Manager Error -7"? When performing a status enquiry of my License Manager, I see the following error:
MLM: No socket connection to license server manager.
License path: 27000@hostname;
FlexNet Licensing error:-7,10015
Why do I receive "License Manager Error -7"? MATLAB Answers — New Questions
hue saturation intensity
I1 = imread(‘127.jpg’);
>> I1 = imresize(I1, [256 256]);
>> [h s i] = rgb2hsi(I1);
??? Undefined function or method ‘rgb2hsi’ for input arguments of
type ‘uint8’.
>> I2 = double(I1);
>> [h s i] = rgb2hsi(I2);
??? Undefined function or method ‘rgb2hsi’ for input arguments of
type ‘double’.
how to i calculate intensity valueI1 = imread(‘127.jpg’);
>> I1 = imresize(I1, [256 256]);
>> [h s i] = rgb2hsi(I1);
??? Undefined function or method ‘rgb2hsi’ for input arguments of
type ‘uint8’.
>> I2 = double(I1);
>> [h s i] = rgb2hsi(I2);
??? Undefined function or method ‘rgb2hsi’ for input arguments of
type ‘double’.
how to i calculate intensity value I1 = imread(‘127.jpg’);
>> I1 = imresize(I1, [256 256]);
>> [h s i] = rgb2hsi(I1);
??? Undefined function or method ‘rgb2hsi’ for input arguments of
type ‘uint8’.
>> I2 = double(I1);
>> [h s i] = rgb2hsi(I2);
??? Undefined function or method ‘rgb2hsi’ for input arguments of
type ‘double’.
how to i calculate intensity value image processing MATLAB Answers — New Questions
How do I use randn vs randi vs rand?
I want a 3×5 matrix of random integers between 5 and 10. So I typed the following:
randi ([5,10], 3, 5) and this worked perfectly fine.
When I wanted a 3×5 matrix of random real numbers between 5 and 10, I assumed I would use randn and type:
randn ([5,10], 3,5) but it kept coming up as an error.
Can someone explain to me what I’m doing wrong? I’m just learning how to use MatLab.I want a 3×5 matrix of random integers between 5 and 10. So I typed the following:
randi ([5,10], 3, 5) and this worked perfectly fine.
When I wanted a 3×5 matrix of random real numbers between 5 and 10, I assumed I would use randn and type:
randn ([5,10], 3,5) but it kept coming up as an error.
Can someone explain to me what I’m doing wrong? I’m just learning how to use MatLab. I want a 3×5 matrix of random integers between 5 and 10. So I typed the following:
randi ([5,10], 3, 5) and this worked perfectly fine.
When I wanted a 3×5 matrix of random real numbers between 5 and 10, I assumed I would use randn and type:
randn ([5,10], 3,5) but it kept coming up as an error.
Can someone explain to me what I’m doing wrong? I’m just learning how to use MatLab. random number generator, random MATLAB Answers — New Questions
How to store users input in a file?
Let’s say I made a input asking for the users name and age, and wanted to say his input to a .txt file, I already know how to do that but my issue is how to keep that stored data if the script was ran again.
my code to store the users name and age:
name = input(‘What is your name? ‘,’s’);
age = input(‘How old are you? ‘);
fid = fopen(‘data.txt’,’w’);
fprintf(fid,’%s is %i years oldn’,name,age);
fclose(fid);Let’s say I made a input asking for the users name and age, and wanted to say his input to a .txt file, I already know how to do that but my issue is how to keep that stored data if the script was ran again.
my code to store the users name and age:
name = input(‘What is your name? ‘,’s’);
age = input(‘How old are you? ‘);
fid = fopen(‘data.txt’,’w’);
fprintf(fid,’%s is %i years oldn’,name,age);
fclose(fid); Let’s say I made a input asking for the users name and age, and wanted to say his input to a .txt file, I already know how to do that but my issue is how to keep that stored data if the script was ran again.
my code to store the users name and age:
name = input(‘What is your name? ‘,’s’);
age = input(‘How old are you? ‘);
fid = fopen(‘data.txt’,’w’);
fprintf(fid,’%s is %i years oldn’,name,age);
fclose(fid); input MATLAB Answers — New Questions
Split a matrix of nodes (x,y,z) into 2/3 matrices with dbscan or spectralcluster
Hi! I should split the matrix ‘M4_5’ or ‘M4_12’ into 2/3 matrices like figure.
I have tried the functions ‘dbscan’ or ‘spectralcluster’ but I cannot subdivide the matrix.
load M4_5.mat
% load M4_12.mat
idx = dbscan(M4,0.3,4);
% idx = spectralcluster(M4,2);
[r1,c] = find(idx == 1);
[r2,c] = find(idx == 2);
M4_a = M4(r1,:);
M4_a = M4(r2,:);
figure
plot3(M4(:,1),M4(:,2),M4(:,3),’k.’,’Markersize’,8);
hold on
plot3(M4_a(:,1),M4_a(:,2),M4_a(:,3),’y.’,’Markersize’,12);
plot3(M4_a(:,1),M4_a(:,2),M4_a(:,3),’m.’,’Markersize’,12);
hold off
axis equalHi! I should split the matrix ‘M4_5’ or ‘M4_12’ into 2/3 matrices like figure.
I have tried the functions ‘dbscan’ or ‘spectralcluster’ but I cannot subdivide the matrix.
load M4_5.mat
% load M4_12.mat
idx = dbscan(M4,0.3,4);
% idx = spectralcluster(M4,2);
[r1,c] = find(idx == 1);
[r2,c] = find(idx == 2);
M4_a = M4(r1,:);
M4_a = M4(r2,:);
figure
plot3(M4(:,1),M4(:,2),M4(:,3),’k.’,’Markersize’,8);
hold on
plot3(M4_a(:,1),M4_a(:,2),M4_a(:,3),’y.’,’Markersize’,12);
plot3(M4_a(:,1),M4_a(:,2),M4_a(:,3),’m.’,’Markersize’,12);
hold off
axis equal Hi! I should split the matrix ‘M4_5’ or ‘M4_12’ into 2/3 matrices like figure.
I have tried the functions ‘dbscan’ or ‘spectralcluster’ but I cannot subdivide the matrix.
load M4_5.mat
% load M4_12.mat
idx = dbscan(M4,0.3,4);
% idx = spectralcluster(M4,2);
[r1,c] = find(idx == 1);
[r2,c] = find(idx == 2);
M4_a = M4(r1,:);
M4_a = M4(r2,:);
figure
plot3(M4(:,1),M4(:,2),M4(:,3),’k.’,’Markersize’,8);
hold on
plot3(M4_a(:,1),M4_a(:,2),M4_a(:,3),’y.’,’Markersize’,12);
plot3(M4_a(:,1),M4_a(:,2),M4_a(:,3),’m.’,’Markersize’,12);
hold off
axis equal dbscan, spectralcluster, data, matrix array, matrix manipulation, matrix, matrices MATLAB Answers — New Questions
How do I get the true position of UIAxes with daspect = [1 1 1] and contained within a grid?
I have an AppDesigner app that features a GridLayout set up like this:
The xy UIAxes object has its data aspect ratio set to [1 1 1], which means that when I resize the window, the axes resize so as to always match the aspect ratio of the plotted data. However, this presents a problem, as the xz and yz UIAxes objects don’t always match the width and/or height of the xy UIAxes object.
After exhausting a number of other potential approaches, I’m now trying to manually update the appropriate ColumnWidth and RowHeight values of the parent GridLayout, but I’m unable to get the true position of the xy UIAxes, because they always correspond to the maximum possible space occupied by the xy UIAxes. If that doesn’t parse in text, this should help:
How can I get the true position I’m looking for?I have an AppDesigner app that features a GridLayout set up like this:
The xy UIAxes object has its data aspect ratio set to [1 1 1], which means that when I resize the window, the axes resize so as to always match the aspect ratio of the plotted data. However, this presents a problem, as the xz and yz UIAxes objects don’t always match the width and/or height of the xy UIAxes object.
After exhausting a number of other potential approaches, I’m now trying to manually update the appropriate ColumnWidth and RowHeight values of the parent GridLayout, but I’m unable to get the true position of the xy UIAxes, because they always correspond to the maximum possible space occupied by the xy UIAxes. If that doesn’t parse in text, this should help:
How can I get the true position I’m looking for? I have an AppDesigner app that features a GridLayout set up like this:
The xy UIAxes object has its data aspect ratio set to [1 1 1], which means that when I resize the window, the axes resize so as to always match the aspect ratio of the plotted data. However, this presents a problem, as the xz and yz UIAxes objects don’t always match the width and/or height of the xy UIAxes object.
After exhausting a number of other potential approaches, I’m now trying to manually update the appropriate ColumnWidth and RowHeight values of the parent GridLayout, but I’m unable to get the true position of the xy UIAxes, because they always correspond to the maximum possible space occupied by the xy UIAxes. If that doesn’t parse in text, this should help:
How can I get the true position I’m looking for? matlab, appdesigner, axes MATLAB Answers — New Questions
Application window cannot be resized or moved
I am having the same problem described in this previous question:
https://www.mathworks.com/matlabcentral/answers/556288-i-cannot-control-the-window-size
I also tried the suggested advice in that post but did not fix the issue.
I am using Ubuntu 20.04.6. I am starting matlab from the command line.I am having the same problem described in this previous question:
https://www.mathworks.com/matlabcentral/answers/556288-i-cannot-control-the-window-size
I also tried the suggested advice in that post but did not fix the issue.
I am using Ubuntu 20.04.6. I am starting matlab from the command line. I am having the same problem described in this previous question:
https://www.mathworks.com/matlabcentral/answers/556288-i-cannot-control-the-window-size
I also tried the suggested advice in that post but did not fix the issue.
I am using Ubuntu 20.04.6. I am starting matlab from the command line. startup MATLAB Answers — New Questions
How can I desactivate Data Type Override option for a Simulink model ?
After executing a Simulink model I had the error message in the image bellow, I click on fix button so matlab enabled the Data Type Override option automatically and now I want to desactivate it because it caused me problems with other variables types .How can I do to desactivate this option from the hole model ?After executing a Simulink model I had the error message in the image bellow, I click on fix button so matlab enabled the Data Type Override option automatically and now I want to desactivate it because it caused me problems with other variables types .How can I do to desactivate this option from the hole model ? After executing a Simulink model I had the error message in the image bellow, I click on fix button so matlab enabled the Data Type Override option automatically and now I want to desactivate it because it caused me problems with other variables types .How can I do to desactivate this option from the hole model ? data type override MATLAB Answers — New Questions
Should I modify x-values for curve fitting with response variable?
I am trying to fit concentration (in x-axis) and approach rate (in y-axis) using a logistic equation. The real values of x are [0.5, 2, 5, 9]. Should I fit real_x vs y? I think I saw somewhere that one should use equidistant points (like x = [1,2,3,4]) for fitting. What is your opinion?I am trying to fit concentration (in x-axis) and approach rate (in y-axis) using a logistic equation. The real values of x are [0.5, 2, 5, 9]. Should I fit real_x vs y? I think I saw somewhere that one should use equidistant points (like x = [1,2,3,4]) for fitting. What is your opinion? I am trying to fit concentration (in x-axis) and approach rate (in y-axis) using a logistic equation. The real values of x are [0.5, 2, 5, 9]. Should I fit real_x vs y? I think I saw somewhere that one should use equidistant points (like x = [1,2,3,4]) for fitting. What is your opinion? curve fitting MATLAB Answers — New Questions
polynomial multiplication not accurate, using conv() vs symbolic
I’m calculating the square of a polynomial inside a loop. It seems to me that, calculating it using conv() is resulting in large errors, compared to converting the polynomial to symbolic and do the calculation there.
Just out of curiosity, I tried to sym2poly the symbolic results back to polynomial, and the error appears again.
However, I can’t using symbolic calculation in the loop, because it’s too slow.
Any input on why this is happening and how to solve it properly? Thanks in advance.
figure
% the polynomial
D4_poly= 1.0e+06 * [ -0.000001003321333
0.000108002928093
-0.004647941272734
0.099959233380745
-1.074286120871490
4.615719487403345];
D4_fn = matlabFunction(poly2sym(D4_poly));
subplot(2,2,1);fplot(D4_fn,[19.999825010467916,23.158281544048581])
% using conv
SqD4_poly = conv(D4_poly’,D4_poly’);
SqD4_fn = matlabFunction(poly2sym(SqD4_poly));
subplot(2,2,2);fplot(SqD4_fn,[19.999825010467916,23.158281544048581])
% using poly2sym
temp = poly2sym(D4_poly);
SqD4_s_fn = matlabFunction(temp ^2);
subplot(2,2,3);fplot(SqD4_s_fn,[19.999825010467916,23.158281544048581])
% sym2poly
SqD4_poly_2 = sym2poly(temp ^2);
SqD4_3_fn = matlabFunction(poly2sym(SqD4_poly_2));
subplot(2,2,4);fplot(SqD4_3_fn,[19.999825010467916,23.158281544048581])I’m calculating the square of a polynomial inside a loop. It seems to me that, calculating it using conv() is resulting in large errors, compared to converting the polynomial to symbolic and do the calculation there.
Just out of curiosity, I tried to sym2poly the symbolic results back to polynomial, and the error appears again.
However, I can’t using symbolic calculation in the loop, because it’s too slow.
Any input on why this is happening and how to solve it properly? Thanks in advance.
figure
% the polynomial
D4_poly= 1.0e+06 * [ -0.000001003321333
0.000108002928093
-0.004647941272734
0.099959233380745
-1.074286120871490
4.615719487403345];
D4_fn = matlabFunction(poly2sym(D4_poly));
subplot(2,2,1);fplot(D4_fn,[19.999825010467916,23.158281544048581])
% using conv
SqD4_poly = conv(D4_poly’,D4_poly’);
SqD4_fn = matlabFunction(poly2sym(SqD4_poly));
subplot(2,2,2);fplot(SqD4_fn,[19.999825010467916,23.158281544048581])
% using poly2sym
temp = poly2sym(D4_poly);
SqD4_s_fn = matlabFunction(temp ^2);
subplot(2,2,3);fplot(SqD4_s_fn,[19.999825010467916,23.158281544048581])
% sym2poly
SqD4_poly_2 = sym2poly(temp ^2);
SqD4_3_fn = matlabFunction(poly2sym(SqD4_poly_2));
subplot(2,2,4);fplot(SqD4_3_fn,[19.999825010467916,23.158281544048581]) I’m calculating the square of a polynomial inside a loop. It seems to me that, calculating it using conv() is resulting in large errors, compared to converting the polynomial to symbolic and do the calculation there.
Just out of curiosity, I tried to sym2poly the symbolic results back to polynomial, and the error appears again.
However, I can’t using symbolic calculation in the loop, because it’s too slow.
Any input on why this is happening and how to solve it properly? Thanks in advance.
figure
% the polynomial
D4_poly= 1.0e+06 * [ -0.000001003321333
0.000108002928093
-0.004647941272734
0.099959233380745
-1.074286120871490
4.615719487403345];
D4_fn = matlabFunction(poly2sym(D4_poly));
subplot(2,2,1);fplot(D4_fn,[19.999825010467916,23.158281544048581])
% using conv
SqD4_poly = conv(D4_poly’,D4_poly’);
SqD4_fn = matlabFunction(poly2sym(SqD4_poly));
subplot(2,2,2);fplot(SqD4_fn,[19.999825010467916,23.158281544048581])
% using poly2sym
temp = poly2sym(D4_poly);
SqD4_s_fn = matlabFunction(temp ^2);
subplot(2,2,3);fplot(SqD4_s_fn,[19.999825010467916,23.158281544048581])
% sym2poly
SqD4_poly_2 = sym2poly(temp ^2);
SqD4_3_fn = matlabFunction(poly2sym(SqD4_poly_2));
subplot(2,2,4);fplot(SqD4_3_fn,[19.999825010467916,23.158281544048581]) conv(), symbolic, poly2sym, sym2poly, accuracy MATLAB Answers — New Questions
I’d like to do various things, including controlling the dimensions of the plot box. What I do here with xlim, ylim, and zlim doens’t work.
I put the following together. It runs, but it doesn’t produce an image that moves on the screen. Instead, the screen moves around the image. I’d prefer the former. I try to expand the scope of the plot box using xlim, ylim, and zlim, but it doesn’t work. I also have a question regarding what is being done with XYZ and XYZ’. I don’t understand what is being done with the single quote mark. Can anyone help me or explain the meaning of the single quote mark? Thank you in advance.
pn=20;
pe=0;
pd=-5;
phi=0;
theta=0;
psi=0;
handle=[];
%Simulation parameters
dpn=-0.2; %Change in position.
dpsi=0.05; %Change in yaw angle.
simlength=100;%Number of Sim Steps
%Draw and update the plane’s position.
for k = 1:simlength
pn = pn+dpn;
psi = psi+dpsi;
%Draw or update the plane.
handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle);
pause(0.1); %Pause to visualize the movement
end
function handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle)
%define points on plane in local NED coordintates
NED = airplanepoints;
%rotate plane by (phi; theta; psi)
NED = rotate(NED, phi, theta, psi);
%translate plane to [pn; pe; pd]
NED = translate(NED, pn, pe, pd);
%transform vertices from NED to XYZ
R = […
0, 1, 0;…
1, 0 , 0;…
0, 0, -1;…
];
XYZ = R* NED’;
%plot plane
if isempty(handle)
handle = plot3(XYZ(1,:),XYZ(2,:),XYZ(3,:),’b’);
xlim = ([-100 100]);
ylim = ([-100 100]);
zlim = ([0 100]);
grid on;%show grid
xlabel(‘X’);ylabel(‘Y’);zlabel(‘Z’);%label axes
axis equal;%Maintain aspect ratio
else
set(handle, ‘XData’, XYZ(1,:), ‘YData’,XYZ(2,:), ‘ZData’,XYZ(3,:));
drawnow
end
end
function XYZ = airplanepoints
%define points on the aircraft in local NED
XYZ = […
0 0 0;%point1
-2 1 1;%point2
-2 1 -1;%point3
0 0 0;%point1
-2 -1 1;%point4
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-2 -1 1;%point4
0 0 0;%point1
-2 1 -1;%point3
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-18 0 0;%point6
-2 1 -1;%point3
-18 0 0;%point6
-2 -1 -1;%point5
-18 0 0;%point6
-2 -1 1;%point4
-18 0 0;%point6
-2 1 1;%point2
0 0 0;%point1
-5 0 0;%point7
-5 -10 0;%point8
-8 -10 0;%point9
-8 10 0;%point10
-5 10 0;%point11
-5 0 0;%point7
-15.5 0 0;%point12
-15.5 2 0;%point13
-17.5 2 0;%point14
-17.5 -2 0;%point15
-15.5 -2 0;%point16
-15.5 0 0;%point12
-18 0 0;%point6
-18 0 -3;%point17
-15.5 0 0;%point15
-18 0 0;%point16
];
end
function XYZ=rotate(XYZ,phi,theta,psi)
%define rotation matrix
R_roll = [
1, 0, 0;
0, cos(phi), -sin(phi);
0, sin(phi), cos(phi)];
R_pitch = [
cos(theta), 0, sin(theta);
0, 1, 0;
-sin(theta), 0, cos(theta)];
R_yaw = [
cos(psi), -sin(psi), 0;
sin(psi), cos(psi), 0;
0, 0, 1];
R = R_roll*R_pitch*R_yaw;
%rotate vertices
XYZ =R*XYZ’;
XYZ = XYZ’;
end
function XYZ = translate(XYZ, pn, pe, pd)
XYZ = XYZ’ + repmat([pn;pe;pd],1,size(XYZ,1));
XYZ=XYZ’;
endI put the following together. It runs, but it doesn’t produce an image that moves on the screen. Instead, the screen moves around the image. I’d prefer the former. I try to expand the scope of the plot box using xlim, ylim, and zlim, but it doesn’t work. I also have a question regarding what is being done with XYZ and XYZ’. I don’t understand what is being done with the single quote mark. Can anyone help me or explain the meaning of the single quote mark? Thank you in advance.
pn=20;
pe=0;
pd=-5;
phi=0;
theta=0;
psi=0;
handle=[];
%Simulation parameters
dpn=-0.2; %Change in position.
dpsi=0.05; %Change in yaw angle.
simlength=100;%Number of Sim Steps
%Draw and update the plane’s position.
for k = 1:simlength
pn = pn+dpn;
psi = psi+dpsi;
%Draw or update the plane.
handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle);
pause(0.1); %Pause to visualize the movement
end
function handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle)
%define points on plane in local NED coordintates
NED = airplanepoints;
%rotate plane by (phi; theta; psi)
NED = rotate(NED, phi, theta, psi);
%translate plane to [pn; pe; pd]
NED = translate(NED, pn, pe, pd);
%transform vertices from NED to XYZ
R = […
0, 1, 0;…
1, 0 , 0;…
0, 0, -1;…
];
XYZ = R* NED’;
%plot plane
if isempty(handle)
handle = plot3(XYZ(1,:),XYZ(2,:),XYZ(3,:),’b’);
xlim = ([-100 100]);
ylim = ([-100 100]);
zlim = ([0 100]);
grid on;%show grid
xlabel(‘X’);ylabel(‘Y’);zlabel(‘Z’);%label axes
axis equal;%Maintain aspect ratio
else
set(handle, ‘XData’, XYZ(1,:), ‘YData’,XYZ(2,:), ‘ZData’,XYZ(3,:));
drawnow
end
end
function XYZ = airplanepoints
%define points on the aircraft in local NED
XYZ = […
0 0 0;%point1
-2 1 1;%point2
-2 1 -1;%point3
0 0 0;%point1
-2 -1 1;%point4
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-2 -1 1;%point4
0 0 0;%point1
-2 1 -1;%point3
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-18 0 0;%point6
-2 1 -1;%point3
-18 0 0;%point6
-2 -1 -1;%point5
-18 0 0;%point6
-2 -1 1;%point4
-18 0 0;%point6
-2 1 1;%point2
0 0 0;%point1
-5 0 0;%point7
-5 -10 0;%point8
-8 -10 0;%point9
-8 10 0;%point10
-5 10 0;%point11
-5 0 0;%point7
-15.5 0 0;%point12
-15.5 2 0;%point13
-17.5 2 0;%point14
-17.5 -2 0;%point15
-15.5 -2 0;%point16
-15.5 0 0;%point12
-18 0 0;%point6
-18 0 -3;%point17
-15.5 0 0;%point15
-18 0 0;%point16
];
end
function XYZ=rotate(XYZ,phi,theta,psi)
%define rotation matrix
R_roll = [
1, 0, 0;
0, cos(phi), -sin(phi);
0, sin(phi), cos(phi)];
R_pitch = [
cos(theta), 0, sin(theta);
0, 1, 0;
-sin(theta), 0, cos(theta)];
R_yaw = [
cos(psi), -sin(psi), 0;
sin(psi), cos(psi), 0;
0, 0, 1];
R = R_roll*R_pitch*R_yaw;
%rotate vertices
XYZ =R*XYZ’;
XYZ = XYZ’;
end
function XYZ = translate(XYZ, pn, pe, pd)
XYZ = XYZ’ + repmat([pn;pe;pd],1,size(XYZ,1));
XYZ=XYZ’;
end I put the following together. It runs, but it doesn’t produce an image that moves on the screen. Instead, the screen moves around the image. I’d prefer the former. I try to expand the scope of the plot box using xlim, ylim, and zlim, but it doesn’t work. I also have a question regarding what is being done with XYZ and XYZ’. I don’t understand what is being done with the single quote mark. Can anyone help me or explain the meaning of the single quote mark? Thank you in advance.
pn=20;
pe=0;
pd=-5;
phi=0;
theta=0;
psi=0;
handle=[];
%Simulation parameters
dpn=-0.2; %Change in position.
dpsi=0.05; %Change in yaw angle.
simlength=100;%Number of Sim Steps
%Draw and update the plane’s position.
for k = 1:simlength
pn = pn+dpn;
psi = psi+dpsi;
%Draw or update the plane.
handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle);
pause(0.1); %Pause to visualize the movement
end
function handle = drawPlaneBody(pn,pe,pd,phi,theta,psi,handle)
%define points on plane in local NED coordintates
NED = airplanepoints;
%rotate plane by (phi; theta; psi)
NED = rotate(NED, phi, theta, psi);
%translate plane to [pn; pe; pd]
NED = translate(NED, pn, pe, pd);
%transform vertices from NED to XYZ
R = […
0, 1, 0;…
1, 0 , 0;…
0, 0, -1;…
];
XYZ = R* NED’;
%plot plane
if isempty(handle)
handle = plot3(XYZ(1,:),XYZ(2,:),XYZ(3,:),’b’);
xlim = ([-100 100]);
ylim = ([-100 100]);
zlim = ([0 100]);
grid on;%show grid
xlabel(‘X’);ylabel(‘Y’);zlabel(‘Z’);%label axes
axis equal;%Maintain aspect ratio
else
set(handle, ‘XData’, XYZ(1,:), ‘YData’,XYZ(2,:), ‘ZData’,XYZ(3,:));
drawnow
end
end
function XYZ = airplanepoints
%define points on the aircraft in local NED
XYZ = […
0 0 0;%point1
-2 1 1;%point2
-2 1 -1;%point3
0 0 0;%point1
-2 -1 1;%point4
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-2 -1 1;%point4
0 0 0;%point1
-2 1 -1;%point3
-2 -1 -1;%point5
0 0 0;%point1
-2 1 1;%point2
-18 0 0;%point6
-2 1 -1;%point3
-18 0 0;%point6
-2 -1 -1;%point5
-18 0 0;%point6
-2 -1 1;%point4
-18 0 0;%point6
-2 1 1;%point2
0 0 0;%point1
-5 0 0;%point7
-5 -10 0;%point8
-8 -10 0;%point9
-8 10 0;%point10
-5 10 0;%point11
-5 0 0;%point7
-15.5 0 0;%point12
-15.5 2 0;%point13
-17.5 2 0;%point14
-17.5 -2 0;%point15
-15.5 -2 0;%point16
-15.5 0 0;%point12
-18 0 0;%point6
-18 0 -3;%point17
-15.5 0 0;%point15
-18 0 0;%point16
];
end
function XYZ=rotate(XYZ,phi,theta,psi)
%define rotation matrix
R_roll = [
1, 0, 0;
0, cos(phi), -sin(phi);
0, sin(phi), cos(phi)];
R_pitch = [
cos(theta), 0, sin(theta);
0, 1, 0;
-sin(theta), 0, cos(theta)];
R_yaw = [
cos(psi), -sin(psi), 0;
sin(psi), cos(psi), 0;
0, 0, 1];
R = R_roll*R_pitch*R_yaw;
%rotate vertices
XYZ =R*XYZ’;
XYZ = XYZ’;
end
function XYZ = translate(XYZ, pn, pe, pd)
XYZ = XYZ’ + repmat([pn;pe;pd],1,size(XYZ,1));
XYZ=XYZ’;
end sizing plot boxes, meaning of single quote mark on existing variable MATLAB Answers — New Questions