Tag Archives: matlab
save animation in subplot
I’m using
while
drawnow;hold off
end
to create an animation. But this animation is just the 6th position as in subplot(2,3,6) (or through next tile repeatedly). To save this animation to the computer while not keeping the other subplots 1~5, what to do?I’m using
while
drawnow;hold off
end
to create an animation. But this animation is just the 6th position as in subplot(2,3,6) (or through next tile repeatedly). To save this animation to the computer while not keeping the other subplots 1~5, what to do? I’m using
while
drawnow;hold off
end
to create an animation. But this animation is just the 6th position as in subplot(2,3,6) (or through next tile repeatedly). To save this animation to the computer while not keeping the other subplots 1~5, what to do? drawnow, movie MATLAB Answers — New Questions
How can I increase the number of decimal places displayed on app designer UITable?
I am working on an app that ultimately produces 4 separate tables, each containing 4 columns of data. For simplicity, I am only including a single example, as I would think the process should be identical for all 4 tables, aside from the name of each table. All of the tables currently only show 4 decimal places. I would like to show more than this. I tried putting the following code in my startup function:
function startupFcn(app)
clc
close all
app.UITable.ColumnFormat = {‘long’,’long’,’long’,’long’}; %4x ‘long’ – 1 for each column?
This does not seem to work, as all of the tables still only display 4 decimal places. Any help would much appreciated. Thank you.I am working on an app that ultimately produces 4 separate tables, each containing 4 columns of data. For simplicity, I am only including a single example, as I would think the process should be identical for all 4 tables, aside from the name of each table. All of the tables currently only show 4 decimal places. I would like to show more than this. I tried putting the following code in my startup function:
function startupFcn(app)
clc
close all
app.UITable.ColumnFormat = {‘long’,’long’,’long’,’long’}; %4x ‘long’ – 1 for each column?
This does not seem to work, as all of the tables still only display 4 decimal places. Any help would much appreciated. Thank you. I am working on an app that ultimately produces 4 separate tables, each containing 4 columns of data. For simplicity, I am only including a single example, as I would think the process should be identical for all 4 tables, aside from the name of each table. All of the tables currently only show 4 decimal places. I would like to show more than this. I tried putting the following code in my startup function:
function startupFcn(app)
clc
close all
app.UITable.ColumnFormat = {‘long’,’long’,’long’,’long’}; %4x ‘long’ – 1 for each column?
This does not seem to work, as all of the tables still only display 4 decimal places. Any help would much appreciated. Thank you. appdesigner, uitable MATLAB Answers — New Questions
Plotting multiple datasets on one plot
I have a set of data for three replicate simulations: run0-run2, these consist of .dat files at a set time interval (here, every 100ns until final time 500ns).
I would like to plot these all on one plot but with a different colour gradient from darker to lighter e.g.
Run0 with a blue gradient dark to light as time increases.
Run1 with a green gradient dark to light as time increases.
Run2 with a red gradient dark to light as time increases.
I created the MATLAB script below but during testing, only the red plots would show up.
Combining into one for loop doesn’t work as I tried that already.
Any help would be greatly apreciated.
Code below and attached.
r0_f100=readmatrix (‘run0_test_fluct-100ns.dat’);
r0_f200=readmatrix (‘run0_test_fluct-200ns.dat’);
r0_f300=readmatrix (‘run0_test_fluct-300ns.dat’);
r0_f400=readmatrix (‘run0_test_fluct-400ns.dat’);
r0_f500=readmatrix (‘run0_test_fluct-500ns.dat’);
x_0=r0_f100(:,1);
y_0=[r0_f100(:,2),r0_f200(:,2),r0_f300(:,2),r0_f400(:,2),r0_f500(:,2)];
r1_f100=readmatrix (‘run1_test_fluct-100ns.dat’);
r1_f200=readmatrix (‘run1_test_fluct-200ns.dat’);
r1_f300=readmatrix (‘run1_test_fluct-300ns.dat’);
r1_f400=readmatrix (‘run1_test_fluct-400ns.dat’);
r1_f500=readmatrix (‘run1_test_fluct-500ns.dat’);
x_1=r1_f100(:,1);
y_1=[r1_f100(:,2),r1_f200(:,2),r1_f300(:,2),r1_f400(:,2),r1_f500(:,2)];
r2_f100=readmatrix (‘run2_test_fluct-100ns.dat’);
r2_f200=readmatrix (‘run2_test_fluct-200ns.dat’);
r2_f300=readmatrix (‘run2_test_fluct-300ns.dat’);
r2_f400=readmatrix (‘run2_test_fluct-400ns.dat’);
r2_f500=readmatrix (‘run2_test_fluct-500ns.dat’);
x_2=r2_f100(:,1);
y_2=[r2_f100(:,2),r2_f200(:,2),r2_f300(:,2),r2_f400(:,2),r2_f500(:,2)];
num_plots = 5;
colors = linspace(0.5, 1, num_plots)’;
figure
hold on
for i=1:num_plots
plot(x_0, y_0(:,i), ‘color’, [0 0 colors(i)]);
end
for i=1:num_plots
plot(x_1, y_1(:,i), ‘color’, [0 colors(i) 0]);
end
for i=1:num_plots
plot(x_2, y_2(:,i), ‘color’, [colors(i) 0 0]);
end
xlabel (‘Residue No.’); ylabel (‘RMSF / Å’);
ax = gca;
fig=gcf;
fig.Position(3:4)=[800,600];
fig.Color=[0.95 0.95 0.95];
ax.Color=[0.8 0.8 0.8];
hold off
%exportgraphics(fig,’test_RMSF.jpg’,’Resolution’,300);I have a set of data for three replicate simulations: run0-run2, these consist of .dat files at a set time interval (here, every 100ns until final time 500ns).
I would like to plot these all on one plot but with a different colour gradient from darker to lighter e.g.
Run0 with a blue gradient dark to light as time increases.
Run1 with a green gradient dark to light as time increases.
Run2 with a red gradient dark to light as time increases.
I created the MATLAB script below but during testing, only the red plots would show up.
Combining into one for loop doesn’t work as I tried that already.
Any help would be greatly apreciated.
Code below and attached.
r0_f100=readmatrix (‘run0_test_fluct-100ns.dat’);
r0_f200=readmatrix (‘run0_test_fluct-200ns.dat’);
r0_f300=readmatrix (‘run0_test_fluct-300ns.dat’);
r0_f400=readmatrix (‘run0_test_fluct-400ns.dat’);
r0_f500=readmatrix (‘run0_test_fluct-500ns.dat’);
x_0=r0_f100(:,1);
y_0=[r0_f100(:,2),r0_f200(:,2),r0_f300(:,2),r0_f400(:,2),r0_f500(:,2)];
r1_f100=readmatrix (‘run1_test_fluct-100ns.dat’);
r1_f200=readmatrix (‘run1_test_fluct-200ns.dat’);
r1_f300=readmatrix (‘run1_test_fluct-300ns.dat’);
r1_f400=readmatrix (‘run1_test_fluct-400ns.dat’);
r1_f500=readmatrix (‘run1_test_fluct-500ns.dat’);
x_1=r1_f100(:,1);
y_1=[r1_f100(:,2),r1_f200(:,2),r1_f300(:,2),r1_f400(:,2),r1_f500(:,2)];
r2_f100=readmatrix (‘run2_test_fluct-100ns.dat’);
r2_f200=readmatrix (‘run2_test_fluct-200ns.dat’);
r2_f300=readmatrix (‘run2_test_fluct-300ns.dat’);
r2_f400=readmatrix (‘run2_test_fluct-400ns.dat’);
r2_f500=readmatrix (‘run2_test_fluct-500ns.dat’);
x_2=r2_f100(:,1);
y_2=[r2_f100(:,2),r2_f200(:,2),r2_f300(:,2),r2_f400(:,2),r2_f500(:,2)];
num_plots = 5;
colors = linspace(0.5, 1, num_plots)’;
figure
hold on
for i=1:num_plots
plot(x_0, y_0(:,i), ‘color’, [0 0 colors(i)]);
end
for i=1:num_plots
plot(x_1, y_1(:,i), ‘color’, [0 colors(i) 0]);
end
for i=1:num_plots
plot(x_2, y_2(:,i), ‘color’, [colors(i) 0 0]);
end
xlabel (‘Residue No.’); ylabel (‘RMSF / Å’);
ax = gca;
fig=gcf;
fig.Position(3:4)=[800,600];
fig.Color=[0.95 0.95 0.95];
ax.Color=[0.8 0.8 0.8];
hold off
%exportgraphics(fig,’test_RMSF.jpg’,’Resolution’,300); I have a set of data for three replicate simulations: run0-run2, these consist of .dat files at a set time interval (here, every 100ns until final time 500ns).
I would like to plot these all on one plot but with a different colour gradient from darker to lighter e.g.
Run0 with a blue gradient dark to light as time increases.
Run1 with a green gradient dark to light as time increases.
Run2 with a red gradient dark to light as time increases.
I created the MATLAB script below but during testing, only the red plots would show up.
Combining into one for loop doesn’t work as I tried that already.
Any help would be greatly apreciated.
Code below and attached.
r0_f100=readmatrix (‘run0_test_fluct-100ns.dat’);
r0_f200=readmatrix (‘run0_test_fluct-200ns.dat’);
r0_f300=readmatrix (‘run0_test_fluct-300ns.dat’);
r0_f400=readmatrix (‘run0_test_fluct-400ns.dat’);
r0_f500=readmatrix (‘run0_test_fluct-500ns.dat’);
x_0=r0_f100(:,1);
y_0=[r0_f100(:,2),r0_f200(:,2),r0_f300(:,2),r0_f400(:,2),r0_f500(:,2)];
r1_f100=readmatrix (‘run1_test_fluct-100ns.dat’);
r1_f200=readmatrix (‘run1_test_fluct-200ns.dat’);
r1_f300=readmatrix (‘run1_test_fluct-300ns.dat’);
r1_f400=readmatrix (‘run1_test_fluct-400ns.dat’);
r1_f500=readmatrix (‘run1_test_fluct-500ns.dat’);
x_1=r1_f100(:,1);
y_1=[r1_f100(:,2),r1_f200(:,2),r1_f300(:,2),r1_f400(:,2),r1_f500(:,2)];
r2_f100=readmatrix (‘run2_test_fluct-100ns.dat’);
r2_f200=readmatrix (‘run2_test_fluct-200ns.dat’);
r2_f300=readmatrix (‘run2_test_fluct-300ns.dat’);
r2_f400=readmatrix (‘run2_test_fluct-400ns.dat’);
r2_f500=readmatrix (‘run2_test_fluct-500ns.dat’);
x_2=r2_f100(:,1);
y_2=[r2_f100(:,2),r2_f200(:,2),r2_f300(:,2),r2_f400(:,2),r2_f500(:,2)];
num_plots = 5;
colors = linspace(0.5, 1, num_plots)’;
figure
hold on
for i=1:num_plots
plot(x_0, y_0(:,i), ‘color’, [0 0 colors(i)]);
end
for i=1:num_plots
plot(x_1, y_1(:,i), ‘color’, [0 colors(i) 0]);
end
for i=1:num_plots
plot(x_2, y_2(:,i), ‘color’, [colors(i) 0 0]);
end
xlabel (‘Residue No.’); ylabel (‘RMSF / Å’);
ax = gca;
fig=gcf;
fig.Position(3:4)=[800,600];
fig.Color=[0.95 0.95 0.95];
ax.Color=[0.8 0.8 0.8];
hold off
%exportgraphics(fig,’test_RMSF.jpg’,’Resolution’,300); multiple datasets, plotting MATLAB Answers — New Questions
Image Processing Toolbox activated?
When I type into command window, license(‘test’, ‘image_toolbox’), it returns 1.
My code reads and displays images by imread, imshow. But it when I use mat2gray in the next line, there’s an error "’mat2gray’ requires Image Processing Toolbox."When I type into command window, license(‘test’, ‘image_toolbox’), it returns 1.
My code reads and displays images by imread, imshow. But it when I use mat2gray in the next line, there’s an error "’mat2gray’ requires Image Processing Toolbox." When I type into command window, license(‘test’, ‘image_toolbox’), it returns 1.
My code reads and displays images by imread, imshow. But it when I use mat2gray in the next line, there’s an error "’mat2gray’ requires Image Processing Toolbox." image-processing toolbox MATLAB Answers — New Questions
Open a picture when an object is clicked.
I would like to attach an object (or something) next to a block that would open a picture when someone clicks on the object. I don’t have a lot of space on my model but I think it would be helpful if someone could click on an object to show a picture of the actual piece of equipment.I would like to attach an object (or something) next to a block that would open a picture when someone clicks on the object. I don’t have a lot of space on my model but I think it would be helpful if someone could click on an object to show a picture of the actual piece of equipment. I would like to attach an object (or something) next to a block that would open a picture when someone clicks on the object. I don’t have a lot of space on my model but I think it would be helpful if someone could click on an object to show a picture of the actual piece of equipment. show picture MATLAB Answers — New Questions
I want to export my variabels to a single .nc file
Hello.
I have a set of variables that i want to export as one .nc file so that i can use the dataset later on. I have tried using the instructions listed in this thread but it keeps returning an error. I’ll include my code and the variables that i use below. And sorry for the rudamentary code, I’m still new to matlab
clear
clc
%masukin waktu
waktu= ncread(‘FABMSAT.nc’,’time’);
waktu= waktu’;
%masukin fito layer 1
fito= ncread(‘FABMSAT.nc’,’npzd_phy’);
fito= fito(:,1,:);
%masukin pasut
pasut= ncread(‘FABMSAT.nc’,’zeta’);
% masukin vector u
u= ncread(‘FABMSAT.nc’,’u’);
u= u(:,1,:);
%Masukin vector v
v= ncread(‘FABMSAT.nc’,’u’);
v= v(:,1,:);
%CUT SUPAYA MULAI 1 FEB 2022
waktu_feb= waktu;
waktu_feb(:,[1:168])=[];
fito_feb= fito;
fito_feb(:,[1:168])=[];
pasut_feb= pasut;
pasut_feb([2:8307],:)=[];
u_feb= u;
u_feb(:,[1:168])=[];
v_feb= v;
v_feb(:,[1:168])=[];
%define dimensions
netcdf.setDefaultFormat(‘NC_FORMAT_CLASSIC’);
ncid = netcdf.create(‘test.nc’,’NC_WRITE’);
dimidfito = netcdf.defDim(ncid,’fito_feb’,fito_feb);
%Define the name of variable
var_fito = netcdf.defVar(ncid, ‘fito_feb’,’NC_FLOAT’,[dimidfito]);
%variables into .nc file
netcdf.endDef(ncid);
netcdf.putVar(ncid,var_fito,fito_feb);
netcdf.close(ncid);Hello.
I have a set of variables that i want to export as one .nc file so that i can use the dataset later on. I have tried using the instructions listed in this thread but it keeps returning an error. I’ll include my code and the variables that i use below. And sorry for the rudamentary code, I’m still new to matlab
clear
clc
%masukin waktu
waktu= ncread(‘FABMSAT.nc’,’time’);
waktu= waktu’;
%masukin fito layer 1
fito= ncread(‘FABMSAT.nc’,’npzd_phy’);
fito= fito(:,1,:);
%masukin pasut
pasut= ncread(‘FABMSAT.nc’,’zeta’);
% masukin vector u
u= ncread(‘FABMSAT.nc’,’u’);
u= u(:,1,:);
%Masukin vector v
v= ncread(‘FABMSAT.nc’,’u’);
v= v(:,1,:);
%CUT SUPAYA MULAI 1 FEB 2022
waktu_feb= waktu;
waktu_feb(:,[1:168])=[];
fito_feb= fito;
fito_feb(:,[1:168])=[];
pasut_feb= pasut;
pasut_feb([2:8307],:)=[];
u_feb= u;
u_feb(:,[1:168])=[];
v_feb= v;
v_feb(:,[1:168])=[];
%define dimensions
netcdf.setDefaultFormat(‘NC_FORMAT_CLASSIC’);
ncid = netcdf.create(‘test.nc’,’NC_WRITE’);
dimidfito = netcdf.defDim(ncid,’fito_feb’,fito_feb);
%Define the name of variable
var_fito = netcdf.defVar(ncid, ‘fito_feb’,’NC_FLOAT’,[dimidfito]);
%variables into .nc file
netcdf.endDef(ncid);
netcdf.putVar(ncid,var_fito,fito_feb);
netcdf.close(ncid); Hello.
I have a set of variables that i want to export as one .nc file so that i can use the dataset later on. I have tried using the instructions listed in this thread but it keeps returning an error. I’ll include my code and the variables that i use below. And sorry for the rudamentary code, I’m still new to matlab
clear
clc
%masukin waktu
waktu= ncread(‘FABMSAT.nc’,’time’);
waktu= waktu’;
%masukin fito layer 1
fito= ncread(‘FABMSAT.nc’,’npzd_phy’);
fito= fito(:,1,:);
%masukin pasut
pasut= ncread(‘FABMSAT.nc’,’zeta’);
% masukin vector u
u= ncread(‘FABMSAT.nc’,’u’);
u= u(:,1,:);
%Masukin vector v
v= ncread(‘FABMSAT.nc’,’u’);
v= v(:,1,:);
%CUT SUPAYA MULAI 1 FEB 2022
waktu_feb= waktu;
waktu_feb(:,[1:168])=[];
fito_feb= fito;
fito_feb(:,[1:168])=[];
pasut_feb= pasut;
pasut_feb([2:8307],:)=[];
u_feb= u;
u_feb(:,[1:168])=[];
v_feb= v;
v_feb(:,[1:168])=[];
%define dimensions
netcdf.setDefaultFormat(‘NC_FORMAT_CLASSIC’);
ncid = netcdf.create(‘test.nc’,’NC_WRITE’);
dimidfito = netcdf.defDim(ncid,’fito_feb’,fito_feb);
%Define the name of variable
var_fito = netcdf.defVar(ncid, ‘fito_feb’,’NC_FLOAT’,[dimidfito]);
%variables into .nc file
netcdf.endDef(ncid);
netcdf.putVar(ncid,var_fito,fito_feb);
netcdf.close(ncid); export, netcdf MATLAB Answers — New Questions
allmargin gives incorrect answers for some discrete time systems
Hi,
Consider the following code:
s = tf("s");
gs = 1/(s*(s+1));
gz = c2d(gs, 4, "zoh");
allmargin(gz)
gclz = zpk(feedback(gz,1,-1));
abs(gclz.P{1})
In R2024a, the stable flag given by allmargin is equal to one, indicating that the closed loop system is stable. On the other hand, the last sentence of the above code shows that the closed-loop system has a pole outside the unit circle, and therefore it is unstable. I do not have this issue in R2022b. Why the difference?
Sincerely
CarlosHi,
Consider the following code:
s = tf("s");
gs = 1/(s*(s+1));
gz = c2d(gs, 4, "zoh");
allmargin(gz)
gclz = zpk(feedback(gz,1,-1));
abs(gclz.P{1})
In R2024a, the stable flag given by allmargin is equal to one, indicating that the closed loop system is stable. On the other hand, the last sentence of the above code shows that the closed-loop system has a pole outside the unit circle, and therefore it is unstable. I do not have this issue in R2022b. Why the difference?
Sincerely
Carlos Hi,
Consider the following code:
s = tf("s");
gs = 1/(s*(s+1));
gz = c2d(gs, 4, "zoh");
allmargin(gz)
gclz = zpk(feedback(gz,1,-1));
abs(gclz.P{1})
In R2024a, the stable flag given by allmargin is equal to one, indicating that the closed loop system is stable. On the other hand, the last sentence of the above code shows that the closed-loop system has a pole outside the unit circle, and therefore it is unstable. I do not have this issue in R2022b. Why the difference?
Sincerely
Carlos allmargin MATLAB Answers — New Questions
i am getting when trying to 6th order dynamic equation uisng matlab function in simulink, ‘
Derivative of state ‘1’ in block ‘Fccu_matlabFcn/Integrator2’ at time 0.042441271689357414 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)Derivative of state ‘1’ in block ‘Fccu_matlabFcn/Integrator2’ at time 0.042441271689357414 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) Derivative of state ‘1’ in block ‘Fccu_matlabFcn/Integrator2’ at time 0.042441271689357414 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) error tolerances MATLAB Answers — New Questions
Please, I need to express the following equations to get the value of M_tot. I write the equations and successfully ran the code but the result is not what I had anticipated.
Please help, I need to express the following equations to get the value of M_tot. I have already written the relevant equations and successfully ran the code, but the result is not what I had anticipated. Would you kindly examine the following code and compare it with the equations for the system?
Sf = 0.01;
Mo = 4*pi*10^-7 ;
Mr = 3200;
Fr= 85000;
w = 2*pi*Fr;
t_TX = 0.01;
t_RX = 0.02;
rs = 0.00006;
r_TX = 17.32*1.58*rs;
r_RX = 17.32*1.58*rs;
R_TX = 0.045;
R_RX = 0.045;
h = 0.3;
d_TX = 0.01;
d_RX = 0.01;
N_TX = 10;
N_RX = 10;
s = 0.005;
Func = 0;
M_fer = 0;
M_air = 0;
syms k
syms x
i
f1 = sqrt ((k^2)+i*(w*Mo*Mr*Sf));
f2 = (Mr-(f1/k))/(Mr+(f1/k));
f3_TX = f2*(1-exp(-2*f1*t_TX)) / (1-((f2)^2)*(exp(-2*f1*t_TX)));
f3_RX = f2*(1-exp(-2*f1*t_RX)) / (1-((f2)^2)*(exp(-2*f1*t_RX)));
f4 = ((f3_TX)*exp(-k*((2*r_TX) + r_RX + h + d_RX)) + (f3_RX * exp(-k*((2*r_RX) + r_TX + h + d_TX))))/(1 – (f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX))));
f5 = (2 * f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX)) * cosh(k*(r_TX + r_RX + h))) / (1 – (f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX))));
for i = 1:N_TX
R_TXn = R_TX + (N_TX – 1)*(s+ 2*r_TX);
for j = 1:N_RX
R_RXn = R_RX + (N_RX – 1)*(s+ 2*r_RX);
Func = @(k) Mo.*pi.*R_TXn.*R_RXn.* ( besselj(1,(R_TXn.*k)) .* besselj(1,(R_RXn.*k)) .* (f4 + f5));
M_fer = vpaintegral(Func(k),k,0,inf);
f = sqrt ((4.*R_TXn.*R_RXn)./ ((r_TX + r_RX + h)^2 +(R_TXn + R_RXn)^2) );
[K_f,E_f] = ellipke(f);
M_air = Mo.*sqrt(R_TXn.*R_RXn).*(2./f).*((1-0.5.*(f^2)).*(K_f) – E_f) ;
end
end
M_tot = M_fer + M_airPlease help, I need to express the following equations to get the value of M_tot. I have already written the relevant equations and successfully ran the code, but the result is not what I had anticipated. Would you kindly examine the following code and compare it with the equations for the system?
Sf = 0.01;
Mo = 4*pi*10^-7 ;
Mr = 3200;
Fr= 85000;
w = 2*pi*Fr;
t_TX = 0.01;
t_RX = 0.02;
rs = 0.00006;
r_TX = 17.32*1.58*rs;
r_RX = 17.32*1.58*rs;
R_TX = 0.045;
R_RX = 0.045;
h = 0.3;
d_TX = 0.01;
d_RX = 0.01;
N_TX = 10;
N_RX = 10;
s = 0.005;
Func = 0;
M_fer = 0;
M_air = 0;
syms k
syms x
i
f1 = sqrt ((k^2)+i*(w*Mo*Mr*Sf));
f2 = (Mr-(f1/k))/(Mr+(f1/k));
f3_TX = f2*(1-exp(-2*f1*t_TX)) / (1-((f2)^2)*(exp(-2*f1*t_TX)));
f3_RX = f2*(1-exp(-2*f1*t_RX)) / (1-((f2)^2)*(exp(-2*f1*t_RX)));
f4 = ((f3_TX)*exp(-k*((2*r_TX) + r_RX + h + d_RX)) + (f3_RX * exp(-k*((2*r_RX) + r_TX + h + d_TX))))/(1 – (f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX))));
f5 = (2 * f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX)) * cosh(k*(r_TX + r_RX + h))) / (1 – (f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX))));
for i = 1:N_TX
R_TXn = R_TX + (N_TX – 1)*(s+ 2*r_TX);
for j = 1:N_RX
R_RXn = R_RX + (N_RX – 1)*(s+ 2*r_RX);
Func = @(k) Mo.*pi.*R_TXn.*R_RXn.* ( besselj(1,(R_TXn.*k)) .* besselj(1,(R_RXn.*k)) .* (f4 + f5));
M_fer = vpaintegral(Func(k),k,0,inf);
f = sqrt ((4.*R_TXn.*R_RXn)./ ((r_TX + r_RX + h)^2 +(R_TXn + R_RXn)^2) );
[K_f,E_f] = ellipke(f);
M_air = Mo.*sqrt(R_TXn.*R_RXn).*(2./f).*((1-0.5.*(f^2)).*(K_f) – E_f) ;
end
end
M_tot = M_fer + M_air Please help, I need to express the following equations to get the value of M_tot. I have already written the relevant equations and successfully ran the code, but the result is not what I had anticipated. Would you kindly examine the following code and compare it with the equations for the system?
Sf = 0.01;
Mo = 4*pi*10^-7 ;
Mr = 3200;
Fr= 85000;
w = 2*pi*Fr;
t_TX = 0.01;
t_RX = 0.02;
rs = 0.00006;
r_TX = 17.32*1.58*rs;
r_RX = 17.32*1.58*rs;
R_TX = 0.045;
R_RX = 0.045;
h = 0.3;
d_TX = 0.01;
d_RX = 0.01;
N_TX = 10;
N_RX = 10;
s = 0.005;
Func = 0;
M_fer = 0;
M_air = 0;
syms k
syms x
i
f1 = sqrt ((k^2)+i*(w*Mo*Mr*Sf));
f2 = (Mr-(f1/k))/(Mr+(f1/k));
f3_TX = f2*(1-exp(-2*f1*t_TX)) / (1-((f2)^2)*(exp(-2*f1*t_TX)));
f3_RX = f2*(1-exp(-2*f1*t_RX)) / (1-((f2)^2)*(exp(-2*f1*t_RX)));
f4 = ((f3_TX)*exp(-k*((2*r_TX) + r_RX + h + d_RX)) + (f3_RX * exp(-k*((2*r_RX) + r_TX + h + d_TX))))/(1 – (f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX))));
f5 = (2 * f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX)) * cosh(k*(r_TX + r_RX + h))) / (1 – (f3_TX * f3_RX * exp(-k*((2*r_TX) + (2*r_RX) + h + d_TX + d_RX))));
for i = 1:N_TX
R_TXn = R_TX + (N_TX – 1)*(s+ 2*r_TX);
for j = 1:N_RX
R_RXn = R_RX + (N_RX – 1)*(s+ 2*r_RX);
Func = @(k) Mo.*pi.*R_TXn.*R_RXn.* ( besselj(1,(R_TXn.*k)) .* besselj(1,(R_RXn.*k)) .* (f4 + f5));
M_fer = vpaintegral(Func(k),k,0,inf);
f = sqrt ((4.*R_TXn.*R_RXn)./ ((r_TX + r_RX + h)^2 +(R_TXn + R_RXn)^2) );
[K_f,E_f] = ellipke(f);
M_air = Mo.*sqrt(R_TXn.*R_RXn).*(2./f).*((1-0.5.*(f^2)).*(K_f) – E_f) ;
end
end
M_tot = M_fer + M_air mutual_inductance MATLAB Answers — New Questions
Simscape not showing assembly correctly in simulation
I imported my assembly from PTC Creo into Simscape and went to run it, but the assembly looks weird; nowhere like my assembly.
A screenshot of the two is below. Any suggestions?I imported my assembly from PTC Creo into Simscape and went to run it, but the assembly looks weird; nowhere like my assembly.
A screenshot of the two is below. Any suggestions? I imported my assembly from PTC Creo into Simscape and went to run it, but the assembly looks weird; nowhere like my assembly.
A screenshot of the two is below. Any suggestions? simscape, simulink, simulation MATLAB Answers — New Questions
how to put a bar above a letter in MATLAB equation?
I want to write letter x with bar above it but when I write $bar{x}$ it is not working in MATLAB online. Please I need your helpI want to write letter x with bar above it but when I write $bar{x}$ it is not working in MATLAB online. Please I need your help I want to write letter x with bar above it but when I write $bar{x}$ it is not working in MATLAB online. Please I need your help mathematics MATLAB Answers — New Questions
Finding NaN and Missing values from a mat cell matrix
Hello, I have obtained a global matrix from an analysis (which is attached here and it is a reduced matrix as it is exceeded the 5mb) and I would like to find the NaN and missing values for each case to sort out some issues in the code for those values before generating a more complex simulation analysis. As you will see in the mat file there are 70 columns with separate information and each row is identified by the 1st column as it is related to the unique event of my database. I would like to generate two tables with the following information:
1st table containing the summary information of NaN values values in the whole matrix (attched file, that it may not contain NaN values as I have to reduce the number of rows for exceeding the 5mb) where it provides their location based on the row (first column: date_event) that provides the date_event, the name of the station provided in colum 46, and the column of the variable that has the NaN value. For example:
matrix_NaN=[‘1985-03-03 22:47:08’, ‘CFLAN,’, ‘Rrup1’; ‘1997-02-19 18:25:14′,’CPLAT’, ‘Rx’; ……….]
2nd table containing the information of missing values like it was provided with the NaN values:
matrix_missing=[‘2003-08-26 21:11:35’, ‘CFLAN,’ ‘Rx’; ‘2003-08-26 21:11:35′,’CTRUJ’, sigma_Rx’; ……….]
I would appreciate the helpHello, I have obtained a global matrix from an analysis (which is attached here and it is a reduced matrix as it is exceeded the 5mb) and I would like to find the NaN and missing values for each case to sort out some issues in the code for those values before generating a more complex simulation analysis. As you will see in the mat file there are 70 columns with separate information and each row is identified by the 1st column as it is related to the unique event of my database. I would like to generate two tables with the following information:
1st table containing the summary information of NaN values values in the whole matrix (attched file, that it may not contain NaN values as I have to reduce the number of rows for exceeding the 5mb) where it provides their location based on the row (first column: date_event) that provides the date_event, the name of the station provided in colum 46, and the column of the variable that has the NaN value. For example:
matrix_NaN=[‘1985-03-03 22:47:08’, ‘CFLAN,’, ‘Rrup1’; ‘1997-02-19 18:25:14′,’CPLAT’, ‘Rx’; ……….]
2nd table containing the information of missing values like it was provided with the NaN values:
matrix_missing=[‘2003-08-26 21:11:35’, ‘CFLAN,’ ‘Rx’; ‘2003-08-26 21:11:35′,’CTRUJ’, sigma_Rx’; ……….]
I would appreciate the help Hello, I have obtained a global matrix from an analysis (which is attached here and it is a reduced matrix as it is exceeded the 5mb) and I would like to find the NaN and missing values for each case to sort out some issues in the code for those values before generating a more complex simulation analysis. As you will see in the mat file there are 70 columns with separate information and each row is identified by the 1st column as it is related to the unique event of my database. I would like to generate two tables with the following information:
1st table containing the summary information of NaN values values in the whole matrix (attched file, that it may not contain NaN values as I have to reduce the number of rows for exceeding the 5mb) where it provides their location based on the row (first column: date_event) that provides the date_event, the name of the station provided in colum 46, and the column of the variable that has the NaN value. For example:
matrix_NaN=[‘1985-03-03 22:47:08’, ‘CFLAN,’, ‘Rrup1’; ‘1997-02-19 18:25:14′,’CPLAT’, ‘Rx’; ……….]
2nd table containing the information of missing values like it was provided with the NaN values:
matrix_missing=[‘2003-08-26 21:11:35’, ‘CFLAN,’ ‘Rx’; ‘2003-08-26 21:11:35′,’CTRUJ’, sigma_Rx’; ……….]
I would appreciate the help finding nan and missing values from a cell matrix MATLAB Answers — New Questions
RF Budget Analyzer calculating noise figure incorrectly
I am currently using the RF Toolbox, to generate cascades using s-parameter files with the RF Budget Analyzer.
When I insert a passive component into the tool, It returns a noise figure value that is not equal to the negative of the Gain (Insertion loss in this case). Does anyone know what could cause this? This occurs even if I import a single S-parameter file, as the only part in the cascade.I am currently using the RF Toolbox, to generate cascades using s-parameter files with the RF Budget Analyzer.
When I insert a passive component into the tool, It returns a noise figure value that is not equal to the negative of the Gain (Insertion loss in this case). Does anyone know what could cause this? This occurs even if I import a single S-parameter file, as the only part in the cascade. I am currently using the RF Toolbox, to generate cascades using s-parameter files with the RF Budget Analyzer.
When I insert a passive component into the tool, It returns a noise figure value that is not equal to the negative of the Gain (Insertion loss in this case). Does anyone know what could cause this? This occurs even if I import a single S-parameter file, as the only part in the cascade. noise figure, rf budget analyzer, rf toolbox MATLAB Answers — New Questions
Add a title to a group of 4 subplots centred at the top
I have a group of subplots and want to add a title at the top, centre. How might one do this? Here is an MWE
subplot(2,2,1)
plot(peaks)
subplot(2,2,2)
plot(peaks)
subplot(2,2,3)
plot(peaks)
subplot(2,2,4)
plot(peaks)I have a group of subplots and want to add a title at the top, centre. How might one do this? Here is an MWE
subplot(2,2,1)
plot(peaks)
subplot(2,2,2)
plot(peaks)
subplot(2,2,3)
plot(peaks)
subplot(2,2,4)
plot(peaks) I have a group of subplots and want to add a title at the top, centre. How might one do this? Here is an MWE
subplot(2,2,1)
plot(peaks)
subplot(2,2,2)
plot(peaks)
subplot(2,2,3)
plot(peaks)
subplot(2,2,4)
plot(peaks) plotting, graphics MATLAB Answers — New Questions
what is ‘Derivative of state in block at time t is not finite. There may be a singularity in the solution.’ error? how to address it?
Hi
I am trying to simulate a thermal fluid system. As soon as I introduce gas-charged accumulator circled red in the circuit, it gives me following error
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘pumpandpipe13082024b.Gas_Charged_Accumulator_TL.T_I’ in block ‘pumpandpipe13082024b/Gas-Charged Accumulator (TL)’ at time 20.0 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
Also, when I introduce elevation gain from port A to port B in pipes TL circled red, i have the following error
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘pumpandpipe13082024b.Centrifugal_Pump_TL1.A.T’ in block ‘pumpandpipe13082024b/Centrifugal Pump (TL)1’ at time 16.666666666666668 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
what do these errors mean?Hi
I am trying to simulate a thermal fluid system. As soon as I introduce gas-charged accumulator circled red in the circuit, it gives me following error
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘pumpandpipe13082024b.Gas_Charged_Accumulator_TL.T_I’ in block ‘pumpandpipe13082024b/Gas-Charged Accumulator (TL)’ at time 20.0 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
Also, when I introduce elevation gain from port A to port B in pipes TL circled red, i have the following error
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘pumpandpipe13082024b.Centrifugal_Pump_TL1.A.T’ in block ‘pumpandpipe13082024b/Centrifugal Pump (TL)1’ at time 16.666666666666668 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
what do these errors mean? Hi
I am trying to simulate a thermal fluid system. As soon as I introduce gas-charged accumulator circled red in the circuit, it gives me following error
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘pumpandpipe13082024b.Gas_Charged_Accumulator_TL.T_I’ in block ‘pumpandpipe13082024b/Gas-Charged Accumulator (TL)’ at time 20.0 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
Also, when I introduce elevation gain from port A to port B in pipes TL circled red, i have the following error
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘pumpandpipe13082024b.Centrifugal_Pump_TL1.A.T’ in block ‘pumpandpipe13082024b/Centrifugal Pump (TL)1’ at time 16.666666666666668 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
what do these errors mean? simscape, error MATLAB Answers — New Questions
Why i am getting Error using Phase1/UIAxesButtonDown Too many input arguments.
Why i am getting Error using Phase1/UIAxesButtonDown Too many input arguments.Why i am getting Error using Phase1/UIAxesButtonDown Too many input arguments. Why i am getting Error using Phase1/UIAxesButtonDown Too many input arguments. matlab app designer MATLAB Answers — New Questions
How to resolve position violation errors in Simulink
Hello, I am working on an 8-axis Stewart platform simulator in Simulink. I have set motion inputs for the 8 prismatic joints using formula-based values and feedback control. Since the initial position of all prismatic joints is 0.5m, I set the priority to high in the Specify Position Target option and entered a value of 0.5m. However, when I run the simulation, a Position Violation error occurs as shown in the picture below. It seems that there is an issue with the motion input for the 8 prismatic joints. If you know how to solve this problem, I would appreciate your help.
I apologize for not being able to attach the entire model as it is part of an ongoing research project.
Thank you for your understanding.Hello, I am working on an 8-axis Stewart platform simulator in Simulink. I have set motion inputs for the 8 prismatic joints using formula-based values and feedback control. Since the initial position of all prismatic joints is 0.5m, I set the priority to high in the Specify Position Target option and entered a value of 0.5m. However, when I run the simulation, a Position Violation error occurs as shown in the picture below. It seems that there is an issue with the motion input for the 8 prismatic joints. If you know how to solve this problem, I would appreciate your help.
I apologize for not being able to attach the entire model as it is part of an ongoing research project.
Thank you for your understanding. Hello, I am working on an 8-axis Stewart platform simulator in Simulink. I have set motion inputs for the 8 prismatic joints using formula-based values and feedback control. Since the initial position of all prismatic joints is 0.5m, I set the priority to high in the Specify Position Target option and entered a value of 0.5m. However, when I run the simulation, a Position Violation error occurs as shown in the picture below. It seems that there is an issue with the motion input for the 8 prismatic joints. If you know how to solve this problem, I would appreciate your help.
I apologize for not being able to attach the entire model as it is part of an ongoing research project.
Thank you for your understanding. simulink, simscape MATLAB Answers — New Questions
after input values and push preview doesn’t display in UIAxes
classdef app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Toolbar matlab.ui.container.Toolbar
PushTool matlab.ui.container.toolbar.PushTool
EditField3_5 matlab.ui.control.NumericEditField
EditField2_5 matlab.ui.control.NumericEditField
EditField2_4 matlab.ui.control.NumericEditField
EditField3_4 matlab.ui.control.NumericEditField
EditField2_3 matlab.ui.control.NumericEditField
EditField2_2 matlab.ui.control.NumericEditField
EditField3_3 matlab.ui.control.NumericEditField
EditField3_2 matlab.ui.control.NumericEditField
EditField3 matlab.ui.control.NumericEditField
EditField2 matlab.ui.control.NumericEditField
DimensionPrpertyLabel matlab.ui.control.Label
PhaseLabel matlab.ui.control.Label
ElementDataLabel matlab.ui.control.Label
DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel matlab.ui.control.Label
CSTButton matlab.ui.control.Button
PreviewButton matlab.ui.control.Button
PhaseReference matlab.ui.control.NumericEditField
PhaseReferenceEditFieldLabel matlab.ui.control.Label
UnitElementDimensionsLabel matlab.ui.control.Label
Y matlab.ui.control.NumericEditField
YEditFieldLabel matlab.ui.control.Label
X matlab.ui.control.NumericEditField
XEditFieldLabel matlab.ui.control.Label
BeamDirectionLabel matlab.ui.control.Label
Azimuth matlab.ui.control.NumericEditField
AzimuthEditFieldLabel matlab.ui.control.Label
Elevation matlab.ui.control.NumericEditField
ElevationEditFieldLabel matlab.ui.control.Label
PhaseCenterCoordinates matlab.ui.control.Label
z matlab.ui.control.NumericEditField
zEditFieldLabel matlab.ui.control.Label
y matlab.ui.control.NumericEditField
yEditFieldLabel matlab.ui.control.Label
x matlab.ui.control.NumericEditField
xEditFieldLabel matlab.ui.control.Label
Image matlab.ui.control.Image
Frequency matlab.ui.control.NumericEditField
FrequencyEditFieldLabel matlab.ui.control.Label
Antennaradius matlab.ui.control.NumericEditField
AntennaradiusEditFieldLabel matlab.ui.control.Label
DesignareflectarrayLabel matlab.ui.control.Label
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CSTButton
function CSTButtonPushed(app, event)
% — Executes on button press in pushbutton2.
% Create GUIDE-style callback args – Added by Migration Tool
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
addpath(genpath(‘C:UsersseymurDesktopcst-matlabCST-MATLAB-API-master’));
cst = actxserver(‘CSTStudio.application’);
mws = cst.invoke(‘NewMWS’);
cst = actxserver(‘CSTStudio.Application’);
mws = cst.OpenFile(‘path_to_your_cst_file.cst’);
fmin=2.2;
fmax=2.6;
function CstDefineFrequencyRange(mws, startFreq, endFreq)
mws.invoke(‘FrequencyRange’, ‘Define’, startFreq, endFreq);
end
mws = cst.invoke(‘NewMWS’);
Xmin=’expanded open’;
Xmax=’expanded open’;
Ymin=’expanded open’;
Ymax=’expanded open’;
Zmin=’expanded open’;
Zmax=’expanded open’;
minfrequency = fmin;
function CstDefineOpenBoundary(mws, minfrequency, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax)
% CstDefineOpenBoundary – Defines the open boundary in CST.
%
% Inputs:
% mws – CST Microwave Studio object
% minfrequency – Minimum frequency for the boundary
% Xmin, Xmax, Ymin, Ymax, Zmin, Zmax – Boundary limits in each direction
% Assuming CST’s boundary settings are being configured using invoke calls
invoke(mws, ‘Boundary’, ‘Define’, ‘Xmin’, Xmin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Xmax’, Xmax);
invoke(mws, ‘Boundary’, ‘Define’, ‘Ymin’, Ymin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Ymax’, Ymax);
invoke(mws, ‘Boundary’, ‘Define’, ‘Zmin’, Zmin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Zmax’, Zmax);
% Set minimum frequency (this part may vary depending on how CST handles this)
invoke(mws, ‘Solver’, ‘FrequencyRange’, minfrequency);
end
freq = app.Frequency.Value * 10^9;
lambda = physconst(‘LightSpeed’)*1000/freq;
k=2*pi/lambda;
ix=1;
iy=1;
data=handles.data;
phas_u=data(:,1)’;
dim_u=data(:,2)’;
the_dir = app.Elevation.Value;
phi_dir = app.Azimuth.Value;
pha_zer = app.PhaseReference.Value;
x_cor = app.x.Value;
y_cor = app.y.Value;
z_cor = app.z.Value;
rad = app.Antennaradius.Value;
uedimx = app.X.Value;
uedimy = app.Y.Value;
for xi=-rad/2+mod(rad/2,uedimx):uedimx:rad/2
for yi=-rad/2+mod(rad/2,uedimy):uedimy:rad/2
if sqrt(xi^2+yi^2)<rad/2
R = sqrt((x_cor-xi)^2+(y_cor-yi)^2+z_cor^2);
phase(ix,iy)=k*(R-sind(the_dir)*(xi*cosd(phi_dir)+yi*sind(phi_dir)))+pha_zer;
m_phase=mod(phase(ix,iy),2*pi);
m_phase_deg=m_phase*180/pi-180;
% phas_lin_map=m_phase_deg*m+n;
if m_phase_deg > phas_u(1,1)
phas_lin_map = phas_u(1,1);
elseif m_phase_deg < phas_u(1,end)
phas_lin_map = phas_u(end,1);
else
dy = diff([0 phas_u]);
dyix = find(dy == 0);
dim_u(dyix) = dim_u(dyix-1)+1E-8;
phas_lin_map = interp1(phas_u, dim_u, m_phase_deg);
end
else
phase(ix,iy)=0;
end
iy=iy+1;
end
ix=ix+1;
iy=1;
end
m_phase=mod(phase,2*pi);
m_phase_deg=m_phase*180/pi;
m_phase_deg(:);
surf(app.UIAxes, m_phase_deg);
view(app.UIAxes, 2);
surf(m_phase_deg)
view(2)
guidata(hObject, handles);
end
% Value changed function: Antennaradius, Frequency
function AntennaradiusEditFieldValueChanged(app, event)
value = app.Antennaradius.Value;
end
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
% Create GUIDE-style callback args – Added by Migration Tool
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
% Frequency
freq = app.Frequency.Value * 10^9;
lambda = physconst(‘LightSpeed’) * 1000 / freq;
k = 2 * pi / lambda;
ix = 1;
iy = 1;
% Sample data (Replace with actual data assignment)
data = [140 0.2; 130 1.5; 0 2.5; -150 3.5; -175 4.5];
phas_u = data(:,1)’;
dim_u = data(:,2)’;
the_dir = app.Elevation.Value;
phi_dir = app.Azimuth.Value;
pha_zer = app.PhaseReference.Value;
x_cor = app.x.Value;
y_cor = app.y.Value;
z_cor = app.z.Value;
rad = app.Antennaradius.Value;
uedimx = app.X.Value;
uedimy = app.Y.Value;
% Initialize phase array
phase = zeros(round(rad/uedimx), round(rad/uedimy));
for xi = -rad/2+mod(rad/2,uedimx):uedimx:rad/2
for yi = -rad/2+mod(rad/2,uedimy):uedimy:rad/2
if sqrt(xi^2+yi^2) < rad/2
R = sqrt((x_cor-xi)^2 + (y_cor-yi)^2 + z_cor^2);
phase(ix, iy) = k * (R – sind(the_dir) * (xi * cosd(phi_dir) + yi * sind(phi_dir))) + pha_zer;
m_phase = mod(phase(ix, iy), 2*pi);
m_phase_deg = m_phase * 180 / pi – 180;
if m_phase_deg > phas_u(1,1)
phas_lin_map = phas_u(1,1);
elseif m_phase_deg < phas_u(1,end)
phas_lin_map = phas_u(end,1);
else
dy = diff([0 phas_u]);
dyix = find(dy == 0);
dim_u(dyix) = dim_u(dyix-1) + 1E-8;
phas_lin_map = interp1(phas_u, dim_u, m_phase_deg);
end
else
phase(ix, iy) = 0;
end
iy = iy + 1;
end
ix = ix + 1;
iy = 1;
end
% Convert to degrees
m_phase = mod(phase, 2*pi);
m_phase_deg = m_phase * 180 / pi;
% Debugging
disp(‘Phase (degrees):’);
disp(m_phase_deg);
% Plotting
surf(app.UIAxes, m_phase_deg);
view(app.UIAxes, 2);
guidata(hObject, handles);
end
end
% Close request function: UIFigure
function UIFigureCloseRequest(app, event)
delete(app)
end
% Value changed function: EditField2
function EditField2ValueChanged(app, event)
value = app.EditField2.Value;
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Get the file path for locating images
pathToMLAPP = fileparts(mfilename(‘fullpath’));
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Color = [0.502 0.502 0.502];
app.UIFigure.Position = [100 100 984 624];
app.UIFigure.Name = ‘MATLAB App’;
app.UIFigure.CloseRequestFcn = createCallbackFcn(app, @UIFigureCloseRequest, true);
% Create Toolbar
app.Toolbar = uitoolbar(app.UIFigure);
% Create PushTool
app.PushTool = uipushtool(app.Toolbar);
app.PushTool.Icon = fullfile(pathToMLAPP, ‘images.png’);
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
app.UIAxes.XColor = [0 0 0];
app.UIAxes.Position = [602 321 329 262];
% Create DesignareflectarrayLabel
app.DesignareflectarrayLabel = uilabel(app.UIFigure);
app.DesignareflectarrayLabel.FontSize = 24;
app.DesignareflectarrayLabel.FontWeight = ‘bold’;
app.DesignareflectarrayLabel.Position = [363 593 261 32];
app.DesignareflectarrayLabel.Text = ‘Design a reflectarray ‘;
% Create AntennaradiusEditFieldLabel
app.AntennaradiusEditFieldLabel = uilabel(app.UIFigure);
app.AntennaradiusEditFieldLabel.HorizontalAlignment = ‘center’;
app.AntennaradiusEditFieldLabel.Position = [22 553 53 30];
app.AntennaradiusEditFieldLabel.Text = {‘Antenna ‘; ‘radius’};
% Create Antennaradius
app.Antennaradius = uieditfield(app.UIFigure, ‘numeric’);
app.Antennaradius.ValueChangedFcn = createCallbackFcn(app, @AntennaradiusEditFieldValueChanged, true);
app.Antennaradius.Position = [90 561 100 22];
% Create FrequencyEditFieldLabel
app.FrequencyEditFieldLabel = uilabel(app.UIFigure);
app.FrequencyEditFieldLabel.HorizontalAlignment = ‘right’;
app.FrequencyEditFieldLabel.Position = [10 522 65 22];
app.FrequencyEditFieldLabel.Text = ‘Frequency ‘;
% Create Frequency
app.Frequency = uieditfield(app.UIFigure, ‘numeric’);
app.Frequency.RoundFractionalValues = ‘on’;
app.Frequency.ValueChangedFcn = createCallbackFcn(app, @AntennaradiusEditFieldValueChanged, true);
app.Frequency.Position = [90 522 100 22];
% Create Image
app.Image = uiimage(app.UIFigure);
app.Image.Position = [231 345 370 219];
app.Image.ImageSource = fullfile(pathToMLAPP, ‘images.png’);
% Create xEditFieldLabel
app.xEditFieldLabel = uilabel(app.UIFigure);
app.xEditFieldLabel.HorizontalAlignment = ‘right’;
app.xEditFieldLabel.Position = [30 447 25 22];
app.xEditFieldLabel.Text = ‘x’;
% Create x
app.x = uieditfield(app.UIFigure, ‘numeric’);
app.x.Position = [70 447 100 22];
% Create yEditFieldLabel
app.yEditFieldLabel = uilabel(app.UIFigure);
app.yEditFieldLabel.HorizontalAlignment = ‘right’;
app.yEditFieldLabel.Position = [30 402 25 22];
app.yEditFieldLabel.Text = ‘y’;
% Create y
app.y = uieditfield(app.UIFigure, ‘numeric’);
app.y.Position = [70 402 100 22];
% Create zEditFieldLabel
app.zEditFieldLabel = uilabel(app.UIFigure);
app.zEditFieldLabel.HorizontalAlignment = ‘right’;
app.zEditFieldLabel.Position = [30 360 25 22];
app.zEditFieldLabel.Text = ‘z’;
% Create z
app.z = uieditfield(app.UIFigure, ‘numeric’);
app.z.Position = [70 360 100 22];
% Create PhaseCenterCoordinates
app.PhaseCenterCoordinates = uilabel(app.UIFigure);
app.PhaseCenterCoordinates.FontSize = 14;
app.PhaseCenterCoordinates.Position = [22 489 170 22];
app.PhaseCenterCoordinates.Text = ‘Phase Center Coordinates’;
% Create ElevationEditFieldLabel
app.ElevationEditFieldLabel = uilabel(app.UIFigure);
app.ElevationEditFieldLabel.HorizontalAlignment = ‘right’;
app.ElevationEditFieldLabel.Position = [15 285 54 22];
app.ElevationEditFieldLabel.Text = ‘Elevation’;
% Create Elevation
app.Elevation = uieditfield(app.UIFigure, ‘numeric’);
app.Elevation.Position = [84 285 64 22];
% Create AzimuthEditFieldLabel
app.AzimuthEditFieldLabel = uilabel(app.UIFigure);
app.AzimuthEditFieldLabel.HorizontalAlignment = ‘right’;
app.AzimuthEditFieldLabel.Position = [15 255 48 22];
app.AzimuthEditFieldLabel.Text = ‘Azimuth’;
% Create Azimuth
app.Azimuth = uieditfield(app.UIFigure, ‘numeric’);
app.Azimuth.Position = [84 255 64 22];
% Create BeamDirectionLabel
app.BeamDirectionLabel = uilabel(app.UIFigure);
app.BeamDirectionLabel.FontSize = 14;
app.BeamDirectionLabel.Position = [10 321 101 22];
app.BeamDirectionLabel.Text = ‘Beam Direction’;
% Create XEditFieldLabel
app.XEditFieldLabel = uilabel(app.UIFigure);
app.XEditFieldLabel.HorizontalAlignment = ‘right’;
app.XEditFieldLabel.Position = [31 174 25 22];
app.XEditFieldLabel.Text = ‘X’;
% Create X
app.X = uieditfield(app.UIFigure, ‘numeric’);
app.X.Position = [71 174 98 22];
% Create YEditFieldLabel
app.YEditFieldLabel = uilabel(app.UIFigure);
app.YEditFieldLabel.HorizontalAlignment = ‘right’;
app.YEditFieldLabel.Position = [29 126 25 22];
app.YEditFieldLabel.Text = ‘Y’;
% Create Y
app.Y = uieditfield(app.UIFigure, ‘numeric’);
app.Y.Position = [69 126 100 22];
% Create UnitElementDimensionsLabel
app.UnitElementDimensionsLabel = uilabel(app.UIFigure);
app.UnitElementDimensionsLabel.FontSize = 14;
app.UnitElementDimensionsLabel.Position = [15 216 162 22];
app.UnitElementDimensionsLabel.Text = ‘Unit Element Dimensions’;
% Create PhaseReferenceEditFieldLabel
app.PhaseReferenceEditFieldLabel = uilabel(app.UIFigure);
app.PhaseReferenceEditFieldLabel.HorizontalAlignment = ‘right’;
app.PhaseReferenceEditFieldLabel.Position = [9 83 98 22];
app.PhaseReferenceEditFieldLabel.Text = ‘Phase Reference’;
% Create PhaseReference
app.PhaseReference = uieditfield(app.UIFigure, ‘numeric’);
app.PhaseReference.Position = [130 83 58 22];
% Create PreviewButton
app.PreviewButton = uibutton(app.UIFigure, ‘push’);
app.PreviewButton.ButtonPushedFcn = createCallbackFcn(app, @PreviewButtonPushed, true);
app.PreviewButton.FontSize = 14;
app.PreviewButton.Position = [731 250 110 25];
app.PreviewButton.Text = ‘Preview’;
% Create CSTButton
app.CSTButton = uibutton(app.UIFigure, ‘push’);
app.CSTButton.ButtonPushedFcn = createCallbackFcn(app, @CSTButtonPushed, true);
app.CSTButton.FontSize = 14;
app.CSTButton.Position = [731 160 110 25];
app.CSTButton.Text = ‘ CST’;
% Create DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel = uilabel(app.UIFigure);
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.BackgroundColor = [0.651 0.651 0.651];
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.FontSize = 14;
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.Position = [661 39 260 76];
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.Text = {‘Desigener Eng .Abdullah Sabah Ibrahim’; ‘Air Navigation Engineer’; ‘uabd704@gmail.com’};
% Create ElementDataLabel
app.ElementDataLabel = uilabel(app.UIFigure);
app.ElementDataLabel.BackgroundColor = [0.502 0.502 0.502];
app.ElementDataLabel.FontSize = 14;
app.ElementDataLabel.Position = [320 310 142 27];
app.ElementDataLabel.Text = ‘Element Data’;
% Create PhaseLabel
app.PhaseLabel = uilabel(app.UIFigure);
app.PhaseLabel.Position = [326 281 39 22];
app.PhaseLabel.Text = ‘Phase’;
% Create DimensionPrpertyLabel
app.DimensionPrpertyLabel = uilabel(app.UIFigure);
app.DimensionPrpertyLabel.Position = [461 276 104 22];
app.DimensionPrpertyLabel.Text = ‘Dimension/Prperty’;
% Create EditField2
app.EditField2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2.ValueChangedFcn = createCallbackFcn(app, @EditField2ValueChanged, true);
app.EditField2.Position = [461 242 100 22];
app.EditField2.Value = 0.2;
% Create EditField3
app.EditField3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3.Position = [321 243 100 22];
app.EditField3.Value = 140;
% Create EditField3_2
app.EditField3_2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_2.Position = [320.997694832939 203.000512259345 100 22];
app.EditField3_2.Value = 130;
% Create EditField3_3
app.EditField3_3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_3.Position = [320.995929173063 161.393369402201 100 22];
% Create EditField2_2
app.EditField2_2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_2.Position = [461 203 100 22];
app.EditField2_2.Value = 1.5;
% Create EditField2_3
app.EditField2_3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_3.Position = [461 163 100 22];
app.EditField2_3.Value = 2.5;
% Create EditField3_4
app.EditField3_4 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_4.Position = [321 123 100 22];
app.EditField3_4.Value = -150;
% Create EditField2_4
app.EditField2_4 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_4.Position = [460.107943943571 122.820894513809 100 22];
app.EditField2_4.Value = 3.5;
% Create EditField2_5
app.EditField2_5 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_5.Position = [461 83 100 22];
app.EditField2_5.Value = 4.5;
% Create EditField3_5
app.EditField3_5 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_5.Position = [320.997989109585 81.5705348423533 100 22];
app.EditField3_5.Value = -175;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = app1
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
endclassdef app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Toolbar matlab.ui.container.Toolbar
PushTool matlab.ui.container.toolbar.PushTool
EditField3_5 matlab.ui.control.NumericEditField
EditField2_5 matlab.ui.control.NumericEditField
EditField2_4 matlab.ui.control.NumericEditField
EditField3_4 matlab.ui.control.NumericEditField
EditField2_3 matlab.ui.control.NumericEditField
EditField2_2 matlab.ui.control.NumericEditField
EditField3_3 matlab.ui.control.NumericEditField
EditField3_2 matlab.ui.control.NumericEditField
EditField3 matlab.ui.control.NumericEditField
EditField2 matlab.ui.control.NumericEditField
DimensionPrpertyLabel matlab.ui.control.Label
PhaseLabel matlab.ui.control.Label
ElementDataLabel matlab.ui.control.Label
DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel matlab.ui.control.Label
CSTButton matlab.ui.control.Button
PreviewButton matlab.ui.control.Button
PhaseReference matlab.ui.control.NumericEditField
PhaseReferenceEditFieldLabel matlab.ui.control.Label
UnitElementDimensionsLabel matlab.ui.control.Label
Y matlab.ui.control.NumericEditField
YEditFieldLabel matlab.ui.control.Label
X matlab.ui.control.NumericEditField
XEditFieldLabel matlab.ui.control.Label
BeamDirectionLabel matlab.ui.control.Label
Azimuth matlab.ui.control.NumericEditField
AzimuthEditFieldLabel matlab.ui.control.Label
Elevation matlab.ui.control.NumericEditField
ElevationEditFieldLabel matlab.ui.control.Label
PhaseCenterCoordinates matlab.ui.control.Label
z matlab.ui.control.NumericEditField
zEditFieldLabel matlab.ui.control.Label
y matlab.ui.control.NumericEditField
yEditFieldLabel matlab.ui.control.Label
x matlab.ui.control.NumericEditField
xEditFieldLabel matlab.ui.control.Label
Image matlab.ui.control.Image
Frequency matlab.ui.control.NumericEditField
FrequencyEditFieldLabel matlab.ui.control.Label
Antennaradius matlab.ui.control.NumericEditField
AntennaradiusEditFieldLabel matlab.ui.control.Label
DesignareflectarrayLabel matlab.ui.control.Label
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CSTButton
function CSTButtonPushed(app, event)
% — Executes on button press in pushbutton2.
% Create GUIDE-style callback args – Added by Migration Tool
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
addpath(genpath(‘C:UsersseymurDesktopcst-matlabCST-MATLAB-API-master’));
cst = actxserver(‘CSTStudio.application’);
mws = cst.invoke(‘NewMWS’);
cst = actxserver(‘CSTStudio.Application’);
mws = cst.OpenFile(‘path_to_your_cst_file.cst’);
fmin=2.2;
fmax=2.6;
function CstDefineFrequencyRange(mws, startFreq, endFreq)
mws.invoke(‘FrequencyRange’, ‘Define’, startFreq, endFreq);
end
mws = cst.invoke(‘NewMWS’);
Xmin=’expanded open’;
Xmax=’expanded open’;
Ymin=’expanded open’;
Ymax=’expanded open’;
Zmin=’expanded open’;
Zmax=’expanded open’;
minfrequency = fmin;
function CstDefineOpenBoundary(mws, minfrequency, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax)
% CstDefineOpenBoundary – Defines the open boundary in CST.
%
% Inputs:
% mws – CST Microwave Studio object
% minfrequency – Minimum frequency for the boundary
% Xmin, Xmax, Ymin, Ymax, Zmin, Zmax – Boundary limits in each direction
% Assuming CST’s boundary settings are being configured using invoke calls
invoke(mws, ‘Boundary’, ‘Define’, ‘Xmin’, Xmin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Xmax’, Xmax);
invoke(mws, ‘Boundary’, ‘Define’, ‘Ymin’, Ymin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Ymax’, Ymax);
invoke(mws, ‘Boundary’, ‘Define’, ‘Zmin’, Zmin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Zmax’, Zmax);
% Set minimum frequency (this part may vary depending on how CST handles this)
invoke(mws, ‘Solver’, ‘FrequencyRange’, minfrequency);
end
freq = app.Frequency.Value * 10^9;
lambda = physconst(‘LightSpeed’)*1000/freq;
k=2*pi/lambda;
ix=1;
iy=1;
data=handles.data;
phas_u=data(:,1)’;
dim_u=data(:,2)’;
the_dir = app.Elevation.Value;
phi_dir = app.Azimuth.Value;
pha_zer = app.PhaseReference.Value;
x_cor = app.x.Value;
y_cor = app.y.Value;
z_cor = app.z.Value;
rad = app.Antennaradius.Value;
uedimx = app.X.Value;
uedimy = app.Y.Value;
for xi=-rad/2+mod(rad/2,uedimx):uedimx:rad/2
for yi=-rad/2+mod(rad/2,uedimy):uedimy:rad/2
if sqrt(xi^2+yi^2)<rad/2
R = sqrt((x_cor-xi)^2+(y_cor-yi)^2+z_cor^2);
phase(ix,iy)=k*(R-sind(the_dir)*(xi*cosd(phi_dir)+yi*sind(phi_dir)))+pha_zer;
m_phase=mod(phase(ix,iy),2*pi);
m_phase_deg=m_phase*180/pi-180;
% phas_lin_map=m_phase_deg*m+n;
if m_phase_deg > phas_u(1,1)
phas_lin_map = phas_u(1,1);
elseif m_phase_deg < phas_u(1,end)
phas_lin_map = phas_u(end,1);
else
dy = diff([0 phas_u]);
dyix = find(dy == 0);
dim_u(dyix) = dim_u(dyix-1)+1E-8;
phas_lin_map = interp1(phas_u, dim_u, m_phase_deg);
end
else
phase(ix,iy)=0;
end
iy=iy+1;
end
ix=ix+1;
iy=1;
end
m_phase=mod(phase,2*pi);
m_phase_deg=m_phase*180/pi;
m_phase_deg(:);
surf(app.UIAxes, m_phase_deg);
view(app.UIAxes, 2);
surf(m_phase_deg)
view(2)
guidata(hObject, handles);
end
% Value changed function: Antennaradius, Frequency
function AntennaradiusEditFieldValueChanged(app, event)
value = app.Antennaradius.Value;
end
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
% Create GUIDE-style callback args – Added by Migration Tool
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
% Frequency
freq = app.Frequency.Value * 10^9;
lambda = physconst(‘LightSpeed’) * 1000 / freq;
k = 2 * pi / lambda;
ix = 1;
iy = 1;
% Sample data (Replace with actual data assignment)
data = [140 0.2; 130 1.5; 0 2.5; -150 3.5; -175 4.5];
phas_u = data(:,1)’;
dim_u = data(:,2)’;
the_dir = app.Elevation.Value;
phi_dir = app.Azimuth.Value;
pha_zer = app.PhaseReference.Value;
x_cor = app.x.Value;
y_cor = app.y.Value;
z_cor = app.z.Value;
rad = app.Antennaradius.Value;
uedimx = app.X.Value;
uedimy = app.Y.Value;
% Initialize phase array
phase = zeros(round(rad/uedimx), round(rad/uedimy));
for xi = -rad/2+mod(rad/2,uedimx):uedimx:rad/2
for yi = -rad/2+mod(rad/2,uedimy):uedimy:rad/2
if sqrt(xi^2+yi^2) < rad/2
R = sqrt((x_cor-xi)^2 + (y_cor-yi)^2 + z_cor^2);
phase(ix, iy) = k * (R – sind(the_dir) * (xi * cosd(phi_dir) + yi * sind(phi_dir))) + pha_zer;
m_phase = mod(phase(ix, iy), 2*pi);
m_phase_deg = m_phase * 180 / pi – 180;
if m_phase_deg > phas_u(1,1)
phas_lin_map = phas_u(1,1);
elseif m_phase_deg < phas_u(1,end)
phas_lin_map = phas_u(end,1);
else
dy = diff([0 phas_u]);
dyix = find(dy == 0);
dim_u(dyix) = dim_u(dyix-1) + 1E-8;
phas_lin_map = interp1(phas_u, dim_u, m_phase_deg);
end
else
phase(ix, iy) = 0;
end
iy = iy + 1;
end
ix = ix + 1;
iy = 1;
end
% Convert to degrees
m_phase = mod(phase, 2*pi);
m_phase_deg = m_phase * 180 / pi;
% Debugging
disp(‘Phase (degrees):’);
disp(m_phase_deg);
% Plotting
surf(app.UIAxes, m_phase_deg);
view(app.UIAxes, 2);
guidata(hObject, handles);
end
end
% Close request function: UIFigure
function UIFigureCloseRequest(app, event)
delete(app)
end
% Value changed function: EditField2
function EditField2ValueChanged(app, event)
value = app.EditField2.Value;
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Get the file path for locating images
pathToMLAPP = fileparts(mfilename(‘fullpath’));
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Color = [0.502 0.502 0.502];
app.UIFigure.Position = [100 100 984 624];
app.UIFigure.Name = ‘MATLAB App’;
app.UIFigure.CloseRequestFcn = createCallbackFcn(app, @UIFigureCloseRequest, true);
% Create Toolbar
app.Toolbar = uitoolbar(app.UIFigure);
% Create PushTool
app.PushTool = uipushtool(app.Toolbar);
app.PushTool.Icon = fullfile(pathToMLAPP, ‘images.png’);
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
app.UIAxes.XColor = [0 0 0];
app.UIAxes.Position = [602 321 329 262];
% Create DesignareflectarrayLabel
app.DesignareflectarrayLabel = uilabel(app.UIFigure);
app.DesignareflectarrayLabel.FontSize = 24;
app.DesignareflectarrayLabel.FontWeight = ‘bold’;
app.DesignareflectarrayLabel.Position = [363 593 261 32];
app.DesignareflectarrayLabel.Text = ‘Design a reflectarray ‘;
% Create AntennaradiusEditFieldLabel
app.AntennaradiusEditFieldLabel = uilabel(app.UIFigure);
app.AntennaradiusEditFieldLabel.HorizontalAlignment = ‘center’;
app.AntennaradiusEditFieldLabel.Position = [22 553 53 30];
app.AntennaradiusEditFieldLabel.Text = {‘Antenna ‘; ‘radius’};
% Create Antennaradius
app.Antennaradius = uieditfield(app.UIFigure, ‘numeric’);
app.Antennaradius.ValueChangedFcn = createCallbackFcn(app, @AntennaradiusEditFieldValueChanged, true);
app.Antennaradius.Position = [90 561 100 22];
% Create FrequencyEditFieldLabel
app.FrequencyEditFieldLabel = uilabel(app.UIFigure);
app.FrequencyEditFieldLabel.HorizontalAlignment = ‘right’;
app.FrequencyEditFieldLabel.Position = [10 522 65 22];
app.FrequencyEditFieldLabel.Text = ‘Frequency ‘;
% Create Frequency
app.Frequency = uieditfield(app.UIFigure, ‘numeric’);
app.Frequency.RoundFractionalValues = ‘on’;
app.Frequency.ValueChangedFcn = createCallbackFcn(app, @AntennaradiusEditFieldValueChanged, true);
app.Frequency.Position = [90 522 100 22];
% Create Image
app.Image = uiimage(app.UIFigure);
app.Image.Position = [231 345 370 219];
app.Image.ImageSource = fullfile(pathToMLAPP, ‘images.png’);
% Create xEditFieldLabel
app.xEditFieldLabel = uilabel(app.UIFigure);
app.xEditFieldLabel.HorizontalAlignment = ‘right’;
app.xEditFieldLabel.Position = [30 447 25 22];
app.xEditFieldLabel.Text = ‘x’;
% Create x
app.x = uieditfield(app.UIFigure, ‘numeric’);
app.x.Position = [70 447 100 22];
% Create yEditFieldLabel
app.yEditFieldLabel = uilabel(app.UIFigure);
app.yEditFieldLabel.HorizontalAlignment = ‘right’;
app.yEditFieldLabel.Position = [30 402 25 22];
app.yEditFieldLabel.Text = ‘y’;
% Create y
app.y = uieditfield(app.UIFigure, ‘numeric’);
app.y.Position = [70 402 100 22];
% Create zEditFieldLabel
app.zEditFieldLabel = uilabel(app.UIFigure);
app.zEditFieldLabel.HorizontalAlignment = ‘right’;
app.zEditFieldLabel.Position = [30 360 25 22];
app.zEditFieldLabel.Text = ‘z’;
% Create z
app.z = uieditfield(app.UIFigure, ‘numeric’);
app.z.Position = [70 360 100 22];
% Create PhaseCenterCoordinates
app.PhaseCenterCoordinates = uilabel(app.UIFigure);
app.PhaseCenterCoordinates.FontSize = 14;
app.PhaseCenterCoordinates.Position = [22 489 170 22];
app.PhaseCenterCoordinates.Text = ‘Phase Center Coordinates’;
% Create ElevationEditFieldLabel
app.ElevationEditFieldLabel = uilabel(app.UIFigure);
app.ElevationEditFieldLabel.HorizontalAlignment = ‘right’;
app.ElevationEditFieldLabel.Position = [15 285 54 22];
app.ElevationEditFieldLabel.Text = ‘Elevation’;
% Create Elevation
app.Elevation = uieditfield(app.UIFigure, ‘numeric’);
app.Elevation.Position = [84 285 64 22];
% Create AzimuthEditFieldLabel
app.AzimuthEditFieldLabel = uilabel(app.UIFigure);
app.AzimuthEditFieldLabel.HorizontalAlignment = ‘right’;
app.AzimuthEditFieldLabel.Position = [15 255 48 22];
app.AzimuthEditFieldLabel.Text = ‘Azimuth’;
% Create Azimuth
app.Azimuth = uieditfield(app.UIFigure, ‘numeric’);
app.Azimuth.Position = [84 255 64 22];
% Create BeamDirectionLabel
app.BeamDirectionLabel = uilabel(app.UIFigure);
app.BeamDirectionLabel.FontSize = 14;
app.BeamDirectionLabel.Position = [10 321 101 22];
app.BeamDirectionLabel.Text = ‘Beam Direction’;
% Create XEditFieldLabel
app.XEditFieldLabel = uilabel(app.UIFigure);
app.XEditFieldLabel.HorizontalAlignment = ‘right’;
app.XEditFieldLabel.Position = [31 174 25 22];
app.XEditFieldLabel.Text = ‘X’;
% Create X
app.X = uieditfield(app.UIFigure, ‘numeric’);
app.X.Position = [71 174 98 22];
% Create YEditFieldLabel
app.YEditFieldLabel = uilabel(app.UIFigure);
app.YEditFieldLabel.HorizontalAlignment = ‘right’;
app.YEditFieldLabel.Position = [29 126 25 22];
app.YEditFieldLabel.Text = ‘Y’;
% Create Y
app.Y = uieditfield(app.UIFigure, ‘numeric’);
app.Y.Position = [69 126 100 22];
% Create UnitElementDimensionsLabel
app.UnitElementDimensionsLabel = uilabel(app.UIFigure);
app.UnitElementDimensionsLabel.FontSize = 14;
app.UnitElementDimensionsLabel.Position = [15 216 162 22];
app.UnitElementDimensionsLabel.Text = ‘Unit Element Dimensions’;
% Create PhaseReferenceEditFieldLabel
app.PhaseReferenceEditFieldLabel = uilabel(app.UIFigure);
app.PhaseReferenceEditFieldLabel.HorizontalAlignment = ‘right’;
app.PhaseReferenceEditFieldLabel.Position = [9 83 98 22];
app.PhaseReferenceEditFieldLabel.Text = ‘Phase Reference’;
% Create PhaseReference
app.PhaseReference = uieditfield(app.UIFigure, ‘numeric’);
app.PhaseReference.Position = [130 83 58 22];
% Create PreviewButton
app.PreviewButton = uibutton(app.UIFigure, ‘push’);
app.PreviewButton.ButtonPushedFcn = createCallbackFcn(app, @PreviewButtonPushed, true);
app.PreviewButton.FontSize = 14;
app.PreviewButton.Position = [731 250 110 25];
app.PreviewButton.Text = ‘Preview’;
% Create CSTButton
app.CSTButton = uibutton(app.UIFigure, ‘push’);
app.CSTButton.ButtonPushedFcn = createCallbackFcn(app, @CSTButtonPushed, true);
app.CSTButton.FontSize = 14;
app.CSTButton.Position = [731 160 110 25];
app.CSTButton.Text = ‘ CST’;
% Create DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel = uilabel(app.UIFigure);
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.BackgroundColor = [0.651 0.651 0.651];
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.FontSize = 14;
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.Position = [661 39 260 76];
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.Text = {‘Desigener Eng .Abdullah Sabah Ibrahim’; ‘Air Navigation Engineer’; ‘uabd704@gmail.com’};
% Create ElementDataLabel
app.ElementDataLabel = uilabel(app.UIFigure);
app.ElementDataLabel.BackgroundColor = [0.502 0.502 0.502];
app.ElementDataLabel.FontSize = 14;
app.ElementDataLabel.Position = [320 310 142 27];
app.ElementDataLabel.Text = ‘Element Data’;
% Create PhaseLabel
app.PhaseLabel = uilabel(app.UIFigure);
app.PhaseLabel.Position = [326 281 39 22];
app.PhaseLabel.Text = ‘Phase’;
% Create DimensionPrpertyLabel
app.DimensionPrpertyLabel = uilabel(app.UIFigure);
app.DimensionPrpertyLabel.Position = [461 276 104 22];
app.DimensionPrpertyLabel.Text = ‘Dimension/Prperty’;
% Create EditField2
app.EditField2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2.ValueChangedFcn = createCallbackFcn(app, @EditField2ValueChanged, true);
app.EditField2.Position = [461 242 100 22];
app.EditField2.Value = 0.2;
% Create EditField3
app.EditField3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3.Position = [321 243 100 22];
app.EditField3.Value = 140;
% Create EditField3_2
app.EditField3_2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_2.Position = [320.997694832939 203.000512259345 100 22];
app.EditField3_2.Value = 130;
% Create EditField3_3
app.EditField3_3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_3.Position = [320.995929173063 161.393369402201 100 22];
% Create EditField2_2
app.EditField2_2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_2.Position = [461 203 100 22];
app.EditField2_2.Value = 1.5;
% Create EditField2_3
app.EditField2_3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_3.Position = [461 163 100 22];
app.EditField2_3.Value = 2.5;
% Create EditField3_4
app.EditField3_4 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_4.Position = [321 123 100 22];
app.EditField3_4.Value = -150;
% Create EditField2_4
app.EditField2_4 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_4.Position = [460.107943943571 122.820894513809 100 22];
app.EditField2_4.Value = 3.5;
% Create EditField2_5
app.EditField2_5 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_5.Position = [461 83 100 22];
app.EditField2_5.Value = 4.5;
% Create EditField3_5
app.EditField3_5 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_5.Position = [320.997989109585 81.5705348423533 100 22];
app.EditField3_5.Value = -175;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = app1
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end classdef app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Toolbar matlab.ui.container.Toolbar
PushTool matlab.ui.container.toolbar.PushTool
EditField3_5 matlab.ui.control.NumericEditField
EditField2_5 matlab.ui.control.NumericEditField
EditField2_4 matlab.ui.control.NumericEditField
EditField3_4 matlab.ui.control.NumericEditField
EditField2_3 matlab.ui.control.NumericEditField
EditField2_2 matlab.ui.control.NumericEditField
EditField3_3 matlab.ui.control.NumericEditField
EditField3_2 matlab.ui.control.NumericEditField
EditField3 matlab.ui.control.NumericEditField
EditField2 matlab.ui.control.NumericEditField
DimensionPrpertyLabel matlab.ui.control.Label
PhaseLabel matlab.ui.control.Label
ElementDataLabel matlab.ui.control.Label
DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel matlab.ui.control.Label
CSTButton matlab.ui.control.Button
PreviewButton matlab.ui.control.Button
PhaseReference matlab.ui.control.NumericEditField
PhaseReferenceEditFieldLabel matlab.ui.control.Label
UnitElementDimensionsLabel matlab.ui.control.Label
Y matlab.ui.control.NumericEditField
YEditFieldLabel matlab.ui.control.Label
X matlab.ui.control.NumericEditField
XEditFieldLabel matlab.ui.control.Label
BeamDirectionLabel matlab.ui.control.Label
Azimuth matlab.ui.control.NumericEditField
AzimuthEditFieldLabel matlab.ui.control.Label
Elevation matlab.ui.control.NumericEditField
ElevationEditFieldLabel matlab.ui.control.Label
PhaseCenterCoordinates matlab.ui.control.Label
z matlab.ui.control.NumericEditField
zEditFieldLabel matlab.ui.control.Label
y matlab.ui.control.NumericEditField
yEditFieldLabel matlab.ui.control.Label
x matlab.ui.control.NumericEditField
xEditFieldLabel matlab.ui.control.Label
Image matlab.ui.control.Image
Frequency matlab.ui.control.NumericEditField
FrequencyEditFieldLabel matlab.ui.control.Label
Antennaradius matlab.ui.control.NumericEditField
AntennaradiusEditFieldLabel matlab.ui.control.Label
DesignareflectarrayLabel matlab.ui.control.Label
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CSTButton
function CSTButtonPushed(app, event)
% — Executes on button press in pushbutton2.
% Create GUIDE-style callback args – Added by Migration Tool
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
addpath(genpath(‘C:UsersseymurDesktopcst-matlabCST-MATLAB-API-master’));
cst = actxserver(‘CSTStudio.application’);
mws = cst.invoke(‘NewMWS’);
cst = actxserver(‘CSTStudio.Application’);
mws = cst.OpenFile(‘path_to_your_cst_file.cst’);
fmin=2.2;
fmax=2.6;
function CstDefineFrequencyRange(mws, startFreq, endFreq)
mws.invoke(‘FrequencyRange’, ‘Define’, startFreq, endFreq);
end
mws = cst.invoke(‘NewMWS’);
Xmin=’expanded open’;
Xmax=’expanded open’;
Ymin=’expanded open’;
Ymax=’expanded open’;
Zmin=’expanded open’;
Zmax=’expanded open’;
minfrequency = fmin;
function CstDefineOpenBoundary(mws, minfrequency, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax)
% CstDefineOpenBoundary – Defines the open boundary in CST.
%
% Inputs:
% mws – CST Microwave Studio object
% minfrequency – Minimum frequency for the boundary
% Xmin, Xmax, Ymin, Ymax, Zmin, Zmax – Boundary limits in each direction
% Assuming CST’s boundary settings are being configured using invoke calls
invoke(mws, ‘Boundary’, ‘Define’, ‘Xmin’, Xmin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Xmax’, Xmax);
invoke(mws, ‘Boundary’, ‘Define’, ‘Ymin’, Ymin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Ymax’, Ymax);
invoke(mws, ‘Boundary’, ‘Define’, ‘Zmin’, Zmin);
invoke(mws, ‘Boundary’, ‘Define’, ‘Zmax’, Zmax);
% Set minimum frequency (this part may vary depending on how CST handles this)
invoke(mws, ‘Solver’, ‘FrequencyRange’, minfrequency);
end
freq = app.Frequency.Value * 10^9;
lambda = physconst(‘LightSpeed’)*1000/freq;
k=2*pi/lambda;
ix=1;
iy=1;
data=handles.data;
phas_u=data(:,1)’;
dim_u=data(:,2)’;
the_dir = app.Elevation.Value;
phi_dir = app.Azimuth.Value;
pha_zer = app.PhaseReference.Value;
x_cor = app.x.Value;
y_cor = app.y.Value;
z_cor = app.z.Value;
rad = app.Antennaradius.Value;
uedimx = app.X.Value;
uedimy = app.Y.Value;
for xi=-rad/2+mod(rad/2,uedimx):uedimx:rad/2
for yi=-rad/2+mod(rad/2,uedimy):uedimy:rad/2
if sqrt(xi^2+yi^2)<rad/2
R = sqrt((x_cor-xi)^2+(y_cor-yi)^2+z_cor^2);
phase(ix,iy)=k*(R-sind(the_dir)*(xi*cosd(phi_dir)+yi*sind(phi_dir)))+pha_zer;
m_phase=mod(phase(ix,iy),2*pi);
m_phase_deg=m_phase*180/pi-180;
% phas_lin_map=m_phase_deg*m+n;
if m_phase_deg > phas_u(1,1)
phas_lin_map = phas_u(1,1);
elseif m_phase_deg < phas_u(1,end)
phas_lin_map = phas_u(end,1);
else
dy = diff([0 phas_u]);
dyix = find(dy == 0);
dim_u(dyix) = dim_u(dyix-1)+1E-8;
phas_lin_map = interp1(phas_u, dim_u, m_phase_deg);
end
else
phase(ix,iy)=0;
end
iy=iy+1;
end
ix=ix+1;
iy=1;
end
m_phase=mod(phase,2*pi);
m_phase_deg=m_phase*180/pi;
m_phase_deg(:);
surf(app.UIAxes, m_phase_deg);
view(app.UIAxes, 2);
surf(m_phase_deg)
view(2)
guidata(hObject, handles);
end
% Value changed function: Antennaradius, Frequency
function AntennaradiusEditFieldValueChanged(app, event)
value = app.Antennaradius.Value;
end
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
% Create GUIDE-style callback args – Added by Migration Tool
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
% Frequency
freq = app.Frequency.Value * 10^9;
lambda = physconst(‘LightSpeed’) * 1000 / freq;
k = 2 * pi / lambda;
ix = 1;
iy = 1;
% Sample data (Replace with actual data assignment)
data = [140 0.2; 130 1.5; 0 2.5; -150 3.5; -175 4.5];
phas_u = data(:,1)’;
dim_u = data(:,2)’;
the_dir = app.Elevation.Value;
phi_dir = app.Azimuth.Value;
pha_zer = app.PhaseReference.Value;
x_cor = app.x.Value;
y_cor = app.y.Value;
z_cor = app.z.Value;
rad = app.Antennaradius.Value;
uedimx = app.X.Value;
uedimy = app.Y.Value;
% Initialize phase array
phase = zeros(round(rad/uedimx), round(rad/uedimy));
for xi = -rad/2+mod(rad/2,uedimx):uedimx:rad/2
for yi = -rad/2+mod(rad/2,uedimy):uedimy:rad/2
if sqrt(xi^2+yi^2) < rad/2
R = sqrt((x_cor-xi)^2 + (y_cor-yi)^2 + z_cor^2);
phase(ix, iy) = k * (R – sind(the_dir) * (xi * cosd(phi_dir) + yi * sind(phi_dir))) + pha_zer;
m_phase = mod(phase(ix, iy), 2*pi);
m_phase_deg = m_phase * 180 / pi – 180;
if m_phase_deg > phas_u(1,1)
phas_lin_map = phas_u(1,1);
elseif m_phase_deg < phas_u(1,end)
phas_lin_map = phas_u(end,1);
else
dy = diff([0 phas_u]);
dyix = find(dy == 0);
dim_u(dyix) = dim_u(dyix-1) + 1E-8;
phas_lin_map = interp1(phas_u, dim_u, m_phase_deg);
end
else
phase(ix, iy) = 0;
end
iy = iy + 1;
end
ix = ix + 1;
iy = 1;
end
% Convert to degrees
m_phase = mod(phase, 2*pi);
m_phase_deg = m_phase * 180 / pi;
% Debugging
disp(‘Phase (degrees):’);
disp(m_phase_deg);
% Plotting
surf(app.UIAxes, m_phase_deg);
view(app.UIAxes, 2);
guidata(hObject, handles);
end
end
% Close request function: UIFigure
function UIFigureCloseRequest(app, event)
delete(app)
end
% Value changed function: EditField2
function EditField2ValueChanged(app, event)
value = app.EditField2.Value;
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Get the file path for locating images
pathToMLAPP = fileparts(mfilename(‘fullpath’));
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Color = [0.502 0.502 0.502];
app.UIFigure.Position = [100 100 984 624];
app.UIFigure.Name = ‘MATLAB App’;
app.UIFigure.CloseRequestFcn = createCallbackFcn(app, @UIFigureCloseRequest, true);
% Create Toolbar
app.Toolbar = uitoolbar(app.UIFigure);
% Create PushTool
app.PushTool = uipushtool(app.Toolbar);
app.PushTool.Icon = fullfile(pathToMLAPP, ‘images.png’);
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
app.UIAxes.XColor = [0 0 0];
app.UIAxes.Position = [602 321 329 262];
% Create DesignareflectarrayLabel
app.DesignareflectarrayLabel = uilabel(app.UIFigure);
app.DesignareflectarrayLabel.FontSize = 24;
app.DesignareflectarrayLabel.FontWeight = ‘bold’;
app.DesignareflectarrayLabel.Position = [363 593 261 32];
app.DesignareflectarrayLabel.Text = ‘Design a reflectarray ‘;
% Create AntennaradiusEditFieldLabel
app.AntennaradiusEditFieldLabel = uilabel(app.UIFigure);
app.AntennaradiusEditFieldLabel.HorizontalAlignment = ‘center’;
app.AntennaradiusEditFieldLabel.Position = [22 553 53 30];
app.AntennaradiusEditFieldLabel.Text = {‘Antenna ‘; ‘radius’};
% Create Antennaradius
app.Antennaradius = uieditfield(app.UIFigure, ‘numeric’);
app.Antennaradius.ValueChangedFcn = createCallbackFcn(app, @AntennaradiusEditFieldValueChanged, true);
app.Antennaradius.Position = [90 561 100 22];
% Create FrequencyEditFieldLabel
app.FrequencyEditFieldLabel = uilabel(app.UIFigure);
app.FrequencyEditFieldLabel.HorizontalAlignment = ‘right’;
app.FrequencyEditFieldLabel.Position = [10 522 65 22];
app.FrequencyEditFieldLabel.Text = ‘Frequency ‘;
% Create Frequency
app.Frequency = uieditfield(app.UIFigure, ‘numeric’);
app.Frequency.RoundFractionalValues = ‘on’;
app.Frequency.ValueChangedFcn = createCallbackFcn(app, @AntennaradiusEditFieldValueChanged, true);
app.Frequency.Position = [90 522 100 22];
% Create Image
app.Image = uiimage(app.UIFigure);
app.Image.Position = [231 345 370 219];
app.Image.ImageSource = fullfile(pathToMLAPP, ‘images.png’);
% Create xEditFieldLabel
app.xEditFieldLabel = uilabel(app.UIFigure);
app.xEditFieldLabel.HorizontalAlignment = ‘right’;
app.xEditFieldLabel.Position = [30 447 25 22];
app.xEditFieldLabel.Text = ‘x’;
% Create x
app.x = uieditfield(app.UIFigure, ‘numeric’);
app.x.Position = [70 447 100 22];
% Create yEditFieldLabel
app.yEditFieldLabel = uilabel(app.UIFigure);
app.yEditFieldLabel.HorizontalAlignment = ‘right’;
app.yEditFieldLabel.Position = [30 402 25 22];
app.yEditFieldLabel.Text = ‘y’;
% Create y
app.y = uieditfield(app.UIFigure, ‘numeric’);
app.y.Position = [70 402 100 22];
% Create zEditFieldLabel
app.zEditFieldLabel = uilabel(app.UIFigure);
app.zEditFieldLabel.HorizontalAlignment = ‘right’;
app.zEditFieldLabel.Position = [30 360 25 22];
app.zEditFieldLabel.Text = ‘z’;
% Create z
app.z = uieditfield(app.UIFigure, ‘numeric’);
app.z.Position = [70 360 100 22];
% Create PhaseCenterCoordinates
app.PhaseCenterCoordinates = uilabel(app.UIFigure);
app.PhaseCenterCoordinates.FontSize = 14;
app.PhaseCenterCoordinates.Position = [22 489 170 22];
app.PhaseCenterCoordinates.Text = ‘Phase Center Coordinates’;
% Create ElevationEditFieldLabel
app.ElevationEditFieldLabel = uilabel(app.UIFigure);
app.ElevationEditFieldLabel.HorizontalAlignment = ‘right’;
app.ElevationEditFieldLabel.Position = [15 285 54 22];
app.ElevationEditFieldLabel.Text = ‘Elevation’;
% Create Elevation
app.Elevation = uieditfield(app.UIFigure, ‘numeric’);
app.Elevation.Position = [84 285 64 22];
% Create AzimuthEditFieldLabel
app.AzimuthEditFieldLabel = uilabel(app.UIFigure);
app.AzimuthEditFieldLabel.HorizontalAlignment = ‘right’;
app.AzimuthEditFieldLabel.Position = [15 255 48 22];
app.AzimuthEditFieldLabel.Text = ‘Azimuth’;
% Create Azimuth
app.Azimuth = uieditfield(app.UIFigure, ‘numeric’);
app.Azimuth.Position = [84 255 64 22];
% Create BeamDirectionLabel
app.BeamDirectionLabel = uilabel(app.UIFigure);
app.BeamDirectionLabel.FontSize = 14;
app.BeamDirectionLabel.Position = [10 321 101 22];
app.BeamDirectionLabel.Text = ‘Beam Direction’;
% Create XEditFieldLabel
app.XEditFieldLabel = uilabel(app.UIFigure);
app.XEditFieldLabel.HorizontalAlignment = ‘right’;
app.XEditFieldLabel.Position = [31 174 25 22];
app.XEditFieldLabel.Text = ‘X’;
% Create X
app.X = uieditfield(app.UIFigure, ‘numeric’);
app.X.Position = [71 174 98 22];
% Create YEditFieldLabel
app.YEditFieldLabel = uilabel(app.UIFigure);
app.YEditFieldLabel.HorizontalAlignment = ‘right’;
app.YEditFieldLabel.Position = [29 126 25 22];
app.YEditFieldLabel.Text = ‘Y’;
% Create Y
app.Y = uieditfield(app.UIFigure, ‘numeric’);
app.Y.Position = [69 126 100 22];
% Create UnitElementDimensionsLabel
app.UnitElementDimensionsLabel = uilabel(app.UIFigure);
app.UnitElementDimensionsLabel.FontSize = 14;
app.UnitElementDimensionsLabel.Position = [15 216 162 22];
app.UnitElementDimensionsLabel.Text = ‘Unit Element Dimensions’;
% Create PhaseReferenceEditFieldLabel
app.PhaseReferenceEditFieldLabel = uilabel(app.UIFigure);
app.PhaseReferenceEditFieldLabel.HorizontalAlignment = ‘right’;
app.PhaseReferenceEditFieldLabel.Position = [9 83 98 22];
app.PhaseReferenceEditFieldLabel.Text = ‘Phase Reference’;
% Create PhaseReference
app.PhaseReference = uieditfield(app.UIFigure, ‘numeric’);
app.PhaseReference.Position = [130 83 58 22];
% Create PreviewButton
app.PreviewButton = uibutton(app.UIFigure, ‘push’);
app.PreviewButton.ButtonPushedFcn = createCallbackFcn(app, @PreviewButtonPushed, true);
app.PreviewButton.FontSize = 14;
app.PreviewButton.Position = [731 250 110 25];
app.PreviewButton.Text = ‘Preview’;
% Create CSTButton
app.CSTButton = uibutton(app.UIFigure, ‘push’);
app.CSTButton.ButtonPushedFcn = createCallbackFcn(app, @CSTButtonPushed, true);
app.CSTButton.FontSize = 14;
app.CSTButton.Position = [731 160 110 25];
app.CSTButton.Text = ‘ CST’;
% Create DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel = uilabel(app.UIFigure);
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.BackgroundColor = [0.651 0.651 0.651];
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.FontSize = 14;
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.Position = [661 39 260 76];
app.DesigenerEngAbdullahSabahIbrahimuabd704gmailcomLabel.Text = {‘Desigener Eng .Abdullah Sabah Ibrahim’; ‘Air Navigation Engineer’; ‘uabd704@gmail.com’};
% Create ElementDataLabel
app.ElementDataLabel = uilabel(app.UIFigure);
app.ElementDataLabel.BackgroundColor = [0.502 0.502 0.502];
app.ElementDataLabel.FontSize = 14;
app.ElementDataLabel.Position = [320 310 142 27];
app.ElementDataLabel.Text = ‘Element Data’;
% Create PhaseLabel
app.PhaseLabel = uilabel(app.UIFigure);
app.PhaseLabel.Position = [326 281 39 22];
app.PhaseLabel.Text = ‘Phase’;
% Create DimensionPrpertyLabel
app.DimensionPrpertyLabel = uilabel(app.UIFigure);
app.DimensionPrpertyLabel.Position = [461 276 104 22];
app.DimensionPrpertyLabel.Text = ‘Dimension/Prperty’;
% Create EditField2
app.EditField2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2.ValueChangedFcn = createCallbackFcn(app, @EditField2ValueChanged, true);
app.EditField2.Position = [461 242 100 22];
app.EditField2.Value = 0.2;
% Create EditField3
app.EditField3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3.Position = [321 243 100 22];
app.EditField3.Value = 140;
% Create EditField3_2
app.EditField3_2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_2.Position = [320.997694832939 203.000512259345 100 22];
app.EditField3_2.Value = 130;
% Create EditField3_3
app.EditField3_3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_3.Position = [320.995929173063 161.393369402201 100 22];
% Create EditField2_2
app.EditField2_2 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_2.Position = [461 203 100 22];
app.EditField2_2.Value = 1.5;
% Create EditField2_3
app.EditField2_3 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_3.Position = [461 163 100 22];
app.EditField2_3.Value = 2.5;
% Create EditField3_4
app.EditField3_4 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_4.Position = [321 123 100 22];
app.EditField3_4.Value = -150;
% Create EditField2_4
app.EditField2_4 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_4.Position = [460.107943943571 122.820894513809 100 22];
app.EditField2_4.Value = 3.5;
% Create EditField2_5
app.EditField2_5 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField2_5.Position = [461 83 100 22];
app.EditField2_5.Value = 4.5;
% Create EditField3_5
app.EditField3_5 = uieditfield(app.UIFigure, ‘numeric’);
app.EditField3_5.Position = [320.997989109585 81.5705348423533 100 22];
app.EditField3_5.Value = -175;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = app1
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end app designer MATLAB Answers — New Questions
hi, find the value of x theoretically?
find the value of x?
((log(1-exp(-x/s)^(n))-log(1-a^(1-exp(-x/s)^(n))))/(1-a))=1/2find the value of x?
((log(1-exp(-x/s)^(n))-log(1-a^(1-exp(-x/s)^(n))))/(1-a))=1/2 find the value of x?
((log(1-exp(-x/s)^(n))-log(1-a^(1-exp(-x/s)^(n))))/(1-a))=1/2 exp, alpha MATLAB Answers — New Questions
Facing problem during simulation on gazebo.
Hi I am trying to simulate this problem https://www.mathworks.com/matlabcentral/fileexchange/64381-matlab-and-simulink-robotics-arena-simulating-quadcopter-missions I have tried virtual box then VMware and after that I have download the files from this link https://www.mathworks.com/support/product/robotics/ros2-vm-installation-instructions-v5.html now the problem I am facing in all these cases is same when I run my simulation in gazebo I am facing errors in importing drone into the world loaded in my scenario. I have already connected simulink with ROS and works fine but my errors come in linux terminal.
Note: I have already followed steps according to documentation provided and tried videos too available on youtube and matlab platform. I have tried diffrent versions of ROS including latest version also ( ROS Noetic Humble Gazebo 11 and ROS Melodic Dashing Gazebov9 ) in a hope maybe old version might help me out in this problem but the error is consistent no matter what I try.
The Error I am facing are of the sort:
qws.urdf file is empty.
[INFO] [1723726120.533970, 0.000000]: Calling service /gazebo/spawn_urdf_model Service call failed: service [/gazebo/spawn_urdf_model] responded with an error: [ERROR] [1723726120.622680, 65.204000]: Spawn service failed. Exiting.
xacro: in-order processing became default in ROS Melodic. You can drop the option. resource not found: imav_2017 ROS path [0]=/opt/ros/melodic/share/ros ROS path [1]=/opt/ros/melodic/share when processing file: quadrotor.urdf.xacro [INFO] [1723726204.610146, 0.000000]: Loading model XML from file qws.urdf [ERROR] [1723726204.611562, 0.000000]: Error: file qws.urdf is emptyHi I am trying to simulate this problem https://www.mathworks.com/matlabcentral/fileexchange/64381-matlab-and-simulink-robotics-arena-simulating-quadcopter-missions I have tried virtual box then VMware and after that I have download the files from this link https://www.mathworks.com/support/product/robotics/ros2-vm-installation-instructions-v5.html now the problem I am facing in all these cases is same when I run my simulation in gazebo I am facing errors in importing drone into the world loaded in my scenario. I have already connected simulink with ROS and works fine but my errors come in linux terminal.
Note: I have already followed steps according to documentation provided and tried videos too available on youtube and matlab platform. I have tried diffrent versions of ROS including latest version also ( ROS Noetic Humble Gazebo 11 and ROS Melodic Dashing Gazebov9 ) in a hope maybe old version might help me out in this problem but the error is consistent no matter what I try.
The Error I am facing are of the sort:
qws.urdf file is empty.
[INFO] [1723726120.533970, 0.000000]: Calling service /gazebo/spawn_urdf_model Service call failed: service [/gazebo/spawn_urdf_model] responded with an error: [ERROR] [1723726120.622680, 65.204000]: Spawn service failed. Exiting.
xacro: in-order processing became default in ROS Melodic. You can drop the option. resource not found: imav_2017 ROS path [0]=/opt/ros/melodic/share/ros ROS path [1]=/opt/ros/melodic/share when processing file: quadrotor.urdf.xacro [INFO] [1723726204.610146, 0.000000]: Loading model XML from file qws.urdf [ERROR] [1723726204.611562, 0.000000]: Error: file qws.urdf is empty Hi I am trying to simulate this problem https://www.mathworks.com/matlabcentral/fileexchange/64381-matlab-and-simulink-robotics-arena-simulating-quadcopter-missions I have tried virtual box then VMware and after that I have download the files from this link https://www.mathworks.com/support/product/robotics/ros2-vm-installation-instructions-v5.html now the problem I am facing in all these cases is same when I run my simulation in gazebo I am facing errors in importing drone into the world loaded in my scenario. I have already connected simulink with ROS and works fine but my errors come in linux terminal.
Note: I have already followed steps according to documentation provided and tried videos too available on youtube and matlab platform. I have tried diffrent versions of ROS including latest version also ( ROS Noetic Humble Gazebo 11 and ROS Melodic Dashing Gazebov9 ) in a hope maybe old version might help me out in this problem but the error is consistent no matter what I try.
The Error I am facing are of the sort:
qws.urdf file is empty.
[INFO] [1723726120.533970, 0.000000]: Calling service /gazebo/spawn_urdf_model Service call failed: service [/gazebo/spawn_urdf_model] responded with an error: [ERROR] [1723726120.622680, 65.204000]: Spawn service failed. Exiting.
xacro: in-order processing became default in ROS Melodic. You can drop the option. resource not found: imav_2017 ROS path [0]=/opt/ros/melodic/share/ros ROS path [1]=/opt/ros/melodic/share when processing file: quadrotor.urdf.xacro [INFO] [1723726204.610146, 0.000000]: Loading model XML from file qws.urdf [ERROR] [1723726204.611562, 0.000000]: Error: file qws.urdf is empty gazebo, uav simulation, ros, linux, ubuntu, robotics arena quadcopter missions MATLAB Answers — New Questions