Category: Matlab
Category Archives: Matlab
Is there any documentation on how to build a transformer encoder from scratch in matlab?
I am building a transformer encoder, and I came accross the following exchange: https://www.mathworks.com/matlabcentral/fileexchange/107375-transformer-models
However, in the exchange there are examples on how to use a pretrained transformer model. I just need an example on how to build a model. Something to give a general idea so I can build on it. I have studied the basics of transformers but I am having some difficulty building the model from scratch.
Thank you in advance.I am building a transformer encoder, and I came accross the following exchange: https://www.mathworks.com/matlabcentral/fileexchange/107375-transformer-models
However, in the exchange there are examples on how to use a pretrained transformer model. I just need an example on how to build a model. Something to give a general idea so I can build on it. I have studied the basics of transformers but I am having some difficulty building the model from scratch.
Thank you in advance. I am building a transformer encoder, and I came accross the following exchange: https://www.mathworks.com/matlabcentral/fileexchange/107375-transformer-models
However, in the exchange there are examples on how to use a pretrained transformer model. I just need an example on how to build a model. Something to give a general idea so I can build on it. I have studied the basics of transformers but I am having some difficulty building the model from scratch.
Thank you in advance. neural networks, transformers MATLAB Answers — New Questions
Yolox dlnetwork error (Dot indexing is not supported for variables of this type.)
Hello,
When I was trying to run "Pretrained-YOLOX-Network-For-Object-Detection" downloaded from https://github.com/matlab-deep-learning/Pretrained-YOLOX-Network-For-Object-Detection, the follwong code raised an error message as follows:
model = helper.downloadPretrainedYoloX(‘yolox_s’);
net = model.net;
——————————————–
net =
Dot indexing is not supported for variables of this type.
Error in dlnetwork/isQuantized (line 1417)
b = this.PrivateNetwork.isQuantized();
Error in deep.internal.quantization.QuantizedNetworkDisplay/mixinQuantizedNetworkHeader (line 23)
strategy = net.getStrategy(isQuantized(net));
Error in dlnetwork/getHeader (line 1427)
header = this.mixinQuantizedNetworkHeader(header, className);
——————————————
I am using R2023b. Could you help me?
Thanks in advance.Hello,
When I was trying to run "Pretrained-YOLOX-Network-For-Object-Detection" downloaded from https://github.com/matlab-deep-learning/Pretrained-YOLOX-Network-For-Object-Detection, the follwong code raised an error message as follows:
model = helper.downloadPretrainedYoloX(‘yolox_s’);
net = model.net;
——————————————–
net =
Dot indexing is not supported for variables of this type.
Error in dlnetwork/isQuantized (line 1417)
b = this.PrivateNetwork.isQuantized();
Error in deep.internal.quantization.QuantizedNetworkDisplay/mixinQuantizedNetworkHeader (line 23)
strategy = net.getStrategy(isQuantized(net));
Error in dlnetwork/getHeader (line 1427)
header = this.mixinQuantizedNetworkHeader(header, className);
——————————————
I am using R2023b. Could you help me?
Thanks in advance. Hello,
When I was trying to run "Pretrained-YOLOX-Network-For-Object-Detection" downloaded from https://github.com/matlab-deep-learning/Pretrained-YOLOX-Network-For-Object-Detection, the follwong code raised an error message as follows:
model = helper.downloadPretrainedYoloX(‘yolox_s’);
net = model.net;
——————————————–
net =
Dot indexing is not supported for variables of this type.
Error in dlnetwork/isQuantized (line 1417)
b = this.PrivateNetwork.isQuantized();
Error in deep.internal.quantization.QuantizedNetworkDisplay/mixinQuantizedNetworkHeader (line 23)
strategy = net.getStrategy(isQuantized(net));
Error in dlnetwork/getHeader (line 1427)
header = this.mixinQuantizedNetworkHeader(header, className);
——————————————
I am using R2023b. Could you help me?
Thanks in advance. dlnetwork yolox MATLAB Answers — New Questions
Replication of a colorbar in MatLab
Hello everyone
I am trying to impement this colorbar:
My attempt has been the following:
colorA=[192 148 92]./255;
colorB=[1 1 1];
colorC=[82 107 120]./255;
cmap3=vertcat(interp1([0 1],[colorA;colorB],linspace(0,1,numcolors/2),’linear’),interp1([0 1],[colorB;colorC],linspace(0,1,numcolors/2+1),’linear’));
cmap3(numcolors/2+1,:)=[];
cmap3=flip(cmap3,1);
clear colorA colorB color C numcolors
which I have done trying to pick the extremal colors at each side of the aforementioned colorbar. However, I obtain something like this:
without that nice blue color evolution on the right side of it. Any suggestions on how to get closer to the reference image?Hello everyone
I am trying to impement this colorbar:
My attempt has been the following:
colorA=[192 148 92]./255;
colorB=[1 1 1];
colorC=[82 107 120]./255;
cmap3=vertcat(interp1([0 1],[colorA;colorB],linspace(0,1,numcolors/2),’linear’),interp1([0 1],[colorB;colorC],linspace(0,1,numcolors/2+1),’linear’));
cmap3(numcolors/2+1,:)=[];
cmap3=flip(cmap3,1);
clear colorA colorB color C numcolors
which I have done trying to pick the extremal colors at each side of the aforementioned colorbar. However, I obtain something like this:
without that nice blue color evolution on the right side of it. Any suggestions on how to get closer to the reference image? Hello everyone
I am trying to impement this colorbar:
My attempt has been the following:
colorA=[192 148 92]./255;
colorB=[1 1 1];
colorC=[82 107 120]./255;
cmap3=vertcat(interp1([0 1],[colorA;colorB],linspace(0,1,numcolors/2),’linear’),interp1([0 1],[colorB;colorC],linspace(0,1,numcolors/2+1),’linear’));
cmap3(numcolors/2+1,:)=[];
cmap3=flip(cmap3,1);
clear colorA colorB color C numcolors
which I have done trying to pick the extremal colors at each side of the aforementioned colorbar. However, I obtain something like this:
without that nice blue color evolution on the right side of it. Any suggestions on how to get closer to the reference image? customized colormap MATLAB Answers — New Questions
Plotting Multiple Shaded Uncertainties
Hi, I am relatively new to coding and having an issue plotting my data. I get files with element concentrations and uncertainties and I’d like to plot many of them on one figure with their corresponding figures shaded. I’ve gotten this code to work for shading the uncertainty for a single element, but I’m not sure this is accurate and the legend is offset (counting the shading as entries). Ideally I won’t need a string of code for each element (I have 11 in my code currently but we measure 140). Thanks for any input!
X = Xactdata.Date(Data); % dates & times from instrument
Elements = [Xactdata.SULPHUR(Data),Xactdata.CHLORINE(Data),Xactdata.POTASSIUM(Data),Xactdata.CALCIUM(Data),Xactdata.TITANIUM(Data),Xactdata.IRON(Data),Xactdata.COPPER(Data),Xactdata.ZINC(Data),Xactdata.ARSENIC(Data),Xactdata.BROMINE(Data),Xactdata.BARIUM(Data)]; %element concentration
E_err = [Xactdata.S_U(Data),Xactdata.Cl_U(Data),Xactdata.K_U(Data),Xactdata.Ca_U(Data),Xactdata.Ti_U(Data),Xactdata.Fe_U(Data),Xactdata.Cu_U(Data),Xactdata.Zn_U(Data),Xactdata.As_U(Data),Xactdata.Br_U(Data),Xactdata.Ba_U(Data)]; %element uncertainty
E_Labels = {"S","Cl","K","Ca","Ti","Fe","Cu","Zn","As","Br","Ba"};
figure
for i = 1:11 %number of elements plotted
plot(X, Elements(:,i))
hold on
patch([x; flip(x)], [Elements(:,i)-E_err(:,i); flip(Elements(:,i)+E_err(:,i))], ‘b’, ‘FaceAlpha’,0.25, ‘EdgeColor’,’none’)
end
legend(E_Labels)
title(‘Element Concentrations’)
ylabel(‘Concentration (ng/m^3)’)
xlabel(‘Date (UTC)’)Hi, I am relatively new to coding and having an issue plotting my data. I get files with element concentrations and uncertainties and I’d like to plot many of them on one figure with their corresponding figures shaded. I’ve gotten this code to work for shading the uncertainty for a single element, but I’m not sure this is accurate and the legend is offset (counting the shading as entries). Ideally I won’t need a string of code for each element (I have 11 in my code currently but we measure 140). Thanks for any input!
X = Xactdata.Date(Data); % dates & times from instrument
Elements = [Xactdata.SULPHUR(Data),Xactdata.CHLORINE(Data),Xactdata.POTASSIUM(Data),Xactdata.CALCIUM(Data),Xactdata.TITANIUM(Data),Xactdata.IRON(Data),Xactdata.COPPER(Data),Xactdata.ZINC(Data),Xactdata.ARSENIC(Data),Xactdata.BROMINE(Data),Xactdata.BARIUM(Data)]; %element concentration
E_err = [Xactdata.S_U(Data),Xactdata.Cl_U(Data),Xactdata.K_U(Data),Xactdata.Ca_U(Data),Xactdata.Ti_U(Data),Xactdata.Fe_U(Data),Xactdata.Cu_U(Data),Xactdata.Zn_U(Data),Xactdata.As_U(Data),Xactdata.Br_U(Data),Xactdata.Ba_U(Data)]; %element uncertainty
E_Labels = {"S","Cl","K","Ca","Ti","Fe","Cu","Zn","As","Br","Ba"};
figure
for i = 1:11 %number of elements plotted
plot(X, Elements(:,i))
hold on
patch([x; flip(x)], [Elements(:,i)-E_err(:,i); flip(Elements(:,i)+E_err(:,i))], ‘b’, ‘FaceAlpha’,0.25, ‘EdgeColor’,’none’)
end
legend(E_Labels)
title(‘Element Concentrations’)
ylabel(‘Concentration (ng/m^3)’)
xlabel(‘Date (UTC)’) Hi, I am relatively new to coding and having an issue plotting my data. I get files with element concentrations and uncertainties and I’d like to plot many of them on one figure with their corresponding figures shaded. I’ve gotten this code to work for shading the uncertainty for a single element, but I’m not sure this is accurate and the legend is offset (counting the shading as entries). Ideally I won’t need a string of code for each element (I have 11 in my code currently but we measure 140). Thanks for any input!
X = Xactdata.Date(Data); % dates & times from instrument
Elements = [Xactdata.SULPHUR(Data),Xactdata.CHLORINE(Data),Xactdata.POTASSIUM(Data),Xactdata.CALCIUM(Data),Xactdata.TITANIUM(Data),Xactdata.IRON(Data),Xactdata.COPPER(Data),Xactdata.ZINC(Data),Xactdata.ARSENIC(Data),Xactdata.BROMINE(Data),Xactdata.BARIUM(Data)]; %element concentration
E_err = [Xactdata.S_U(Data),Xactdata.Cl_U(Data),Xactdata.K_U(Data),Xactdata.Ca_U(Data),Xactdata.Ti_U(Data),Xactdata.Fe_U(Data),Xactdata.Cu_U(Data),Xactdata.Zn_U(Data),Xactdata.As_U(Data),Xactdata.Br_U(Data),Xactdata.Ba_U(Data)]; %element uncertainty
E_Labels = {"S","Cl","K","Ca","Ti","Fe","Cu","Zn","As","Br","Ba"};
figure
for i = 1:11 %number of elements plotted
plot(X, Elements(:,i))
hold on
patch([x; flip(x)], [Elements(:,i)-E_err(:,i); flip(Elements(:,i)+E_err(:,i))], ‘b’, ‘FaceAlpha’,0.25, ‘EdgeColor’,’none’)
end
legend(E_Labels)
title(‘Element Concentrations’)
ylabel(‘Concentration (ng/m^3)’)
xlabel(‘Date (UTC)’) plotting, data, uncertainty, std, data import, figure MATLAB Answers — New Questions
Split array into groups of close numbers
Greetings,
Is there a built-in function in MATLAB to split an 1D array into groups of close numbers?
For example, I have an array
a = [1 2 3 10 11]
and want to split it into N = 2 groups. I expect to see something like
result{1} = [1 2 3]
result{2} = [10 11]Greetings,
Is there a built-in function in MATLAB to split an 1D array into groups of close numbers?
For example, I have an array
a = [1 2 3 10 11]
and want to split it into N = 2 groups. I expect to see something like
result{1} = [1 2 3]
result{2} = [10 11] Greetings,
Is there a built-in function in MATLAB to split an 1D array into groups of close numbers?
For example, I have an array
a = [1 2 3 10 11]
and want to split it into N = 2 groups. I expect to see something like
result{1} = [1 2 3]
result{2} = [10 11] array MATLAB Answers — New Questions
Split array into groups of close numbers
Greetings,
Is there a built-in function in MATLAB to split an 1D array into groups of close numbers?
For example, I have an array
a = [1 2 3 10 11]
and want to split it into N = 2 groups. I expect to see something like
result{1} = [1 2 3]
result{2} = [10 11]Greetings,
Is there a built-in function in MATLAB to split an 1D array into groups of close numbers?
For example, I have an array
a = [1 2 3 10 11]
and want to split it into N = 2 groups. I expect to see something like
result{1} = [1 2 3]
result{2} = [10 11] Greetings,
Is there a built-in function in MATLAB to split an 1D array into groups of close numbers?
For example, I have an array
a = [1 2 3 10 11]
and want to split it into N = 2 groups. I expect to see something like
result{1} = [1 2 3]
result{2} = [10 11] array MATLAB Answers — New Questions
Can we generate best fitted nonlinear equation between 4 inputs and 1 output, if we dont know the equation initially
Can we generate best fitted nonlinear equation between 4 inputs and 1 output, if we dont know the equation initiallyCan we generate best fitted nonlinear equation between 4 inputs and 1 output, if we dont know the equation initially Can we generate best fitted nonlinear equation between 4 inputs and 1 output, if we dont know the equation initially regression MATLAB Answers — New Questions
Intersections between two discretised functions
Hi Everybody, I have the following problem:
I have two vectors:
v1 = list of values representing a discretised non monotonic function
v2 = list of values representing a constant and horizontal line
v1 has no analytical model. It’s just a vector containing the values a function assumes in a given interval.
To make everything clearer, let’s consider the following case:
v1 = list of 100 values representing a parabola: y= x^2, with x=linspace(-5, +5, 100)
v2 = ones(1,100)
f = @(x) x.^2;
values = linspace(-5, 5, 100);
v1 = f(values);
v2 = ones(1,100);
Clearly, the intersection points are two, for x1=-1 and x2=+1.
Now let’s forget about the fact that we had the analytical expression for v1 and let’s just consider the vector itself.
How can I implement this on Matalb for a generical vector v1 which is not monotonic and is supposed to have two intersection points with v2? I tried doing something with interp1 but couldn’t figure it out.
Thanks a lot to whoever will help me!Hi Everybody, I have the following problem:
I have two vectors:
v1 = list of values representing a discretised non monotonic function
v2 = list of values representing a constant and horizontal line
v1 has no analytical model. It’s just a vector containing the values a function assumes in a given interval.
To make everything clearer, let’s consider the following case:
v1 = list of 100 values representing a parabola: y= x^2, with x=linspace(-5, +5, 100)
v2 = ones(1,100)
f = @(x) x.^2;
values = linspace(-5, 5, 100);
v1 = f(values);
v2 = ones(1,100);
Clearly, the intersection points are two, for x1=-1 and x2=+1.
Now let’s forget about the fact that we had the analytical expression for v1 and let’s just consider the vector itself.
How can I implement this on Matalb for a generical vector v1 which is not monotonic and is supposed to have two intersection points with v2? I tried doing something with interp1 but couldn’t figure it out.
Thanks a lot to whoever will help me! Hi Everybody, I have the following problem:
I have two vectors:
v1 = list of values representing a discretised non monotonic function
v2 = list of values representing a constant and horizontal line
v1 has no analytical model. It’s just a vector containing the values a function assumes in a given interval.
To make everything clearer, let’s consider the following case:
v1 = list of 100 values representing a parabola: y= x^2, with x=linspace(-5, +5, 100)
v2 = ones(1,100)
f = @(x) x.^2;
values = linspace(-5, 5, 100);
v1 = f(values);
v2 = ones(1,100);
Clearly, the intersection points are two, for x1=-1 and x2=+1.
Now let’s forget about the fact that we had the analytical expression for v1 and let’s just consider the vector itself.
How can I implement this on Matalb for a generical vector v1 which is not monotonic and is supposed to have two intersection points with v2? I tried doing something with interp1 but couldn’t figure it out.
Thanks a lot to whoever will help me! interpolation, intersection, function, numerical MATLAB Answers — New Questions
Static methods are unnecessary, right?
I researched static methods and feel that static methods are non-essential in matlab.There would be no inconvenience if matlab did not provide a static method.I wonder if my above opinion is correct?
The benefit of static methods is "not related to the specific object", only related to classes.Can be called inside the class.Also can be called by the object!
I found I can do what the static method does with ordinary methods!
Here’s a simple example.method1 didn’t use input argument. I can use method1 in constructor.Although the program uses ‘obj.method1’ to call method1, this does not mean that method1 is related to any specific object.
classdef test<handle
properties
X
Y
end
methods
function obj = test(inputArg1,inputArg2)
obj.X = inputArg1 + inputArg2;
obj.Y=obj.method1(inputArg2);
end
end
methods
function value = method1(obj,inputArg)
value = 3 + 3;
end
end
end
Here’s a more complex example.Use object-oriented programming method to draw three-dimensional surface graph. It is required to define two classes, one of which stores the data of the function, and uses a static method to calculate the grid coordinates of the interval in this class; the function of the other class is to draw a three-dimensional surface map, and the drawing process is realized by a static method.
@MfunEval/MfunEval.m
classdef MfunEval
properties
HFun;
Lm = [-2*pi 2*pi];
end
properties (Dependent = true)
Data;
end
methods
function obj = MfunEval(fun_handle,limits) %Constructor
obj.HFun = fun_handle;
obj.Lm = limits;
end
function data = get.Data(obj) %
[x,y] = MfunEval.grid(obj.Lm);
z= obj.HFun(x,y);
data.X = x;
data.Y = y;
data.Z = z;
end
end
methods (Static) %Static methods
function [x,y] = grid(lim)
step = (lim(2)-lim(1))/50;
[x,y] = meshgrid(lim(1):step:lim(2));
end
end
end
@MfunView/MfunView.m
classdef MfunView
properties
FunObj
HSurf
end
methods
function obj = MfunView(fobj) %Constructor
obj.FunObj= fobj;
end
end
methods (Static = true) %
createViews(a) %
end
end
@MfunView/ createViews.m
function createViews(funevalobj)
viewobj=MfunView(funevalobj);
viewobj.HSurf = surf(viewobj.FunObj.Data.X,…
viewobj.FunObj.Data.Y,…
viewobj.FunObj.Data.Z);
shading interp;
end
I modified @MfunEval/MfunEval.m Replaced MfunEval.grid with obj.grid.I change the static method to a normal method. The program can still run!
classdef MfunEval
properties
HFun;
Lm = [-2*pi 2*pi];
end
properties (Dependent = true)
Data;
end
methods
function obj = MfunEval(fun_handle,limits) %Constructor
obj.HFun = fun_handle;
obj.Lm = limits;
end
function data = get.Data(obj)
%[x,y] = MfunEval.grid(obj.Lm);
[x,y] = obj.grid(obj.Lm); %call grid function
z= obj.HFun(x,y);
data.X = x;
data.Y = y;
data.Z = z;
end
end
methods %(Static) %change Static
function [x,y] = grid(obj,lim)
step = (lim(2)-lim(1))/50;
[x,y] = meshgrid(lim(1):step:lim(2));
end
end
endI researched static methods and feel that static methods are non-essential in matlab.There would be no inconvenience if matlab did not provide a static method.I wonder if my above opinion is correct?
The benefit of static methods is "not related to the specific object", only related to classes.Can be called inside the class.Also can be called by the object!
I found I can do what the static method does with ordinary methods!
Here’s a simple example.method1 didn’t use input argument. I can use method1 in constructor.Although the program uses ‘obj.method1’ to call method1, this does not mean that method1 is related to any specific object.
classdef test<handle
properties
X
Y
end
methods
function obj = test(inputArg1,inputArg2)
obj.X = inputArg1 + inputArg2;
obj.Y=obj.method1(inputArg2);
end
end
methods
function value = method1(obj,inputArg)
value = 3 + 3;
end
end
end
Here’s a more complex example.Use object-oriented programming method to draw three-dimensional surface graph. It is required to define two classes, one of which stores the data of the function, and uses a static method to calculate the grid coordinates of the interval in this class; the function of the other class is to draw a three-dimensional surface map, and the drawing process is realized by a static method.
@MfunEval/MfunEval.m
classdef MfunEval
properties
HFun;
Lm = [-2*pi 2*pi];
end
properties (Dependent = true)
Data;
end
methods
function obj = MfunEval(fun_handle,limits) %Constructor
obj.HFun = fun_handle;
obj.Lm = limits;
end
function data = get.Data(obj) %
[x,y] = MfunEval.grid(obj.Lm);
z= obj.HFun(x,y);
data.X = x;
data.Y = y;
data.Z = z;
end
end
methods (Static) %Static methods
function [x,y] = grid(lim)
step = (lim(2)-lim(1))/50;
[x,y] = meshgrid(lim(1):step:lim(2));
end
end
end
@MfunView/MfunView.m
classdef MfunView
properties
FunObj
HSurf
end
methods
function obj = MfunView(fobj) %Constructor
obj.FunObj= fobj;
end
end
methods (Static = true) %
createViews(a) %
end
end
@MfunView/ createViews.m
function createViews(funevalobj)
viewobj=MfunView(funevalobj);
viewobj.HSurf = surf(viewobj.FunObj.Data.X,…
viewobj.FunObj.Data.Y,…
viewobj.FunObj.Data.Z);
shading interp;
end
I modified @MfunEval/MfunEval.m Replaced MfunEval.grid with obj.grid.I change the static method to a normal method. The program can still run!
classdef MfunEval
properties
HFun;
Lm = [-2*pi 2*pi];
end
properties (Dependent = true)
Data;
end
methods
function obj = MfunEval(fun_handle,limits) %Constructor
obj.HFun = fun_handle;
obj.Lm = limits;
end
function data = get.Data(obj)
%[x,y] = MfunEval.grid(obj.Lm);
[x,y] = obj.grid(obj.Lm); %call grid function
z= obj.HFun(x,y);
data.X = x;
data.Y = y;
data.Z = z;
end
end
methods %(Static) %change Static
function [x,y] = grid(obj,lim)
step = (lim(2)-lim(1))/50;
[x,y] = meshgrid(lim(1):step:lim(2));
end
end
end I researched static methods and feel that static methods are non-essential in matlab.There would be no inconvenience if matlab did not provide a static method.I wonder if my above opinion is correct?
The benefit of static methods is "not related to the specific object", only related to classes.Can be called inside the class.Also can be called by the object!
I found I can do what the static method does with ordinary methods!
Here’s a simple example.method1 didn’t use input argument. I can use method1 in constructor.Although the program uses ‘obj.method1’ to call method1, this does not mean that method1 is related to any specific object.
classdef test<handle
properties
X
Y
end
methods
function obj = test(inputArg1,inputArg2)
obj.X = inputArg1 + inputArg2;
obj.Y=obj.method1(inputArg2);
end
end
methods
function value = method1(obj,inputArg)
value = 3 + 3;
end
end
end
Here’s a more complex example.Use object-oriented programming method to draw three-dimensional surface graph. It is required to define two classes, one of which stores the data of the function, and uses a static method to calculate the grid coordinates of the interval in this class; the function of the other class is to draw a three-dimensional surface map, and the drawing process is realized by a static method.
@MfunEval/MfunEval.m
classdef MfunEval
properties
HFun;
Lm = [-2*pi 2*pi];
end
properties (Dependent = true)
Data;
end
methods
function obj = MfunEval(fun_handle,limits) %Constructor
obj.HFun = fun_handle;
obj.Lm = limits;
end
function data = get.Data(obj) %
[x,y] = MfunEval.grid(obj.Lm);
z= obj.HFun(x,y);
data.X = x;
data.Y = y;
data.Z = z;
end
end
methods (Static) %Static methods
function [x,y] = grid(lim)
step = (lim(2)-lim(1))/50;
[x,y] = meshgrid(lim(1):step:lim(2));
end
end
end
@MfunView/MfunView.m
classdef MfunView
properties
FunObj
HSurf
end
methods
function obj = MfunView(fobj) %Constructor
obj.FunObj= fobj;
end
end
methods (Static = true) %
createViews(a) %
end
end
@MfunView/ createViews.m
function createViews(funevalobj)
viewobj=MfunView(funevalobj);
viewobj.HSurf = surf(viewobj.FunObj.Data.X,…
viewobj.FunObj.Data.Y,…
viewobj.FunObj.Data.Z);
shading interp;
end
I modified @MfunEval/MfunEval.m Replaced MfunEval.grid with obj.grid.I change the static method to a normal method. The program can still run!
classdef MfunEval
properties
HFun;
Lm = [-2*pi 2*pi];
end
properties (Dependent = true)
Data;
end
methods
function obj = MfunEval(fun_handle,limits) %Constructor
obj.HFun = fun_handle;
obj.Lm = limits;
end
function data = get.Data(obj)
%[x,y] = MfunEval.grid(obj.Lm);
[x,y] = obj.grid(obj.Lm); %call grid function
z= obj.HFun(x,y);
data.X = x;
data.Y = y;
data.Z = z;
end
end
methods %(Static) %change Static
function [x,y] = grid(obj,lim)
step = (lim(2)-lim(1))/50;
[x,y] = meshgrid(lim(1):step:lim(2));
end
end
end static methods, classes, methods MATLAB Answers — New Questions
Draw the surface of a two variables function
When I run the code below I get the figure below.
[X,Y] = meshgrid(-10:1:10);
Z = -X.*exp(-X.*Y) + cos(X);
surf(X,Y,Z,’FaceAlpha’,0.75)
What wrong scaling or errors could be contributing to MATLAB’s failure in accurately rendering the surface of the function defined by the code above? In general, what is the best way to plot a 3d surface which has complicated shape like the one above. I have the same problem with the function f = @(x,y) ln(1+x.^2+y.^2) – (x-1).^2 – y.^2When I run the code below I get the figure below.
[X,Y] = meshgrid(-10:1:10);
Z = -X.*exp(-X.*Y) + cos(X);
surf(X,Y,Z,’FaceAlpha’,0.75)
What wrong scaling or errors could be contributing to MATLAB’s failure in accurately rendering the surface of the function defined by the code above? In general, what is the best way to plot a 3d surface which has complicated shape like the one above. I have the same problem with the function f = @(x,y) ln(1+x.^2+y.^2) – (x-1).^2 – y.^2 When I run the code below I get the figure below.
[X,Y] = meshgrid(-10:1:10);
Z = -X.*exp(-X.*Y) + cos(X);
surf(X,Y,Z,’FaceAlpha’,0.75)
What wrong scaling or errors could be contributing to MATLAB’s failure in accurately rendering the surface of the function defined by the code above? In general, what is the best way to plot a 3d surface which has complicated shape like the one above. I have the same problem with the function f = @(x,y) ln(1+x.^2+y.^2) – (x-1).^2 – y.^2 surf, mesh MATLAB Answers — New Questions
Scrambler/Descrambler in 802.11 standard
Hello,
Im trying to implement 802.11 scrambler/descrambler in matlab. Based on the standard, it should look sth like this:
<</matlabcentral/answers/uploaded_files/18967/Bez%C2%A0tytu%C5%82u.png>>
My code looks like this:
data=zeros(1,7); %data
register=[1 0 1 1 1 0 1]; %initial state
for i=1:7
temp=xor(register(1),register(4)); % x7 and x4 xor
out(8-i,1)=xor(data(8-i,1),temp); %output bit
register=circshift(register’,-1,1)’; %shift left
register(7)=data(8-i,1); %insert data to register
end
When im trying to descramble data, with same code and same initial state it gives wrong results.
What am i doing wrong??
Is there any way to guess or estimate initial state at the receiver side??
It is correct to sim this using comm. toolbox?
scr = comm.Scrambler(2, [0 -4 -7],…
[1 0 1 1 1 0 1]);
Best,
ErnestHello,
Im trying to implement 802.11 scrambler/descrambler in matlab. Based on the standard, it should look sth like this:
<</matlabcentral/answers/uploaded_files/18967/Bez%C2%A0tytu%C5%82u.png>>
My code looks like this:
data=zeros(1,7); %data
register=[1 0 1 1 1 0 1]; %initial state
for i=1:7
temp=xor(register(1),register(4)); % x7 and x4 xor
out(8-i,1)=xor(data(8-i,1),temp); %output bit
register=circshift(register’,-1,1)’; %shift left
register(7)=data(8-i,1); %insert data to register
end
When im trying to descramble data, with same code and same initial state it gives wrong results.
What am i doing wrong??
Is there any way to guess or estimate initial state at the receiver side??
It is correct to sim this using comm. toolbox?
scr = comm.Scrambler(2, [0 -4 -7],…
[1 0 1 1 1 0 1]);
Best,
Ernest Hello,
Im trying to implement 802.11 scrambler/descrambler in matlab. Based on the standard, it should look sth like this:
<</matlabcentral/answers/uploaded_files/18967/Bez%C2%A0tytu%C5%82u.png>>
My code looks like this:
data=zeros(1,7); %data
register=[1 0 1 1 1 0 1]; %initial state
for i=1:7
temp=xor(register(1),register(4)); % x7 and x4 xor
out(8-i,1)=xor(data(8-i,1),temp); %output bit
register=circshift(register’,-1,1)’; %shift left
register(7)=data(8-i,1); %insert data to register
end
When im trying to descramble data, with same code and same initial state it gives wrong results.
What am i doing wrong??
Is there any way to guess or estimate initial state at the receiver side??
It is correct to sim this using comm. toolbox?
scr = comm.Scrambler(2, [0 -4 -7],…
[1 0 1 1 1 0 1]);
Best,
Ernest scrambler, descrambler, wlan, 802.11, wifi, code MATLAB Answers — New Questions
How to export a cell matrix into a MS Excel file
Attached is a cell array which I would like to export into a MS Excel spreasheet where each row correspond to one (of 12) years and would represent a tab inside that Excel file. Each of the 8 columns (or variables) would represent a column inside each tab.
I know this can be done with the ‘xlswrite’ command (see here for an example). But that command has now been superseded by the ‘writecell’ command, which I have problems with. Thanks!Attached is a cell array which I would like to export into a MS Excel spreasheet where each row correspond to one (of 12) years and would represent a tab inside that Excel file. Each of the 8 columns (or variables) would represent a column inside each tab.
I know this can be done with the ‘xlswrite’ command (see here for an example). But that command has now been superseded by the ‘writecell’ command, which I have problems with. Thanks! Attached is a cell array which I would like to export into a MS Excel spreasheet where each row correspond to one (of 12) years and would represent a tab inside that Excel file. Each of the 8 columns (or variables) would represent a column inside each tab.
I know this can be done with the ‘xlswrite’ command (see here for an example). But that command has now been superseded by the ‘writecell’ command, which I have problems with. Thanks! ms excel conversion MATLAB Answers — New Questions
How to export a cell matrix into a MS Excel file
Attached is a cell array which I would like to export into a MS Excel spreasheet where each row correspond to one (of 12) years and would represent a tab inside that Excel file. Each of the 8 columns (or variables) would represent a column inside each tab.
I know this can be done with the ‘xlswrite’ command (see here for an example). But that command has now been superseded by the ‘writecell’ command, which I have problems with. Thanks!Attached is a cell array which I would like to export into a MS Excel spreasheet where each row correspond to one (of 12) years and would represent a tab inside that Excel file. Each of the 8 columns (or variables) would represent a column inside each tab.
I know this can be done with the ‘xlswrite’ command (see here for an example). But that command has now been superseded by the ‘writecell’ command, which I have problems with. Thanks! Attached is a cell array which I would like to export into a MS Excel spreasheet where each row correspond to one (of 12) years and would represent a tab inside that Excel file. Each of the 8 columns (or variables) would represent a column inside each tab.
I know this can be done with the ‘xlswrite’ command (see here for an example). But that command has now been superseded by the ‘writecell’ command, which I have problems with. Thanks! ms excel conversion MATLAB Answers — New Questions
kmeans with centroids from previous analysis
Hello everyone,
I wanted to confirm whether my approach is right. I have centroids from a previous kmeans analysis, and now I’d like to extract the membership indexes for these clusters from new data. Am I correct by using:
SubjectMembershipIndex = kmeans(Data, [], ‘Distance’,’cityblock’, ‘Start’, PreviousCentroids);
Thanks!
Best
HansHello everyone,
I wanted to confirm whether my approach is right. I have centroids from a previous kmeans analysis, and now I’d like to extract the membership indexes for these clusters from new data. Am I correct by using:
SubjectMembershipIndex = kmeans(Data, [], ‘Distance’,’cityblock’, ‘Start’, PreviousCentroids);
Thanks!
Best
Hans Hello everyone,
I wanted to confirm whether my approach is right. I have centroids from a previous kmeans analysis, and now I’d like to extract the membership indexes for these clusters from new data. Am I correct by using:
SubjectMembershipIndex = kmeans(Data, [], ‘Distance’,’cityblock’, ‘Start’, PreviousCentroids);
Thanks!
Best
Hans kmeans previous centroids MATLAB Answers — New Questions
impulse response from transfer function in matlab
i have a transfer function given by
H(z)= 1-z^(-1)/1-z^(-1)+z^(-2)
how to find its impulse response h(n) in matlab
what is the code for the same ?i have a transfer function given by
H(z)= 1-z^(-1)/1-z^(-1)+z^(-2)
how to find its impulse response h(n) in matlab
what is the code for the same ? i have a transfer function given by
H(z)= 1-z^(-1)/1-z^(-1)+z^(-2)
how to find its impulse response h(n) in matlab
what is the code for the same ? lti system MATLAB Answers — New Questions
Matlab Crash on Sonoma(macOS 14.0)
Matlab2023b works fine on my computer with macOS 13.6. I find that the matlab 2023b is supported on Sonoma, so I update the system to it. However, after the update matlab crashs each time I launch it. And I find similar report on stack overflow.
The crash report:
——————————————————————————–
Segmentation violation detected at 2023-10-02 08:03:40 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Java Version : Java 1.8.0_382-b05 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
MATLAB Architecture : maca64
MATLAB Entitlement ID : [FILTERED]
MATLAB Root : /Applications/MATLAB_R2023b.app
MATLAB Version : 23.2.0.2365128 (R2023b)
OpenGL : hardware
Operating System : Mac OS 版本14.0(版号23A344)
Process ID : 5522
Processor ID : ABI64 ARM ARM64E FIRESTORM_ICESTORM HG
Session Key : [FILTERED]
Window System : Quartz
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ” id 0x294e2b000
Register State (from fault):
X0 = 0000000000000012 X1 = 0000000000000000
X2 = 0000000000000001 X3 = 0000000000000000
X4 = 00000001d9ae8630 X5 = 0000000000000000
X6 = 0000000000000000 X7 = 0000000000000403
X8 = 1194967f20a30012 X9 = 0000000000000000
X10 = 0000000000000001 X11 = 0000000000000000
X12 = 0000000010800000 X13 = 0000000000000001
X14 = 0000000000000000 X15 = 0000000084004000
X16 = 0000000182884e00 X17 = 0000000237fd36d0
X18 = 0000000000000000 X19 = 0000000236d00a60
X20 = 0000000000000000 X21 = 0000000000000000
X22 = 0000000294e2a670 X23 = 000000000000001a
X24 = 0000000000000000 X25 = 0000000000000000
X26 = 0000000294e290e0 X27 = 0000000000000000
X28 = 0000600065e36520
FP = 0000000294e27ae0 LR = 5154800182884e38
SP = 0000000294e27ae0 PC = 00000001829cd6f0
CPSR = 60001000
Stack Trace (from fault):
[ 0] 0x0000000104904d90 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00019856 _ZN10foundation4core4diag15stacktrace_base7captureERKNS1_14thread_contextEm+00000064
[ 1] 0x0000000104907c58 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00031832 _ZN10foundation4core4test17terminate_handledERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+00002144
[ 2] 0x0000000104907118 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00028952 _ZN10foundation4core4diag13terminate_logEPKcPK17__darwin_ucontext+00000140
[ 3] 0x000000010b0653b0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00529328 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00011892
[ 4] 0x000000010b063250 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00520784 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00003348
[ 5] 0x000000010b060cf0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00511216 mnFatalSignalHandler+00000140
[ 6] 0x000000018284da24 /usr/lib/system/libsystem_platform.dylib+00014884 _sigtramp+00000056
[ 7] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 8] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 9] 0x0000000204c93578 /System/Library/PrivateFrameworks/IO80211.framework/Versions/A/IO80211+00017784 Apple80211Scan+00000584
[ 10] 0x00000001361d5994 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01923476 FqTtUQGnylG+00000356
[ 11] 0x00000001361d5da4 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01924516 AjEdeqBE+00000564
[ 12] 0x00000001361e4e00 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01986048 GxnmPknfylG+00000176
[ 13] 0x00000001361e42cc /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01983180 OexMpdMAylG+00000332
[ 14] 0x00000001361e4628 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01984040 tQpdOundylG+00000052
[ 15] 0x000000018281f034 /usr/lib/system/libsystem_pthread.dylib+00028724 _pthread_start+00000136
[ 16] 0x0000000182819e3c /usr/lib/system/libsystem_pthread.dylib+00007740 thread_start+00000008
PS: when I run matlab on terminal, there are two warnings as:
CodeCache is full. Compiler has been disabled.
Try increasing the code cache size using -XX:ReservedCodeCacheSize=
objc[16042]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2325b2888) and /Applications/MATLAB_R2023b.app/bin/maca64/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib (0x10bc41e70).
One of the two will be used. Which one is undefined.Matlab2023b works fine on my computer with macOS 13.6. I find that the matlab 2023b is supported on Sonoma, so I update the system to it. However, after the update matlab crashs each time I launch it. And I find similar report on stack overflow.
The crash report:
——————————————————————————–
Segmentation violation detected at 2023-10-02 08:03:40 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Java Version : Java 1.8.0_382-b05 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
MATLAB Architecture : maca64
MATLAB Entitlement ID : [FILTERED]
MATLAB Root : /Applications/MATLAB_R2023b.app
MATLAB Version : 23.2.0.2365128 (R2023b)
OpenGL : hardware
Operating System : Mac OS 版本14.0(版号23A344)
Process ID : 5522
Processor ID : ABI64 ARM ARM64E FIRESTORM_ICESTORM HG
Session Key : [FILTERED]
Window System : Quartz
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ” id 0x294e2b000
Register State (from fault):
X0 = 0000000000000012 X1 = 0000000000000000
X2 = 0000000000000001 X3 = 0000000000000000
X4 = 00000001d9ae8630 X5 = 0000000000000000
X6 = 0000000000000000 X7 = 0000000000000403
X8 = 1194967f20a30012 X9 = 0000000000000000
X10 = 0000000000000001 X11 = 0000000000000000
X12 = 0000000010800000 X13 = 0000000000000001
X14 = 0000000000000000 X15 = 0000000084004000
X16 = 0000000182884e00 X17 = 0000000237fd36d0
X18 = 0000000000000000 X19 = 0000000236d00a60
X20 = 0000000000000000 X21 = 0000000000000000
X22 = 0000000294e2a670 X23 = 000000000000001a
X24 = 0000000000000000 X25 = 0000000000000000
X26 = 0000000294e290e0 X27 = 0000000000000000
X28 = 0000600065e36520
FP = 0000000294e27ae0 LR = 5154800182884e38
SP = 0000000294e27ae0 PC = 00000001829cd6f0
CPSR = 60001000
Stack Trace (from fault):
[ 0] 0x0000000104904d90 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00019856 _ZN10foundation4core4diag15stacktrace_base7captureERKNS1_14thread_contextEm+00000064
[ 1] 0x0000000104907c58 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00031832 _ZN10foundation4core4test17terminate_handledERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+00002144
[ 2] 0x0000000104907118 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00028952 _ZN10foundation4core4diag13terminate_logEPKcPK17__darwin_ucontext+00000140
[ 3] 0x000000010b0653b0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00529328 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00011892
[ 4] 0x000000010b063250 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00520784 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00003348
[ 5] 0x000000010b060cf0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00511216 mnFatalSignalHandler+00000140
[ 6] 0x000000018284da24 /usr/lib/system/libsystem_platform.dylib+00014884 _sigtramp+00000056
[ 7] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 8] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 9] 0x0000000204c93578 /System/Library/PrivateFrameworks/IO80211.framework/Versions/A/IO80211+00017784 Apple80211Scan+00000584
[ 10] 0x00000001361d5994 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01923476 FqTtUQGnylG+00000356
[ 11] 0x00000001361d5da4 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01924516 AjEdeqBE+00000564
[ 12] 0x00000001361e4e00 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01986048 GxnmPknfylG+00000176
[ 13] 0x00000001361e42cc /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01983180 OexMpdMAylG+00000332
[ 14] 0x00000001361e4628 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01984040 tQpdOundylG+00000052
[ 15] 0x000000018281f034 /usr/lib/system/libsystem_pthread.dylib+00028724 _pthread_start+00000136
[ 16] 0x0000000182819e3c /usr/lib/system/libsystem_pthread.dylib+00007740 thread_start+00000008
PS: when I run matlab on terminal, there are two warnings as:
CodeCache is full. Compiler has been disabled.
Try increasing the code cache size using -XX:ReservedCodeCacheSize=
objc[16042]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2325b2888) and /Applications/MATLAB_R2023b.app/bin/maca64/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib (0x10bc41e70).
One of the two will be used. Which one is undefined. Matlab2023b works fine on my computer with macOS 13.6. I find that the matlab 2023b is supported on Sonoma, so I update the system to it. However, after the update matlab crashs each time I launch it. And I find similar report on stack overflow.
The crash report:
——————————————————————————–
Segmentation violation detected at 2023-10-02 08:03:40 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Java Version : Java 1.8.0_382-b05 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
MATLAB Architecture : maca64
MATLAB Entitlement ID : [FILTERED]
MATLAB Root : /Applications/MATLAB_R2023b.app
MATLAB Version : 23.2.0.2365128 (R2023b)
OpenGL : hardware
Operating System : Mac OS 版本14.0(版号23A344)
Process ID : 5522
Processor ID : ABI64 ARM ARM64E FIRESTORM_ICESTORM HG
Session Key : [FILTERED]
Window System : Quartz
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ” id 0x294e2b000
Register State (from fault):
X0 = 0000000000000012 X1 = 0000000000000000
X2 = 0000000000000001 X3 = 0000000000000000
X4 = 00000001d9ae8630 X5 = 0000000000000000
X6 = 0000000000000000 X7 = 0000000000000403
X8 = 1194967f20a30012 X9 = 0000000000000000
X10 = 0000000000000001 X11 = 0000000000000000
X12 = 0000000010800000 X13 = 0000000000000001
X14 = 0000000000000000 X15 = 0000000084004000
X16 = 0000000182884e00 X17 = 0000000237fd36d0
X18 = 0000000000000000 X19 = 0000000236d00a60
X20 = 0000000000000000 X21 = 0000000000000000
X22 = 0000000294e2a670 X23 = 000000000000001a
X24 = 0000000000000000 X25 = 0000000000000000
X26 = 0000000294e290e0 X27 = 0000000000000000
X28 = 0000600065e36520
FP = 0000000294e27ae0 LR = 5154800182884e38
SP = 0000000294e27ae0 PC = 00000001829cd6f0
CPSR = 60001000
Stack Trace (from fault):
[ 0] 0x0000000104904d90 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00019856 _ZN10foundation4core4diag15stacktrace_base7captureERKNS1_14thread_contextEm+00000064
[ 1] 0x0000000104907c58 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00031832 _ZN10foundation4core4test17terminate_handledERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+00002144
[ 2] 0x0000000104907118 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00028952 _ZN10foundation4core4diag13terminate_logEPKcPK17__darwin_ucontext+00000140
[ 3] 0x000000010b0653b0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00529328 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00011892
[ 4] 0x000000010b063250 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00520784 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00003348
[ 5] 0x000000010b060cf0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00511216 mnFatalSignalHandler+00000140
[ 6] 0x000000018284da24 /usr/lib/system/libsystem_platform.dylib+00014884 _sigtramp+00000056
[ 7] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 8] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 9] 0x0000000204c93578 /System/Library/PrivateFrameworks/IO80211.framework/Versions/A/IO80211+00017784 Apple80211Scan+00000584
[ 10] 0x00000001361d5994 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01923476 FqTtUQGnylG+00000356
[ 11] 0x00000001361d5da4 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01924516 AjEdeqBE+00000564
[ 12] 0x00000001361e4e00 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01986048 GxnmPknfylG+00000176
[ 13] 0x00000001361e42cc /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01983180 OexMpdMAylG+00000332
[ 14] 0x00000001361e4628 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01984040 tQpdOundylG+00000052
[ 15] 0x000000018281f034 /usr/lib/system/libsystem_pthread.dylib+00028724 _pthread_start+00000136
[ 16] 0x0000000182819e3c /usr/lib/system/libsystem_pthread.dylib+00007740 thread_start+00000008
PS: when I run matlab on terminal, there are two warnings as:
CodeCache is full. Compiler has been disabled.
Try increasing the code cache size using -XX:ReservedCodeCacheSize=
objc[16042]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2325b2888) and /Applications/MATLAB_R2023b.app/bin/maca64/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib (0x10bc41e70).
One of the two will be used. Which one is undefined. java, sonoma, macos 14, segv MATLAB Answers — New Questions
Matlab Crash on Sonoma(macOS 14.0)
Matlab2023b works fine on my computer with macOS 13.6. I find that the matlab 2023b is supported on Sonoma, so I update the system to it. However, after the update matlab crashs each time I launch it. And I find similar report on stack overflow.
The crash report:
——————————————————————————–
Segmentation violation detected at 2023-10-02 08:03:40 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Java Version : Java 1.8.0_382-b05 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
MATLAB Architecture : maca64
MATLAB Entitlement ID : [FILTERED]
MATLAB Root : /Applications/MATLAB_R2023b.app
MATLAB Version : 23.2.0.2365128 (R2023b)
OpenGL : hardware
Operating System : Mac OS 版本14.0(版号23A344)
Process ID : 5522
Processor ID : ABI64 ARM ARM64E FIRESTORM_ICESTORM HG
Session Key : [FILTERED]
Window System : Quartz
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ” id 0x294e2b000
Register State (from fault):
X0 = 0000000000000012 X1 = 0000000000000000
X2 = 0000000000000001 X3 = 0000000000000000
X4 = 00000001d9ae8630 X5 = 0000000000000000
X6 = 0000000000000000 X7 = 0000000000000403
X8 = 1194967f20a30012 X9 = 0000000000000000
X10 = 0000000000000001 X11 = 0000000000000000
X12 = 0000000010800000 X13 = 0000000000000001
X14 = 0000000000000000 X15 = 0000000084004000
X16 = 0000000182884e00 X17 = 0000000237fd36d0
X18 = 0000000000000000 X19 = 0000000236d00a60
X20 = 0000000000000000 X21 = 0000000000000000
X22 = 0000000294e2a670 X23 = 000000000000001a
X24 = 0000000000000000 X25 = 0000000000000000
X26 = 0000000294e290e0 X27 = 0000000000000000
X28 = 0000600065e36520
FP = 0000000294e27ae0 LR = 5154800182884e38
SP = 0000000294e27ae0 PC = 00000001829cd6f0
CPSR = 60001000
Stack Trace (from fault):
[ 0] 0x0000000104904d90 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00019856 _ZN10foundation4core4diag15stacktrace_base7captureERKNS1_14thread_contextEm+00000064
[ 1] 0x0000000104907c58 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00031832 _ZN10foundation4core4test17terminate_handledERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+00002144
[ 2] 0x0000000104907118 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00028952 _ZN10foundation4core4diag13terminate_logEPKcPK17__darwin_ucontext+00000140
[ 3] 0x000000010b0653b0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00529328 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00011892
[ 4] 0x000000010b063250 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00520784 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00003348
[ 5] 0x000000010b060cf0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00511216 mnFatalSignalHandler+00000140
[ 6] 0x000000018284da24 /usr/lib/system/libsystem_platform.dylib+00014884 _sigtramp+00000056
[ 7] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 8] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 9] 0x0000000204c93578 /System/Library/PrivateFrameworks/IO80211.framework/Versions/A/IO80211+00017784 Apple80211Scan+00000584
[ 10] 0x00000001361d5994 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01923476 FqTtUQGnylG+00000356
[ 11] 0x00000001361d5da4 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01924516 AjEdeqBE+00000564
[ 12] 0x00000001361e4e00 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01986048 GxnmPknfylG+00000176
[ 13] 0x00000001361e42cc /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01983180 OexMpdMAylG+00000332
[ 14] 0x00000001361e4628 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01984040 tQpdOundylG+00000052
[ 15] 0x000000018281f034 /usr/lib/system/libsystem_pthread.dylib+00028724 _pthread_start+00000136
[ 16] 0x0000000182819e3c /usr/lib/system/libsystem_pthread.dylib+00007740 thread_start+00000008
PS: when I run matlab on terminal, there are two warnings as:
CodeCache is full. Compiler has been disabled.
Try increasing the code cache size using -XX:ReservedCodeCacheSize=
objc[16042]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2325b2888) and /Applications/MATLAB_R2023b.app/bin/maca64/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib (0x10bc41e70).
One of the two will be used. Which one is undefined.Matlab2023b works fine on my computer with macOS 13.6. I find that the matlab 2023b is supported on Sonoma, so I update the system to it. However, after the update matlab crashs each time I launch it. And I find similar report on stack overflow.
The crash report:
——————————————————————————–
Segmentation violation detected at 2023-10-02 08:03:40 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Java Version : Java 1.8.0_382-b05 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
MATLAB Architecture : maca64
MATLAB Entitlement ID : [FILTERED]
MATLAB Root : /Applications/MATLAB_R2023b.app
MATLAB Version : 23.2.0.2365128 (R2023b)
OpenGL : hardware
Operating System : Mac OS 版本14.0(版号23A344)
Process ID : 5522
Processor ID : ABI64 ARM ARM64E FIRESTORM_ICESTORM HG
Session Key : [FILTERED]
Window System : Quartz
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ” id 0x294e2b000
Register State (from fault):
X0 = 0000000000000012 X1 = 0000000000000000
X2 = 0000000000000001 X3 = 0000000000000000
X4 = 00000001d9ae8630 X5 = 0000000000000000
X6 = 0000000000000000 X7 = 0000000000000403
X8 = 1194967f20a30012 X9 = 0000000000000000
X10 = 0000000000000001 X11 = 0000000000000000
X12 = 0000000010800000 X13 = 0000000000000001
X14 = 0000000000000000 X15 = 0000000084004000
X16 = 0000000182884e00 X17 = 0000000237fd36d0
X18 = 0000000000000000 X19 = 0000000236d00a60
X20 = 0000000000000000 X21 = 0000000000000000
X22 = 0000000294e2a670 X23 = 000000000000001a
X24 = 0000000000000000 X25 = 0000000000000000
X26 = 0000000294e290e0 X27 = 0000000000000000
X28 = 0000600065e36520
FP = 0000000294e27ae0 LR = 5154800182884e38
SP = 0000000294e27ae0 PC = 00000001829cd6f0
CPSR = 60001000
Stack Trace (from fault):
[ 0] 0x0000000104904d90 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00019856 _ZN10foundation4core4diag15stacktrace_base7captureERKNS1_14thread_contextEm+00000064
[ 1] 0x0000000104907c58 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00031832 _ZN10foundation4core4test17terminate_handledERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+00002144
[ 2] 0x0000000104907118 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00028952 _ZN10foundation4core4diag13terminate_logEPKcPK17__darwin_ucontext+00000140
[ 3] 0x000000010b0653b0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00529328 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00011892
[ 4] 0x000000010b063250 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00520784 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00003348
[ 5] 0x000000010b060cf0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00511216 mnFatalSignalHandler+00000140
[ 6] 0x000000018284da24 /usr/lib/system/libsystem_platform.dylib+00014884 _sigtramp+00000056
[ 7] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 8] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 9] 0x0000000204c93578 /System/Library/PrivateFrameworks/IO80211.framework/Versions/A/IO80211+00017784 Apple80211Scan+00000584
[ 10] 0x00000001361d5994 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01923476 FqTtUQGnylG+00000356
[ 11] 0x00000001361d5da4 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01924516 AjEdeqBE+00000564
[ 12] 0x00000001361e4e00 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01986048 GxnmPknfylG+00000176
[ 13] 0x00000001361e42cc /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01983180 OexMpdMAylG+00000332
[ 14] 0x00000001361e4628 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01984040 tQpdOundylG+00000052
[ 15] 0x000000018281f034 /usr/lib/system/libsystem_pthread.dylib+00028724 _pthread_start+00000136
[ 16] 0x0000000182819e3c /usr/lib/system/libsystem_pthread.dylib+00007740 thread_start+00000008
PS: when I run matlab on terminal, there are two warnings as:
CodeCache is full. Compiler has been disabled.
Try increasing the code cache size using -XX:ReservedCodeCacheSize=
objc[16042]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2325b2888) and /Applications/MATLAB_R2023b.app/bin/maca64/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib (0x10bc41e70).
One of the two will be used. Which one is undefined. Matlab2023b works fine on my computer with macOS 13.6. I find that the matlab 2023b is supported on Sonoma, so I update the system to it. However, after the update matlab crashs each time I launch it. And I find similar report on stack overflow.
The crash report:
——————————————————————————–
Segmentation violation detected at 2023-10-02 08:03:40 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Java Version : Java 1.8.0_382-b05 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
MATLAB Architecture : maca64
MATLAB Entitlement ID : [FILTERED]
MATLAB Root : /Applications/MATLAB_R2023b.app
MATLAB Version : 23.2.0.2365128 (R2023b)
OpenGL : hardware
Operating System : Mac OS 版本14.0(版号23A344)
Process ID : 5522
Processor ID : ABI64 ARM ARM64E FIRESTORM_ICESTORM HG
Session Key : [FILTERED]
Window System : Quartz
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ” id 0x294e2b000
Register State (from fault):
X0 = 0000000000000012 X1 = 0000000000000000
X2 = 0000000000000001 X3 = 0000000000000000
X4 = 00000001d9ae8630 X5 = 0000000000000000
X6 = 0000000000000000 X7 = 0000000000000403
X8 = 1194967f20a30012 X9 = 0000000000000000
X10 = 0000000000000001 X11 = 0000000000000000
X12 = 0000000010800000 X13 = 0000000000000001
X14 = 0000000000000000 X15 = 0000000084004000
X16 = 0000000182884e00 X17 = 0000000237fd36d0
X18 = 0000000000000000 X19 = 0000000236d00a60
X20 = 0000000000000000 X21 = 0000000000000000
X22 = 0000000294e2a670 X23 = 000000000000001a
X24 = 0000000000000000 X25 = 0000000000000000
X26 = 0000000294e290e0 X27 = 0000000000000000
X28 = 0000600065e36520
FP = 0000000294e27ae0 LR = 5154800182884e38
SP = 0000000294e27ae0 PC = 00000001829cd6f0
CPSR = 60001000
Stack Trace (from fault):
[ 0] 0x0000000104904d90 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00019856 _ZN10foundation4core4diag15stacktrace_base7captureERKNS1_14thread_contextEm+00000064
[ 1] 0x0000000104907c58 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00031832 _ZN10foundation4core4test17terminate_handledERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+00002144
[ 2] 0x0000000104907118 /Applications/MATLAB_R2023b.app/bin/maca64/libmwfl.dylib+00028952 _ZN10foundation4core4diag13terminate_logEPKcPK17__darwin_ucontext+00000140
[ 3] 0x000000010b0653b0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00529328 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00011892
[ 4] 0x000000010b063250 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00520784 _Z19mnPrintErrorMessageRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+00003348
[ 5] 0x000000010b060cf0 /Applications/MATLAB_R2023b.app/bin/maca64/libmwmcr.dylib+00511216 mnFatalSignalHandler+00000140
[ 6] 0x000000018284da24 /usr/lib/system/libsystem_platform.dylib+00014884 _sigtramp+00000056
[ 7] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 8] 0x0000000182884e38 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00028216 CFDictionaryGetValue+00000056
[ 9] 0x0000000204c93578 /System/Library/PrivateFrameworks/IO80211.framework/Versions/A/IO80211+00017784 Apple80211Scan+00000584
[ 10] 0x00000001361d5994 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01923476 FqTtUQGnylG+00000356
[ 11] 0x00000001361d5da4 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01924516 AjEdeqBE+00000564
[ 12] 0x00000001361e4e00 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01986048 GxnmPknfylG+00000176
[ 13] 0x00000001361e42cc /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01983180 OexMpdMAylG+00000332
[ 14] 0x00000001361e4628 /Applications/MATLAB_R2023b.app/bin/maca64/matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.dylib+01984040 tQpdOundylG+00000052
[ 15] 0x000000018281f034 /usr/lib/system/libsystem_pthread.dylib+00028724 _pthread_start+00000136
[ 16] 0x0000000182819e3c /usr/lib/system/libsystem_pthread.dylib+00007740 thread_start+00000008
PS: when I run matlab on terminal, there are two warnings as:
CodeCache is full. Compiler has been disabled.
Try increasing the code cache size using -XX:ReservedCodeCacheSize=
objc[16042]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2325b2888) and /Applications/MATLAB_R2023b.app/bin/maca64/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib (0x10bc41e70).
One of the two will be used. Which one is undefined. java, sonoma, macos 14, segv MATLAB Answers — New Questions
Modify or adding data in SimulationOutput
Hello,
my request is related to the Simulink results that are written in Simulink.SimulationOutput. Is there a possibility to modify it, add something etc. via Matlab code?
Background:
I’ve designed a WebApp in which I’ve integrated a Simulink model. I’ve used a template that is described here: Generate and Deploy a MATLAB App with SimAppTemplate for a Model – MATLAB & Simulink – MathWorks Deutschland
I’ve also integrated an FMU model (although this information is probably rather unimportant at this point). The overall model and app/webapp runs fine. The results of the simulation are written to app.SimulationHelper.InputOutput.SimulationOutput and processed further by the app. Everything works fine.
Challenge:
Is there a way to cache a previous simulation call (that works) and then write it back to the "SimulationOutput" workspace? Apparently this is write-protected and this is not possible without further ado.
The background is that I want to display (plot) several different simulation runs and compare them (e.g. if I have changed a parameter).
I would be grateful for your ideas.Hello,
my request is related to the Simulink results that are written in Simulink.SimulationOutput. Is there a possibility to modify it, add something etc. via Matlab code?
Background:
I’ve designed a WebApp in which I’ve integrated a Simulink model. I’ve used a template that is described here: Generate and Deploy a MATLAB App with SimAppTemplate for a Model – MATLAB & Simulink – MathWorks Deutschland
I’ve also integrated an FMU model (although this information is probably rather unimportant at this point). The overall model and app/webapp runs fine. The results of the simulation are written to app.SimulationHelper.InputOutput.SimulationOutput and processed further by the app. Everything works fine.
Challenge:
Is there a way to cache a previous simulation call (that works) and then write it back to the "SimulationOutput" workspace? Apparently this is write-protected and this is not possible without further ado.
The background is that I want to display (plot) several different simulation runs and compare them (e.g. if I have changed a parameter).
I would be grateful for your ideas. Hello,
my request is related to the Simulink results that are written in Simulink.SimulationOutput. Is there a possibility to modify it, add something etc. via Matlab code?
Background:
I’ve designed a WebApp in which I’ve integrated a Simulink model. I’ve used a template that is described here: Generate and Deploy a MATLAB App with SimAppTemplate for a Model – MATLAB & Simulink – MathWorks Deutschland
I’ve also integrated an FMU model (although this information is probably rather unimportant at this point). The overall model and app/webapp runs fine. The results of the simulation are written to app.SimulationHelper.InputOutput.SimulationOutput and processed further by the app. Everything works fine.
Challenge:
Is there a way to cache a previous simulation call (that works) and then write it back to the "SimulationOutput" workspace? Apparently this is write-protected and this is not possible without further ado.
The background is that I want to display (plot) several different simulation runs and compare them (e.g. if I have changed a parameter).
I would be grateful for your ideas. webapp, simulink, simulationoutput, modify MATLAB Answers — New Questions
you need to use ascii code too
function [Program_Pr11] = Program_Pr11(Program_Pr11)
% 1 – Încarcă textul din fișierul RTF
fileID = fopen(‘text.rtf’,’r’); % Înlocuiește ‘text.rtf’ cu numele fișierului tău
text = fscanf(fileID,’%c’);
fclose(fileID);
% 2 – Determină limba textului (acest exemplu folosește o librărie externă, apelând un serviciu online sau o bibliotecă MATLAB)
detected_language = detectLanguage(text);
% 3 – Numărul de cuvinte și apariția fiecărui cuvânt
words = split(text, ‘ ‘);
num_words = numel(words);
word_counts = countOccurrences(words);
% 4 – Numărul de litere și frecvența fiecărui caracter
letters = replace(text, ‘ ‘, ”); % Elimină spațiile
num_letters = numel(letters);
letter_counts = countOccurrences(letters);
unique_chars = unique(letters);
% 5 – Verifică și completează dicționarul cu cuvintele din text
dictionary = loadDictionary(); % Încarcă dicționarul existent
missing_words = findMissingWords(words, dictionary);
updated_dictionary = addToDictionary(missing_words, dictionary);
% 6 – Verifică prezența anumitor cuvinte indicate în text
specified_words = {‘word1’, ‘word2’, ‘word3’}; % Cuvintele de verificat
word_presence = checkWordPresence(specified_words, words);
% 7 – Reprezintă grafic frecvențele de apariție ale caracterelor în text
figure;
bar(unique_chars, letter_counts);
xlabel(‘Caractere’);
ylabel(‘Frecvență de apariție’);
title(‘Frecvențele de apariție ale caracterelor în text’);
% Funcțiile auxiliare
function detected_language = detectLanguage(text)
% Implementează funcția pentru a detecta limba textului
% Returnează limba detectată
% Poate fi necesară utilizarea unor servicii sau biblioteci specializate
% Exemplu: detected_language = MyLanguageDetectionFunction(text);
detected_language = ‘Romanian’; % Exemplu: limba detectată este româna
end
function counts = countOccurrences(items)
unique_items = unique(items);
counts = zeros(size(unique_items));
for i = 1:numel(unique_items)
counts(i) = sum(ismember(items, unique_items(i)));
end
end
function dictionary = loadDictionary()
% Implementează funcția pentru a încărca dicționarul
% Returnează dicționarul
dictionary = {‘word1’, ‘word2’, ‘word3’}; % Exemplu: dicționarul tău
end
function missing_words = findMissingWords(words, dictionary)
missing_words = setdiff(unique(words), dictionary);
end
function updated_dictionary = addToDictionary(new_words, dictionary)
updated_dictionary = [dictionary new_words];
end
function word_presence = checkWordPresence(specific_words, words)
word_presence = ismember(specific_words, words);
end
endfunction [Program_Pr11] = Program_Pr11(Program_Pr11)
% 1 – Încarcă textul din fișierul RTF
fileID = fopen(‘text.rtf’,’r’); % Înlocuiește ‘text.rtf’ cu numele fișierului tău
text = fscanf(fileID,’%c’);
fclose(fileID);
% 2 – Determină limba textului (acest exemplu folosește o librărie externă, apelând un serviciu online sau o bibliotecă MATLAB)
detected_language = detectLanguage(text);
% 3 – Numărul de cuvinte și apariția fiecărui cuvânt
words = split(text, ‘ ‘);
num_words = numel(words);
word_counts = countOccurrences(words);
% 4 – Numărul de litere și frecvența fiecărui caracter
letters = replace(text, ‘ ‘, ”); % Elimină spațiile
num_letters = numel(letters);
letter_counts = countOccurrences(letters);
unique_chars = unique(letters);
% 5 – Verifică și completează dicționarul cu cuvintele din text
dictionary = loadDictionary(); % Încarcă dicționarul existent
missing_words = findMissingWords(words, dictionary);
updated_dictionary = addToDictionary(missing_words, dictionary);
% 6 – Verifică prezența anumitor cuvinte indicate în text
specified_words = {‘word1’, ‘word2’, ‘word3’}; % Cuvintele de verificat
word_presence = checkWordPresence(specified_words, words);
% 7 – Reprezintă grafic frecvențele de apariție ale caracterelor în text
figure;
bar(unique_chars, letter_counts);
xlabel(‘Caractere’);
ylabel(‘Frecvență de apariție’);
title(‘Frecvențele de apariție ale caracterelor în text’);
% Funcțiile auxiliare
function detected_language = detectLanguage(text)
% Implementează funcția pentru a detecta limba textului
% Returnează limba detectată
% Poate fi necesară utilizarea unor servicii sau biblioteci specializate
% Exemplu: detected_language = MyLanguageDetectionFunction(text);
detected_language = ‘Romanian’; % Exemplu: limba detectată este româna
end
function counts = countOccurrences(items)
unique_items = unique(items);
counts = zeros(size(unique_items));
for i = 1:numel(unique_items)
counts(i) = sum(ismember(items, unique_items(i)));
end
end
function dictionary = loadDictionary()
% Implementează funcția pentru a încărca dicționarul
% Returnează dicționarul
dictionary = {‘word1’, ‘word2’, ‘word3’}; % Exemplu: dicționarul tău
end
function missing_words = findMissingWords(words, dictionary)
missing_words = setdiff(unique(words), dictionary);
end
function updated_dictionary = addToDictionary(new_words, dictionary)
updated_dictionary = [dictionary new_words];
end
function word_presence = checkWordPresence(specific_words, words)
word_presence = ismember(specific_words, words);
end
end function [Program_Pr11] = Program_Pr11(Program_Pr11)
% 1 – Încarcă textul din fișierul RTF
fileID = fopen(‘text.rtf’,’r’); % Înlocuiește ‘text.rtf’ cu numele fișierului tău
text = fscanf(fileID,’%c’);
fclose(fileID);
% 2 – Determină limba textului (acest exemplu folosește o librărie externă, apelând un serviciu online sau o bibliotecă MATLAB)
detected_language = detectLanguage(text);
% 3 – Numărul de cuvinte și apariția fiecărui cuvânt
words = split(text, ‘ ‘);
num_words = numel(words);
word_counts = countOccurrences(words);
% 4 – Numărul de litere și frecvența fiecărui caracter
letters = replace(text, ‘ ‘, ”); % Elimină spațiile
num_letters = numel(letters);
letter_counts = countOccurrences(letters);
unique_chars = unique(letters);
% 5 – Verifică și completează dicționarul cu cuvintele din text
dictionary = loadDictionary(); % Încarcă dicționarul existent
missing_words = findMissingWords(words, dictionary);
updated_dictionary = addToDictionary(missing_words, dictionary);
% 6 – Verifică prezența anumitor cuvinte indicate în text
specified_words = {‘word1’, ‘word2’, ‘word3’}; % Cuvintele de verificat
word_presence = checkWordPresence(specified_words, words);
% 7 – Reprezintă grafic frecvențele de apariție ale caracterelor în text
figure;
bar(unique_chars, letter_counts);
xlabel(‘Caractere’);
ylabel(‘Frecvență de apariție’);
title(‘Frecvențele de apariție ale caracterelor în text’);
% Funcțiile auxiliare
function detected_language = detectLanguage(text)
% Implementează funcția pentru a detecta limba textului
% Returnează limba detectată
% Poate fi necesară utilizarea unor servicii sau biblioteci specializate
% Exemplu: detected_language = MyLanguageDetectionFunction(text);
detected_language = ‘Romanian’; % Exemplu: limba detectată este româna
end
function counts = countOccurrences(items)
unique_items = unique(items);
counts = zeros(size(unique_items));
for i = 1:numel(unique_items)
counts(i) = sum(ismember(items, unique_items(i)));
end
end
function dictionary = loadDictionary()
% Implementează funcția pentru a încărca dicționarul
% Returnează dicționarul
dictionary = {‘word1’, ‘word2’, ‘word3’}; % Exemplu: dicționarul tău
end
function missing_words = findMissingWords(words, dictionary)
missing_words = setdiff(unique(words), dictionary);
end
function updated_dictionary = addToDictionary(new_words, dictionary)
updated_dictionary = [dictionary new_words];
end
function word_presence = checkWordPresence(specific_words, words)
word_presence = ismember(specific_words, words);
end
end matlab function, function, matlab MATLAB Answers — New Questions
For Loop iteration only displays last plot in PPT slides
I created a code to display my plots onto a Powerpoint (PPT) slide. The issue lies with MATLAB would generate all the plots but would only display the last plot on all the PPT slides. So far the only method is to copy the for loop, change the range (ex: 1:1, 2:2, 3:3, etc) and the "plot.png" numerical. I want to eliminate this tedious method and have an easier method for each slide to display each corresponding plot.
In this example length(fileList) = 6. The fileList respresents the 6 plots generated in this example. Prior I had length(fileList) in the for loop but it would only display the last plot on the slides.
X1 = length(fileList);
for j = 1:1 %length(fileList)
imgFIG = openfig(strcat(fileList(j).folder,”,fileList(j).name));
saveas(imgFIG,’plot.png’);
imgPNG = imread(‘plot.png’);
imgPNG2 = imresize(imgPNG, 1.5);
imwrite(imgPNG2,’plot2.png’)
imgPNG3 = Picture(‘plot2.png’);
fName = fileList(j).name;
z = fName(27:28);
dataSlides = add(ppt,’Title and Content’);
newTitle = strcat(‘Step’, {‘ ‘}, z,’ Simulations’);
replace(dataSlides,’Title’, newTitle);
replace(dataSlides,’Content’, imgPNG3);
clearvars -except j pL ppt directory fileList dirSize X1
end
for j = 2:1:X1
imgFIG = openfig(strcat(fileList(j).folder,”,fileList(j).name));
saveas(imgFIG,’plot4.png’);
imgPNG = imread(‘plot4.png’);
imgPNG2 = imresize(imgPNG, 1.5);
imwrite(imgPNG2,’plot5.png’)
imgPNG3 = Picture(‘plot5.png’);
fName = fileList(j).name;
z = fName(27:28);
dataSlides = add(ppt,’Title and Content’);
newTitle = strcat(‘Step’, {‘ ‘}, z,’ Simulations’);
replace(dataSlides,’Title’, newTitle);
replace(dataSlides,’Content’, imgPNG3);
clearvars -except j pL ppt directory fileList dirSize X1
end
close(ppt);
rptview(ppt);
endI created a code to display my plots onto a Powerpoint (PPT) slide. The issue lies with MATLAB would generate all the plots but would only display the last plot on all the PPT slides. So far the only method is to copy the for loop, change the range (ex: 1:1, 2:2, 3:3, etc) and the "plot.png" numerical. I want to eliminate this tedious method and have an easier method for each slide to display each corresponding plot.
In this example length(fileList) = 6. The fileList respresents the 6 plots generated in this example. Prior I had length(fileList) in the for loop but it would only display the last plot on the slides.
X1 = length(fileList);
for j = 1:1 %length(fileList)
imgFIG = openfig(strcat(fileList(j).folder,”,fileList(j).name));
saveas(imgFIG,’plot.png’);
imgPNG = imread(‘plot.png’);
imgPNG2 = imresize(imgPNG, 1.5);
imwrite(imgPNG2,’plot2.png’)
imgPNG3 = Picture(‘plot2.png’);
fName = fileList(j).name;
z = fName(27:28);
dataSlides = add(ppt,’Title and Content’);
newTitle = strcat(‘Step’, {‘ ‘}, z,’ Simulations’);
replace(dataSlides,’Title’, newTitle);
replace(dataSlides,’Content’, imgPNG3);
clearvars -except j pL ppt directory fileList dirSize X1
end
for j = 2:1:X1
imgFIG = openfig(strcat(fileList(j).folder,”,fileList(j).name));
saveas(imgFIG,’plot4.png’);
imgPNG = imread(‘plot4.png’);
imgPNG2 = imresize(imgPNG, 1.5);
imwrite(imgPNG2,’plot5.png’)
imgPNG3 = Picture(‘plot5.png’);
fName = fileList(j).name;
z = fName(27:28);
dataSlides = add(ppt,’Title and Content’);
newTitle = strcat(‘Step’, {‘ ‘}, z,’ Simulations’);
replace(dataSlides,’Title’, newTitle);
replace(dataSlides,’Content’, imgPNG3);
clearvars -except j pL ppt directory fileList dirSize X1
end
close(ppt);
rptview(ppt);
end I created a code to display my plots onto a Powerpoint (PPT) slide. The issue lies with MATLAB would generate all the plots but would only display the last plot on all the PPT slides. So far the only method is to copy the for loop, change the range (ex: 1:1, 2:2, 3:3, etc) and the "plot.png" numerical. I want to eliminate this tedious method and have an easier method for each slide to display each corresponding plot.
In this example length(fileList) = 6. The fileList respresents the 6 plots generated in this example. Prior I had length(fileList) in the for loop but it would only display the last plot on the slides.
X1 = length(fileList);
for j = 1:1 %length(fileList)
imgFIG = openfig(strcat(fileList(j).folder,”,fileList(j).name));
saveas(imgFIG,’plot.png’);
imgPNG = imread(‘plot.png’);
imgPNG2 = imresize(imgPNG, 1.5);
imwrite(imgPNG2,’plot2.png’)
imgPNG3 = Picture(‘plot2.png’);
fName = fileList(j).name;
z = fName(27:28);
dataSlides = add(ppt,’Title and Content’);
newTitle = strcat(‘Step’, {‘ ‘}, z,’ Simulations’);
replace(dataSlides,’Title’, newTitle);
replace(dataSlides,’Content’, imgPNG3);
clearvars -except j pL ppt directory fileList dirSize X1
end
for j = 2:1:X1
imgFIG = openfig(strcat(fileList(j).folder,”,fileList(j).name));
saveas(imgFIG,’plot4.png’);
imgPNG = imread(‘plot4.png’);
imgPNG2 = imresize(imgPNG, 1.5);
imwrite(imgPNG2,’plot5.png’)
imgPNG3 = Picture(‘plot5.png’);
fName = fileList(j).name;
z = fName(27:28);
dataSlides = add(ppt,’Title and Content’);
newTitle = strcat(‘Step’, {‘ ‘}, z,’ Simulations’);
replace(dataSlides,’Title’, newTitle);
replace(dataSlides,’Content’, imgPNG3);
clearvars -except j pL ppt directory fileList dirSize X1
end
close(ppt);
rptview(ppt);
end for loop, powerpoint, ppt, iteration, plot, multiple plot, matlab function, loop MATLAB Answers — New Questions