Category: Matlab
Category Archives: Matlab
create a 3D average plan (or normal) from two 3D plans (or normals)
How can I determine the average plan knowing the plans of the two attached sets of nodes?
load plan_1_2.mat
figure
plot3(plan_1(:,1),plan_1(:,2),plan_1(:,3),’mo’,’Markersize’,4); % normal 1
hold on
plot3(plan_2(:,1),plan_2(:,2),plan_2(:,3),’go’,’Markersize’,4); % normal 2
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid off
Or, is it possible to create an average normals?How can I determine the average plan knowing the plans of the two attached sets of nodes?
load plan_1_2.mat
figure
plot3(plan_1(:,1),plan_1(:,2),plan_1(:,3),’mo’,’Markersize’,4); % normal 1
hold on
plot3(plan_2(:,1),plan_2(:,2),plan_2(:,3),’go’,’Markersize’,4); % normal 2
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid off
Or, is it possible to create an average normals? How can I determine the average plan knowing the plans of the two attached sets of nodes?
load plan_1_2.mat
figure
plot3(plan_1(:,1),plan_1(:,2),plan_1(:,3),’mo’,’Markersize’,4); % normal 1
hold on
plot3(plan_2(:,1),plan_2(:,2),plan_2(:,3),’go’,’Markersize’,4); % normal 2
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid off
Or, is it possible to create an average normals? norm, normal, average, mean, plan, 3d, 3d plots MATLAB Answers — New Questions
Unable to write to Simulink cache file ‘C:modelname.slxc’ because you do not have write permission for the file.
when I am trying to generate c code from my model, I encounter this error, how to resolve this?
Unable to write to Simulink cache file ‘C:modelname.slxc’ because you do not have write permission for the file.when I am trying to generate c code from my model, I encounter this error, how to resolve this?
Unable to write to Simulink cache file ‘C:modelname.slxc’ because you do not have write permission for the file. when I am trying to generate c code from my model, I encounter this error, how to resolve this?
Unable to write to Simulink cache file ‘C:modelname.slxc’ because you do not have write permission for the file. simulink, code generation MATLAB Answers — New Questions
What is wrong with this code for finding out the number of significant digits after decimal?
I have created this code for finding the number of siignificant digits after decimal for Cody, but for some reason, it shows error (semantic). Can anyone please help identify why? Thank you.
The error comes when I apply:
x = [1.000 1.04 0.22 10.1; 2.05 2.33 4.1 1000.31; 5.00010 6.429 7.492 8.0]
I tried debugging, but the error comes due to 6.429 having a ‘1’ after another 11 zeroes.
Code:
function y = find_max_sigdec(x)
stop = 0;
i = 0;
if x == fix(x)
y = 0;
else
while stop == 0
x = x*10;
i = i+1;
if x == fix(x)
y = i;
stop = 1;
end
end
end
endI have created this code for finding the number of siignificant digits after decimal for Cody, but for some reason, it shows error (semantic). Can anyone please help identify why? Thank you.
The error comes when I apply:
x = [1.000 1.04 0.22 10.1; 2.05 2.33 4.1 1000.31; 5.00010 6.429 7.492 8.0]
I tried debugging, but the error comes due to 6.429 having a ‘1’ after another 11 zeroes.
Code:
function y = find_max_sigdec(x)
stop = 0;
i = 0;
if x == fix(x)
y = 0;
else
while stop == 0
x = x*10;
i = i+1;
if x == fix(x)
y = i;
stop = 1;
end
end
end
end I have created this code for finding the number of siignificant digits after decimal for Cody, but for some reason, it shows error (semantic). Can anyone please help identify why? Thank you.
The error comes when I apply:
x = [1.000 1.04 0.22 10.1; 2.05 2.33 4.1 1000.31; 5.00010 6.429 7.492 8.0]
I tried debugging, but the error comes due to 6.429 having a ‘1’ after another 11 zeroes.
Code:
function y = find_max_sigdec(x)
stop = 0;
i = 0;
if x == fix(x)
y = 0;
else
while stop == 0
x = x*10;
i = i+1;
if x == fix(x)
y = i;
stop = 1;
end
end
end
end significant digits, rounding off MATLAB Answers — New Questions
Distributed digital subarray analysis
clc; clear all; close all;
f = 3e8;
Nx = 10; % number of antennas in subarray
Ns1 = 5;% number of sub array
h = 8; % number of virtual array between subarray
c = 3e8;
lambda = c / f;
dx = 0.42*lambda;
beta = 2 * pi / lambda;
theta = [20];
K = length(theta);
L = round(Nx / 3);
Ri = ones(1,K);
A = 1000;
SNR1 =20;
%% sub array
for Ns = 1 : Ns1
for SNR = 1: SNR1
for l = 1 :A
for m = 1: Ns
for p = 1 : Nx
pos = (m-1)*Nx+p;
P_mp(pos) = (p-(Ns*Nx+(Ns-1)*h+1)/2+(m-1)*(Nx+h));
P_mp1(m,p) = (p-(Ns*Nx+(Ns-1)*h+1)/2+(m-1)*(Nx+h));
end
end
% P_mp1 = P_mp1 + 2*(0.5-rand(Ns,Nx))*pos_var_amp;
A_mp = [];
A_mp_a = [];
E_mp_a = [];
for i = 1:Ns
E_mp(:,:,i) = exp(-1j*beta*P_mp1(i,:)’*dx*sind(theta)); % pole 값
A_mp(:,:,i) = Ri.*E_mp(:,:,i); % 측정 값
A_mp = awgn(A_mp, SNR, ‘measured’); % noise 추가
A_mp1 = sum(A_mp,2);
A_mc(:,:,i) = A_mp1(1:Nx – L + 1,:,i);
A_mr(:,:,i) = A_mp1(Nx – L + 1:Nx,:,i);
A_mk(:,:,i) = hankel(A_mc(:,:,i), A_mr(:,:,i)); % Create Hankel matrix with A_c as the first column and A_r as the last row
E_mp_a = [E_mp_a; E_mp(:,:,i)];
A_mp_a = [A_mp_a ;A_mp1(:,:,i)];
end
%% Hankel stack
Y_ss = A_mk(:,:,1);
if Ns> 1
for z = 2:Ns
Y_ss = [Y_ss ; A_mk(:,:,z)];
end
else
Y_ss = A_mk(:,:,1);
end
[U, S, V] = svd(Y_ss);
V0 = V(:, 1:K);
V1 = V0(1:end-1, :);
V2 = V0(2:end, :);
z_k = eig(pinv(V1) * V2);
find_theta_realarray_MPM(l,:)= asind((imag(log(z_k))*lambda)/(2*pi*dx))’;
rmse_real_mpm(l,:) = sort(theta) – sort(find_theta_realarray_MPM(l,:));
end
rmse_real_MPM_sum = sum(sum(abs(rmse_real_mpm).^2,1),2);
rmse_real_MPM_sum = sqrt(rmse_real_MPM_sum/(A*K));
rmse_real_MPM_sum1(SNR,Ns)= rmse_real_MPM_sum(rmse_real_MPM_sum ~= 0);
end
end
plot(1:SNR1 , rmse_real_MPM_sum1,’-d’,’LineWidth’,1.4)
legend(‘1-subarray’,’2-subarray’,’3-subarray’,’4-subarray’,’5-subarray’)
I think the RMSE should be lower as the subarray increases, but why is the RMSE reversed when the SNR is low?
plz help me…..clc; clear all; close all;
f = 3e8;
Nx = 10; % number of antennas in subarray
Ns1 = 5;% number of sub array
h = 8; % number of virtual array between subarray
c = 3e8;
lambda = c / f;
dx = 0.42*lambda;
beta = 2 * pi / lambda;
theta = [20];
K = length(theta);
L = round(Nx / 3);
Ri = ones(1,K);
A = 1000;
SNR1 =20;
%% sub array
for Ns = 1 : Ns1
for SNR = 1: SNR1
for l = 1 :A
for m = 1: Ns
for p = 1 : Nx
pos = (m-1)*Nx+p;
P_mp(pos) = (p-(Ns*Nx+(Ns-1)*h+1)/2+(m-1)*(Nx+h));
P_mp1(m,p) = (p-(Ns*Nx+(Ns-1)*h+1)/2+(m-1)*(Nx+h));
end
end
% P_mp1 = P_mp1 + 2*(0.5-rand(Ns,Nx))*pos_var_amp;
A_mp = [];
A_mp_a = [];
E_mp_a = [];
for i = 1:Ns
E_mp(:,:,i) = exp(-1j*beta*P_mp1(i,:)’*dx*sind(theta)); % pole 값
A_mp(:,:,i) = Ri.*E_mp(:,:,i); % 측정 값
A_mp = awgn(A_mp, SNR, ‘measured’); % noise 추가
A_mp1 = sum(A_mp,2);
A_mc(:,:,i) = A_mp1(1:Nx – L + 1,:,i);
A_mr(:,:,i) = A_mp1(Nx – L + 1:Nx,:,i);
A_mk(:,:,i) = hankel(A_mc(:,:,i), A_mr(:,:,i)); % Create Hankel matrix with A_c as the first column and A_r as the last row
E_mp_a = [E_mp_a; E_mp(:,:,i)];
A_mp_a = [A_mp_a ;A_mp1(:,:,i)];
end
%% Hankel stack
Y_ss = A_mk(:,:,1);
if Ns> 1
for z = 2:Ns
Y_ss = [Y_ss ; A_mk(:,:,z)];
end
else
Y_ss = A_mk(:,:,1);
end
[U, S, V] = svd(Y_ss);
V0 = V(:, 1:K);
V1 = V0(1:end-1, :);
V2 = V0(2:end, :);
z_k = eig(pinv(V1) * V2);
find_theta_realarray_MPM(l,:)= asind((imag(log(z_k))*lambda)/(2*pi*dx))’;
rmse_real_mpm(l,:) = sort(theta) – sort(find_theta_realarray_MPM(l,:));
end
rmse_real_MPM_sum = sum(sum(abs(rmse_real_mpm).^2,1),2);
rmse_real_MPM_sum = sqrt(rmse_real_MPM_sum/(A*K));
rmse_real_MPM_sum1(SNR,Ns)= rmse_real_MPM_sum(rmse_real_MPM_sum ~= 0);
end
end
plot(1:SNR1 , rmse_real_MPM_sum1,’-d’,’LineWidth’,1.4)
legend(‘1-subarray’,’2-subarray’,’3-subarray’,’4-subarray’,’5-subarray’)
I think the RMSE should be lower as the subarray increases, but why is the RMSE reversed when the SNR is low?
plz help me….. clc; clear all; close all;
f = 3e8;
Nx = 10; % number of antennas in subarray
Ns1 = 5;% number of sub array
h = 8; % number of virtual array between subarray
c = 3e8;
lambda = c / f;
dx = 0.42*lambda;
beta = 2 * pi / lambda;
theta = [20];
K = length(theta);
L = round(Nx / 3);
Ri = ones(1,K);
A = 1000;
SNR1 =20;
%% sub array
for Ns = 1 : Ns1
for SNR = 1: SNR1
for l = 1 :A
for m = 1: Ns
for p = 1 : Nx
pos = (m-1)*Nx+p;
P_mp(pos) = (p-(Ns*Nx+(Ns-1)*h+1)/2+(m-1)*(Nx+h));
P_mp1(m,p) = (p-(Ns*Nx+(Ns-1)*h+1)/2+(m-1)*(Nx+h));
end
end
% P_mp1 = P_mp1 + 2*(0.5-rand(Ns,Nx))*pos_var_amp;
A_mp = [];
A_mp_a = [];
E_mp_a = [];
for i = 1:Ns
E_mp(:,:,i) = exp(-1j*beta*P_mp1(i,:)’*dx*sind(theta)); % pole 값
A_mp(:,:,i) = Ri.*E_mp(:,:,i); % 측정 값
A_mp = awgn(A_mp, SNR, ‘measured’); % noise 추가
A_mp1 = sum(A_mp,2);
A_mc(:,:,i) = A_mp1(1:Nx – L + 1,:,i);
A_mr(:,:,i) = A_mp1(Nx – L + 1:Nx,:,i);
A_mk(:,:,i) = hankel(A_mc(:,:,i), A_mr(:,:,i)); % Create Hankel matrix with A_c as the first column and A_r as the last row
E_mp_a = [E_mp_a; E_mp(:,:,i)];
A_mp_a = [A_mp_a ;A_mp1(:,:,i)];
end
%% Hankel stack
Y_ss = A_mk(:,:,1);
if Ns> 1
for z = 2:Ns
Y_ss = [Y_ss ; A_mk(:,:,z)];
end
else
Y_ss = A_mk(:,:,1);
end
[U, S, V] = svd(Y_ss);
V0 = V(:, 1:K);
V1 = V0(1:end-1, :);
V2 = V0(2:end, :);
z_k = eig(pinv(V1) * V2);
find_theta_realarray_MPM(l,:)= asind((imag(log(z_k))*lambda)/(2*pi*dx))’;
rmse_real_mpm(l,:) = sort(theta) – sort(find_theta_realarray_MPM(l,:));
end
rmse_real_MPM_sum = sum(sum(abs(rmse_real_mpm).^2,1),2);
rmse_real_MPM_sum = sqrt(rmse_real_MPM_sum/(A*K));
rmse_real_MPM_sum1(SNR,Ns)= rmse_real_MPM_sum(rmse_real_MPM_sum ~= 0);
end
end
plot(1:SNR1 , rmse_real_MPM_sum1,’-d’,’LineWidth’,1.4)
legend(‘1-subarray’,’2-subarray’,’3-subarray’,’4-subarray’,’5-subarray’)
I think the RMSE should be lower as the subarray increases, but why is the RMSE reversed when the SNR is low?
plz help me….. ddsa, doa, hankel, svd, snr MATLAB Answers — New Questions
How can I resolve this issue when I try to get c code from simulink model?
Error:Unable to write to Simulink cache file ‘E:Laptop DataPersonalPHD DATAUWPIMyModel.slxc’ because you do not have write permission for the file.Error:Unable to write to Simulink cache file ‘E:Laptop DataPersonalPHD DATAUWPIMyModel.slxc’ because you do not have write permission for the file. Error:Unable to write to Simulink cache file ‘E:Laptop DataPersonalPHD DATAUWPIMyModel.slxc’ because you do not have write permission for the file. code generation MATLAB Answers — New Questions
find the maxima and the maximum
A conical cup is to be made from a circular piece of paper having a radius of 8 cm by cutting out a sector from the paper. Find the maximum capacity of such a cup. derivatives with full solution and drawingA conical cup is to be made from a circular piece of paper having a radius of 8 cm by cutting out a sector from the paper. Find the maximum capacity of such a cup. derivatives with full solution and drawing A conical cup is to be made from a circular piece of paper having a radius of 8 cm by cutting out a sector from the paper. Find the maximum capacity of such a cup. derivatives with full solution and drawing please finf the maxima and maximum. MATLAB Answers — New Questions
I am unable to find the battery builder app from SIMSCAPE BATTERY TRAINING
I was doing simscape battery training and I am unable to find the battery builder app
I tried to find the same from matlab environment still I cannot find it.I was doing simscape battery training and I am unable to find the battery builder app
I tried to find the same from matlab environment still I cannot find it. I was doing simscape battery training and I am unable to find the battery builder app
I tried to find the same from matlab environment still I cannot find it. #simscape battery MATLAB Answers — New Questions
I am using writetable for exporting the workspace variables into excel sheet
I have a excel template in which I export the matlab workspace variables
I am using this code –> writematrix(variables_1,’result.xlsx’,’Sheet’,1,’Range’,’B2′);
After extraction the file changes its column width which I fixed earlier as a templateI have a excel template in which I export the matlab workspace variables
I am using this code –> writematrix(variables_1,’result.xlsx’,’Sheet’,1,’Range’,’B2′);
After extraction the file changes its column width which I fixed earlier as a template I have a excel template in which I export the matlab workspace variables
I am using this code –> writematrix(variables_1,’result.xlsx’,’Sheet’,1,’Range’,’B2′);
After extraction the file changes its column width which I fixed earlier as a template exporting MATLAB Answers — New Questions
How do I retrieve the legend icons property from an existing legend?
Hi,
I have a script that automatically adjusts an existing figure’s linewidth, among other things. It does not work the same with Matlab 2016b. I have modified the script to be 2016b compatible for the most part. It updates the plot line widths but the lines in the legend are not updated. I need to add extra commands in the script to also update the lines in the legend. If I build the legend, I can retrieve the icons property and it is easy:
[~,icons] = legend(‘data 1′,’data 2’);
set(icons,’linewidth’,2);
I need to do this with an existing legend and I cannot find how to retrieve this ‘icons’ propertyHi,
I have a script that automatically adjusts an existing figure’s linewidth, among other things. It does not work the same with Matlab 2016b. I have modified the script to be 2016b compatible for the most part. It updates the plot line widths but the lines in the legend are not updated. I need to add extra commands in the script to also update the lines in the legend. If I build the legend, I can retrieve the icons property and it is easy:
[~,icons] = legend(‘data 1′,’data 2’);
set(icons,’linewidth’,2);
I need to do this with an existing legend and I cannot find how to retrieve this ‘icons’ property Hi,
I have a script that automatically adjusts an existing figure’s linewidth, among other things. It does not work the same with Matlab 2016b. I have modified the script to be 2016b compatible for the most part. It updates the plot line widths but the lines in the legend are not updated. I need to add extra commands in the script to also update the lines in the legend. If I build the legend, I can retrieve the icons property and it is easy:
[~,icons] = legend(‘data 1′,’data 2’);
set(icons,’linewidth’,2);
I need to do this with an existing legend and I cannot find how to retrieve this ‘icons’ property plot MATLAB Answers — New Questions
Simulating engagement of two helical gears
Hello,
I need to simulate two helical gears engagement. One of them is not controllable in terms of revolution. So, it has random revolution per minute. The other one can be controlled in terms of torque and revolution. With a special method, I need to engage these gears. I need to copy behavior of uncontrollable one. After their revolutions are same and steady, at this point I need to engage them.
I may use a PID controller to monitorize and copy uncontrollable one. How can I simulate that?Hello,
I need to simulate two helical gears engagement. One of them is not controllable in terms of revolution. So, it has random revolution per minute. The other one can be controlled in terms of torque and revolution. With a special method, I need to engage these gears. I need to copy behavior of uncontrollable one. After their revolutions are same and steady, at this point I need to engage them.
I may use a PID controller to monitorize and copy uncontrollable one. How can I simulate that? Hello,
I need to simulate two helical gears engagement. One of them is not controllable in terms of revolution. So, it has random revolution per minute. The other one can be controlled in terms of torque and revolution. With a special method, I need to engage these gears. I need to copy behavior of uncontrollable one. After their revolutions are same and steady, at this point I need to engage them.
I may use a PID controller to monitorize and copy uncontrollable one. How can I simulate that? helical gears, pid, simulink, engagement MATLAB Answers — New Questions
tcpclient Sending Nested Strings
I’m trying to send the string below using the Matlab tcpclient. I need to send a string that contains two strings as shown below. I tried converting the entire string below to an asciiArray using the uint8(stringBelow) function and then fwrite(t, asciiArray, ‘uint8’) but that didn’t work either.
Is there a way to send the exact composite string shown below in tcpclient?
>> writeline(t,"Unit.CommandAsText("myFile",1,"Millisecond")")
writeline(t,"Unit.CommandAsText("myFile",1,"Millisecond")")
↑
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error.
To construct matrices, use brackets instead of parentheses.I’m trying to send the string below using the Matlab tcpclient. I need to send a string that contains two strings as shown below. I tried converting the entire string below to an asciiArray using the uint8(stringBelow) function and then fwrite(t, asciiArray, ‘uint8’) but that didn’t work either.
Is there a way to send the exact composite string shown below in tcpclient?
>> writeline(t,"Unit.CommandAsText("myFile",1,"Millisecond")")
writeline(t,"Unit.CommandAsText("myFile",1,"Millisecond")")
↑
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error.
To construct matrices, use brackets instead of parentheses. I’m trying to send the string below using the Matlab tcpclient. I need to send a string that contains two strings as shown below. I tried converting the entire string below to an asciiArray using the uint8(stringBelow) function and then fwrite(t, asciiArray, ‘uint8’) but that didn’t work either.
Is there a way to send the exact composite string shown below in tcpclient?
>> writeline(t,"Unit.CommandAsText("myFile",1,"Millisecond")")
writeline(t,"Unit.CommandAsText("myFile",1,"Millisecond")")
↑
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error.
To construct matrices, use brackets instead of parentheses. tcpclient, string, nested string MATLAB Answers — New Questions
Arrowhead is turning the wrong way
The arrowhead is pointing the wrong way in the x-axis. See figure below.
Definerer alle landes forskydningsbæreevne
clc; clear; close all; clc ;
Forhold = 1/2 ;
Forhold2 = 54/228;
f_vk0 = 0.4 ; % Klæbningsbidrag [MPa]
mu_k = 0.65 ; % Friktionskoefficient
f_bt = 1.00 ; % Trækstyrke af sten [MPa]
f_k = 10.00 ; % Trykstyrke af sten [MPa]
sigma1 = -0.0:0.1:1.6 ;
sigma2 = 0.1:0.1:10.2;
sigma3 = 8.3:0.1:10 ;
sigma23 = 9.1:0.1:10 ;
Friction = (f_vk0 + mu_k * sigma1) / (1 + mu_k * 2 * Forhold) ;
Tension_failure = f_bt / 2.3 * sqrt(1 + sigma2/f_bt) ;
Compression_failure = (f_k – sigma3) * 1/Forhold*(1/2) ;
Friction2 = (f_vk0 + mu_k * sigma1) / (1 + mu_k * 2 * Forhold2) ;
Tension_failure = f_bt / 2.3 * sqrt(1 + sigma2/f_bt) ;
Compression_failure2 = (f_k – sigma23) * 1/Forhold2*(1/2) ;
Plotter forskydningsbæreevnerne
hf = figure() ;
hold on
plot(sigma1, Friction,’–‘,’Color’,[0.4660 0.6740 0.1880],’LineWidth’,1.3)
plot(sigma2, Tension_failure,’–‘,’Color’,[0.9290 0.6940 0.1250],’LineWidth’,1.3)
plot(sigma3, Compression_failure,’–‘,’Color’,[0.4940 0.1840 0.5560],’LineWidth’,1.3)
plot(sigma1, Friction2,’LineWidth’,1.3)
plot(sigma2, Tension_failure,’Color’,[0.6350 0.0780 0.1840],’LineWidth’,1.3)
plot(sigma23, Compression_failure2,’Color’,[0.8500 0.3250 0.0980],’LineWidth’,1.3)
% Shade the area between [sigma1, Friction] and [sigma1, Friction2]
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
grid on;
xlim([0 12])
ylim([0 2])
% Shade the area between [sigma1, Friction] and [sigma1, Friction2]
[x0,y0,~,~] = intersections(sigma1,Friction,sigma2, Tension_failure);
ind = (sigma1<x0);
sigma1b = [sigma1(ind) x0]; % add x0 of true intersection point
Frictionp = [Friction(ind) y0]; % add y0 of true intersection point
[x1,y1,~,~] = intersections(sigma1,Friction2,sigma2, Tension_failure);
ind = (sigma1<x1);
sigma1c = [sigma1(ind) x1]; % add x1 of true intersection point
Friction2p = [Friction2(ind) y1]; % add y1 of true intersection point
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
tt = fill([sigma1b, fliplr(sigma1c)], [Frictionp, fliplr(Friction2p)], [0.6350 0.0780 0.1840],’FaceAlpha’,0.0,’EdgeColor’, ‘none’);
hatchfill2(tt,’single’,’HatchAngle’,-45,’HatchDensity’,90,’HatchColor’,[0.6350 0.0780 0.1840],’HatchLineWidth’,1)
% Shade the area between [sigma3, Compression_failure] and [sigma3, Compression_failure2 ]
[x01,y01,~,~] = intersections(sigma3, Compression_failure,sigma2,Tension_failure);
ind = (sigma3>x01);
sigma1b = [x01 sigma3(ind)]; % add x0 of true intersection point
Frictionp = [y01 Compression_failure(ind)]; % add y0 of true intersection point
[x11,y11,~,~] = intersections(sigma23, Compression_failure2,sigma2,Tension_failure);
ind = (sigma23>x11);
sigma1c = [x11 sigma23(ind)]; % add x1 of true intersection point
Friction2p = [y11 Compression_failure2(ind)]; % add y1 of true intersection point
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
tt2 = fill([sigma1b, fliplr(sigma1c)], [Frictionp, fliplr(Friction2p)], [0.6350 0.0780 0.1840], ‘EdgeColor’, ‘none’,’FaceAlpha’,0.0);
hatchfill2(tt2,’single’,’HatchAngle’,-45,’HatchDensity’,90,’HatchColor’,[0.6350 0.0780 0.1840],’HatchLineWidth’,1)
hax = gca;
hax.XDir = ‘reverse’; % flip axis direction
hax.YAxisLocation = ‘right’; % move ticks & labels to the other side
xlim([-2 12])
ylim([-0.5 2])
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [-1.5 11];
ha.Y = [0 0] ;
%Define the variable
xac = -2; %x arrow coordinate
yac = 0; %y arrow coordinate
xas = 12; %x arrow shift
yas = 0; %y arrow shift
ha = annotation(‘arrow’);
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [-1.5 11];
ha.Y = [0 0] ;
ha = annotation(‘arrow’);
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [0 0];
ha.Y = [-0.4 2] ;
% remove old box and axes
box on
set(gca,’YColor’,get(gca,’Color’))
set(gca,’XColor’,get(gca,’Color’))
set(gca, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 14)
set(gca, ‘XTickLabel’, {});
set(gca, ‘YTickLabel’, {});
legend({‘Friction failure (M&M)’,’Tension failure (M&M)’,’Compression failure (M&M)’,’Friction failure (DK)’,’Tension failure (DK)’,’Compression failure (DK)’},’Location’,’northeast’,’NumColumns’,1,’Orientation’,’vertical’)The arrowhead is pointing the wrong way in the x-axis. See figure below.
Definerer alle landes forskydningsbæreevne
clc; clear; close all; clc ;
Forhold = 1/2 ;
Forhold2 = 54/228;
f_vk0 = 0.4 ; % Klæbningsbidrag [MPa]
mu_k = 0.65 ; % Friktionskoefficient
f_bt = 1.00 ; % Trækstyrke af sten [MPa]
f_k = 10.00 ; % Trykstyrke af sten [MPa]
sigma1 = -0.0:0.1:1.6 ;
sigma2 = 0.1:0.1:10.2;
sigma3 = 8.3:0.1:10 ;
sigma23 = 9.1:0.1:10 ;
Friction = (f_vk0 + mu_k * sigma1) / (1 + mu_k * 2 * Forhold) ;
Tension_failure = f_bt / 2.3 * sqrt(1 + sigma2/f_bt) ;
Compression_failure = (f_k – sigma3) * 1/Forhold*(1/2) ;
Friction2 = (f_vk0 + mu_k * sigma1) / (1 + mu_k * 2 * Forhold2) ;
Tension_failure = f_bt / 2.3 * sqrt(1 + sigma2/f_bt) ;
Compression_failure2 = (f_k – sigma23) * 1/Forhold2*(1/2) ;
Plotter forskydningsbæreevnerne
hf = figure() ;
hold on
plot(sigma1, Friction,’–‘,’Color’,[0.4660 0.6740 0.1880],’LineWidth’,1.3)
plot(sigma2, Tension_failure,’–‘,’Color’,[0.9290 0.6940 0.1250],’LineWidth’,1.3)
plot(sigma3, Compression_failure,’–‘,’Color’,[0.4940 0.1840 0.5560],’LineWidth’,1.3)
plot(sigma1, Friction2,’LineWidth’,1.3)
plot(sigma2, Tension_failure,’Color’,[0.6350 0.0780 0.1840],’LineWidth’,1.3)
plot(sigma23, Compression_failure2,’Color’,[0.8500 0.3250 0.0980],’LineWidth’,1.3)
% Shade the area between [sigma1, Friction] and [sigma1, Friction2]
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
grid on;
xlim([0 12])
ylim([0 2])
% Shade the area between [sigma1, Friction] and [sigma1, Friction2]
[x0,y0,~,~] = intersections(sigma1,Friction,sigma2, Tension_failure);
ind = (sigma1<x0);
sigma1b = [sigma1(ind) x0]; % add x0 of true intersection point
Frictionp = [Friction(ind) y0]; % add y0 of true intersection point
[x1,y1,~,~] = intersections(sigma1,Friction2,sigma2, Tension_failure);
ind = (sigma1<x1);
sigma1c = [sigma1(ind) x1]; % add x1 of true intersection point
Friction2p = [Friction2(ind) y1]; % add y1 of true intersection point
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
tt = fill([sigma1b, fliplr(sigma1c)], [Frictionp, fliplr(Friction2p)], [0.6350 0.0780 0.1840],’FaceAlpha’,0.0,’EdgeColor’, ‘none’);
hatchfill2(tt,’single’,’HatchAngle’,-45,’HatchDensity’,90,’HatchColor’,[0.6350 0.0780 0.1840],’HatchLineWidth’,1)
% Shade the area between [sigma3, Compression_failure] and [sigma3, Compression_failure2 ]
[x01,y01,~,~] = intersections(sigma3, Compression_failure,sigma2,Tension_failure);
ind = (sigma3>x01);
sigma1b = [x01 sigma3(ind)]; % add x0 of true intersection point
Frictionp = [y01 Compression_failure(ind)]; % add y0 of true intersection point
[x11,y11,~,~] = intersections(sigma23, Compression_failure2,sigma2,Tension_failure);
ind = (sigma23>x11);
sigma1c = [x11 sigma23(ind)]; % add x1 of true intersection point
Friction2p = [y11 Compression_failure2(ind)]; % add y1 of true intersection point
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
tt2 = fill([sigma1b, fliplr(sigma1c)], [Frictionp, fliplr(Friction2p)], [0.6350 0.0780 0.1840], ‘EdgeColor’, ‘none’,’FaceAlpha’,0.0);
hatchfill2(tt2,’single’,’HatchAngle’,-45,’HatchDensity’,90,’HatchColor’,[0.6350 0.0780 0.1840],’HatchLineWidth’,1)
hax = gca;
hax.XDir = ‘reverse’; % flip axis direction
hax.YAxisLocation = ‘right’; % move ticks & labels to the other side
xlim([-2 12])
ylim([-0.5 2])
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [-1.5 11];
ha.Y = [0 0] ;
%Define the variable
xac = -2; %x arrow coordinate
yac = 0; %y arrow coordinate
xas = 12; %x arrow shift
yas = 0; %y arrow shift
ha = annotation(‘arrow’);
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [-1.5 11];
ha.Y = [0 0] ;
ha = annotation(‘arrow’);
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [0 0];
ha.Y = [-0.4 2] ;
% remove old box and axes
box on
set(gca,’YColor’,get(gca,’Color’))
set(gca,’XColor’,get(gca,’Color’))
set(gca, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 14)
set(gca, ‘XTickLabel’, {});
set(gca, ‘YTickLabel’, {});
legend({‘Friction failure (M&M)’,’Tension failure (M&M)’,’Compression failure (M&M)’,’Friction failure (DK)’,’Tension failure (DK)’,’Compression failure (DK)’},’Location’,’northeast’,’NumColumns’,1,’Orientation’,’vertical’) The arrowhead is pointing the wrong way in the x-axis. See figure below.
Definerer alle landes forskydningsbæreevne
clc; clear; close all; clc ;
Forhold = 1/2 ;
Forhold2 = 54/228;
f_vk0 = 0.4 ; % Klæbningsbidrag [MPa]
mu_k = 0.65 ; % Friktionskoefficient
f_bt = 1.00 ; % Trækstyrke af sten [MPa]
f_k = 10.00 ; % Trykstyrke af sten [MPa]
sigma1 = -0.0:0.1:1.6 ;
sigma2 = 0.1:0.1:10.2;
sigma3 = 8.3:0.1:10 ;
sigma23 = 9.1:0.1:10 ;
Friction = (f_vk0 + mu_k * sigma1) / (1 + mu_k * 2 * Forhold) ;
Tension_failure = f_bt / 2.3 * sqrt(1 + sigma2/f_bt) ;
Compression_failure = (f_k – sigma3) * 1/Forhold*(1/2) ;
Friction2 = (f_vk0 + mu_k * sigma1) / (1 + mu_k * 2 * Forhold2) ;
Tension_failure = f_bt / 2.3 * sqrt(1 + sigma2/f_bt) ;
Compression_failure2 = (f_k – sigma23) * 1/Forhold2*(1/2) ;
Plotter forskydningsbæreevnerne
hf = figure() ;
hold on
plot(sigma1, Friction,’–‘,’Color’,[0.4660 0.6740 0.1880],’LineWidth’,1.3)
plot(sigma2, Tension_failure,’–‘,’Color’,[0.9290 0.6940 0.1250],’LineWidth’,1.3)
plot(sigma3, Compression_failure,’–‘,’Color’,[0.4940 0.1840 0.5560],’LineWidth’,1.3)
plot(sigma1, Friction2,’LineWidth’,1.3)
plot(sigma2, Tension_failure,’Color’,[0.6350 0.0780 0.1840],’LineWidth’,1.3)
plot(sigma23, Compression_failure2,’Color’,[0.8500 0.3250 0.0980],’LineWidth’,1.3)
% Shade the area between [sigma1, Friction] and [sigma1, Friction2]
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
grid on;
xlim([0 12])
ylim([0 2])
% Shade the area between [sigma1, Friction] and [sigma1, Friction2]
[x0,y0,~,~] = intersections(sigma1,Friction,sigma2, Tension_failure);
ind = (sigma1<x0);
sigma1b = [sigma1(ind) x0]; % add x0 of true intersection point
Frictionp = [Friction(ind) y0]; % add y0 of true intersection point
[x1,y1,~,~] = intersections(sigma1,Friction2,sigma2, Tension_failure);
ind = (sigma1<x1);
sigma1c = [sigma1(ind) x1]; % add x1 of true intersection point
Friction2p = [Friction2(ind) y1]; % add y1 of true intersection point
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
tt = fill([sigma1b, fliplr(sigma1c)], [Frictionp, fliplr(Friction2p)], [0.6350 0.0780 0.1840],’FaceAlpha’,0.0,’EdgeColor’, ‘none’);
hatchfill2(tt,’single’,’HatchAngle’,-45,’HatchDensity’,90,’HatchColor’,[0.6350 0.0780 0.1840],’HatchLineWidth’,1)
% Shade the area between [sigma3, Compression_failure] and [sigma3, Compression_failure2 ]
[x01,y01,~,~] = intersections(sigma3, Compression_failure,sigma2,Tension_failure);
ind = (sigma3>x01);
sigma1b = [x01 sigma3(ind)]; % add x0 of true intersection point
Frictionp = [y01 Compression_failure(ind)]; % add y0 of true intersection point
[x11,y11,~,~] = intersections(sigma23, Compression_failure2,sigma2,Tension_failure);
ind = (sigma23>x11);
sigma1c = [x11 sigma23(ind)]; % add x1 of true intersection point
Friction2p = [y11 Compression_failure2(ind)]; % add y1 of true intersection point
% fill([sigma1, fliplr(sigma1)], [Friction, fliplr(Friction2)], [0.7 0.7 0.7], ‘EdgeColor’, ‘none’);
tt2 = fill([sigma1b, fliplr(sigma1c)], [Frictionp, fliplr(Friction2p)], [0.6350 0.0780 0.1840], ‘EdgeColor’, ‘none’,’FaceAlpha’,0.0);
hatchfill2(tt2,’single’,’HatchAngle’,-45,’HatchDensity’,90,’HatchColor’,[0.6350 0.0780 0.1840],’HatchLineWidth’,1)
hax = gca;
hax.XDir = ‘reverse’; % flip axis direction
hax.YAxisLocation = ‘right’; % move ticks & labels to the other side
xlim([-2 12])
ylim([-0.5 2])
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [-1.5 11];
ha.Y = [0 0] ;
%Define the variable
xac = -2; %x arrow coordinate
yac = 0; %y arrow coordinate
xas = 12; %x arrow shift
yas = 0; %y arrow shift
ha = annotation(‘arrow’);
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [-1.5 11];
ha.Y = [0 0] ;
ha = annotation(‘arrow’);
ha.Parent = hf.CurrentAxes; % associate annotation with current axes
% now you can use data units
ha.X = [0 0];
ha.Y = [-0.4 2] ;
% remove old box and axes
box on
set(gca,’YColor’,get(gca,’Color’))
set(gca,’XColor’,get(gca,’Color’))
set(gca, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 14)
set(gca, ‘XTickLabel’, {});
set(gca, ‘YTickLabel’, {});
legend({‘Friction failure (M&M)’,’Tension failure (M&M)’,’Compression failure (M&M)’,’Friction failure (DK)’,’Tension failure (DK)’,’Compression failure (DK)’},’Location’,’northeast’,’NumColumns’,1,’Orientation’,’vertical’) annotation(‘arrow’), ‘reverse’ MATLAB Answers — New Questions
Workspace sorting order of new desktop
Hello. Lately I’ve been trying the new feature "new desktop" for version 2024a which introduced the dark theme. I am really enjoying it, however I am going through an issue which is quite critical for my work.
With earlier versions, sorting variables in the workspace always prioritized alphabetical order, sorting by the first letter of the variable name regardless if it was uppercase or lower (e.g. the variables were sorted as a… – A… – b… – B…).
In the "new desktop" mode (not sure if it’s actually introduced entirely in 2024a [edit: I checked this and it does not happen in standard 2024a]), the sorting appears to be different, prioritizing the capitalized letter and only after sorting by the lowercase letters (so A… – B… – a… – b…).
This is actually a huge dealbreaker for me, as my work is strongly related to the old feature and I cannot simply adapt to it. I tried to look into the preferences but I couldn’t manage to find an option to bring back the legacy feature. Is there a way to go back to the previous workspace sorting order? It would be a shame to downgrade to the previous Matlab release since I’m enjoying the new one, but I’ll be forced to do it if I can’t solve this issue. Thank you.Hello. Lately I’ve been trying the new feature "new desktop" for version 2024a which introduced the dark theme. I am really enjoying it, however I am going through an issue which is quite critical for my work.
With earlier versions, sorting variables in the workspace always prioritized alphabetical order, sorting by the first letter of the variable name regardless if it was uppercase or lower (e.g. the variables were sorted as a… – A… – b… – B…).
In the "new desktop" mode (not sure if it’s actually introduced entirely in 2024a [edit: I checked this and it does not happen in standard 2024a]), the sorting appears to be different, prioritizing the capitalized letter and only after sorting by the lowercase letters (so A… – B… – a… – b…).
This is actually a huge dealbreaker for me, as my work is strongly related to the old feature and I cannot simply adapt to it. I tried to look into the preferences but I couldn’t manage to find an option to bring back the legacy feature. Is there a way to go back to the previous workspace sorting order? It would be a shame to downgrade to the previous Matlab release since I’m enjoying the new one, but I’ll be forced to do it if I can’t solve this issue. Thank you. Hello. Lately I’ve been trying the new feature "new desktop" for version 2024a which introduced the dark theme. I am really enjoying it, however I am going through an issue which is quite critical for my work.
With earlier versions, sorting variables in the workspace always prioritized alphabetical order, sorting by the first letter of the variable name regardless if it was uppercase or lower (e.g. the variables were sorted as a… – A… – b… – B…).
In the "new desktop" mode (not sure if it’s actually introduced entirely in 2024a [edit: I checked this and it does not happen in standard 2024a]), the sorting appears to be different, prioritizing the capitalized letter and only after sorting by the lowercase letters (so A… – B… – a… – b…).
This is actually a huge dealbreaker for me, as my work is strongly related to the old feature and I cannot simply adapt to it. I tried to look into the preferences but I couldn’t manage to find an option to bring back the legacy feature. Is there a way to go back to the previous workspace sorting order? It would be a shame to downgrade to the previous Matlab release since I’m enjoying the new one, but I’ll be forced to do it if I can’t solve this issue. Thank you. workspace, variables, sort MATLAB Answers — New Questions
Contour plot from x and y data points with corresponding contour level
I have sets of x and y data points that correspond to a specific contour level. For example (x1,y1) and (x2,y2) correspond to a contour level of 0.1 and (x3,y3) and (x4,y4) correspond to a contour level of 0.01. How do I plot these using the contour function?
In the attached .mat file, I have a cell array of tables. Each table has x and y data and the corresponding contour level (which is labeled Density). Basically, if you plot the x and y data using plot() it will create the contour, but I want to use contour() to plot to leverage labeling contours.I have sets of x and y data points that correspond to a specific contour level. For example (x1,y1) and (x2,y2) correspond to a contour level of 0.1 and (x3,y3) and (x4,y4) correspond to a contour level of 0.01. How do I plot these using the contour function?
In the attached .mat file, I have a cell array of tables. Each table has x and y data and the corresponding contour level (which is labeled Density). Basically, if you plot the x and y data using plot() it will create the contour, but I want to use contour() to plot to leverage labeling contours. I have sets of x and y data points that correspond to a specific contour level. For example (x1,y1) and (x2,y2) correspond to a contour level of 0.1 and (x3,y3) and (x4,y4) correspond to a contour level of 0.01. How do I plot these using the contour function?
In the attached .mat file, I have a cell array of tables. Each table has x and y data and the corresponding contour level (which is labeled Density). Basically, if you plot the x and y data using plot() it will create the contour, but I want to use contour() to plot to leverage labeling contours. contour, contour plot MATLAB Answers — New Questions
how to calling out the data in the matrix
i want to calling out the data in the matrix. for example;
t=[1 2 3; 4 5 6; 7 8 9]
what coding can be used to calling out the specific data like calling 3 in the t matrix.i want to calling out the data in the matrix. for example;
t=[1 2 3; 4 5 6; 7 8 9]
what coding can be used to calling out the specific data like calling 3 in the t matrix. i want to calling out the data in the matrix. for example;
t=[1 2 3; 4 5 6; 7 8 9]
what coding can be used to calling out the specific data like calling 3 in the t matrix. ??? MATLAB Answers — New Questions
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