Tag Archives: matlab
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
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
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
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
Regarding the execution time in the ‘Simulink Support Package for Arduino Hardware’
Hello,
I have some questions regarding the execution time in the ‘Simulink Support Package for Arduino Hardware’.
Q1. If I want to run a Simulink model at 100Hz on Arduino Hardware, should I set the Fixed-step size to 10ms in the Solver details? (My model is based on sensor values)
Q2. Or my model is based on sensor values, and I want it to run at 100Hz. In this case, should I set the sample time of the I2C controller read block to 10ms?
Q3. What happens if the execution time of my model exceeds 10ms (an overrun occurs)?
For example, let’s assume that the model operates based on sensor values received (start model) every 10ms. If the algorithm takes 15ms to run, I see two possible options:
The algorithm runs with the sensor values from time t, and the sensor values from t+10ms are discarded (since the algorithm is still running), and the algorithm runs again with the sensor values from t+20ms.
The algorithm runs with the sensor values from time t, and as soon as the algorithm finishes, it starts again with the sensor values from t+10ms at t+15ms.
Which one happens? I believe it is option 1.
If someone knows, please provide an answer.
Thank you.Hello,
I have some questions regarding the execution time in the ‘Simulink Support Package for Arduino Hardware’.
Q1. If I want to run a Simulink model at 100Hz on Arduino Hardware, should I set the Fixed-step size to 10ms in the Solver details? (My model is based on sensor values)
Q2. Or my model is based on sensor values, and I want it to run at 100Hz. In this case, should I set the sample time of the I2C controller read block to 10ms?
Q3. What happens if the execution time of my model exceeds 10ms (an overrun occurs)?
For example, let’s assume that the model operates based on sensor values received (start model) every 10ms. If the algorithm takes 15ms to run, I see two possible options:
The algorithm runs with the sensor values from time t, and the sensor values from t+10ms are discarded (since the algorithm is still running), and the algorithm runs again with the sensor values from t+20ms.
The algorithm runs with the sensor values from time t, and as soon as the algorithm finishes, it starts again with the sensor values from t+10ms at t+15ms.
Which one happens? I believe it is option 1.
If someone knows, please provide an answer.
Thank you. Hello,
I have some questions regarding the execution time in the ‘Simulink Support Package for Arduino Hardware’.
Q1. If I want to run a Simulink model at 100Hz on Arduino Hardware, should I set the Fixed-step size to 10ms in the Solver details? (My model is based on sensor values)
Q2. Or my model is based on sensor values, and I want it to run at 100Hz. In this case, should I set the sample time of the I2C controller read block to 10ms?
Q3. What happens if the execution time of my model exceeds 10ms (an overrun occurs)?
For example, let’s assume that the model operates based on sensor values received (start model) every 10ms. If the algorithm takes 15ms to run, I see two possible options:
The algorithm runs with the sensor values from time t, and the sensor values from t+10ms are discarded (since the algorithm is still running), and the algorithm runs again with the sensor values from t+20ms.
The algorithm runs with the sensor values from time t, and as soon as the algorithm finishes, it starts again with the sensor values from t+10ms at t+15ms.
Which one happens? I believe it is option 1.
If someone knows, please provide an answer.
Thank you. simulink, simulink support package for arduino hardware, execution time, overrun MATLAB Answers — New Questions
Can’t get better interpolation at some points
Hi all,
I would be grateful if someone could help with the following matter:
I have a set of complex data called [a2norm_real and a2norm_imag (as per attached)], and another set of complex data was generated as shown in the code. I tried to achieve better interpolation for the Gain, but it fails at certain points (as per attached). No matter how many points I generate, it fails at the same place each time. I have tried different 1D and 2D interpolation methods (including the one below), but this was the best one I could achieve. Thanks!
Here is the code:
data2 = readtable(‘System Gain.xlsx’, ‘VariableNamingRule’, ‘preserve’);
% Process the second file
a2norm_real = data2{:, 5};
a2norm_imag = data2{:, 6};
a2norm_complx = complex(a2norm_real,a2norm_imag);
Gain = complex(data2{:, 1}, data2{:, 2});
a21_mag = linspace(min(abs(a2norm_complx)),max(abs(a2norm_complx)),31).’;
a21_ph = linspace(0,0,31).’;
a21_complx = a21_mag.*exp(1i*pi/180.*a21_ph);
% Perform the interpolation
Interp = griddata(a2norm_real, a2norm_imag, Gain, real(a21_complx), imag(a21_complx), ‘nearest’);
figure;
plot(abs(a2norm_complx), System_Gain, ‘o’, ‘DisplayName’, ‘System gain’);
hold on;
plot(abs(a21_target), System_Gain_Interp, ‘:*’, ‘DisplayName’, ‘System_Gain_Selected’);
legend(‘show’); % Displays the legend with the DisplayName labels
title(‘(Default) Linear Interpolation’);
grid on;
legend(‘Location’, ‘best’);Hi all,
I would be grateful if someone could help with the following matter:
I have a set of complex data called [a2norm_real and a2norm_imag (as per attached)], and another set of complex data was generated as shown in the code. I tried to achieve better interpolation for the Gain, but it fails at certain points (as per attached). No matter how many points I generate, it fails at the same place each time. I have tried different 1D and 2D interpolation methods (including the one below), but this was the best one I could achieve. Thanks!
Here is the code:
data2 = readtable(‘System Gain.xlsx’, ‘VariableNamingRule’, ‘preserve’);
% Process the second file
a2norm_real = data2{:, 5};
a2norm_imag = data2{:, 6};
a2norm_complx = complex(a2norm_real,a2norm_imag);
Gain = complex(data2{:, 1}, data2{:, 2});
a21_mag = linspace(min(abs(a2norm_complx)),max(abs(a2norm_complx)),31).’;
a21_ph = linspace(0,0,31).’;
a21_complx = a21_mag.*exp(1i*pi/180.*a21_ph);
% Perform the interpolation
Interp = griddata(a2norm_real, a2norm_imag, Gain, real(a21_complx), imag(a21_complx), ‘nearest’);
figure;
plot(abs(a2norm_complx), System_Gain, ‘o’, ‘DisplayName’, ‘System gain’);
hold on;
plot(abs(a21_target), System_Gain_Interp, ‘:*’, ‘DisplayName’, ‘System_Gain_Selected’);
legend(‘show’); % Displays the legend with the DisplayName labels
title(‘(Default) Linear Interpolation’);
grid on;
legend(‘Location’, ‘best’); Hi all,
I would be grateful if someone could help with the following matter:
I have a set of complex data called [a2norm_real and a2norm_imag (as per attached)], and another set of complex data was generated as shown in the code. I tried to achieve better interpolation for the Gain, but it fails at certain points (as per attached). No matter how many points I generate, it fails at the same place each time. I have tried different 1D and 2D interpolation methods (including the one below), but this was the best one I could achieve. Thanks!
Here is the code:
data2 = readtable(‘System Gain.xlsx’, ‘VariableNamingRule’, ‘preserve’);
% Process the second file
a2norm_real = data2{:, 5};
a2norm_imag = data2{:, 6};
a2norm_complx = complex(a2norm_real,a2norm_imag);
Gain = complex(data2{:, 1}, data2{:, 2});
a21_mag = linspace(min(abs(a2norm_complx)),max(abs(a2norm_complx)),31).’;
a21_ph = linspace(0,0,31).’;
a21_complx = a21_mag.*exp(1i*pi/180.*a21_ph);
% Perform the interpolation
Interp = griddata(a2norm_real, a2norm_imag, Gain, real(a21_complx), imag(a21_complx), ‘nearest’);
figure;
plot(abs(a2norm_complx), System_Gain, ‘o’, ‘DisplayName’, ‘System gain’);
hold on;
plot(abs(a21_target), System_Gain_Interp, ‘:*’, ‘DisplayName’, ‘System_Gain_Selected’);
legend(‘show’); % Displays the legend with the DisplayName labels
title(‘(Default) Linear Interpolation’);
grid on;
legend(‘Location’, ‘best’); interpolation MATLAB Answers — New Questions
How to define the tire and ground contact for tire enveloping characteristics in Simscape Multibody (to simulate the tire driving over an obstacle)?
Hi, I have question regarding the tire and the ground contact in Simscape Multibody. From the contact forces library I am able to define the contact, but it is a point contact and secondly the wheel does not have tire enveloping behavior, when it comes in contact with an obstacle. The point follows the obstacle as it is, which should not be the case for the simulation.
It will be great help, if anyone suggest me the solution for the described problem?
And thank you very much for the contact force library. It is very helpful :)Hi, I have question regarding the tire and the ground contact in Simscape Multibody. From the contact forces library I am able to define the contact, but it is a point contact and secondly the wheel does not have tire enveloping behavior, when it comes in contact with an obstacle. The point follows the obstacle as it is, which should not be the case for the simulation.
It will be great help, if anyone suggest me the solution for the described problem?
And thank you very much for the contact force library. It is very helpful 🙂 Hi, I have question regarding the tire and the ground contact in Simscape Multibody. From the contact forces library I am able to define the contact, but it is a point contact and secondly the wheel does not have tire enveloping behavior, when it comes in contact with an obstacle. The point follows the obstacle as it is, which should not be the case for the simulation.
It will be great help, if anyone suggest me the solution for the described problem?
And thank you very much for the contact force library. It is very helpful 🙂 tire, tire envelope, rolling over an obstacle, tire contact behavior MATLAB Answers — New Questions
Write MuPAD code to produce a graph of two circles, radii 2 and 3, with the centre of the smaller circle at (x = −2, y = 1) and the centre of the larger circle at (x = 3, y =
Write MuPAD code to produce a graph of two circles, radii 2 and 3, with the centre of the smaller circle at (x = -2, y = 1) and the centre of the larger circle at (x = 3, y = 1). The axes should be labelled appropriately, and there should be suitable titles for each circle, and for the scene. The colour of the smaller circle should be red and that of the larger circle should be blue.Write MuPAD code to produce a graph of two circles, radii 2 and 3, with the centre of the smaller circle at (x = -2, y = 1) and the centre of the larger circle at (x = 3, y = 1). The axes should be labelled appropriately, and there should be suitable titles for each circle, and for the scene. The colour of the smaller circle should be red and that of the larger circle should be blue. Write MuPAD code to produce a graph of two circles, radii 2 and 3, with the centre of the smaller circle at (x = -2, y = 1) and the centre of the larger circle at (x = 3, y = 1). The axes should be labelled appropriately, and there should be suitable titles for each circle, and for the scene. The colour of the smaller circle should be red and that of the larger circle should be blue. mupad MATLAB Answers — New Questions
How to debug a suddenly closing/crashing appdesigner app
I am working on an more or less complex appdesigner application wich controls a test stand in a laboratory. So I can not give an example or reproduce the error.
After a random runtime of 10 min. to 2 h the app closes without any message, so I am not sure if I should call this a "crash". The first error message comes from a listener that can not execute since the object was deleted.
By setting a breakpoint in the delete(app) function, created by appdesigner, I was able get a callstack.
"MyApp.mlapp fcn: MyApp.delete ;line 1686"
"FigureController.m fcn: FigureController.onViewKilled ;line 820"
"FigurePlatformHost.m fcn: FigurePlatformHost.onViewKilled ;line 59"
"CEFFigurePlatformHost.m fcn: @(event,data)this.onViewKilled() ;line 94"
"Callback.m fcn: Callback.execute ;line 128"
"webwindow.m fcn: webwindow.onCustomEvent ;line 1528"
"webwindow.m fcn: @(source,data)obj.onCustomEvent(data.Type,data.Data) ;line 349"
"Channel.m fcn: Channel.onCustomEvent ;line 575"
"Channel.m fcn: @(source,data)obj.onCustomEvent(data.Type,data.Data) ;line 473"
The Channel file is +matlabshared+asyncio+internalChannel.m
In the last line of the callstack, the "Custom" Event of the Channel is raised. The event data is
data.Type = "processExit"
data.Data = struct with fields: exitStatus: 3
The event source is a asyncioimpl.Channel, which is a c++ implementation of the Channel and the debugger can not look into this.
Is there any way of tracing the cause of this error?
Thank you for your help!I am working on an more or less complex appdesigner application wich controls a test stand in a laboratory. So I can not give an example or reproduce the error.
After a random runtime of 10 min. to 2 h the app closes without any message, so I am not sure if I should call this a "crash". The first error message comes from a listener that can not execute since the object was deleted.
By setting a breakpoint in the delete(app) function, created by appdesigner, I was able get a callstack.
"MyApp.mlapp fcn: MyApp.delete ;line 1686"
"FigureController.m fcn: FigureController.onViewKilled ;line 820"
"FigurePlatformHost.m fcn: FigurePlatformHost.onViewKilled ;line 59"
"CEFFigurePlatformHost.m fcn: @(event,data)this.onViewKilled() ;line 94"
"Callback.m fcn: Callback.execute ;line 128"
"webwindow.m fcn: webwindow.onCustomEvent ;line 1528"
"webwindow.m fcn: @(source,data)obj.onCustomEvent(data.Type,data.Data) ;line 349"
"Channel.m fcn: Channel.onCustomEvent ;line 575"
"Channel.m fcn: @(source,data)obj.onCustomEvent(data.Type,data.Data) ;line 473"
The Channel file is +matlabshared+asyncio+internalChannel.m
In the last line of the callstack, the "Custom" Event of the Channel is raised. The event data is
data.Type = "processExit"
data.Data = struct with fields: exitStatus: 3
The event source is a asyncioimpl.Channel, which is a c++ implementation of the Channel and the debugger can not look into this.
Is there any way of tracing the cause of this error?
Thank you for your help! I am working on an more or less complex appdesigner application wich controls a test stand in a laboratory. So I can not give an example or reproduce the error.
After a random runtime of 10 min. to 2 h the app closes without any message, so I am not sure if I should call this a "crash". The first error message comes from a listener that can not execute since the object was deleted.
By setting a breakpoint in the delete(app) function, created by appdesigner, I was able get a callstack.
"MyApp.mlapp fcn: MyApp.delete ;line 1686"
"FigureController.m fcn: FigureController.onViewKilled ;line 820"
"FigurePlatformHost.m fcn: FigurePlatformHost.onViewKilled ;line 59"
"CEFFigurePlatformHost.m fcn: @(event,data)this.onViewKilled() ;line 94"
"Callback.m fcn: Callback.execute ;line 128"
"webwindow.m fcn: webwindow.onCustomEvent ;line 1528"
"webwindow.m fcn: @(source,data)obj.onCustomEvent(data.Type,data.Data) ;line 349"
"Channel.m fcn: Channel.onCustomEvent ;line 575"
"Channel.m fcn: @(source,data)obj.onCustomEvent(data.Type,data.Data) ;line 473"
The Channel file is +matlabshared+asyncio+internalChannel.m
In the last line of the callstack, the "Custom" Event of the Channel is raised. The event data is
data.Type = "processExit"
data.Data = struct with fields: exitStatus: 3
The event source is a asyncioimpl.Channel, which is a c++ implementation of the Channel and the debugger can not look into this.
Is there any way of tracing the cause of this error?
Thank you for your help! appdesigner, debug, crash MATLAB Answers — New Questions
Crosstab by using the same input for both arguments
If I run one of the examples of crosstab, I get the same result as indicated in the crosstab webpage:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x2)
However, if I use the same input for both arguments of crosstab, I get a p-value basically equal to zero:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x1)
Shouldn’t I get a p-value higher if I use the same input for both argument of crosstab? (I was thinking about a p-value close to 1 actually)If I run one of the examples of crosstab, I get the same result as indicated in the crosstab webpage:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x2)
However, if I use the same input for both arguments of crosstab, I get a p-value basically equal to zero:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x1)
Shouldn’t I get a p-value higher if I use the same input for both argument of crosstab? (I was thinking about a p-value close to 1 actually) If I run one of the examples of crosstab, I get the same result as indicated in the crosstab webpage:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x2)
However, if I use the same input for both arguments of crosstab, I get a p-value basically equal to zero:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x1)
Shouldn’t I get a p-value higher if I use the same input for both argument of crosstab? (I was thinking about a p-value close to 1 actually) crosstab, p-value MATLAB Answers — New Questions
Problem during runing the Ansys in batch mode
I have installed student trial version of Matlab and Ansys. During the calculation in Matlab from which I run Ansys in batch mode, there is an error.
While, during the calculation the following error occure
Abort(100) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 100) – process 0I have installed student trial version of Matlab and Ansys. During the calculation in Matlab from which I run Ansys in batch mode, there is an error.
While, during the calculation the following error occure
Abort(100) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 100) – process 0 I have installed student trial version of Matlab and Ansys. During the calculation in Matlab from which I run Ansys in batch mode, there is an error.
While, during the calculation the following error occure
Abort(100) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 100) – process 0 optimization, parallel computing, algorithm, genetic algorithm MATLAB Answers — New Questions
I am trying to solve the system of coupled partial differential equations described in the attachment using the function pdepe. My code runs into this error:
function [c,f,s] = pdefun(x,t,u,dudx) % Equation to solve
c = [1; 1];
f = [-0.6; 1.32].*u;
s = [0; 0];
end
function u0 = pdeic(x) % Initial Conditions
u0 = [sin(pi*x); sin(pi*x)];
end
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t) % Boundary Conditions
pl = [2.2*ul(2)+ ul(1); 0];
ql = [0; 0];
pr = [0; ur(2)];
qr = [0; 0];
end
x = linspace(0,1,50);
t = linspace(0,2,50);
m = 0;
sol = pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
surf(x,t,u1)
title(‘u_(x,t)’)
xlabel(‘Distance x’)
ylabel(‘Time t’)function [c,f,s] = pdefun(x,t,u,dudx) % Equation to solve
c = [1; 1];
f = [-0.6; 1.32].*u;
s = [0; 0];
end
function u0 = pdeic(x) % Initial Conditions
u0 = [sin(pi*x); sin(pi*x)];
end
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t) % Boundary Conditions
pl = [2.2*ul(2)+ ul(1); 0];
ql = [0; 0];
pr = [0; ur(2)];
qr = [0; 0];
end
x = linspace(0,1,50);
t = linspace(0,2,50);
m = 0;
sol = pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
surf(x,t,u1)
title(‘u_(x,t)’)
xlabel(‘Distance x’)
ylabel(‘Time t’) function [c,f,s] = pdefun(x,t,u,dudx) % Equation to solve
c = [1; 1];
f = [-0.6; 1.32].*u;
s = [0; 0];
end
function u0 = pdeic(x) % Initial Conditions
u0 = [sin(pi*x); sin(pi*x)];
end
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t) % Boundary Conditions
pl = [2.2*ul(2)+ ul(1); 0];
ql = [0; 0];
pr = [0; ur(2)];
qr = [0; 0];
end
x = linspace(0,1,50);
t = linspace(0,2,50);
m = 0;
sol = pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
surf(x,t,u1)
title(‘u_(x,t)’)
xlabel(‘Distance x’)
ylabel(‘Time t’) pde, pdepe MATLAB Answers — New Questions
How do I use the unit per mille in Simulink parameters and ports?
In simulink parameters and ports can be specified to use units as described here: https://se.mathworks.com/help/simulink/ug/units-in-simulink.html
For dimensionless pure scaled numbers percent (1e-2), ppm (1e-6), ppb (1e-9) and ppt (1e-12) can be used. But is there a way to specify per mille (‰)? Using 0.001 does not work.In simulink parameters and ports can be specified to use units as described here: https://se.mathworks.com/help/simulink/ug/units-in-simulink.html
For dimensionless pure scaled numbers percent (1e-2), ppm (1e-6), ppb (1e-9) and ppt (1e-12) can be used. But is there a way to specify per mille (‰)? Using 0.001 does not work. In simulink parameters and ports can be specified to use units as described here: https://se.mathworks.com/help/simulink/ug/units-in-simulink.html
For dimensionless pure scaled numbers percent (1e-2), ppm (1e-6), ppb (1e-9) and ppt (1e-12) can be used. But is there a way to specify per mille (‰)? Using 0.001 does not work. per_mille, units, per mille, unit MATLAB Answers — New Questions