Author: PuTI
Identify and refill dark spots on the leopard with neighboring pixels
Remove the dark spots on the leopard.
i tried converting the color image into grayscale.Applied ostu thresholding to create binary image.
using the morophological operations i was able to create a mask, used mask to refilll the black spots on the color image. i did not get the desired result.
what other steps i can implement to achieve an image with no black spotsRemove the dark spots on the leopard.
i tried converting the color image into grayscale.Applied ostu thresholding to create binary image.
using the morophological operations i was able to create a mask, used mask to refilll the black spots on the color image. i did not get the desired result.
what other steps i can implement to achieve an image with no black spots Remove the dark spots on the leopard.
i tried converting the color image into grayscale.Applied ostu thresholding to create binary image.
using the morophological operations i was able to create a mask, used mask to refilll the black spots on the color image. i did not get the desired result.
what other steps i can implement to achieve an image with no black spots image processing, image segmentation, hole filling MATLAB Answers — New Questions
The student has not been able to complete the creation of her account because it is blocked. How long will she have to wait before trying to create her account again?
I have a student who tried to create her account but entered the wrong university email address. When she retried with the correct email and set up her password, that part worked. However, when she attempted to log in, she received an error message saying the account was blocked. She then tried to change her password and enter the authentication code, but in all cases the attempts were rejected.
How long will she have to wait before trying to create her account again?
Thank you very much in advance for your help.I have a student who tried to create her account but entered the wrong university email address. When she retried with the correct email and set up her password, that part worked. However, when she attempted to log in, she received an error message saying the account was blocked. She then tried to change her password and enter the authentication code, but in all cases the attempts were rejected.
How long will she have to wait before trying to create her account again?
Thank you very much in advance for your help. I have a student who tried to create her account but entered the wrong university email address. When she retried with the correct email and set up her password, that part worked. However, when she attempted to log in, she received an error message saying the account was blocked. She then tried to change her password and enter the authentication code, but in all cases the attempts were rejected.
How long will she have to wait before trying to create her account again?
Thank you very much in advance for your help. account blocked MATLAB Answers — New Questions
How to plot an optimization in logarithmic scale?
The following code is expected to plot the output of Rosenbrock’s function against number of iterations ( *for the sake of the problem, don’t be concerned with the quality of the source code*).
function value = banana(x0)
a = x0(1);
b = x0(2);
x = x0(3);
y = x0(4);
value = (1 – x + a)^2 + 100 * (y – b * (x – a)^2)^2;
end
a = int8(4 * rand()) / 2;
b = int8(4 * rand()) / 2;
[x1, y1] = random(a, b);
[x2, y2] = random(a, b);
[x3, y3] = random(a, b);
[x4, y4] = random(a, b);
x = [x1; x2; x3; x4];
y = [y1; y2; y3; y4];
save values.mat;
for i = 1
x0 = [a, b, x(i), y(i)];
options = optimset(‘PlotFcns’, { @optimplotfval });
[solution_point, fval,exitflag,output] = fminsearch(@banana,double(x0),options);
old_x=[x(i),y(i)];
new_x_1 = linspace(-2,2,51);
new_x_2 = linspace(-2,2,51);
for j=1:51
if(new_x_1(j)>= old_x(1))
new_x_1(j)=old_x(1);
break;
end
end
for j=1:51
if(new_x_2(j)>= old_x(2))
new_x_2(j)=old_x(2);
break;
end
end
end
<</matlabcentral/answers/uploaded_files/66646/untitled.png>>
*My questions are,*
(1) Is this plot really showing the output of Rosenbrock’s function against number of iterations?
(2) The plot shows a sudden slump in the output of the function. I need to show this plot in logarithmic form, so that a smooth curve is plotted. How can I do that?The following code is expected to plot the output of Rosenbrock’s function against number of iterations ( *for the sake of the problem, don’t be concerned with the quality of the source code*).
function value = banana(x0)
a = x0(1);
b = x0(2);
x = x0(3);
y = x0(4);
value = (1 – x + a)^2 + 100 * (y – b * (x – a)^2)^2;
end
a = int8(4 * rand()) / 2;
b = int8(4 * rand()) / 2;
[x1, y1] = random(a, b);
[x2, y2] = random(a, b);
[x3, y3] = random(a, b);
[x4, y4] = random(a, b);
x = [x1; x2; x3; x4];
y = [y1; y2; y3; y4];
save values.mat;
for i = 1
x0 = [a, b, x(i), y(i)];
options = optimset(‘PlotFcns’, { @optimplotfval });
[solution_point, fval,exitflag,output] = fminsearch(@banana,double(x0),options);
old_x=[x(i),y(i)];
new_x_1 = linspace(-2,2,51);
new_x_2 = linspace(-2,2,51);
for j=1:51
if(new_x_1(j)>= old_x(1))
new_x_1(j)=old_x(1);
break;
end
end
for j=1:51
if(new_x_2(j)>= old_x(2))
new_x_2(j)=old_x(2);
break;
end
end
end
<</matlabcentral/answers/uploaded_files/66646/untitled.png>>
*My questions are,*
(1) Is this plot really showing the output of Rosenbrock’s function against number of iterations?
(2) The plot shows a sudden slump in the output of the function. I need to show this plot in logarithmic form, so that a smooth curve is plotted. How can I do that? The following code is expected to plot the output of Rosenbrock’s function against number of iterations ( *for the sake of the problem, don’t be concerned with the quality of the source code*).
function value = banana(x0)
a = x0(1);
b = x0(2);
x = x0(3);
y = x0(4);
value = (1 – x + a)^2 + 100 * (y – b * (x – a)^2)^2;
end
a = int8(4 * rand()) / 2;
b = int8(4 * rand()) / 2;
[x1, y1] = random(a, b);
[x2, y2] = random(a, b);
[x3, y3] = random(a, b);
[x4, y4] = random(a, b);
x = [x1; x2; x3; x4];
y = [y1; y2; y3; y4];
save values.mat;
for i = 1
x0 = [a, b, x(i), y(i)];
options = optimset(‘PlotFcns’, { @optimplotfval });
[solution_point, fval,exitflag,output] = fminsearch(@banana,double(x0),options);
old_x=[x(i),y(i)];
new_x_1 = linspace(-2,2,51);
new_x_2 = linspace(-2,2,51);
for j=1:51
if(new_x_1(j)>= old_x(1))
new_x_1(j)=old_x(1);
break;
end
end
for j=1:51
if(new_x_2(j)>= old_x(2))
new_x_2(j)=old_x(2);
break;
end
end
end
<</matlabcentral/answers/uploaded_files/66646/untitled.png>>
*My questions are,*
(1) Is this plot really showing the output of Rosenbrock’s function against number of iterations?
(2) The plot shows a sudden slump in the output of the function. I need to show this plot in logarithmic form, so that a smooth curve is plotted. How can I do that? optimization, plotting, graphics, graph MATLAB Answers — New Questions
Remove whitespace in Legend with Latex Labels
Hi, does anyone know why there is so much whitespace after each entry in the legend here? I’ve tried to shrink the legend width by doing:
pos = legend.Position;
pos(3) = 0.5*pos(3);
legend.Position = pos;
But this hasn’t worked. I’ve attached the code below.
Any help would be appreciated.
Here is the code below: (I’m sure there is a better way to write the legend names out, but I’m lazy and this was good enough for my purposes).
f = figure;
hold on
plot(Cl, Cm(:,1),"-bsquare")
plot(Cl, Cm(:,3),"-bdiamond")
plot(Cl, Cm(:,5),"-b^")
plot(Cl, Cm(:,7),"-bv")
plot(Cl, Cm(:,2),"-rsquare")
plot(Cl, Cm(:,4),"-rdiamond")
plot(Cl, Cm(:,6),"-r^")
plot(Cl, Cm(:,8),"-rv")
hold off
xlim([-1.1, 1.4])
leg = legend({‘$x_{cg}=0.18bar{c}, delta_e = 0degree $’,’$x_{cg}=0.22bar{c}, delta_e = 0degree $’,’$x_{cg}=0.26bar{c}, delta_e = 0degree $’,’$x_{cg}=0.30bar{c}, delta_e = 0degree $’,’$x_{cg}=0.18bar{c}, delta_e = 5degree $’,’$x_{cg}=0.22bar{c}, delta_e = 5degree $’,’$x_{cg}=0.26bar{c}, delta_e = 5degree $’,’$x_{cg}=0.30bar{c}, delta_e = 5degree $’},’Interpreter’,’latex’, ‘Location’,’northeast’, ‘FontSize’,11);
% pos = leg.Position;
% pos(3) = 0.25*pos(3); % Tried this, didn’t work
% leg.Position = pos;
grid on
ax = gca;
ax.GridLineWidth = 1.5;
ax.XAxis.MinorTick = ‘on’;
ax.XMinorGrid = ‘on’;
ax.YAxis.MinorTick = ‘on’;
ax.YMinorGrid = ‘on’;
f.Units = ‘pixels’;
f.Position = [10,10,990,490];Hi, does anyone know why there is so much whitespace after each entry in the legend here? I’ve tried to shrink the legend width by doing:
pos = legend.Position;
pos(3) = 0.5*pos(3);
legend.Position = pos;
But this hasn’t worked. I’ve attached the code below.
Any help would be appreciated.
Here is the code below: (I’m sure there is a better way to write the legend names out, but I’m lazy and this was good enough for my purposes).
f = figure;
hold on
plot(Cl, Cm(:,1),"-bsquare")
plot(Cl, Cm(:,3),"-bdiamond")
plot(Cl, Cm(:,5),"-b^")
plot(Cl, Cm(:,7),"-bv")
plot(Cl, Cm(:,2),"-rsquare")
plot(Cl, Cm(:,4),"-rdiamond")
plot(Cl, Cm(:,6),"-r^")
plot(Cl, Cm(:,8),"-rv")
hold off
xlim([-1.1, 1.4])
leg = legend({‘$x_{cg}=0.18bar{c}, delta_e = 0degree $’,’$x_{cg}=0.22bar{c}, delta_e = 0degree $’,’$x_{cg}=0.26bar{c}, delta_e = 0degree $’,’$x_{cg}=0.30bar{c}, delta_e = 0degree $’,’$x_{cg}=0.18bar{c}, delta_e = 5degree $’,’$x_{cg}=0.22bar{c}, delta_e = 5degree $’,’$x_{cg}=0.26bar{c}, delta_e = 5degree $’,’$x_{cg}=0.30bar{c}, delta_e = 5degree $’},’Interpreter’,’latex’, ‘Location’,’northeast’, ‘FontSize’,11);
% pos = leg.Position;
% pos(3) = 0.25*pos(3); % Tried this, didn’t work
% leg.Position = pos;
grid on
ax = gca;
ax.GridLineWidth = 1.5;
ax.XAxis.MinorTick = ‘on’;
ax.XMinorGrid = ‘on’;
ax.YAxis.MinorTick = ‘on’;
ax.YMinorGrid = ‘on’;
f.Units = ‘pixels’;
f.Position = [10,10,990,490]; Hi, does anyone know why there is so much whitespace after each entry in the legend here? I’ve tried to shrink the legend width by doing:
pos = legend.Position;
pos(3) = 0.5*pos(3);
legend.Position = pos;
But this hasn’t worked. I’ve attached the code below.
Any help would be appreciated.
Here is the code below: (I’m sure there is a better way to write the legend names out, but I’m lazy and this was good enough for my purposes).
f = figure;
hold on
plot(Cl, Cm(:,1),"-bsquare")
plot(Cl, Cm(:,3),"-bdiamond")
plot(Cl, Cm(:,5),"-b^")
plot(Cl, Cm(:,7),"-bv")
plot(Cl, Cm(:,2),"-rsquare")
plot(Cl, Cm(:,4),"-rdiamond")
plot(Cl, Cm(:,6),"-r^")
plot(Cl, Cm(:,8),"-rv")
hold off
xlim([-1.1, 1.4])
leg = legend({‘$x_{cg}=0.18bar{c}, delta_e = 0degree $’,’$x_{cg}=0.22bar{c}, delta_e = 0degree $’,’$x_{cg}=0.26bar{c}, delta_e = 0degree $’,’$x_{cg}=0.30bar{c}, delta_e = 0degree $’,’$x_{cg}=0.18bar{c}, delta_e = 5degree $’,’$x_{cg}=0.22bar{c}, delta_e = 5degree $’,’$x_{cg}=0.26bar{c}, delta_e = 5degree $’,’$x_{cg}=0.30bar{c}, delta_e = 5degree $’},’Interpreter’,’latex’, ‘Location’,’northeast’, ‘FontSize’,11);
% pos = leg.Position;
% pos(3) = 0.25*pos(3); % Tried this, didn’t work
% leg.Position = pos;
grid on
ax = gca;
ax.GridLineWidth = 1.5;
ax.XAxis.MinorTick = ‘on’;
ax.XMinorGrid = ‘on’;
ax.YAxis.MinorTick = ‘on’;
ax.YMinorGrid = ‘on’;
f.Units = ‘pixels’;
f.Position = [10,10,990,490]; legend MATLAB Answers — New Questions
Is there a way in Simulink/System Composer to override the drag and drop event?
I wish to drag a block from a different application and drop it into simulink/System Composer. Upon dropping the block, Simulink should call a pre-defined Matlab function.
Is this kind of drop-handler customization possible?I wish to drag a block from a different application and drop it into simulink/System Composer. Upon dropping the block, Simulink should call a pre-defined Matlab function.
Is this kind of drop-handler customization possible? I wish to drag a block from a different application and drop it into simulink/System Composer. Upon dropping the block, Simulink should call a pre-defined Matlab function.
Is this kind of drop-handler customization possible? customization, simulink, systemcomposer, ui MATLAB Answers — New Questions
simulink matlab function dimension error
In my first Matlab function, I set the input to a 4×1 vector, a feedback vector, and a scalar, but the output is a scalar. Please tell me how to make the output a 4×1 vector. I have attached my simulink fileIn my first Matlab function, I set the input to a 4×1 vector, a feedback vector, and a scalar, but the output is a scalar. Please tell me how to make the output a 4×1 vector. I have attached my simulink file In my first Matlab function, I set the input to a 4×1 vector, a feedback vector, and a scalar, but the output is a scalar. Please tell me how to make the output a 4×1 vector. I have attached my simulink file simulink MATLAB Answers — New Questions
Help me understand this PQ Controller Model (ABC to dq-reference using Park Transform) in Simulink
Good day! I’m currently having troubles interpreting this block diagram of a PQ controller, which I will be applying for BESS support in a bus network.
Right now, I’m figuring out how I should implement the Park Transform block to convert from ABC to dq reference in Simulink. I’m also confused when I should implement the transfer functions and PI controllers (considering the dq-reference).
If any further context is needed, I will try my best to provide more.
Also, if you are an expert in control modeling, especially in BESS, I would love to keep in contact with you for more help, as I have more questions with regards to my BESS model for voltage and frequency support.
Thank you very much!Good day! I’m currently having troubles interpreting this block diagram of a PQ controller, which I will be applying for BESS support in a bus network.
Right now, I’m figuring out how I should implement the Park Transform block to convert from ABC to dq reference in Simulink. I’m also confused when I should implement the transfer functions and PI controllers (considering the dq-reference).
If any further context is needed, I will try my best to provide more.
Also, if you are an expert in control modeling, especially in BESS, I would love to keep in contact with you for more help, as I have more questions with regards to my BESS model for voltage and frequency support.
Thank you very much! Good day! I’m currently having troubles interpreting this block diagram of a PQ controller, which I will be applying for BESS support in a bus network.
Right now, I’m figuring out how I should implement the Park Transform block to convert from ABC to dq reference in Simulink. I’m also confused when I should implement the transfer functions and PI controllers (considering the dq-reference).
If any further context is needed, I will try my best to provide more.
Also, if you are an expert in control modeling, especially in BESS, I would love to keep in contact with you for more help, as I have more questions with regards to my BESS model for voltage and frequency support.
Thank you very much! simulink, control, transfer function MATLAB Answers — New Questions
Unable to use structName.?ClassName for VideoWriter class
I am finding the structName.?ClassName method of arguments validation does not work when trying to validate name-value arguments for the VideoWriter class.
I have a short function:
function myDemo(videoData,fileName,vwOpts)
arguments
videoData
fileName
vwOpts.?VideoWriter
end
disp(vwOpts);
videoObj = VideoWriter(fileName);
% Open video, write, close, etc.
end % MakeVideo
I would expect that calling this function with VideoWriter properties such as FrameRate would result in vwOpts being a struct that contains values passed to the function. However, I am getting the error:
>> myDemo(0:10,"myVideo.avi","FrameRate",20)
Error using myDemo
Too many input arguments.
I validated my approach by attempting to filter for arguments to the Bar() function by mimicking the matlab.graphics.chart.primitive.Bar example shown in the documentation and was successful.
I noticed I get this same error when failing to specify the full name of the Bar class, so looked for other methods of specifying the VideoWriter class, using matlab.audiovideo.VideoWriter as the full class name, with no success.
What am I missing about this approach? Is there a way of locating the full name of the VideoWriter class, or is there some reason I should not expect this example to work?
Thanks!I am finding the structName.?ClassName method of arguments validation does not work when trying to validate name-value arguments for the VideoWriter class.
I have a short function:
function myDemo(videoData,fileName,vwOpts)
arguments
videoData
fileName
vwOpts.?VideoWriter
end
disp(vwOpts);
videoObj = VideoWriter(fileName);
% Open video, write, close, etc.
end % MakeVideo
I would expect that calling this function with VideoWriter properties such as FrameRate would result in vwOpts being a struct that contains values passed to the function. However, I am getting the error:
>> myDemo(0:10,"myVideo.avi","FrameRate",20)
Error using myDemo
Too many input arguments.
I validated my approach by attempting to filter for arguments to the Bar() function by mimicking the matlab.graphics.chart.primitive.Bar example shown in the documentation and was successful.
I noticed I get this same error when failing to specify the full name of the Bar class, so looked for other methods of specifying the VideoWriter class, using matlab.audiovideo.VideoWriter as the full class name, with no success.
What am I missing about this approach? Is there a way of locating the full name of the VideoWriter class, or is there some reason I should not expect this example to work?
Thanks! I am finding the structName.?ClassName method of arguments validation does not work when trying to validate name-value arguments for the VideoWriter class.
I have a short function:
function myDemo(videoData,fileName,vwOpts)
arguments
videoData
fileName
vwOpts.?VideoWriter
end
disp(vwOpts);
videoObj = VideoWriter(fileName);
% Open video, write, close, etc.
end % MakeVideo
I would expect that calling this function with VideoWriter properties such as FrameRate would result in vwOpts being a struct that contains values passed to the function. However, I am getting the error:
>> myDemo(0:10,"myVideo.avi","FrameRate",20)
Error using myDemo
Too many input arguments.
I validated my approach by attempting to filter for arguments to the Bar() function by mimicking the matlab.graphics.chart.primitive.Bar example shown in the documentation and was successful.
I noticed I get this same error when failing to specify the full name of the Bar class, so looked for other methods of specifying the VideoWriter class, using matlab.audiovideo.VideoWriter as the full class name, with no success.
What am I missing about this approach? Is there a way of locating the full name of the VideoWriter class, or is there some reason I should not expect this example to work?
Thanks! arguments validation MATLAB Answers — New Questions
using standalone app designer how to print figure using pushbutton ,thanks .
using standalone app designer need to using pushbutton to print figures.using standalone app designer need to using pushbutton to print figures. using standalone app designer need to using pushbutton to print figures. app designer, print figure of standalone app designer using push MATLAB Answers — New Questions
ilaplace doesn’t handle tanh()
While doing convolutions, I wanted to convolve a function f() with a square wave. There are two Laplace transformations of a square wave that I tried, as shown below. The problem occurs when I do the inverse Laplace on the Laplace of the original square wave, or more precisely when I attempt to plot that result. (In the code below I only show the inverse laplace of the laplace transformed squarewave, not the convolution.)
% P1 = ilaplace( 1/s*(1-2/(exp(T/2*s)+1)) );
P2 = ilaplace( 1/s*tanh(s*T/4) );
% Unfortunately, both don’t work with the symbolic toolbox.
assume(P2,’real’)
Tsteps = 0.1:0.5:20;
num = vpa(subs(P2,t,Tsteps),6)’;
stairs(Tsteps(:),num(:,1))
When I inspect the contents of num, the (voluminous!) contents are largely symbolic:
[conj(subs(diff(floor(s), s), s, -400))*(35.334851093590259552001953125 + 0.00000000023283064365386962890625i) + conj(s …
My program works with ‘simpler’ functions, like sinewaves, and then plots OK.
The stairs function faults in the (undocumented) getRealData().
Do I have to assume() something on the arguments of laplace(), ilaplace(), subs() or vpa()?
% getRealData returns the real components of ARGS. If ARGS contains any
% complex data, a warning is displayed. If any of ARGS are not numeric
% and cannot be converted to a double, an error is thrown.While doing convolutions, I wanted to convolve a function f() with a square wave. There are two Laplace transformations of a square wave that I tried, as shown below. The problem occurs when I do the inverse Laplace on the Laplace of the original square wave, or more precisely when I attempt to plot that result. (In the code below I only show the inverse laplace of the laplace transformed squarewave, not the convolution.)
% P1 = ilaplace( 1/s*(1-2/(exp(T/2*s)+1)) );
P2 = ilaplace( 1/s*tanh(s*T/4) );
% Unfortunately, both don’t work with the symbolic toolbox.
assume(P2,’real’)
Tsteps = 0.1:0.5:20;
num = vpa(subs(P2,t,Tsteps),6)’;
stairs(Tsteps(:),num(:,1))
When I inspect the contents of num, the (voluminous!) contents are largely symbolic:
[conj(subs(diff(floor(s), s), s, -400))*(35.334851093590259552001953125 + 0.00000000023283064365386962890625i) + conj(s …
My program works with ‘simpler’ functions, like sinewaves, and then plots OK.
The stairs function faults in the (undocumented) getRealData().
Do I have to assume() something on the arguments of laplace(), ilaplace(), subs() or vpa()?
% getRealData returns the real components of ARGS. If ARGS contains any
% complex data, a warning is displayed. If any of ARGS are not numeric
% and cannot be converted to a double, an error is thrown. While doing convolutions, I wanted to convolve a function f() with a square wave. There are two Laplace transformations of a square wave that I tried, as shown below. The problem occurs when I do the inverse Laplace on the Laplace of the original square wave, or more precisely when I attempt to plot that result. (In the code below I only show the inverse laplace of the laplace transformed squarewave, not the convolution.)
% P1 = ilaplace( 1/s*(1-2/(exp(T/2*s)+1)) );
P2 = ilaplace( 1/s*tanh(s*T/4) );
% Unfortunately, both don’t work with the symbolic toolbox.
assume(P2,’real’)
Tsteps = 0.1:0.5:20;
num = vpa(subs(P2,t,Tsteps),6)’;
stairs(Tsteps(:),num(:,1))
When I inspect the contents of num, the (voluminous!) contents are largely symbolic:
[conj(subs(diff(floor(s), s), s, -400))*(35.334851093590259552001953125 + 0.00000000023283064365386962890625i) + conj(s …
My program works with ‘simpler’ functions, like sinewaves, and then plots OK.
The stairs function faults in the (undocumented) getRealData().
Do I have to assume() something on the arguments of laplace(), ilaplace(), subs() or vpa()?
% getRealData returns the real components of ARGS. If ARGS contains any
% complex data, a warning is displayed. If any of ARGS are not numeric
% and cannot be converted to a double, an error is thrown. laplace, inverse laplace, symbolic, plot MATLAB Answers — New Questions
How can I insert breakpoints and implement debug step-by-step execution when running the FFE class functions in Serdes Designer Tools?
CEI-224G-MR Transmitter/Receiver IBIS-AMI Model – MATLAB & Simulink
How can I insert breakpoints and implement debug step-by-step execution when running the FFE class functions in Serdes Designer Tools? In the CEI-224G-MR Transmitter/Receiver IBIS-AMI Model example provided by MATLAB, I want to step through the stepImpl function in FFE to learn the specific calculation process within the function.
Step 1: Added print statements and inserted breakpoints in the stepImpl function.
Step 2: Clicked the run button in the Simulink menu bar to start simulation.
Step 3: The ‘stepImpl stop’ print information can be seen in Simulink’s Diagnostic Viewer, indicating that the program has executed into the stepImpl function. However, the program does not pause here and eventually completes running.
How can I make the program pause at the stepImpl function of FFE for debug debugging?CEI-224G-MR Transmitter/Receiver IBIS-AMI Model – MATLAB & Simulink
How can I insert breakpoints and implement debug step-by-step execution when running the FFE class functions in Serdes Designer Tools? In the CEI-224G-MR Transmitter/Receiver IBIS-AMI Model example provided by MATLAB, I want to step through the stepImpl function in FFE to learn the specific calculation process within the function.
Step 1: Added print statements and inserted breakpoints in the stepImpl function.
Step 2: Clicked the run button in the Simulink menu bar to start simulation.
Step 3: The ‘stepImpl stop’ print information can be seen in Simulink’s Diagnostic Viewer, indicating that the program has executed into the stepImpl function. However, the program does not pause here and eventually completes running.
How can I make the program pause at the stepImpl function of FFE for debug debugging? CEI-224G-MR Transmitter/Receiver IBIS-AMI Model – MATLAB & Simulink
How can I insert breakpoints and implement debug step-by-step execution when running the FFE class functions in Serdes Designer Tools? In the CEI-224G-MR Transmitter/Receiver IBIS-AMI Model example provided by MATLAB, I want to step through the stepImpl function in FFE to learn the specific calculation process within the function.
Step 1: Added print statements and inserted breakpoints in the stepImpl function.
Step 2: Clicked the run button in the Simulink menu bar to start simulation.
Step 3: The ‘stepImpl stop’ print information can be seen in Simulink’s Diagnostic Viewer, indicating that the program has executed into the stepImpl function. However, the program does not pause here and eventually completes running.
How can I make the program pause at the stepImpl function of FFE for debug debugging? serdes, ffe, debug, 224g, 112g, breakpoint, stepimpl, classdef MATLAB Answers — New Questions
Plotting sum of two vectors
I’m using Runge-Kutta method to solve a coupled system of EDO.
The function y1 is valid until a certain time (here is the "ts2" parameter). After this time, y8 is valid.
I want to plot y1 from 0 to ts2 (which happens without problem) and y8 from ts2 until the end.
But, I get the error "Arrays have incompatible sizes for this operation." during the second part.
%Parameters
or =0.2;
oc = 0.2;
gamma = 0.01;
gam=0.01;
Gamma = 1;
Gamma1 = Gamma;
Gamma2 = Gamma;
Gamma3 = 9/10;
Gamma5 = 1/10;
sig13ts2 = 5.2;
sig57ts = 2.6;
ts2=10;
f1 = @(t,y1,y2) (-Gamma/2-gam/2)*y1 -i*or*y2;
f2 = @(t,y1,y2) -i*or*y1+(-gam/2)*y2;
h=0.0001;
t(1) = 0;
y1(1) = 0;
y2(1) = sig57ts;
for j=1:1100000
t(j+1)=t(j)+h;
k1y1 = h*f1(t(j), y1(j), y2(j));
k1y2 = h*f2(t(j), y1(j), y2(j));
k2y1 = h*f1(t(j)+h/2,y1(j)+k1y1/2,y2(j)+k1y2/2);
k2y2 = h*f2(t(j)+h/2,y1(j)+k1y1/2,y2(j)+k1y2/2);
k3y1 = h*f1(t(j)+h/2,y1(j)+k2y1/2,y2(j)+k2y2/2);
k3y2 = h*f2(t(j)+h/2,y1(j)+k2y1/2,y2(j)+k2y2/2);
k4y1 = h*f1(t(j)+h, y1(j)+k3y1, y2(j)+k3y2);
k4y2 = h*f2(t(j)+h, y1(j)+k3y1, y2(j)+k3y2);
y1(j+1)=y1(j) + (k1y1 + 2*k2y1 + 2*k3y1 + k4y1)/6;
y2(j+1)=y2(j) + (k1y2 + 2*k2y2 + 2*k3y2 + k4y2)/6;
end
plot(t(1:ts2/h),abs(y1(1:ts2/h)).^2)
xlim([0 60])
hold on
%% Ligando C apos ts2
f3 = @(t,y3,y4,y5,y6,y7,y8) -(+Gamma2/2+gam/2)*y3+1i*oc*y4-1i*oc*y5;
f4 = @(t,y3,y4,y5,y6,y7,y8) 1i*oc*y3-(+gamma/2)*y4+Gamma3*y5-1i*oc*y6;
f5 = @(t,y3,y4,y5,y6,y7,y8) -1i*oc*y3-(Gamma1)*y5+1i*oc*y6;
f6 = @(t,y3,y4,y5,y6,y7,y8) -1i*oc*y4+1i*oc*y5+(-Gamma1/2-gamma/2)*y6;
f7 = @(t,y3,y4,y5,y6,y7,y8) -1i*or*y8+(-Gamma2/2-gam/2)*y7;
f8 = @(t,y3,y4,y5,y6,y7,y8) -1i*or*y7+Gamma5*y5-(gam/2)*y8;
t(1) = ts2;
y3(1) = 0;
y4(1) = sig13ts2;
y5(1) = 0;
y6(1) = 0;
y7(1) = y1(ts2/h);
y8(1) = y2(ts2/h);
for j=1:1000000
t(j+1)=t(j)+h;
k1y3 = h*f3(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y4 = h*f4(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y5 = h*f5(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y6 = h*f6(t(j), y3(j), y4(j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/6;
y8(j+1)=y8(j) + (k1y8 + 2*k2y8 + 2*k3y8 + k4y8)/6;
end
plot(t,abs(y8).^2+abs(y1(ts2/h:end)).^2)I’m using Runge-Kutta method to solve a coupled system of EDO.
The function y1 is valid until a certain time (here is the "ts2" parameter). After this time, y8 is valid.
I want to plot y1 from 0 to ts2 (which happens without problem) and y8 from ts2 until the end.
But, I get the error "Arrays have incompatible sizes for this operation." during the second part.
%Parameters
or =0.2;
oc = 0.2;
gamma = 0.01;
gam=0.01;
Gamma = 1;
Gamma1 = Gamma;
Gamma2 = Gamma;
Gamma3 = 9/10;
Gamma5 = 1/10;
sig13ts2 = 5.2;
sig57ts = 2.6;
ts2=10;
f1 = @(t,y1,y2) (-Gamma/2-gam/2)*y1 -i*or*y2;
f2 = @(t,y1,y2) -i*or*y1+(-gam/2)*y2;
h=0.0001;
t(1) = 0;
y1(1) = 0;
y2(1) = sig57ts;
for j=1:1100000
t(j+1)=t(j)+h;
k1y1 = h*f1(t(j), y1(j), y2(j));
k1y2 = h*f2(t(j), y1(j), y2(j));
k2y1 = h*f1(t(j)+h/2,y1(j)+k1y1/2,y2(j)+k1y2/2);
k2y2 = h*f2(t(j)+h/2,y1(j)+k1y1/2,y2(j)+k1y2/2);
k3y1 = h*f1(t(j)+h/2,y1(j)+k2y1/2,y2(j)+k2y2/2);
k3y2 = h*f2(t(j)+h/2,y1(j)+k2y1/2,y2(j)+k2y2/2);
k4y1 = h*f1(t(j)+h, y1(j)+k3y1, y2(j)+k3y2);
k4y2 = h*f2(t(j)+h, y1(j)+k3y1, y2(j)+k3y2);
y1(j+1)=y1(j) + (k1y1 + 2*k2y1 + 2*k3y1 + k4y1)/6;
y2(j+1)=y2(j) + (k1y2 + 2*k2y2 + 2*k3y2 + k4y2)/6;
end
plot(t(1:ts2/h),abs(y1(1:ts2/h)).^2)
xlim([0 60])
hold on
%% Ligando C apos ts2
f3 = @(t,y3,y4,y5,y6,y7,y8) -(+Gamma2/2+gam/2)*y3+1i*oc*y4-1i*oc*y5;
f4 = @(t,y3,y4,y5,y6,y7,y8) 1i*oc*y3-(+gamma/2)*y4+Gamma3*y5-1i*oc*y6;
f5 = @(t,y3,y4,y5,y6,y7,y8) -1i*oc*y3-(Gamma1)*y5+1i*oc*y6;
f6 = @(t,y3,y4,y5,y6,y7,y8) -1i*oc*y4+1i*oc*y5+(-Gamma1/2-gamma/2)*y6;
f7 = @(t,y3,y4,y5,y6,y7,y8) -1i*or*y8+(-Gamma2/2-gam/2)*y7;
f8 = @(t,y3,y4,y5,y6,y7,y8) -1i*or*y7+Gamma5*y5-(gam/2)*y8;
t(1) = ts2;
y3(1) = 0;
y4(1) = sig13ts2;
y5(1) = 0;
y6(1) = 0;
y7(1) = y1(ts2/h);
y8(1) = y2(ts2/h);
for j=1:1000000
t(j+1)=t(j)+h;
k1y3 = h*f3(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y4 = h*f4(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y5 = h*f5(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y6 = h*f6(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y7 = h*f7(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y8 = h*f8(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k2y3 = h*f3(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y4 = h*f4(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y5 = h*f5(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y6 = h*f6(t(j)+h/2,y3(j)+k1y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)+k3y8);
k4y5 = h*f5(t(j)+h, y3(j)+k3y3, y4(j)+k3y4,y5(j)+k3y5,y6(j)+k3y6,y7(j)+k3y7,y8(j)+k3y8);
k4y6 = h*f6(t(j)+h, y3(j)+k3y3, y4(j)+k3y4,y5(j)+k3y5,y6(j)+k3y6,y7(j)+k3y7,y8(j)+k3y8);
k4y7 = h*f7(t(j)+h, y3(j)+k3y3, y4(j)+k3y4,y5(j)+k3y5,y6(j)+k3y6,y7(j)+k3y7,y8(j)+k3y8);
k4y8 = h*f8(t(j)+h, y3(j)+k3y3, y4(j)+k3y4,y5(j)+k3y5,y6(j)+k3y6,y7(j)+k3y7,y8(j)+k3y8);
y3(j+1)=y3(j) + (k1y3 + 2*k2y3 + 2*k3y3 + k4y3)/6;
y4(j+1)=y4(j) + (k1y4 + 2*k2y4 + 2*k3y4 + k4y4)/6;
y5(j+1)=y5(j) + (k1y5 + 2*k2y5 + 2*k3y5 + k4y5)/6;
y6(j+1)=y6(j) + (k1y6 + 2*k2y6 + 2*k3y6 + k4y6)/6;
y7(j+1)=y7(j) + (k1y7 + 2*k2y7 + 2*k3y7 + k4y7)/6;
y8(j+1)=y8(j) + (k1y8 + 2*k2y8 + 2*k3y8 + k4y8)/6;
end
plot(t,abs(y8).^2+abs(y1(ts2/h:end)).^2) I’m using Runge-Kutta method to solve a coupled system of EDO.
The function y1 is valid until a certain time (here is the "ts2" parameter). After this time, y8 is valid.
I want to plot y1 from 0 to ts2 (which happens without problem) and y8 from ts2 until the end.
But, I get the error "Arrays have incompatible sizes for this operation." during the second part.
%Parameters
or =0.2;
oc = 0.2;
gamma = 0.01;
gam=0.01;
Gamma = 1;
Gamma1 = Gamma;
Gamma2 = Gamma;
Gamma3 = 9/10;
Gamma5 = 1/10;
sig13ts2 = 5.2;
sig57ts = 2.6;
ts2=10;
f1 = @(t,y1,y2) (-Gamma/2-gam/2)*y1 -i*or*y2;
f2 = @(t,y1,y2) -i*or*y1+(-gam/2)*y2;
h=0.0001;
t(1) = 0;
y1(1) = 0;
y2(1) = sig57ts;
for j=1:1100000
t(j+1)=t(j)+h;
k1y1 = h*f1(t(j), y1(j), y2(j));
k1y2 = h*f2(t(j), y1(j), y2(j));
k2y1 = h*f1(t(j)+h/2,y1(j)+k1y1/2,y2(j)+k1y2/2);
k2y2 = h*f2(t(j)+h/2,y1(j)+k1y1/2,y2(j)+k1y2/2);
k3y1 = h*f1(t(j)+h/2,y1(j)+k2y1/2,y2(j)+k2y2/2);
k3y2 = h*f2(t(j)+h/2,y1(j)+k2y1/2,y2(j)+k2y2/2);
k4y1 = h*f1(t(j)+h, y1(j)+k3y1, y2(j)+k3y2);
k4y2 = h*f2(t(j)+h, y1(j)+k3y1, y2(j)+k3y2);
y1(j+1)=y1(j) + (k1y1 + 2*k2y1 + 2*k3y1 + k4y1)/6;
y2(j+1)=y2(j) + (k1y2 + 2*k2y2 + 2*k3y2 + k4y2)/6;
end
plot(t(1:ts2/h),abs(y1(1:ts2/h)).^2)
xlim([0 60])
hold on
%% Ligando C apos ts2
f3 = @(t,y3,y4,y5,y6,y7,y8) -(+Gamma2/2+gam/2)*y3+1i*oc*y4-1i*oc*y5;
f4 = @(t,y3,y4,y5,y6,y7,y8) 1i*oc*y3-(+gamma/2)*y4+Gamma3*y5-1i*oc*y6;
f5 = @(t,y3,y4,y5,y6,y7,y8) -1i*oc*y3-(Gamma1)*y5+1i*oc*y6;
f6 = @(t,y3,y4,y5,y6,y7,y8) -1i*oc*y4+1i*oc*y5+(-Gamma1/2-gamma/2)*y6;
f7 = @(t,y3,y4,y5,y6,y7,y8) -1i*or*y8+(-Gamma2/2-gam/2)*y7;
f8 = @(t,y3,y4,y5,y6,y7,y8) -1i*or*y7+Gamma5*y5-(gam/2)*y8;
t(1) = ts2;
y3(1) = 0;
y4(1) = sig13ts2;
y5(1) = 0;
y6(1) = 0;
y7(1) = y1(ts2/h);
y8(1) = y2(ts2/h);
for j=1:1000000
t(j+1)=t(j)+h;
k1y3 = h*f3(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y4 = h*f4(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y5 = h*f5(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y6 = h*f6(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y7 = h*f7(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k1y8 = h*f8(t(j), y3(j), y4(j), y5(j), y6(j), y7(j), y8(j));
k2y3 = h*f3(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y4 = h*f4(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y5 = h*f5(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y6 = h*f6(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y7 = h*f7(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k2y8 = h*f8(t(j)+h/2,y3(j)+k1y3/2,y4(j)+k1y4/2,y5(j)+k1y5/2,y6(j)+k1y6/2,y7(j)++k1y7/2,y8(j)+k1y8/2);
k3y3 = h*f3(t(j)+h/2,y3(j)+k2y3/2,y4(j)+k2y4/2,y5(j)+k2y5/2,y6(j)+k2y6/2,y7(j)+k2y7/2,y8(j)+k2y8/2);
k3y4 = h*f4(t(j)+h/2,y3(j)+k2y3/2,y4(j)+k2y4/2,y5(j)+k2y5/2,y6(j)+k2y6/2,y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/6;
y5(j+1)=y5(j) + (k1y5 + 2*k2y5 + 2*k3y5 + k4y5)/6;
y6(j+1)=y6(j) + (k1y6 + 2*k2y6 + 2*k3y6 + k4y6)/6;
y7(j+1)=y7(j) + (k1y7 + 2*k2y7 + 2*k3y7 + k4y7)/6;
y8(j+1)=y8(j) + (k1y8 + 2*k2y8 + 2*k3y8 + k4y8)/6;
end
plot(t,abs(y8).^2+abs(y1(ts2/h:end)).^2) vector, plot, numerical integration MATLAB Answers — New Questions
R2017b GUIDE does not create callbacks
Have a GUIDE GUI with associated code created usng R2015b. In R2015b, GUIDE offers automatic creation of default callbacks for GUI a control – e.g., a toolbar toggle – and writes the function skeleton into the GUI code.
This does not happen with my R2017b installation. Furthermore, specifying the callbacks manually on the property sheet also does not create the skeleton/template in the GUI code?
Work around?Have a GUIDE GUI with associated code created usng R2015b. In R2015b, GUIDE offers automatic creation of default callbacks for GUI a control – e.g., a toolbar toggle – and writes the function skeleton into the GUI code.
This does not happen with my R2017b installation. Furthermore, specifying the callbacks manually on the property sheet also does not create the skeleton/template in the GUI code?
Work around? Have a GUIDE GUI with associated code created usng R2015b. In R2015b, GUIDE offers automatic creation of default callbacks for GUI a control – e.g., a toolbar toggle – and writes the function skeleton into the GUI code.
This does not happen with my R2017b installation. Furthermore, specifying the callbacks manually on the property sheet also does not create the skeleton/template in the GUI code?
Work around? guide, callback MATLAB Answers — New Questions
Transpose matrix and your transposition
How can I transpose Thais Matrix: Matrix = zeros(3500000,3);How can I transpose Thais Matrix: Matrix = zeros(3500000,3); How can I transpose Thais Matrix: Matrix = zeros(3500000,3); transpose matriz MATLAB Answers — New Questions
FMCW radar chirp signal parameter
Hi
I’m pretty new to matlab and I’m currently trying to create a chirp transmitting signal for a fmcw radar setup in simulink.
The constrains are:
transmitting frequency f0 = 2.4 GHz
object distance reference = 200 m
Maximum bandwidth B = 80 MHz
I have tried using chirp blocks in simulink but the result didn’t look like a chirp signal.
any help setting up the chirp signal is much appreciated : )Hi
I’m pretty new to matlab and I’m currently trying to create a chirp transmitting signal for a fmcw radar setup in simulink.
The constrains are:
transmitting frequency f0 = 2.4 GHz
object distance reference = 200 m
Maximum bandwidth B = 80 MHz
I have tried using chirp blocks in simulink but the result didn’t look like a chirp signal.
any help setting up the chirp signal is much appreciated : ) Hi
I’m pretty new to matlab and I’m currently trying to create a chirp transmitting signal for a fmcw radar setup in simulink.
The constrains are:
transmitting frequency f0 = 2.4 GHz
object distance reference = 200 m
Maximum bandwidth B = 80 MHz
I have tried using chirp blocks in simulink but the result didn’t look like a chirp signal.
any help setting up the chirp signal is much appreciated : ) fmcw chirp MATLAB Answers — New Questions
How to form clusters correctly while implementing the work “Energy Centroid Clustering Algorithm”?
I have been implementing the work titled "Energy centroid clustering algorithm to enhance the network lifetime of wireless sensor networks". However, even after following the psuedocodes I am not able to form clusters correctly initially. The Cluster Heads are one below the other rather than being distributed in the sensing region.
The above images are of my implementation. Below is the image as given in the paper.
I have problems in correctly interpreting the Psuedocode-2 given in the paper.
Also, what values of a sensor node’s transmission radius are assumed?
What should be the default compression ratio after data aggregation by the Cluster Head, as it is not given in the paper?
Any help would be highly appreciated.I have been implementing the work titled "Energy centroid clustering algorithm to enhance the network lifetime of wireless sensor networks". However, even after following the psuedocodes I am not able to form clusters correctly initially. The Cluster Heads are one below the other rather than being distributed in the sensing region.
The above images are of my implementation. Below is the image as given in the paper.
I have problems in correctly interpreting the Psuedocode-2 given in the paper.
Also, what values of a sensor node’s transmission radius are assumed?
What should be the default compression ratio after data aggregation by the Cluster Head, as it is not given in the paper?
Any help would be highly appreciated. I have been implementing the work titled "Energy centroid clustering algorithm to enhance the network lifetime of wireless sensor networks". However, even after following the psuedocodes I am not able to form clusters correctly initially. The Cluster Heads are one below the other rather than being distributed in the sensing region.
The above images are of my implementation. Below is the image as given in the paper.
I have problems in correctly interpreting the Psuedocode-2 given in the paper.
Also, what values of a sensor node’s transmission radius are assumed?
What should be the default compression ratio after data aggregation by the Cluster Head, as it is not given in the paper?
Any help would be highly appreciated. wireless sensor networks, clustering MATLAB Answers — New Questions
Readall stops because of non-existing data, Can I skip these?
Hi y’all,
When I run my code I get an error:
Error using matlab.io.datastore.TabularDatastore/readall (line 196)
Unable to parse a "Numeric" field when reading row 39898, field 7.
Actual Text: "N,07121.27550,W,2,28,0.9,0.79,M,,,5,0131*01"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive
Is there a way to have the readall function skip these ,,, non-existing values in my data?
Code:
function [] = each_day_table(folder_referenced, output_folder_location)
dimention = size(folder_referenced) ;
for i = 1:dimention(2)
datastore_result = datastore(folder_referenced(i)) ;
original_data = readall(datastore_result) ;
new_table = new_table_useful_data(original_data) ;
[~, name, ext] = fileparts(folder_referenced(i)) ;
output_filename = fullfile(output_folder_location, "new_" + name + ext) ;
writetable(new_table, output_filename)
end
folder_with_files = dir(input_folder_location) ; % define directory where files are
filenames = fullfile({folder_with_files.folder}, {folder_with_files.name}) ; % access file path and name information
csvFiles = endsWith(filenames, ‘.csv’) ; % use logi → determining which values end in .csv (fullfile provides axtra info we don’t want)
filenames = filenames(csvFiles) ; % create cell array with all file names
each_day_table(filenames, output_folder_location) ; % applies all the functions to the files
I’ve attached a ference file.Hi y’all,
When I run my code I get an error:
Error using matlab.io.datastore.TabularDatastore/readall (line 196)
Unable to parse a "Numeric" field when reading row 39898, field 7.
Actual Text: "N,07121.27550,W,2,28,0.9,0.79,M,,,5,0131*01"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive
Is there a way to have the readall function skip these ,,, non-existing values in my data?
Code:
function [] = each_day_table(folder_referenced, output_folder_location)
dimention = size(folder_referenced) ;
for i = 1:dimention(2)
datastore_result = datastore(folder_referenced(i)) ;
original_data = readall(datastore_result) ;
new_table = new_table_useful_data(original_data) ;
[~, name, ext] = fileparts(folder_referenced(i)) ;
output_filename = fullfile(output_folder_location, "new_" + name + ext) ;
writetable(new_table, output_filename)
end
folder_with_files = dir(input_folder_location) ; % define directory where files are
filenames = fullfile({folder_with_files.folder}, {folder_with_files.name}) ; % access file path and name information
csvFiles = endsWith(filenames, ‘.csv’) ; % use logi → determining which values end in .csv (fullfile provides axtra info we don’t want)
filenames = filenames(csvFiles) ; % create cell array with all file names
each_day_table(filenames, output_folder_location) ; % applies all the functions to the files
I’ve attached a ference file. Hi y’all,
When I run my code I get an error:
Error using matlab.io.datastore.TabularDatastore/readall (line 196)
Unable to parse a "Numeric" field when reading row 39898, field 7.
Actual Text: "N,07121.27550,W,2,28,0.9,0.79,M,,,5,0131*01"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive
Is there a way to have the readall function skip these ,,, non-existing values in my data?
Code:
function [] = each_day_table(folder_referenced, output_folder_location)
dimention = size(folder_referenced) ;
for i = 1:dimention(2)
datastore_result = datastore(folder_referenced(i)) ;
original_data = readall(datastore_result) ;
new_table = new_table_useful_data(original_data) ;
[~, name, ext] = fileparts(folder_referenced(i)) ;
output_filename = fullfile(output_folder_location, "new_" + name + ext) ;
writetable(new_table, output_filename)
end
folder_with_files = dir(input_folder_location) ; % define directory where files are
filenames = fullfile({folder_with_files.folder}, {folder_with_files.name}) ; % access file path and name information
csvFiles = endsWith(filenames, ‘.csv’) ; % use logi → determining which values end in .csv (fullfile provides axtra info we don’t want)
filenames = filenames(csvFiles) ; % create cell array with all file names
each_day_table(filenames, output_folder_location) ; % applies all the functions to the files
I’ve attached a ference file. readall, missing data MATLAB Answers — New Questions
How to Bypass OneDrive Files Download
I just installed MATLAB on my work laptop with Windows 11. The org uses OneDrive for file storage. My OneDrive is set to only download files when they are opened ("Always keep on this device" is checked off).
What I discovered was that MATLAB insists on downloading all the files in the folder where I want to navigate to to save my script. As in, if I want to save the script in the folder OneDrive/Documents/Some Folder, and there is like 20GB of other files in that folder, MATLAB will trigger download of all 20GB of other files before it will even let me save my one file.
What’s even worse, when I cancel the automatic download MATLAB freezes. If I Block App in automatic downloads MATLAB freezes. After it freezes the only way to close it is force quit through the Task Manager. So my options are: I let MATLAB download whatever it wants as I navigate through my OneDrive, or freeze the program by cancelling the downloads.
I haven’t used MATLAB since v. 2021 and this behavior is new for me. Is there anything I can do to use the software without downloading files to local drive? I simply do not have space for that (nor the time to download GB of files each time I want to move around my OneDrive). I can use admin account but only temporarily, after coordinating with the IT department.
I found a couple of threads here on this topic but nothing that answers my question. Thank you in advance.I just installed MATLAB on my work laptop with Windows 11. The org uses OneDrive for file storage. My OneDrive is set to only download files when they are opened ("Always keep on this device" is checked off).
What I discovered was that MATLAB insists on downloading all the files in the folder where I want to navigate to to save my script. As in, if I want to save the script in the folder OneDrive/Documents/Some Folder, and there is like 20GB of other files in that folder, MATLAB will trigger download of all 20GB of other files before it will even let me save my one file.
What’s even worse, when I cancel the automatic download MATLAB freezes. If I Block App in automatic downloads MATLAB freezes. After it freezes the only way to close it is force quit through the Task Manager. So my options are: I let MATLAB download whatever it wants as I navigate through my OneDrive, or freeze the program by cancelling the downloads.
I haven’t used MATLAB since v. 2021 and this behavior is new for me. Is there anything I can do to use the software without downloading files to local drive? I simply do not have space for that (nor the time to download GB of files each time I want to move around my OneDrive). I can use admin account but only temporarily, after coordinating with the IT department.
I found a couple of threads here on this topic but nothing that answers my question. Thank you in advance. I just installed MATLAB on my work laptop with Windows 11. The org uses OneDrive for file storage. My OneDrive is set to only download files when they are opened ("Always keep on this device" is checked off).
What I discovered was that MATLAB insists on downloading all the files in the folder where I want to navigate to to save my script. As in, if I want to save the script in the folder OneDrive/Documents/Some Folder, and there is like 20GB of other files in that folder, MATLAB will trigger download of all 20GB of other files before it will even let me save my one file.
What’s even worse, when I cancel the automatic download MATLAB freezes. If I Block App in automatic downloads MATLAB freezes. After it freezes the only way to close it is force quit through the Task Manager. So my options are: I let MATLAB download whatever it wants as I navigate through my OneDrive, or freeze the program by cancelling the downloads.
I haven’t used MATLAB since v. 2021 and this behavior is new for me. Is there anything I can do to use the software without downloading files to local drive? I simply do not have space for that (nor the time to download GB of files each time I want to move around my OneDrive). I can use admin account but only temporarily, after coordinating with the IT department.
I found a couple of threads here on this topic but nothing that answers my question. Thank you in advance. onedrive MATLAB Answers — New Questions
Error when building model in simulink “Error(s) encountered while building model”
Matlab is failing to compile every block in my main. The error doesn’t give me any other information except: "Error(s) encountered while building model" and then a list of all the blocks that failed to compile. The command window says "the make command returned an error of 2, ‘An error occurred during the call to make’ is not recognized as an internal or external command, operable program or batch file."
I’m using R2013a and one of the updates listed below must have deleted microsoft SDK 7.1 the other night. The code worked fine before these updates. After reinstalling .NET framework 4 and the SDK it’s still failing to compile. I think it may be a problem with the mex or xpc setup or maybe I still need to reinstall something.
security update – microsoft visual studio 2010 xml editor
definition update – microsoft security essentials
security update – microsoft visual c++ 2008 service pack 1
security update – microsoft visual studio 2010
Any help would be appreciatedMatlab is failing to compile every block in my main. The error doesn’t give me any other information except: "Error(s) encountered while building model" and then a list of all the blocks that failed to compile. The command window says "the make command returned an error of 2, ‘An error occurred during the call to make’ is not recognized as an internal or external command, operable program or batch file."
I’m using R2013a and one of the updates listed below must have deleted microsoft SDK 7.1 the other night. The code worked fine before these updates. After reinstalling .NET framework 4 and the SDK it’s still failing to compile. I think it may be a problem with the mex or xpc setup or maybe I still need to reinstall something.
security update – microsoft visual studio 2010 xml editor
definition update – microsoft security essentials
security update – microsoft visual c++ 2008 service pack 1
security update – microsoft visual studio 2010
Any help would be appreciated Matlab is failing to compile every block in my main. The error doesn’t give me any other information except: "Error(s) encountered while building model" and then a list of all the blocks that failed to compile. The command window says "the make command returned an error of 2, ‘An error occurred during the call to make’ is not recognized as an internal or external command, operable program or batch file."
I’m using R2013a and one of the updates listed below must have deleted microsoft SDK 7.1 the other night. The code worked fine before these updates. After reinstalling .NET framework 4 and the SDK it’s still failing to compile. I think it may be a problem with the mex or xpc setup or maybe I still need to reinstall something.
security update – microsoft visual studio 2010 xml editor
definition update – microsoft security essentials
security update – microsoft visual c++ 2008 service pack 1
security update – microsoft visual studio 2010
Any help would be appreciated xpc, simulink, an error occurred during the call to make, matlab compiler, build error, xpc setup, mex, mex compiler MATLAB Answers — New Questions
Can someone help me to obtain the FRF curve and plot the curve?
%%
% clear memory
clear all
clc
%% % Define material properties and beam dimensions % % %
%xx—————————————————————————————-xx%
width = 0.3; % beam width
t1 = 0.1; % beam thickness of first layer
t2 = 0.1; % beam thickness of second layer
L = 1; % beam length
poisson1 = 0.33; % Poisson’s ratio first layer
poisson2 = 0.33; % Poisson’s ratio second layer
rho1 = 1700; % density of material 1
rho2 = 1240; % density of material 2
E1 = 2.2e11; % modulus of elasticity for material 1
E2 = 7.9e19; % modulus of elasticity for material 1
E3=7.9e9; % modulus of elasticity for material 2
% % % beam load parameters % % %
%xx—————————————————————————————-xx%
n = 0; % material gradation index
P = -100; % uniform distributed load
Mb = 24.4; % ratio of Young’s moduli between two materials
E2 = E1 / Mb;
% % % Derived FGM parameters % % %
%xx—————————————————————————————-xx%
[C1, I01, I1, A01] = effectstifmass(width, t1, rho1, rho2, E1, E2, Mb, n, poisson1);
[C2, I02, I2, A02] = effectstifmass(width, t2, rho1, rho2, E3, E3, Mb, n, poisson2);
% Mass parameters for FGM
numberElements = 40;
nodeCoordinates = linspace(0, L, numberElements + 1);
xx = nodeCoordinates’;
x = xx’;
elementNodes = zeros(size(nodeCoordinates, 2) – 1, 2);
for i = 1:size(nodeCoordinates, 2) – 1
elementNodes(i, 1) = i;
elementNodes(i, 2) = i + 1;
end
numberNodes = size(xx, 1);
GDof = 2 * numberNodes;
% % % Static analysis % % %
%xx—————————————————————————————-xx%
% Computation of the system stiffness, force, mass
[stiffness1, force, mass1] = formStiffnessMassTimoshenkoBeam(GDof, numberElements, …
elementNodes, numberNodes, xx, C1, P, rho1, I01, t1);
[stiffness2, ~, mass2] = formStiffnessMassTimoshenkoBeam(GDof, numberElements, …
elementNodes, numberNodes, xx, C2, P, rho1, I02, t2);
% % % Boundary conditions % % %
%xx—————————————————————————————-xx%
fixedNodeW = [1, 1];
fixedNodeTX = [1, 2];
prescribedDof = [fixedNodeW; fixedNodeTX + numberNodes];
stiffness = stiffness1 + stiffness2 + stiffness1;
mass = mass1 + mass2 + mass1;
K = stiffness;
m = mass;
% % % Free vibration analysis % % %
%xx—————————————————————————————-xx%
[modes, eigenvalues] = eigenvalue(GDof, prescribedDof, stiffness, mass, 0);
omega = sqrt(eigenvalues) * L * L * sqrt(rho1 * A01 / E1 / I01);
disp(‘First 3 dimensionless frequencies:’)
disp(omega(1:3))
f = sqrt(eigenvalues);
disp(‘First 3 natural frequencies (Hz):’)
disp(f(1:3))
% Drawing mesh and deformed shape
modeNumber = 3;
V1 = modes(:, 1:modeNumber);
% Normalize the mode shapes for better visualization
for i = 1:modeNumber
V1(:,i) = V1(:,i) / max(abs(V1(:,i)));
end
% Plot the first 3 mode shapes
figure;
for i = 1:modeNumber
subplot(3,1,i);
plot(x, V1(1:numberNodes, i), ‘LineWidth’, 2);
title([‘Mode Shape ‘, num2str(i)]);
xlabel(‘Beam Length (x)’);
ylabel(‘Normalized Displacement’);
grid on;
end
% Solve for static displacements
displacements = solution(GDof, prescribedDof, stiffness, force);
U = displacements;
% Max displacement
disp(‘Max normal displacement:’)
disp(min(U(1:numberNodes)))
% % % Forced vibration analysis % % %
%xx—————————————————————————————-xx%
c1 = 1.5;
c2 = 0.9; % damping coefficients
Ca = c1 * mass + c2 * stiffness;
F = @(t) force * sin(2* t); % time-dependent load
D0 = zeros(GDof,1); % initial displacement
V0 = zeros(GDof,1); % initial velocity
dt = 0.005; T = 100; tt = 0:dt:T;
[D, V, A] = Newmark(mass, Ca, stiffness, F, D0, V0, dt, T);
% Plot forced vibration displacement at a node
figure;
plot(tt, D(21,:), ‘b’, ‘LineWidth’, 2);
title(‘Forced Vibration Displacement at Node 21’);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
grid on;
% % % Export results to Excel % % %
%xx—————————————————————————————-xx%
xlswrite(‘mode vibration result.xlsx’, [x(:), V1(1:numberNodes,:)]);
xlswrite(‘normal displacement.xlsx’, [x(:), U(1:numberNodes,:)]);
xlswrite(‘forced displacement.xlsx’, [tt’, D(21,:)’]);
this is my current code%%
% clear memory
clear all
clc
%% % Define material properties and beam dimensions % % %
%xx—————————————————————————————-xx%
width = 0.3; % beam width
t1 = 0.1; % beam thickness of first layer
t2 = 0.1; % beam thickness of second layer
L = 1; % beam length
poisson1 = 0.33; % Poisson’s ratio first layer
poisson2 = 0.33; % Poisson’s ratio second layer
rho1 = 1700; % density of material 1
rho2 = 1240; % density of material 2
E1 = 2.2e11; % modulus of elasticity for material 1
E2 = 7.9e19; % modulus of elasticity for material 1
E3=7.9e9; % modulus of elasticity for material 2
% % % beam load parameters % % %
%xx—————————————————————————————-xx%
n = 0; % material gradation index
P = -100; % uniform distributed load
Mb = 24.4; % ratio of Young’s moduli between two materials
E2 = E1 / Mb;
% % % Derived FGM parameters % % %
%xx—————————————————————————————-xx%
[C1, I01, I1, A01] = effectstifmass(width, t1, rho1, rho2, E1, E2, Mb, n, poisson1);
[C2, I02, I2, A02] = effectstifmass(width, t2, rho1, rho2, E3, E3, Mb, n, poisson2);
% Mass parameters for FGM
numberElements = 40;
nodeCoordinates = linspace(0, L, numberElements + 1);
xx = nodeCoordinates’;
x = xx’;
elementNodes = zeros(size(nodeCoordinates, 2) – 1, 2);
for i = 1:size(nodeCoordinates, 2) – 1
elementNodes(i, 1) = i;
elementNodes(i, 2) = i + 1;
end
numberNodes = size(xx, 1);
GDof = 2 * numberNodes;
% % % Static analysis % % %
%xx—————————————————————————————-xx%
% Computation of the system stiffness, force, mass
[stiffness1, force, mass1] = formStiffnessMassTimoshenkoBeam(GDof, numberElements, …
elementNodes, numberNodes, xx, C1, P, rho1, I01, t1);
[stiffness2, ~, mass2] = formStiffnessMassTimoshenkoBeam(GDof, numberElements, …
elementNodes, numberNodes, xx, C2, P, rho1, I02, t2);
% % % Boundary conditions % % %
%xx—————————————————————————————-xx%
fixedNodeW = [1, 1];
fixedNodeTX = [1, 2];
prescribedDof = [fixedNodeW; fixedNodeTX + numberNodes];
stiffness = stiffness1 + stiffness2 + stiffness1;
mass = mass1 + mass2 + mass1;
K = stiffness;
m = mass;
% % % Free vibration analysis % % %
%xx—————————————————————————————-xx%
[modes, eigenvalues] = eigenvalue(GDof, prescribedDof, stiffness, mass, 0);
omega = sqrt(eigenvalues) * L * L * sqrt(rho1 * A01 / E1 / I01);
disp(‘First 3 dimensionless frequencies:’)
disp(omega(1:3))
f = sqrt(eigenvalues);
disp(‘First 3 natural frequencies (Hz):’)
disp(f(1:3))
% Drawing mesh and deformed shape
modeNumber = 3;
V1 = modes(:, 1:modeNumber);
% Normalize the mode shapes for better visualization
for i = 1:modeNumber
V1(:,i) = V1(:,i) / max(abs(V1(:,i)));
end
% Plot the first 3 mode shapes
figure;
for i = 1:modeNumber
subplot(3,1,i);
plot(x, V1(1:numberNodes, i), ‘LineWidth’, 2);
title([‘Mode Shape ‘, num2str(i)]);
xlabel(‘Beam Length (x)’);
ylabel(‘Normalized Displacement’);
grid on;
end
% Solve for static displacements
displacements = solution(GDof, prescribedDof, stiffness, force);
U = displacements;
% Max displacement
disp(‘Max normal displacement:’)
disp(min(U(1:numberNodes)))
% % % Forced vibration analysis % % %
%xx—————————————————————————————-xx%
c1 = 1.5;
c2 = 0.9; % damping coefficients
Ca = c1 * mass + c2 * stiffness;
F = @(t) force * sin(2* t); % time-dependent load
D0 = zeros(GDof,1); % initial displacement
V0 = zeros(GDof,1); % initial velocity
dt = 0.005; T = 100; tt = 0:dt:T;
[D, V, A] = Newmark(mass, Ca, stiffness, F, D0, V0, dt, T);
% Plot forced vibration displacement at a node
figure;
plot(tt, D(21,:), ‘b’, ‘LineWidth’, 2);
title(‘Forced Vibration Displacement at Node 21’);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
grid on;
% % % Export results to Excel % % %
%xx—————————————————————————————-xx%
xlswrite(‘mode vibration result.xlsx’, [x(:), V1(1:numberNodes,:)]);
xlswrite(‘normal displacement.xlsx’, [x(:), U(1:numberNodes,:)]);
xlswrite(‘forced displacement.xlsx’, [tt’, D(21,:)’]);
this is my current code %%
% clear memory
clear all
clc
%% % Define material properties and beam dimensions % % %
%xx—————————————————————————————-xx%
width = 0.3; % beam width
t1 = 0.1; % beam thickness of first layer
t2 = 0.1; % beam thickness of second layer
L = 1; % beam length
poisson1 = 0.33; % Poisson’s ratio first layer
poisson2 = 0.33; % Poisson’s ratio second layer
rho1 = 1700; % density of material 1
rho2 = 1240; % density of material 2
E1 = 2.2e11; % modulus of elasticity for material 1
E2 = 7.9e19; % modulus of elasticity for material 1
E3=7.9e9; % modulus of elasticity for material 2
% % % beam load parameters % % %
%xx—————————————————————————————-xx%
n = 0; % material gradation index
P = -100; % uniform distributed load
Mb = 24.4; % ratio of Young’s moduli between two materials
E2 = E1 / Mb;
% % % Derived FGM parameters % % %
%xx—————————————————————————————-xx%
[C1, I01, I1, A01] = effectstifmass(width, t1, rho1, rho2, E1, E2, Mb, n, poisson1);
[C2, I02, I2, A02] = effectstifmass(width, t2, rho1, rho2, E3, E3, Mb, n, poisson2);
% Mass parameters for FGM
numberElements = 40;
nodeCoordinates = linspace(0, L, numberElements + 1);
xx = nodeCoordinates’;
x = xx’;
elementNodes = zeros(size(nodeCoordinates, 2) – 1, 2);
for i = 1:size(nodeCoordinates, 2) – 1
elementNodes(i, 1) = i;
elementNodes(i, 2) = i + 1;
end
numberNodes = size(xx, 1);
GDof = 2 * numberNodes;
% % % Static analysis % % %
%xx—————————————————————————————-xx%
% Computation of the system stiffness, force, mass
[stiffness1, force, mass1] = formStiffnessMassTimoshenkoBeam(GDof, numberElements, …
elementNodes, numberNodes, xx, C1, P, rho1, I01, t1);
[stiffness2, ~, mass2] = formStiffnessMassTimoshenkoBeam(GDof, numberElements, …
elementNodes, numberNodes, xx, C2, P, rho1, I02, t2);
% % % Boundary conditions % % %
%xx—————————————————————————————-xx%
fixedNodeW = [1, 1];
fixedNodeTX = [1, 2];
prescribedDof = [fixedNodeW; fixedNodeTX + numberNodes];
stiffness = stiffness1 + stiffness2 + stiffness1;
mass = mass1 + mass2 + mass1;
K = stiffness;
m = mass;
% % % Free vibration analysis % % %
%xx—————————————————————————————-xx%
[modes, eigenvalues] = eigenvalue(GDof, prescribedDof, stiffness, mass, 0);
omega = sqrt(eigenvalues) * L * L * sqrt(rho1 * A01 / E1 / I01);
disp(‘First 3 dimensionless frequencies:’)
disp(omega(1:3))
f = sqrt(eigenvalues);
disp(‘First 3 natural frequencies (Hz):’)
disp(f(1:3))
% Drawing mesh and deformed shape
modeNumber = 3;
V1 = modes(:, 1:modeNumber);
% Normalize the mode shapes for better visualization
for i = 1:modeNumber
V1(:,i) = V1(:,i) / max(abs(V1(:,i)));
end
% Plot the first 3 mode shapes
figure;
for i = 1:modeNumber
subplot(3,1,i);
plot(x, V1(1:numberNodes, i), ‘LineWidth’, 2);
title([‘Mode Shape ‘, num2str(i)]);
xlabel(‘Beam Length (x)’);
ylabel(‘Normalized Displacement’);
grid on;
end
% Solve for static displacements
displacements = solution(GDof, prescribedDof, stiffness, force);
U = displacements;
% Max displacement
disp(‘Max normal displacement:’)
disp(min(U(1:numberNodes)))
% % % Forced vibration analysis % % %
%xx—————————————————————————————-xx%
c1 = 1.5;
c2 = 0.9; % damping coefficients
Ca = c1 * mass + c2 * stiffness;
F = @(t) force * sin(2* t); % time-dependent load
D0 = zeros(GDof,1); % initial displacement
V0 = zeros(GDof,1); % initial velocity
dt = 0.005; T = 100; tt = 0:dt:T;
[D, V, A] = Newmark(mass, Ca, stiffness, F, D0, V0, dt, T);
% Plot forced vibration displacement at a node
figure;
plot(tt, D(21,:), ‘b’, ‘LineWidth’, 2);
title(‘Forced Vibration Displacement at Node 21’);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
grid on;
% % % Export results to Excel % % %
%xx—————————————————————————————-xx%
xlswrite(‘mode vibration result.xlsx’, [x(:), V1(1:numberNodes,:)]);
xlswrite(‘normal displacement.xlsx’, [x(:), U(1:numberNodes,:)]);
xlswrite(‘forced displacement.xlsx’, [tt’, D(21,:)’]);
this is my current code composites vibartion MATLAB Answers — New Questions