Category: Matlab
Category Archives: Matlab
Calculate mean of all variables that have a mean
I have a table with mixed types of variables. I want to calculate the mean of any variable that can have a mean without converting to another type- so just numericals, logicals, etc. and leave string types alone. I do not want to specify which ones to find the mean for because I will probably add variables to this table eventually. The AI made up this apparently fake option, which is what I am looking for: ‘Exclude’, {‘StringVar’}I have a table with mixed types of variables. I want to calculate the mean of any variable that can have a mean without converting to another type- so just numericals, logicals, etc. and leave string types alone. I do not want to specify which ones to find the mean for because I will probably add variables to this table eventually. The AI made up this apparently fake option, which is what I am looking for: ‘Exclude’, {‘StringVar’} I have a table with mixed types of variables. I want to calculate the mean of any variable that can have a mean without converting to another type- so just numericals, logicals, etc. and leave string types alone. I do not want to specify which ones to find the mean for because I will probably add variables to this table eventually. The AI made up this apparently fake option, which is what I am looking for: ‘Exclude’, {‘StringVar’} table MATLAB Answers — New Questions
Find input to function 1 that results in function 2 returning 0
Hello,
I have a function that traces raypaths given input criteria. I then have a second function that solves for error at a given point in space. I am able to find the launch angles that would result in bracketing the target.
My question is this: having solved for launch angles that bracket the point, how do I find the launch angle that results in zero error? An excerpt of the code I am working with is below
rayangle = (-90:.1:90)
nray=length(rayangle)
for ii=1:nray
theta0=rayangle(ii)
z_r=raysolver(z0,theta0,cmat,nstep,rstep); %calling the function that traces the rays
z_r_theta0(ii,:)=z_r(1,:); %Saving the path of each ray in z_r_theta0
end
%% Finding error
%target co-ordinates
r=50000;
z=1100;
d_error=deptherror(r,z,z_r_theta0); %gives me depth error for each launch angle
bracket_ray=crossray(d_error)%this gives me all the launch angles that bracket the target.
%what I need is to find theta0 for each set of bracketing launch angles
%that result in d_error == 0Hello,
I have a function that traces raypaths given input criteria. I then have a second function that solves for error at a given point in space. I am able to find the launch angles that would result in bracketing the target.
My question is this: having solved for launch angles that bracket the point, how do I find the launch angle that results in zero error? An excerpt of the code I am working with is below
rayangle = (-90:.1:90)
nray=length(rayangle)
for ii=1:nray
theta0=rayangle(ii)
z_r=raysolver(z0,theta0,cmat,nstep,rstep); %calling the function that traces the rays
z_r_theta0(ii,:)=z_r(1,:); %Saving the path of each ray in z_r_theta0
end
%% Finding error
%target co-ordinates
r=50000;
z=1100;
d_error=deptherror(r,z,z_r_theta0); %gives me depth error for each launch angle
bracket_ray=crossray(d_error)%this gives me all the launch angles that bracket the target.
%what I need is to find theta0 for each set of bracketing launch angles
%that result in d_error == 0 Hello,
I have a function that traces raypaths given input criteria. I then have a second function that solves for error at a given point in space. I am able to find the launch angles that would result in bracketing the target.
My question is this: having solved for launch angles that bracket the point, how do I find the launch angle that results in zero error? An excerpt of the code I am working with is below
rayangle = (-90:.1:90)
nray=length(rayangle)
for ii=1:nray
theta0=rayangle(ii)
z_r=raysolver(z0,theta0,cmat,nstep,rstep); %calling the function that traces the rays
z_r_theta0(ii,:)=z_r(1,:); %Saving the path of each ray in z_r_theta0
end
%% Finding error
%target co-ordinates
r=50000;
z=1100;
d_error=deptherror(r,z,z_r_theta0); %gives me depth error for each launch angle
bracket_ray=crossray(d_error)%this gives me all the launch angles that bracket the target.
%what I need is to find theta0 for each set of bracketing launch angles
%that result in d_error == 0 zero solver MATLAB Answers — New Questions
while executing Polyspace Bugfinder and code prover we are getting this Error: identifier “Float64” is undefined
while executing Polyspace Bugfinder and code prover we are getting this Error: identifier "Float64" is undefinedwhile executing Polyspace Bugfinder and code prover we are getting this Error: identifier "Float64" is undefined while executing Polyspace Bugfinder and code prover we are getting this Error: identifier "Float64" is undefined polyspace, matlab MATLAB Answers — New Questions
how to generate a dome shape by using defined points
Hi all,
i am trying to generate a semi ellipsoidal dome shape by using x, y, z values and below is my code. in the code i defined the x,y,z values but i am unable to assign those values to sphere.
any suggestions and thanks in advance
clc
x = [65 55.2125 50.8267 46.7398 42.9232 39.3476 35.9815 32.7882 29.7175 26.6833 23.4690 18.7605];
y = x;
z = [0.0,0.9,2.7,5.2,8.2,11.8,15.8,20.3,25.2,30.7,37.1,47.5]; % max height of dome is 47.5
[x,y,z] = sphere(20);
x = x(12:end,:);
y = y(12:end,:);
z = z(12:end,:);
r = 65; % radius of the dome
surf(r.*x,r.*y,r.*z);
axis equal;Hi all,
i am trying to generate a semi ellipsoidal dome shape by using x, y, z values and below is my code. in the code i defined the x,y,z values but i am unable to assign those values to sphere.
any suggestions and thanks in advance
clc
x = [65 55.2125 50.8267 46.7398 42.9232 39.3476 35.9815 32.7882 29.7175 26.6833 23.4690 18.7605];
y = x;
z = [0.0,0.9,2.7,5.2,8.2,11.8,15.8,20.3,25.2,30.7,37.1,47.5]; % max height of dome is 47.5
[x,y,z] = sphere(20);
x = x(12:end,:);
y = y(12:end,:);
z = z(12:end,:);
r = 65; % radius of the dome
surf(r.*x,r.*y,r.*z);
axis equal; Hi all,
i am trying to generate a semi ellipsoidal dome shape by using x, y, z values and below is my code. in the code i defined the x,y,z values but i am unable to assign those values to sphere.
any suggestions and thanks in advance
clc
x = [65 55.2125 50.8267 46.7398 42.9232 39.3476 35.9815 32.7882 29.7175 26.6833 23.4690 18.7605];
y = x;
z = [0.0,0.9,2.7,5.2,8.2,11.8,15.8,20.3,25.2,30.7,37.1,47.5]; % max height of dome is 47.5
[x,y,z] = sphere(20);
x = x(12:end,:);
y = y(12:end,:);
z = z(12:end,:);
r = 65; % radius of the dome
surf(r.*x,r.*y,r.*z);
axis equal; dome MATLAB Answers — New Questions
Parrot minidrone – wifi vs bluetooth connection
Hello,
I’d like to connect my Parrot Mambo and Rolling Spider minidrone to my laptop to go through the Programming Drones with Simulink steps as described here – https://www.mathworks.com/videos/programming-drones-with-simulink-1513024653640.html . Connection using the bluetooth is descibed on the mentioned link.
But I found also these guidelines – Connect to Parrot Mambo Drone Over Wi-Fi descibing connection via the wifi.
So may I ask you which way is currently prefered? I tried it briefly and it seems that only bluetooth works for me.
Thank youHello,
I’d like to connect my Parrot Mambo and Rolling Spider minidrone to my laptop to go through the Programming Drones with Simulink steps as described here – https://www.mathworks.com/videos/programming-drones-with-simulink-1513024653640.html . Connection using the bluetooth is descibed on the mentioned link.
But I found also these guidelines – Connect to Parrot Mambo Drone Over Wi-Fi descibing connection via the wifi.
So may I ask you which way is currently prefered? I tried it briefly and it seems that only bluetooth works for me.
Thank you Hello,
I’d like to connect my Parrot Mambo and Rolling Spider minidrone to my laptop to go through the Programming Drones with Simulink steps as described here – https://www.mathworks.com/videos/programming-drones-with-simulink-1513024653640.html . Connection using the bluetooth is descibed on the mentioned link.
But I found also these guidelines – Connect to Parrot Mambo Drone Over Wi-Fi descibing connection via the wifi.
So may I ask you which way is currently prefered? I tried it briefly and it seems that only bluetooth works for me.
Thank you parrot minidrone, parrot mambo, parrot rolling spider, bluetooth, wifi MATLAB Answers — New Questions
Low performance when training SVM model using “polynomial” kernel function
Hello,
I am trying to compare the performance of SVM regression (or SVR) between "rbf", "polynomial", and "linear".
The training works well when using "rbf" and "linear" (e.g., 0.7~0.8 of R^2).
However, when "polynomial" function was applied as kernel function, the performance degraded to 0.001 of R^2 or negative.
I used the code:
Mdl = fitrsvm(X,Y,"Standardize",’true’,’KernelFunction’,’polynomial’,’OptimizeHyperparameters’,{‘BoxConstraint’,’Epsilon’,’KernelScale’,’PolynomialOrder’},’HyperparameterOptimizationOptions’,struct(‘MaxObjectiveEvaluations’,100))
Please help
Thank you.Hello,
I am trying to compare the performance of SVM regression (or SVR) between "rbf", "polynomial", and "linear".
The training works well when using "rbf" and "linear" (e.g., 0.7~0.8 of R^2).
However, when "polynomial" function was applied as kernel function, the performance degraded to 0.001 of R^2 or negative.
I used the code:
Mdl = fitrsvm(X,Y,"Standardize",’true’,’KernelFunction’,’polynomial’,’OptimizeHyperparameters’,{‘BoxConstraint’,’Epsilon’,’KernelScale’,’PolynomialOrder’},’HyperparameterOptimizationOptions’,struct(‘MaxObjectiveEvaluations’,100))
Please help
Thank you. Hello,
I am trying to compare the performance of SVM regression (or SVR) between "rbf", "polynomial", and "linear".
The training works well when using "rbf" and "linear" (e.g., 0.7~0.8 of R^2).
However, when "polynomial" function was applied as kernel function, the performance degraded to 0.001 of R^2 or negative.
I used the code:
Mdl = fitrsvm(X,Y,"Standardize",’true’,’KernelFunction’,’polynomial’,’OptimizeHyperparameters’,{‘BoxConstraint’,’Epsilon’,’KernelScale’,’PolynomialOrder’},’HyperparameterOptimizationOptions’,struct(‘MaxObjectiveEvaluations’,100))
Please help
Thank you. svm, polynomial, regression MATLAB Answers — New Questions
How to make csv file negative to positive to use CNN
I want to analyze ECG data using CNN.
But my data has negative values. How can i fix these situation to put data in CNN?
Negative value are important because they are directly measured values by ECG test.I want to analyze ECG data using CNN.
But my data has negative values. How can i fix these situation to put data in CNN?
Negative value are important because they are directly measured values by ECG test. I want to analyze ECG data using CNN.
But my data has negative values. How can i fix these situation to put data in CNN?
Negative value are important because they are directly measured values by ECG test. cnn, ecg, negative, positive, csv MATLAB Answers — New Questions
Simulating load profile in Simulink
I am trying to add a variable load (Residential Load profile) in small microgrid system. I have the load profile data but i couldn’t find a way to add it in simulink. I know about three phase dynamic load, however i am looking to add a customize load profile in simulink. Is there any way i can setup load profile in Simulink. I will really appreciate the help. Thanks.I am trying to add a variable load (Residential Load profile) in small microgrid system. I have the load profile data but i couldn’t find a way to add it in simulink. I know about three phase dynamic load, however i am looking to add a customize load profile in simulink. Is there any way i can setup load profile in Simulink. I will really appreciate the help. Thanks. I am trying to add a variable load (Residential Load profile) in small microgrid system. I have the load profile data but i couldn’t find a way to add it in simulink. I know about three phase dynamic load, however i am looking to add a customize load profile in simulink. Is there any way i can setup load profile in Simulink. I will really appreciate the help. Thanks. load profile, simulink MATLAB Answers — New Questions
How to make an FMU debugging-friendly in Simulink?
We are trying to develop an FMU that is compatible with Simulink. We are using Matlab 2023b+ on Windows x64. The FMU is FMI v3.0 and was originally generated using MSVC 2022 on Windows. The FMU only support co-simulation currently.
We are able to successfully use the FMU using `fmusim`, the executable provided here: https://github.com/modelica/Reference-FMUs . The FMU also correctly works in FMPy https://github.com/CATIA-Systems/FMPy . The FMU also passes the validation check here: https://fmu-check.herokuapp.com/ . However, when we try in Simulink, the simulation stays stuck on t=0.0, i.e. the start. We have added logs to the FMU and are able to see which statement the execution is stuck on, though, the reason for that is not clear.
To solve this, we would like to try to debug by placing breakpoints and view the value of the local variables etc. When trying to use the fmudialog.compileFMUSources we get a few compile errors. How can one better control the exact compile command that is used by compileFMUSources? Is there a way to avoid re-compilation since it was recently compiled with MSVC?We are trying to develop an FMU that is compatible with Simulink. We are using Matlab 2023b+ on Windows x64. The FMU is FMI v3.0 and was originally generated using MSVC 2022 on Windows. The FMU only support co-simulation currently.
We are able to successfully use the FMU using `fmusim`, the executable provided here: https://github.com/modelica/Reference-FMUs . The FMU also correctly works in FMPy https://github.com/CATIA-Systems/FMPy . The FMU also passes the validation check here: https://fmu-check.herokuapp.com/ . However, when we try in Simulink, the simulation stays stuck on t=0.0, i.e. the start. We have added logs to the FMU and are able to see which statement the execution is stuck on, though, the reason for that is not clear.
To solve this, we would like to try to debug by placing breakpoints and view the value of the local variables etc. When trying to use the fmudialog.compileFMUSources we get a few compile errors. How can one better control the exact compile command that is used by compileFMUSources? Is there a way to avoid re-compilation since it was recently compiled with MSVC? We are trying to develop an FMU that is compatible with Simulink. We are using Matlab 2023b+ on Windows x64. The FMU is FMI v3.0 and was originally generated using MSVC 2022 on Windows. The FMU only support co-simulation currently.
We are able to successfully use the FMU using `fmusim`, the executable provided here: https://github.com/modelica/Reference-FMUs . The FMU also correctly works in FMPy https://github.com/CATIA-Systems/FMPy . The FMU also passes the validation check here: https://fmu-check.herokuapp.com/ . However, when we try in Simulink, the simulation stays stuck on t=0.0, i.e. the start. We have added logs to the FMU and are able to see which statement the execution is stuck on, though, the reason for that is not clear.
To solve this, we would like to try to debug by placing breakpoints and view the value of the local variables etc. When trying to use the fmudialog.compileFMUSources we get a few compile errors. How can one better control the exact compile command that is used by compileFMUSources? Is there a way to avoid re-compilation since it was recently compiled with MSVC? fmu, debugging, simulink, co-simulation MATLAB Answers — New Questions
setting the yticklabels with $10^{-2}$ appearing at the top
I want the y axis to be labelled as
But I actually got
The problem is that the ticklabels are too wide. How can I make it appprear as I desire?I want the y axis to be labelled as
But I actually got
The problem is that the ticklabels are too wide. How can I make it appprear as I desire? I want the y axis to be labelled as
But I actually got
The problem is that the ticklabels are too wide. How can I make it appprear as I desire? plot MATLAB Answers — New Questions
How to calculate very large number by Matlab
I want to find S_1+S_2+S_3I want to find S_1+S_2+S_3 I want to find S_1+S_2+S_3 @staff MATLAB Answers — New Questions
How to choose value of Ts for converting continuous state space (SS) matrix to discrete SS matrix?
Hi,
I converted Transfer function to state space matrix but I am curious how to choose best Ts?
I am not sure what is the function of this Ts related to plant?
I just used random values of Ts to check the affect of conversion, I found that changing Ts can chane the Discrete SS A,B matrices while it has no affect on C matrix.
I will use c2d distrete state space matrix in MPC controller for designing a controller to deploy on real plant. Please help me in understanding Ts and how to choose the best Ts value based on some facts?
My code is
%Transfer Function By System identification
num = [-1.324 6.6e05 -6.914e09 5.128e13 -1.054e19]
den = [1 1.99e04 1.371e09 1.145e13 4.037e17]
%Conversion to SS
plant = tf([num],[den], ‘OutputDelay’,0.001)
% Simplify the model to remove insignificant poles and zeros
SSpzt = ss(plant) %This gives continuous time linear state space model of TFpzt
Ac = SSpzt.A;
Bc = SSpzt.B;
Cc = SSpzt.C;
Dc = SSpzt.D;
Ts = 0.0001 %Sampling time actual = 3.1309e-05
Td = 0.009; %time Delay baed on frequency data
%Contineous Model to discrete Statespace Matrices
SSpzt_dis = c2dm(Ac,Bc,Cc,Dc,Ts)
[Ad,Bd,Cd,Dd] = c2dm(Ac, Bc, Cc, Dc, Ts)
sysdis = ss(Ad,Bd,Cd,Dd,Ts)
sysdis.D = 0Hi,
I converted Transfer function to state space matrix but I am curious how to choose best Ts?
I am not sure what is the function of this Ts related to plant?
I just used random values of Ts to check the affect of conversion, I found that changing Ts can chane the Discrete SS A,B matrices while it has no affect on C matrix.
I will use c2d distrete state space matrix in MPC controller for designing a controller to deploy on real plant. Please help me in understanding Ts and how to choose the best Ts value based on some facts?
My code is
%Transfer Function By System identification
num = [-1.324 6.6e05 -6.914e09 5.128e13 -1.054e19]
den = [1 1.99e04 1.371e09 1.145e13 4.037e17]
%Conversion to SS
plant = tf([num],[den], ‘OutputDelay’,0.001)
% Simplify the model to remove insignificant poles and zeros
SSpzt = ss(plant) %This gives continuous time linear state space model of TFpzt
Ac = SSpzt.A;
Bc = SSpzt.B;
Cc = SSpzt.C;
Dc = SSpzt.D;
Ts = 0.0001 %Sampling time actual = 3.1309e-05
Td = 0.009; %time Delay baed on frequency data
%Contineous Model to discrete Statespace Matrices
SSpzt_dis = c2dm(Ac,Bc,Cc,Dc,Ts)
[Ad,Bd,Cd,Dd] = c2dm(Ac, Bc, Cc, Dc, Ts)
sysdis = ss(Ad,Bd,Cd,Dd,Ts)
sysdis.D = 0 Hi,
I converted Transfer function to state space matrix but I am curious how to choose best Ts?
I am not sure what is the function of this Ts related to plant?
I just used random values of Ts to check the affect of conversion, I found that changing Ts can chane the Discrete SS A,B matrices while it has no affect on C matrix.
I will use c2d distrete state space matrix in MPC controller for designing a controller to deploy on real plant. Please help me in understanding Ts and how to choose the best Ts value based on some facts?
My code is
%Transfer Function By System identification
num = [-1.324 6.6e05 -6.914e09 5.128e13 -1.054e19]
den = [1 1.99e04 1.371e09 1.145e13 4.037e17]
%Conversion to SS
plant = tf([num],[den], ‘OutputDelay’,0.001)
% Simplify the model to remove insignificant poles and zeros
SSpzt = ss(plant) %This gives continuous time linear state space model of TFpzt
Ac = SSpzt.A;
Bc = SSpzt.B;
Cc = SSpzt.C;
Dc = SSpzt.D;
Ts = 0.0001 %Sampling time actual = 3.1309e-05
Td = 0.009; %time Delay baed on frequency data
%Contineous Model to discrete Statespace Matrices
SSpzt_dis = c2dm(Ac,Bc,Cc,Dc,Ts)
[Ad,Bd,Cd,Dd] = c2dm(Ac, Bc, Cc, Dc, Ts)
sysdis = ss(Ad,Bd,Cd,Dd,Ts)
sysdis.D = 0 state space modeling, model predictive controller, system identification MATLAB Answers — New Questions
Has the MATLAB ‘mget’ function changed from versions R2020a to R2024a?
I ask this question becasue i have a script that runs perfectly well in the 2020 version using mget. Once i upgraded to 2024 the mget function started to run into issues and now i get an error every time i use it. Can i get some guidance on how to fix this?I ask this question becasue i have a script that runs perfectly well in the 2020 version using mget. Once i upgraded to 2024 the mget function started to run into issues and now i get an error every time i use it. Can i get some guidance on how to fix this? I ask this question becasue i have a script that runs perfectly well in the 2020 version using mget. Once i upgraded to 2024 the mget function started to run into issues and now i get an error every time i use it. Can i get some guidance on how to fix this? ftp, mget.m MATLAB Answers — New Questions
No se como crear un 4×1 polyshape with 3 properties
Error using polyshape/checkInput
x- and y-coordinate vectors must both be numeric or both be cell arrays.
Error in polyshape (line 169)
[X, Y, tc, simpl, collinear] = polyshape.checkInput(param, varargin{:});
Error in untitled2 (line 19)
cborders=polyshape(cborders)Error using polyshape/checkInput
x- and y-coordinate vectors must both be numeric or both be cell arrays.
Error in polyshape (line 169)
[X, Y, tc, simpl, collinear] = polyshape.checkInput(param, varargin{:});
Error in untitled2 (line 19)
cborders=polyshape(cborders) Error using polyshape/checkInput
x- and y-coordinate vectors must both be numeric or both be cell arrays.
Error in polyshape (line 169)
[X, Y, tc, simpl, collinear] = polyshape.checkInput(param, varargin{:});
Error in untitled2 (line 19)
cborders=polyshape(cborders) polyshape MATLAB Answers — New Questions
Custom fit curve and plotted curve are different, help
Hi everyone, I’m using the Fitter App to fit some point with a custom equation, the fit is done correctly but when I put the same values for the same parameters in a MATLAB to plot the points with a scatterplot and the fit curve like a plot the fit curve is shifted up or down, and I have to manually adjust the parameters to get a decent looking graph (I’m posting an example)Hi everyone, I’m using the Fitter App to fit some point with a custom equation, the fit is done correctly but when I put the same values for the same parameters in a MATLAB to plot the points with a scatterplot and the fit curve like a plot the fit curve is shifted up or down, and I have to manually adjust the parameters to get a decent looking graph (I’m posting an example) Hi everyone, I’m using the Fitter App to fit some point with a custom equation, the fit is done correctly but when I put the same values for the same parameters in a MATLAB to plot the points with a scatterplot and the fit curve like a plot the fit curve is shifted up or down, and I have to manually adjust the parameters to get a decent looking graph (I’m posting an example) curve fitting, plot MATLAB Answers — New Questions
Does MATLAB’s pattern() function use full-wave MoM or superposition of elements for antenna array analysis?
This question is probably more for MATLAB staffs but I am open to any response.
I am conducting research to compare the results of radiation patterns and electromagnetic behaviors of various antenna arrays. Specifically, for the same array, I am interested in simulations that consider the entire array structure, which includes multiple antenna elements and their excitations, versus simulations of individual array elements followed by superimposing their patterns, EM fields, and phase fronts.
I reviewed the MATLAB documentation on Modeling Mutual Coupling in Large Arrays Using Embedded Element Pattern , which provided a clear example of full-wave Method of Moments (MoM) simulation approaches compared to the superposition of isolated elements. Additionally, the Method of Moments Solver for Metal and Dielectric Structures documentation explained that multiple excitation feeds create a voltage matrix that interacts with the iteration matrix. This process exemplifies the full-wave MoM approach, incorporating the entire array structure and excitation points concurrently.
However, I also came across this PDF, Smart RF Design of Digitally Controlled RF Transmitters and Receivers from MathWorks themselves. On page 15 of the slides, it says:
"Phased Array System Toolbox computes the array pattern using the superposition of the pattern of each individual element – ULA, URA, UCA and conformal arrays use the same pattern for all elements – Heterogeneous arrays have different patterns for different elements"
The statement in the PDF seems to contradict the documentation provided, suggesting that the array pattern is computed using the superposition of each individual element instead of a full-wave Method of Moments (MoM) approach.
After reading, now I am confused, if I simply do the following:
% Create the first Custom3D object using triangulation
customShape = shape.Custom3D(tr);
% Create the second Custom3D object using triangulation
customShape2 = shape.Custom3D(tr2);
% Create the third Custom3D object using triangulation
customShape3 = shape.Custom3D(tr3);
%assign locations to the Custom3D objects
[~]= translate(customShape,[0 0 0]);
[~]= translate(customShape2,[1 0 0]);
[~]= translate(customShape3,[0 0 1]);
%creat the array using the combined Custom3D objects
antShapearray = customShape + customShape2 + customShape3;
antarray = customAntenna(Shape=antShapearray);
[~] = createFeed(antarray,[0 0 0; 1 0 0; 0 0 1],[1 1 1]);
%obtain EM results
show(antarray)
pattern(antarray,freq)
Does MATLAB analyze the antenna array as a whole, or does it analyze each geometry individually and then superimpose the results?
Many thanksThis question is probably more for MATLAB staffs but I am open to any response.
I am conducting research to compare the results of radiation patterns and electromagnetic behaviors of various antenna arrays. Specifically, for the same array, I am interested in simulations that consider the entire array structure, which includes multiple antenna elements and their excitations, versus simulations of individual array elements followed by superimposing their patterns, EM fields, and phase fronts.
I reviewed the MATLAB documentation on Modeling Mutual Coupling in Large Arrays Using Embedded Element Pattern , which provided a clear example of full-wave Method of Moments (MoM) simulation approaches compared to the superposition of isolated elements. Additionally, the Method of Moments Solver for Metal and Dielectric Structures documentation explained that multiple excitation feeds create a voltage matrix that interacts with the iteration matrix. This process exemplifies the full-wave MoM approach, incorporating the entire array structure and excitation points concurrently.
However, I also came across this PDF, Smart RF Design of Digitally Controlled RF Transmitters and Receivers from MathWorks themselves. On page 15 of the slides, it says:
"Phased Array System Toolbox computes the array pattern using the superposition of the pattern of each individual element – ULA, URA, UCA and conformal arrays use the same pattern for all elements – Heterogeneous arrays have different patterns for different elements"
The statement in the PDF seems to contradict the documentation provided, suggesting that the array pattern is computed using the superposition of each individual element instead of a full-wave Method of Moments (MoM) approach.
After reading, now I am confused, if I simply do the following:
% Create the first Custom3D object using triangulation
customShape = shape.Custom3D(tr);
% Create the second Custom3D object using triangulation
customShape2 = shape.Custom3D(tr2);
% Create the third Custom3D object using triangulation
customShape3 = shape.Custom3D(tr3);
%assign locations to the Custom3D objects
[~]= translate(customShape,[0 0 0]);
[~]= translate(customShape2,[1 0 0]);
[~]= translate(customShape3,[0 0 1]);
%creat the array using the combined Custom3D objects
antShapearray = customShape + customShape2 + customShape3;
antarray = customAntenna(Shape=antShapearray);
[~] = createFeed(antarray,[0 0 0; 1 0 0; 0 0 1],[1 1 1]);
%obtain EM results
show(antarray)
pattern(antarray,freq)
Does MATLAB analyze the antenna array as a whole, or does it analyze each geometry individually and then superimpose the results?
Many thanks This question is probably more for MATLAB staffs but I am open to any response.
I am conducting research to compare the results of radiation patterns and electromagnetic behaviors of various antenna arrays. Specifically, for the same array, I am interested in simulations that consider the entire array structure, which includes multiple antenna elements and their excitations, versus simulations of individual array elements followed by superimposing their patterns, EM fields, and phase fronts.
I reviewed the MATLAB documentation on Modeling Mutual Coupling in Large Arrays Using Embedded Element Pattern , which provided a clear example of full-wave Method of Moments (MoM) simulation approaches compared to the superposition of isolated elements. Additionally, the Method of Moments Solver for Metal and Dielectric Structures documentation explained that multiple excitation feeds create a voltage matrix that interacts with the iteration matrix. This process exemplifies the full-wave MoM approach, incorporating the entire array structure and excitation points concurrently.
However, I also came across this PDF, Smart RF Design of Digitally Controlled RF Transmitters and Receivers from MathWorks themselves. On page 15 of the slides, it says:
"Phased Array System Toolbox computes the array pattern using the superposition of the pattern of each individual element – ULA, URA, UCA and conformal arrays use the same pattern for all elements – Heterogeneous arrays have different patterns for different elements"
The statement in the PDF seems to contradict the documentation provided, suggesting that the array pattern is computed using the superposition of each individual element instead of a full-wave Method of Moments (MoM) approach.
After reading, now I am confused, if I simply do the following:
% Create the first Custom3D object using triangulation
customShape = shape.Custom3D(tr);
% Create the second Custom3D object using triangulation
customShape2 = shape.Custom3D(tr2);
% Create the third Custom3D object using triangulation
customShape3 = shape.Custom3D(tr3);
%assign locations to the Custom3D objects
[~]= translate(customShape,[0 0 0]);
[~]= translate(customShape2,[1 0 0]);
[~]= translate(customShape3,[0 0 1]);
%creat the array using the combined Custom3D objects
antShapearray = customShape + customShape2 + customShape3;
antarray = customAntenna(Shape=antShapearray);
[~] = createFeed(antarray,[0 0 0; 1 0 0; 0 0 1],[1 1 1]);
%obtain EM results
show(antarray)
pattern(antarray,freq)
Does MATLAB analyze the antenna array as a whole, or does it analyze each geometry individually and then superimpose the results?
Many thanks antenna array, array simulation MATLAB Answers — New Questions
Unrecognized function or variable ‘START_GUI’.
I’m trying to get "AnaSP, a MATLAB software suite to ANAlyse SPheroids’ features Brought to you by: piccila" to load up but it isn’t and I’m following the video tutorial https://www.youtube.com/watch?v=ZqANSYfMnss&t=3s. I can’t tell what to do any idea what to do if I get Unrecognized function or variable ‘START_GUI’. when I try to start up the programI’m trying to get "AnaSP, a MATLAB software suite to ANAlyse SPheroids’ features Brought to you by: piccila" to load up but it isn’t and I’m following the video tutorial https://www.youtube.com/watch?v=ZqANSYfMnss&t=3s. I can’t tell what to do any idea what to do if I get Unrecognized function or variable ‘START_GUI’. when I try to start up the program I’m trying to get "AnaSP, a MATLAB software suite to ANAlyse SPheroids’ features Brought to you by: piccila" to load up but it isn’t and I’m following the video tutorial https://www.youtube.com/watch?v=ZqANSYfMnss&t=3s. I can’t tell what to do any idea what to do if I get Unrecognized function or variable ‘START_GUI’. when I try to start up the program anasp MATLAB Answers — New Questions
Multiplication of submatrices of a matrix
I have a J X J matrix $C$ that is upper triangular. Also, C’C is positive definite. I also have a matrix $A$ formed by submatrices of size J X K as follows, A = [A_1 ; A_2 ; A_3 ; … A_N ]
where A_i = [I B_i] for each $i$. I is the identity matrix of size J and B_i is a matrix of size J C (K-J). I create a new matrix A_new such that
A_new = [C*A_1; C*A_2,…;C*A_N]
Notice that A_new can be written as A_new = [C CB_1 ; C CB_2 ; … C CB_N ].
Is there a way for me to write A_new’ * A_new in terms of matrix operations or concatenations?
I have a loop in Matlab where I need to obtain a matrix A_new for different values of C. This is extremely costly computationally as the matrices B_i and C are huge. Any help is appreciated!
Thank you!I have a J X J matrix $C$ that is upper triangular. Also, C’C is positive definite. I also have a matrix $A$ formed by submatrices of size J X K as follows, A = [A_1 ; A_2 ; A_3 ; … A_N ]
where A_i = [I B_i] for each $i$. I is the identity matrix of size J and B_i is a matrix of size J C (K-J). I create a new matrix A_new such that
A_new = [C*A_1; C*A_2,…;C*A_N]
Notice that A_new can be written as A_new = [C CB_1 ; C CB_2 ; … C CB_N ].
Is there a way for me to write A_new’ * A_new in terms of matrix operations or concatenations?
I have a loop in Matlab where I need to obtain a matrix A_new for different values of C. This is extremely costly computationally as the matrices B_i and C are huge. Any help is appreciated!
Thank you! I have a J X J matrix $C$ that is upper triangular. Also, C’C is positive definite. I also have a matrix $A$ formed by submatrices of size J X K as follows, A = [A_1 ; A_2 ; A_3 ; … A_N ]
where A_i = [I B_i] for each $i$. I is the identity matrix of size J and B_i is a matrix of size J C (K-J). I create a new matrix A_new such that
A_new = [C*A_1; C*A_2,…;C*A_N]
Notice that A_new can be written as A_new = [C CB_1 ; C CB_2 ; … C CB_N ].
Is there a way for me to write A_new’ * A_new in terms of matrix operations or concatenations?
I have a loop in Matlab where I need to obtain a matrix A_new for different values of C. This is extremely costly computationally as the matrices B_i and C are huge. Any help is appreciated!
Thank you! matrix manipulation MATLAB Answers — New Questions
What is the origin of the discrepancy in binning caused by the built-in Freedman–Diaconis method in the histcounts function?
I am attempting to use the Freedman–Diaconis (FD) rule to determine appropriate bins for a right-skewed dataset. Within the histcounts MATLAB function, the parameter ‘BinMethod’ has a built-in FD formula via the parameter value ‘fd.’ On the MATLAB reference page for histcounts, the formula for the FD rule that is supposedly applied to calculate bin-width when one calls ‘fd’ is correctly cited as the following:
2*iqr(X(:))*numel(X)^(-1/3)
In my testing, I have found that the actual bins produced by the ‘fd’ method vary significantly from what one expects to observe when manually applying the FD rule. Even accounting for the fact that "histcounts adjusts the number of bins slightly so that the bin edges fall on ‘nice’ numbers, rather than using these exact formulas" as stated on the MATLAB reference page, the differences in binning are substantial. While I have not been able to discern an exact pattern regarding the differences between MATLAB and manual FD binning, I have observed that the MATLAB FD typically reduces the number of total bins by a factor of 2-10 across various datasets.
To illustrate this issue, I’ve attached a MATLAB script that re-creates this discrepancy. With this seed, the manual FD rule is generating 239 bins and the MATLAB FD rule is generating 106 bins. I’ve also attached the output figures. Similar discrepancies occur regardless of seed or population size.
clear
clc
%Data Generation
rng(1);
data = randn(10000, 1);
skewed_data = exp(data);
%Manual FD
bin_length = 2*iqr(skewed_data(:))*numel(skewed_data)^(-1/3); %Formula from MATLAB references
edges = min(skewed_data):bin_length:max(skewed_data);
b = histcounts(skewed_data, edges);
figure
bar(edges(1:end-1), b, ‘histc’);
xlabel(‘Value’);
ylabel(‘Frequency’);
title(‘Manual FD’);
disp(‘Number of bins for manual FD:’)
disp(length(b));
%MATLAB FD
[b, edges] = histcounts(skewed_data,’BinMethod’,’fd’);
figure
bar(edges(1:end-1), b, ‘histc’);
xlabel(‘Value’);
ylabel(‘Frequency’);
title(‘MATLAB FD’);
disp(‘Number of bins for MATLAB FD:’)
disp(length(b));
Regarding my interest in this discrepancy: I used both MATLAB FD and manual FD binning on a dataset before conducting non-linear optimization, and I found that the resulting models were best when the MATLAB FD was applied. I am preparing to publish, and I want to be able to explain exactly how my data is being binned to maximize performance. As a result, I would like to know how the MATLAB FD method, and broadly histcounts is binning my data.
Of note: I’ve found similar differences in binning between the MATLAB and real real formula for Sturges and Scott as well. While I imagine that the origin of this difference may be similar, I am primarily concerned with Freedman–Diaconis currently.I am attempting to use the Freedman–Diaconis (FD) rule to determine appropriate bins for a right-skewed dataset. Within the histcounts MATLAB function, the parameter ‘BinMethod’ has a built-in FD formula via the parameter value ‘fd.’ On the MATLAB reference page for histcounts, the formula for the FD rule that is supposedly applied to calculate bin-width when one calls ‘fd’ is correctly cited as the following:
2*iqr(X(:))*numel(X)^(-1/3)
In my testing, I have found that the actual bins produced by the ‘fd’ method vary significantly from what one expects to observe when manually applying the FD rule. Even accounting for the fact that "histcounts adjusts the number of bins slightly so that the bin edges fall on ‘nice’ numbers, rather than using these exact formulas" as stated on the MATLAB reference page, the differences in binning are substantial. While I have not been able to discern an exact pattern regarding the differences between MATLAB and manual FD binning, I have observed that the MATLAB FD typically reduces the number of total bins by a factor of 2-10 across various datasets.
To illustrate this issue, I’ve attached a MATLAB script that re-creates this discrepancy. With this seed, the manual FD rule is generating 239 bins and the MATLAB FD rule is generating 106 bins. I’ve also attached the output figures. Similar discrepancies occur regardless of seed or population size.
clear
clc
%Data Generation
rng(1);
data = randn(10000, 1);
skewed_data = exp(data);
%Manual FD
bin_length = 2*iqr(skewed_data(:))*numel(skewed_data)^(-1/3); %Formula from MATLAB references
edges = min(skewed_data):bin_length:max(skewed_data);
b = histcounts(skewed_data, edges);
figure
bar(edges(1:end-1), b, ‘histc’);
xlabel(‘Value’);
ylabel(‘Frequency’);
title(‘Manual FD’);
disp(‘Number of bins for manual FD:’)
disp(length(b));
%MATLAB FD
[b, edges] = histcounts(skewed_data,’BinMethod’,’fd’);
figure
bar(edges(1:end-1), b, ‘histc’);
xlabel(‘Value’);
ylabel(‘Frequency’);
title(‘MATLAB FD’);
disp(‘Number of bins for MATLAB FD:’)
disp(length(b));
Regarding my interest in this discrepancy: I used both MATLAB FD and manual FD binning on a dataset before conducting non-linear optimization, and I found that the resulting models were best when the MATLAB FD was applied. I am preparing to publish, and I want to be able to explain exactly how my data is being binned to maximize performance. As a result, I would like to know how the MATLAB FD method, and broadly histcounts is binning my data.
Of note: I’ve found similar differences in binning between the MATLAB and real real formula for Sturges and Scott as well. While I imagine that the origin of this difference may be similar, I am primarily concerned with Freedman–Diaconis currently. I am attempting to use the Freedman–Diaconis (FD) rule to determine appropriate bins for a right-skewed dataset. Within the histcounts MATLAB function, the parameter ‘BinMethod’ has a built-in FD formula via the parameter value ‘fd.’ On the MATLAB reference page for histcounts, the formula for the FD rule that is supposedly applied to calculate bin-width when one calls ‘fd’ is correctly cited as the following:
2*iqr(X(:))*numel(X)^(-1/3)
In my testing, I have found that the actual bins produced by the ‘fd’ method vary significantly from what one expects to observe when manually applying the FD rule. Even accounting for the fact that "histcounts adjusts the number of bins slightly so that the bin edges fall on ‘nice’ numbers, rather than using these exact formulas" as stated on the MATLAB reference page, the differences in binning are substantial. While I have not been able to discern an exact pattern regarding the differences between MATLAB and manual FD binning, I have observed that the MATLAB FD typically reduces the number of total bins by a factor of 2-10 across various datasets.
To illustrate this issue, I’ve attached a MATLAB script that re-creates this discrepancy. With this seed, the manual FD rule is generating 239 bins and the MATLAB FD rule is generating 106 bins. I’ve also attached the output figures. Similar discrepancies occur regardless of seed or population size.
clear
clc
%Data Generation
rng(1);
data = randn(10000, 1);
skewed_data = exp(data);
%Manual FD
bin_length = 2*iqr(skewed_data(:))*numel(skewed_data)^(-1/3); %Formula from MATLAB references
edges = min(skewed_data):bin_length:max(skewed_data);
b = histcounts(skewed_data, edges);
figure
bar(edges(1:end-1), b, ‘histc’);
xlabel(‘Value’);
ylabel(‘Frequency’);
title(‘Manual FD’);
disp(‘Number of bins for manual FD:’)
disp(length(b));
%MATLAB FD
[b, edges] = histcounts(skewed_data,’BinMethod’,’fd’);
figure
bar(edges(1:end-1), b, ‘histc’);
xlabel(‘Value’);
ylabel(‘Frequency’);
title(‘MATLAB FD’);
disp(‘Number of bins for MATLAB FD:’)
disp(length(b));
Regarding my interest in this discrepancy: I used both MATLAB FD and manual FD binning on a dataset before conducting non-linear optimization, and I found that the resulting models were best when the MATLAB FD was applied. I am preparing to publish, and I want to be able to explain exactly how my data is being binned to maximize performance. As a result, I would like to know how the MATLAB FD method, and broadly histcounts is binning my data.
Of note: I’ve found similar differences in binning between the MATLAB and real real formula for Sturges and Scott as well. While I imagine that the origin of this difference may be similar, I am primarily concerned with Freedman–Diaconis currently. freedman–diaconis, binning, histogram MATLAB Answers — New Questions
nonlinear dynamics(Measure synchronization)
Dear Everyone
I’m working on my Phd thsesis on measure synchronization under nonlinear dynamics.am currently stuck with the average bare energy and interaction energy code for my work.i have gotten the Time series,phase plot,poincare section,frquency and power spectrum of my work.
am trying to reproduce the avareage bare energy code for ”Exploring the route to measure synchronization in non-linearly coupled Hamiltonian systems” journal. I have done the phase plot,time series ,frequency and power spectrum of this jounal.
this is the code i try to use for the average bare energy of this journal and its not working.
function dxdt = exploring(t,x,y)
dxdt = zeros(4,1);
dxdt(1) = x(3);
dxdt(2) = x(4);
dxdt(3) = -x(1) + y*x(1)*x(2^2);
dxdt(4) = -x(2) + y*x(1)^2*x(2);
%% %% Average bear energy
clear all; close all; clc; %#ok<CLALL>
y=[0 0.07 0.15 0.52];
m=length(y);
tspan=[500:0.001:1400];
T=0:0.01:1400;
L=10;
E=0.2;
p1=0.2;
p2=sqrt(2*E – (p1)^2);
E1=((p1)^2 + y*(p1)^2)/2;
E2=((p2)^2 + y*(p2)^2)/2;
R =(1./ T) * integral((E1*E2),0,T);
for i=1:m
[t,R] = ode45(@(t,R) exploring(t,R,y(i)),tspan,[0 0 p1 p2]);
end
figure(i)
plot(t,R(:,1),’-b’);
xlabel(‘t’);
ylabel(‘X’);
hold on
plot(t,R(:,2),’-r’)
xlabel(‘t’);
ylabel(‘x1,x2’);%ylim([-1 1]);
I need your assistance, support and suggestion.
i would welcome any code with related to the average bare energy and intereaction energy for any oscillator.
ThanksDear Everyone
I’m working on my Phd thsesis on measure synchronization under nonlinear dynamics.am currently stuck with the average bare energy and interaction energy code for my work.i have gotten the Time series,phase plot,poincare section,frquency and power spectrum of my work.
am trying to reproduce the avareage bare energy code for ”Exploring the route to measure synchronization in non-linearly coupled Hamiltonian systems” journal. I have done the phase plot,time series ,frequency and power spectrum of this jounal.
this is the code i try to use for the average bare energy of this journal and its not working.
function dxdt = exploring(t,x,y)
dxdt = zeros(4,1);
dxdt(1) = x(3);
dxdt(2) = x(4);
dxdt(3) = -x(1) + y*x(1)*x(2^2);
dxdt(4) = -x(2) + y*x(1)^2*x(2);
%% %% Average bear energy
clear all; close all; clc; %#ok<CLALL>
y=[0 0.07 0.15 0.52];
m=length(y);
tspan=[500:0.001:1400];
T=0:0.01:1400;
L=10;
E=0.2;
p1=0.2;
p2=sqrt(2*E – (p1)^2);
E1=((p1)^2 + y*(p1)^2)/2;
E2=((p2)^2 + y*(p2)^2)/2;
R =(1./ T) * integral((E1*E2),0,T);
for i=1:m
[t,R] = ode45(@(t,R) exploring(t,R,y(i)),tspan,[0 0 p1 p2]);
end
figure(i)
plot(t,R(:,1),’-b’);
xlabel(‘t’);
ylabel(‘X’);
hold on
plot(t,R(:,2),’-r’)
xlabel(‘t’);
ylabel(‘x1,x2’);%ylim([-1 1]);
I need your assistance, support and suggestion.
i would welcome any code with related to the average bare energy and intereaction energy for any oscillator.
Thanks Dear Everyone
I’m working on my Phd thsesis on measure synchronization under nonlinear dynamics.am currently stuck with the average bare energy and interaction energy code for my work.i have gotten the Time series,phase plot,poincare section,frquency and power spectrum of my work.
am trying to reproduce the avareage bare energy code for ”Exploring the route to measure synchronization in non-linearly coupled Hamiltonian systems” journal. I have done the phase plot,time series ,frequency and power spectrum of this jounal.
this is the code i try to use for the average bare energy of this journal and its not working.
function dxdt = exploring(t,x,y)
dxdt = zeros(4,1);
dxdt(1) = x(3);
dxdt(2) = x(4);
dxdt(3) = -x(1) + y*x(1)*x(2^2);
dxdt(4) = -x(2) + y*x(1)^2*x(2);
%% %% Average bear energy
clear all; close all; clc; %#ok<CLALL>
y=[0 0.07 0.15 0.52];
m=length(y);
tspan=[500:0.001:1400];
T=0:0.01:1400;
L=10;
E=0.2;
p1=0.2;
p2=sqrt(2*E – (p1)^2);
E1=((p1)^2 + y*(p1)^2)/2;
E2=((p2)^2 + y*(p2)^2)/2;
R =(1./ T) * integral((E1*E2),0,T);
for i=1:m
[t,R] = ode45(@(t,R) exploring(t,R,y(i)),tspan,[0 0 p1 p2]);
end
figure(i)
plot(t,R(:,1),’-b’);
xlabel(‘t’);
ylabel(‘X’);
hold on
plot(t,R(:,2),’-r’)
xlabel(‘t’);
ylabel(‘x1,x2’);%ylim([-1 1]);
I need your assistance, support and suggestion.
i would welcome any code with related to the average bare energy and intereaction energy for any oscillator.
Thanks signal processing MATLAB Answers — New Questions