after input values and push preview doesn't display in UIAxes

2 次查看(过去 30 天)
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:\Users\seymur\Desktop\cst-matlab\CST-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

回答(2 个)

Voss
Voss 2024-8-15
编辑:Voss 2024-8-15
Looks like you've got an extra PreviewButtonPushed function declaration:
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
% Button pushed function: PreviewButton
function PreviewButtonPushed(app, event)
Remove one of those and its associated end, and then see what happens when you click the Preview button.
  1 个评论
abdullah sabah
abdullah sabah 2024-8-23
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
x5 matlab.ui.control.NumericEditField
y5 matlab.ui.control.NumericEditField
y4 matlab.ui.control.NumericEditField
x4 matlab.ui.control.NumericEditField
y3 matlab.ui.control.NumericEditField
y2 matlab.ui.control.NumericEditField
x3 matlab.ui.control.NumericEditField
x2 matlab.ui.control.NumericEditField
x1 matlab.ui.control.NumericEditField
y1 matlab.ui.control.NumericEditField
DimensionPropertyLabel matlab.ui.control.Label
PhaseLabel matlab.ui.control.Label
ElementDataLabel 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)
% Define CST material properties
material = 'Copper (annealed)';
% Connect to CST
cst = actxserver('CSTStudio.application');
mws = cst.invoke('NewMWS');
% Set units and frequency range
mws.invoke('Units').invoke('Frequency', 'GHz');
mws.invoke('Units').invoke('Geometry', 'mm');
mws.invoke('Units').invoke('Time', 'ns');
mws.invoke('Solver').invoke('FrequencyRange', 31, 33); % Frequency range around 32 GHz
% Define open boundary
mws.invoke('Boundary').invoke('Xmin', 'open');
mws.invoke('Boundary').invoke('Xmax', 'open');
mws.invoke('Boundary').invoke('Ymin', 'open');
mws.invoke('Boundary').invoke('Ymax', 'open');
mws.invoke('Boundary').invoke('Zmin', 'open');
mws.invoke('Boundary').invoke('Zmax', 'open');
% Sample data from the app
X = [app.x1.Value, app.x2.Value, app.x3.Value, app.x4.Value, app.x5.Value];
Y = [app.y1.Value, app.y2.Value, app.y3.Value, app.y4.Value, app.y5.Value];
element_size_x = app.X.Value;
element_size_y = app.Y.Value;
% Create unit cells in CST
for i = 1:length(X)
% Create patch
name = ['Patch', num2str(i)];
component = 'Reflectarray';
Xrange = [-element_size_x/2, element_size_x/2] + X(i);
Yrange = [-element_size_y/2, element_size_y/2] + Y(i);
Zrange = [0, 0.1]; % Height of the patch, can be adjusted
% Use custom function to create brick in CST
Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange);
end
% Save and close CST project
mws.invoke('SaveAs', 'Reflectarray_32GHz.cst', 'True');
end
% Custom function to create a brick in CST
function Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange)
brick = mws.invoke('Brick');
brick.invoke('Reset');
brick.invoke('Name', name);
brick.invoke('Component', component);
brick.invoke('Material', material);
brick.invoke('Xrange', Xrange(1), Xrange(2));
brick.invoke('Yrange', Yrange(1), Yrange(2));
brick.invoke('Zrange', Zrange(1), Zrange(2));
brick.invoke('Create');
end
% Value changed function: Antennaradius, Frequency
function AntennaradiusEditFieldValueChanged(app, event)
value = app.Antennaradius.Value;
end
% 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 = [app.x1.Value app.y1.Value; app.x2.Value app.y2.Value; app.x3.Value app.y3.Value; app.x4.Value app.y5.Value ; app.x5.Value app.y5.Value];
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
% Close request function: UIFigure
function UIFigureCloseRequest(app, event)
delete(app)
end
% Value changed function: y1
function y1ValueChanged(app, event)
value = app.y1.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);
title(app.UIAxes, 'Title')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [582 331 346 269];
% 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 = [221 365 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 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 DimensionPropertyLabel
app.DimensionPropertyLabel = uilabel(app.UIFigure);
app.DimensionPropertyLabel.Position = [461 276 110 22];
app.DimensionPropertyLabel.Text = 'Dimension/Property';
% Create y1
app.y1 = uieditfield(app.UIFigure, 'numeric');
app.y1.ValueChangedFcn = createCallbackFcn(app, @y1ValueChanged, true);
app.y1.Position = [461 242 100 22];
% Create x1
app.x1 = uieditfield(app.UIFigure, 'numeric');
app.x1.Position = [321 243 100 22];
% Create x2
app.x2 = uieditfield(app.UIFigure, 'numeric');
app.x2.Position = [321 203 100 22];
% Create x3
app.x3 = uieditfield(app.UIFigure, 'numeric');
app.x3.Position = [321 161 100 22];
% Create y2
app.y2 = uieditfield(app.UIFigure, 'numeric');
app.y2.Position = [461 203 100 22];
% Create y3
app.y3 = uieditfield(app.UIFigure, 'numeric');
app.y3.Position = [461 163 100 22];
% Create x4
app.x4 = uieditfield(app.UIFigure, 'numeric');
app.x4.Position = [321 123 100 22];
% Create y4
app.y4 = uieditfield(app.UIFigure, 'numeric');
app.y4.Position = [460 123 100 22];
% Create y5
app.y5 = uieditfield(app.UIFigure, 'numeric');
app.y5.Position = [461 83 100 22];
% Create x5
app.x5 = uieditfield(app.UIFigure, 'numeric');
app.x5.Position = [321 82 100 22];
% 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
error
Incorrect number or types of inputs or outputs for function 'Cstbrick'.
Error in app1/CSTButtonPushed (line 93)
Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange);
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.

请先登录,再进行评论。


abdullah sabah
abdullah sabah 2024-8-23
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
x5 matlab.ui.control.NumericEditField
y5 matlab.ui.control.NumericEditField
y4 matlab.ui.control.NumericEditField
x4 matlab.ui.control.NumericEditField
y3 matlab.ui.control.NumericEditField
y2 matlab.ui.control.NumericEditField
x3 matlab.ui.control.NumericEditField
x2 matlab.ui.control.NumericEditField
x1 matlab.ui.control.NumericEditField
y1 matlab.ui.control.NumericEditField
DimensionPropertyLabel matlab.ui.control.Label
PhaseLabel matlab.ui.control.Label
ElementDataLabel 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)
% Define CST material properties
material = 'Copper (annealed)';
% Connect to CST
cst = actxserver('CSTStudio.application');
mws = cst.invoke('NewMWS');
% Set units and frequency range
mws.invoke('Units').invoke('Frequency', 'GHz');
mws.invoke('Units').invoke('Geometry', 'mm');
mws.invoke('Units').invoke('Time', 'ns');
mws.invoke('Solver').invoke('FrequencyRange', 31, 33); % Frequency range around 32 GHz
% Define open boundary
mws.invoke('Boundary').invoke('Xmin', 'open');
mws.invoke('Boundary').invoke('Xmax', 'open');
mws.invoke('Boundary').invoke('Ymin', 'open');
mws.invoke('Boundary').invoke('Ymax', 'open');
mws.invoke('Boundary').invoke('Zmin', 'open');
mws.invoke('Boundary').invoke('Zmax', 'open');
% Sample data from the app
X = [app.x1.Value, app.x2.Value, app.x3.Value, app.x4.Value, app.x5.Value];
Y = [app.y1.Value, app.y2.Value, app.y3.Value, app.y4.Value, app.y5.Value];
element_size_x = app.X.Value;
element_size_y = app.Y.Value;
% Create unit cells in CST
for i = 1:length(X)
% Create patch
name = ['Patch', num2str(i)];
component = 'Reflectarray';
Xrange = [-element_size_x/2, element_size_x/2] + X(i);
Yrange = [-element_size_y/2, element_size_y/2] + Y(i);
Zrange = [0, 0.1]; % Height of the patch, can be adjusted
% Use custom function to create brick in CST
Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange);
end
% Save and close CST project
mws.invoke('SaveAs', 'Reflectarray_32GHz.cst', 'True');
end
% Custom function to create a brick in CST
function Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange)
brick = mws.invoke('Brick');
brick.invoke('Reset');
brick.invoke('Name', name);
brick.invoke('Component', component);
brick.invoke('Material', material);
brick.invoke('Xrange', Xrange(1), Xrange(2));
brick.invoke('Yrange', Yrange(1), Yrange(2));
brick.invoke('Zrange', Zrange(1), Zrange(2));
brick.invoke('Create');
end
% Value changed function: Antennaradius, Frequency
function AntennaradiusEditFieldValueChanged(app, event)
value = app.Antennaradius.Value;
end
% 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 = [app.x1.Value app.y1.Value; app.x2.Value app.y2.Value; app.x3.Value app.y3.Value; app.x4.Value app.y5.Value ; app.x5.Value app.y5.Value];
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
% Close request function: UIFigure
function UIFigureCloseRequest(app, event)
delete(app)
end
% Value changed function: y1
function y1ValueChanged(app, event)
value = app.y1.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);
title(app.UIAxes, 'Title')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [582 331 346 269];
% 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 = [221 365 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 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 DimensionPropertyLabel
app.DimensionPropertyLabel = uilabel(app.UIFigure);
app.DimensionPropertyLabel.Position = [461 276 110 22];
app.DimensionPropertyLabel.Text = 'Dimension/Property';
% Create y1
app.y1 = uieditfield(app.UIFigure, 'numeric');
app.y1.ValueChangedFcn = createCallbackFcn(app, @y1ValueChanged, true);
app.y1.Position = [461 242 100 22];
% Create x1
app.x1 = uieditfield(app.UIFigure, 'numeric');
app.x1.Position = [321 243 100 22];
% Create x2
app.x2 = uieditfield(app.UIFigure, 'numeric');
app.x2.Position = [321 203 100 22];
% Create x3
app.x3 = uieditfield(app.UIFigure, 'numeric');
app.x3.Position = [321 161 100 22];
% Create y2
app.y2 = uieditfield(app.UIFigure, 'numeric');
app.y2.Position = [461 203 100 22];
% Create y3
app.y3 = uieditfield(app.UIFigure, 'numeric');
app.y3.Position = [461 163 100 22];
% Create x4
app.x4 = uieditfield(app.UIFigure, 'numeric');
app.x4.Position = [321 123 100 22];
% Create y4
app.y4 = uieditfield(app.UIFigure, 'numeric');
app.y4.Position = [460 123 100 22];
% Create y5
app.y5 = uieditfield(app.UIFigure, 'numeric');
app.y5.Position = [461 83 100 22];
% Create x5
app.x5 = uieditfield(app.UIFigure, 'numeric');
app.x5.Position = [321 82 100 22];
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
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
x5 matlab.ui.control.NumericEditField
y5 matlab.ui.control.NumericEditField
y4 matlab.ui.control.NumericEditField
x4 matlab.ui.control.NumericEditField
y3 matlab.ui.control.NumericEditField
y2 matlab.ui.control.NumericEditField
x3 matlab.ui.control.NumericEditField
x2 matlab.ui.control.NumericEditField
x1 matlab.ui.control.NumericEditField
y1 matlab.ui.control.NumericEditField
DimensionPropertyLabel matlab.ui.control.Label
PhaseLabel matlab.ui.control.Label
ElementDataLabel 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)
% Define CST material properties
material = 'Copper (annealed)';
% Connect to CST
cst = actxserver('CSTStudio.application');
mws = cst.invoke('NewMWS');
% Set units and frequency range
mws.invoke('Units').invoke('Frequency', 'GHz');
mws.invoke('Units').invoke('Geometry', 'mm');
mws.invoke('Units').invoke('Time', 'ns');
mws.invoke('Solver').invoke('FrequencyRange', 31, 33); % Frequency range around 32 GHz
% Define open boundary
mws.invoke('Boundary').invoke('Xmin', 'open');
mws.invoke('Boundary').invoke('Xmax', 'open');
mws.invoke('Boundary').invoke('Ymin', 'open');
mws.invoke('Boundary').invoke('Ymax', 'open');
mws.invoke('Boundary').invoke('Zmin', 'open');
mws.invoke('Boundary').invoke('Zmax', 'open');
% Sample data from the app
X = [app.x1.Value, app.x2.Value, app.x3.Value, app.x4.Value, app.x5.Value];
Y = [app.y1.Value, app.y2.Value, app.y3.Value, app.y4.Value, app.y5.Value];
element_size_x = app.X.Value;
element_size_y = app.Y.Value;
% Create unit cells in CST
for i = 1:length(X)
% Create patch
name = ['Patch', num2str(i)];
component = 'Reflectarray';
Xrange = [-element_size_x/2, element_size_x/2] + X(i);
Yrange = [-element_size_y/2, element_size_y/2] + Y(i);
Zrange = [0, 0.1]; % Height of the patch, can be adjusted
% Use custom function to create brick in CST
Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange);
end
% Save and close CST project
mws.invoke('SaveAs', 'Reflectarray_32GHz.cst', 'True');
end
% Custom function to create a brick in CST
function Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange)
brick = mws.invoke('Brick');
brick.invoke('Reset');
brick.invoke('Name', name);
brick.invoke('Component', component);
brick.invoke('Material', material);
brick.invoke('Xrange', Xrange(1), Xrange(2));
brick.invoke('Yrange', Yrange(1), Yrange(2));
brick.invoke('Zrange', Zrange(1), Zrange(2));
brick.invoke('Create');
end
% Value changed function: Antennaradius, Frequency
function AntennaradiusEditFieldValueChanged(app, event)
value = app.Antennaradius.Value;
end
% 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 = [app.x1.Value app.y1.Value; app.x2.Value app.y2.Value; app.x3.Value app.y3.Value; app.x4.Value app.y5.Value ; app.x5.Value app.y5.Value];
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
% Close request function: UIFigure
function UIFigureCloseRequest(app, event)
delete(app)
end
% Value changed function: y1
function y1ValueChanged(app, event)
value = app.y1.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);
title(app.UIAxes, 'Title')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [582 331 346 269];
% 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 = [221 365 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 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 DimensionPropertyLabel
app.DimensionPropertyLabel = uilabel(app.UIFigure);
app.DimensionPropertyLabel.Position = [461 276 110 22];
app.DimensionPropertyLabel.Text = 'Dimension/Property';
% Create y1
app.y1 = uieditfield(app.UIFigure, 'numeric');
app.y1.ValueChangedFcn = createCallbackFcn(app, @y1ValueChanged, true);
app.y1.Position = [461 242 100 22];
% Create x1
app.x1 = uieditfield(app.UIFigure, 'numeric');
app.x1.Position = [321 243 100 22];
% Create x2
app.x2 = uieditfield(app.UIFigure, 'numeric');
app.x2.Position = [321 203 100 22];
% Create x3
app.x3 = uieditfield(app.UIFigure, 'numeric');
app.x3.Position = [321 161 100 22];
% Create y2
app.y2 = uieditfield(app.UIFigure, 'numeric');
app.y2.Position = [461 203 100 22];
% Create y3
app.y3 = uieditfield(app.UIFigure, 'numeric');
app.y3.Position = [461 163 100 22];
% Create x4
app.x4 = uieditfield(app.UIFigure, 'numeric');
app.x4.Position = [321 123 100 22];
% Create y4
app.y4 = uieditfield(app.UIFigure, 'numeric');
app.y4.Position = [460 123 100 22];
% Create y5
app.y5 = uieditfield(app.UIFigure, 'numeric');
app.y5.Position = [461 83 100 22];
% Create x5
app.x5 = uieditfield(app.UIFigure, 'numeric');
app.x5.Position = [321 82 100 22];
% 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 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
error Incorrect number or types of inputs or outputs for function 'Cstbrick'.
Error in app1/CSTButtonPushed (line 93)
Cstbrick(mws, name, component, material, Xrange, Yrange, Zrange);
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by