Category: Matlab
Category Archives: Matlab
How can i detect the amplitude of a sinusoidal signal in Simulink ?
Hello,
I am working on a project in Simulink … i want to extract the amplitude of a sinusoidal signal as it shown below … how can i extract the value of the amplitude in simulink ? the frequency of the signal is variant with time .Thanks in advance
<</matlabcentral/answers/uploaded_files/114375/k.PNG>>Hello,
I am working on a project in Simulink … i want to extract the amplitude of a sinusoidal signal as it shown below … how can i extract the value of the amplitude in simulink ? the frequency of the signal is variant with time .Thanks in advance
<</matlabcentral/answers/uploaded_files/114375/k.PNG>> Hello,
I am working on a project in Simulink … i want to extract the amplitude of a sinusoidal signal as it shown below … how can i extract the value of the amplitude in simulink ? the frequency of the signal is variant with time .Thanks in advance
<</matlabcentral/answers/uploaded_files/114375/k.PNG>> simulink, signal, amplitude, detect, extract amplitude MATLAB Answers — New Questions
Opening multiple instances of MATLAB causes endless folder access errors
Whenever I try to open two instances of MATLAB, I run into an endless loop of error windows. For example, if I’m running 2022b and I try to start an instance of 2021b, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
…and so on.
I’m using a Mac OS Monterey 12.6.1.
Does anyone know how to fix this?Whenever I try to open two instances of MATLAB, I run into an endless loop of error windows. For example, if I’m running 2022b and I try to start an instance of 2021b, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
…and so on.
I’m using a Mac OS Monterey 12.6.1.
Does anyone know how to fix this? Whenever I try to open two instances of MATLAB, I run into an endless loop of error windows. For example, if I’m running 2022b and I try to start an instance of 2021b, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2021b” would like to access files in your Documents folder.
When I click OK, I get this popup message:
“MATLAB_R2022b” would like to access files in your Documents folder.
…and so on.
I’m using a Mac OS Monterey 12.6.1.
Does anyone know how to fix this? error MATLAB Answers — New Questions
Can two users have access and use matlab on one computer?
We have one shared windows computer with Matlab installed and two users who wants to access and work with matlab not at the same time. Is this possible? if yes, how do I have to setup this solution?We have one shared windows computer with Matlab installed and two users who wants to access and work with matlab not at the same time. Is this possible? if yes, how do I have to setup this solution? We have one shared windows computer with Matlab installed and two users who wants to access and work with matlab not at the same time. Is this possible? if yes, how do I have to setup this solution? matlab accesss by two users MATLAB Answers — New Questions
(Code) How to generate the DSB-SC using message signal (tone modulation)
*(Code) How to generate the DSB-SC using message signal (tone modulation) with frequency 2kHz and a carrier signal of frequency 100kHz**(Code) How to generate the DSB-SC using message signal (tone modulation) with frequency 2kHz and a carrier signal of frequency 100kHz* *(Code) How to generate the DSB-SC using message signal (tone modulation) with frequency 2kHz and a carrier signal of frequency 100kHz* tone modulation, dsb-sc, how to generate dsb-sc, how to generate dsb-sc using a message signal tone modulation MATLAB Answers — New Questions
Simulink error “variable-size matrix but its size is specified as inherited or fixed”
I’m building a MPC controller for a state space plant (, , with , , ).
I implemented the MPC as Matlab function, whose inputs are
enable (a flag that enables the controller. If it is equal to false, then the outputs are set equal to zero);
X_ref (a vector of size , with the reference state value for each step in the prediction horizon );
U_ref (a vector of size , with the reference input value for each step in the prediction horizon );
x_k ( a vector of the current state );
mpc (a structure with the data for the MPC implementation and all the preprocessed matrices; this is the only function input of type "parameter data"; it’s value is read from matlab workspace).
The output is the vector , that is the control action for the plant. It is constructed in the following way
function u_k = mpc_controller(enable, X_ref, U_ref, x_k, mpc)
if enable
…
[z_opt, ~, flag] = quadprog((H+H’)./2, f, Ain, bin, Aeq, beq, lb, ub, [], options);
else
idx = 1;
z_opt = zeros(mpc.nu, 1);
end
u_k = z_opt(idx:(idx+mpc.nu-1));
where mpc.nu is , while idx is a index appositely constructed in the code.
The same function works perfectly when running in Matlab, but once exported into simulink in the Matlab function, the following error rises:
Error: ‘u_k’ is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify ‘u_k’ is defined in terms of non-tunable parameters, or select the ‘Variable Size’ check box and specify the upper bounds in the Size box.
I fixed the u_k value in the property inspector (inside the matlab function block) equal to mpc.nu, that is the actual length of the output, since it cannot have the feature "variable size" because one of the block in series with the matlab function block is a demux.
Do you have any idea on how to manage this problem? Thanks in advanceI’m building a MPC controller for a state space plant (, , with , , ).
I implemented the MPC as Matlab function, whose inputs are
enable (a flag that enables the controller. If it is equal to false, then the outputs are set equal to zero);
X_ref (a vector of size , with the reference state value for each step in the prediction horizon );
U_ref (a vector of size , with the reference input value for each step in the prediction horizon );
x_k ( a vector of the current state );
mpc (a structure with the data for the MPC implementation and all the preprocessed matrices; this is the only function input of type "parameter data"; it’s value is read from matlab workspace).
The output is the vector , that is the control action for the plant. It is constructed in the following way
function u_k = mpc_controller(enable, X_ref, U_ref, x_k, mpc)
if enable
…
[z_opt, ~, flag] = quadprog((H+H’)./2, f, Ain, bin, Aeq, beq, lb, ub, [], options);
else
idx = 1;
z_opt = zeros(mpc.nu, 1);
end
u_k = z_opt(idx:(idx+mpc.nu-1));
where mpc.nu is , while idx is a index appositely constructed in the code.
The same function works perfectly when running in Matlab, but once exported into simulink in the Matlab function, the following error rises:
Error: ‘u_k’ is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify ‘u_k’ is defined in terms of non-tunable parameters, or select the ‘Variable Size’ check box and specify the upper bounds in the Size box.
I fixed the u_k value in the property inspector (inside the matlab function block) equal to mpc.nu, that is the actual length of the output, since it cannot have the feature "variable size" because one of the block in series with the matlab function block is a demux.
Do you have any idea on how to manage this problem? Thanks in advance I’m building a MPC controller for a state space plant (, , with , , ).
I implemented the MPC as Matlab function, whose inputs are
enable (a flag that enables the controller. If it is equal to false, then the outputs are set equal to zero);
X_ref (a vector of size , with the reference state value for each step in the prediction horizon );
U_ref (a vector of size , with the reference input value for each step in the prediction horizon );
x_k ( a vector of the current state );
mpc (a structure with the data for the MPC implementation and all the preprocessed matrices; this is the only function input of type "parameter data"; it’s value is read from matlab workspace).
The output is the vector , that is the control action for the plant. It is constructed in the following way
function u_k = mpc_controller(enable, X_ref, U_ref, x_k, mpc)
if enable
…
[z_opt, ~, flag] = quadprog((H+H’)./2, f, Ain, bin, Aeq, beq, lb, ub, [], options);
else
idx = 1;
z_opt = zeros(mpc.nu, 1);
end
u_k = z_opt(idx:(idx+mpc.nu-1));
where mpc.nu is , while idx is a index appositely constructed in the code.
The same function works perfectly when running in Matlab, but once exported into simulink in the Matlab function, the following error rises:
Error: ‘u_k’ is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify ‘u_k’ is defined in terms of non-tunable parameters, or select the ‘Variable Size’ check box and specify the upper bounds in the Size box.
I fixed the u_k value in the property inspector (inside the matlab function block) equal to mpc.nu, that is the actual length of the output, since it cannot have the feature "variable size" because one of the block in series with the matlab function block is a demux.
Do you have any idea on how to manage this problem? Thanks in advance simulink, matlab function, variable-size matrix MATLAB Answers — New Questions
Modulating of OFDM signal
i want to ask how i can modulate the OFDM signal to higher frequency (2MHz for example) in Matlab simulinki want to ask how i can modulate the OFDM signal to higher frequency (2MHz for example) in Matlab simulink i want to ask how i can modulate the OFDM signal to higher frequency (2MHz for example) in Matlab simulink papr ofdm MATLAB Answers — New Questions
How to find volume of a curve [f(x)] which is rotated along y-axis?
We have a input function y = f(x) and we have to find the volume along x-axis and y-axis. (solid of revolution) The minimum and maximum values of x are given
I am getting the volume along x-axis but I am getting an error while finding the volume along the y-axis.
The values of f(x) and domain is : –
x^(1/2), 0<=x<=4
3*cos(0.4*x+pi), -5<=x<=5
sin(x)+3, -5<=x<=5
x^3, 0<=x<=3
Here is my code
%Volume along x-axis
clc
clear all
syms x y
%fx = input(‘Enter the function : ‘)
xmin = input(‘Enter minimum value of x : ‘)
xmax = input(‘Enter maximum value of x : ‘)
intfx = int((fx)^2,xmin,xmax)
vx = pi*(intfx)
vx = double(vx)
sprintf(‘The volume along x-axis is %d’,vx)
%Volume along y-axis
y_fx_equation_wrt_x = y == fx
x_fy_equation_wrt_y = solve(y_fx_equation_wrt_x, x)
fy = x_fy_equation_wrt_y
ymin = subs(fx,x,xmin)
ymax = subs(fx,x,xmax)
intfy = abs(int(fy^2,ymin,ymax))
vy = pi*(intfy)
vyy = double(vy)
sprintf(‘The volume along y-axis is %d’,vyy)
In output 1 I get an error but on output 2 I don’t.
What am I doing wrong?
Output 1
y = 3*cos(0.4*x+pi)
3*cos(0.4*x+pi)
fx =
-3*cos((2*x)/5)
Enter minimum value of x :
-5
xmin =
-5
Enter maximum value of x :
5
xmax =
5
intfx =
(45*sin(4))/4 + 45
vx =
pi*((45*sin(4))/4 + 45)
vx =
114.6241
ans =
‘The volume along x-axis is 1.146241e+02’
y_fx_equation_wrt_x =
y == -3*cos((2*x)/5)
x_fy_equation_wrt_y =
(5*pi)/2 – (5*acos(y/3))/2
(5*pi)/2 + (5*acos(y/3))/2
fy =
(5*pi)/2 – (5*acos(y/3))/2
(5*pi)/2 + (5*acos(y/3))/2
ymin =
-3*cos(2)
ymax =
-3*cos(2)
Error using ^ (line 442)
Matrix must be square.
Error in Week6classwork1_2 (line 35)
intfy = abs(int(fy^2,ymin,ymax))
Output 2
y = x^(0.5)
Enter the function :
x^(0.5)
fx =
x^(1/2)
Enter minimum value of x :
0
xmin =
0
Enter maximum value of x :
4
xmax =
4
intfx =
8
vx =
8*pi
vx =
25.1327
ans =
‘The volume along x-axis is 2.513274e+01’
y_fx_equation_wrt_x =
y == x^(1/2)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the ‘ReturnConditions’ value as ‘true’.
x_fy_equation_wrt_y =
y^2
fy =
y^2
ymin =
0
ymax =
2
intfy =
32/5
vy =
(32*pi)/5
vyy =
20.1062
ans =
‘The volume along y-axis is 2.010619e+01’We have a input function y = f(x) and we have to find the volume along x-axis and y-axis. (solid of revolution) The minimum and maximum values of x are given
I am getting the volume along x-axis but I am getting an error while finding the volume along the y-axis.
The values of f(x) and domain is : –
x^(1/2), 0<=x<=4
3*cos(0.4*x+pi), -5<=x<=5
sin(x)+3, -5<=x<=5
x^3, 0<=x<=3
Here is my code
%Volume along x-axis
clc
clear all
syms x y
%fx = input(‘Enter the function : ‘)
xmin = input(‘Enter minimum value of x : ‘)
xmax = input(‘Enter maximum value of x : ‘)
intfx = int((fx)^2,xmin,xmax)
vx = pi*(intfx)
vx = double(vx)
sprintf(‘The volume along x-axis is %d’,vx)
%Volume along y-axis
y_fx_equation_wrt_x = y == fx
x_fy_equation_wrt_y = solve(y_fx_equation_wrt_x, x)
fy = x_fy_equation_wrt_y
ymin = subs(fx,x,xmin)
ymax = subs(fx,x,xmax)
intfy = abs(int(fy^2,ymin,ymax))
vy = pi*(intfy)
vyy = double(vy)
sprintf(‘The volume along y-axis is %d’,vyy)
In output 1 I get an error but on output 2 I don’t.
What am I doing wrong?
Output 1
y = 3*cos(0.4*x+pi)
3*cos(0.4*x+pi)
fx =
-3*cos((2*x)/5)
Enter minimum value of x :
-5
xmin =
-5
Enter maximum value of x :
5
xmax =
5
intfx =
(45*sin(4))/4 + 45
vx =
pi*((45*sin(4))/4 + 45)
vx =
114.6241
ans =
‘The volume along x-axis is 1.146241e+02’
y_fx_equation_wrt_x =
y == -3*cos((2*x)/5)
x_fy_equation_wrt_y =
(5*pi)/2 – (5*acos(y/3))/2
(5*pi)/2 + (5*acos(y/3))/2
fy =
(5*pi)/2 – (5*acos(y/3))/2
(5*pi)/2 + (5*acos(y/3))/2
ymin =
-3*cos(2)
ymax =
-3*cos(2)
Error using ^ (line 442)
Matrix must be square.
Error in Week6classwork1_2 (line 35)
intfy = abs(int(fy^2,ymin,ymax))
Output 2
y = x^(0.5)
Enter the function :
x^(0.5)
fx =
x^(1/2)
Enter minimum value of x :
0
xmin =
0
Enter maximum value of x :
4
xmax =
4
intfx =
8
vx =
8*pi
vx =
25.1327
ans =
‘The volume along x-axis is 2.513274e+01’
y_fx_equation_wrt_x =
y == x^(1/2)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the ‘ReturnConditions’ value as ‘true’.
x_fy_equation_wrt_y =
y^2
fy =
y^2
ymin =
0
ymax =
2
intfy =
32/5
vy =
(32*pi)/5
vyy =
20.1062
ans =
‘The volume along y-axis is 2.010619e+01’ We have a input function y = f(x) and we have to find the volume along x-axis and y-axis. (solid of revolution) The minimum and maximum values of x are given
I am getting the volume along x-axis but I am getting an error while finding the volume along the y-axis.
The values of f(x) and domain is : –
x^(1/2), 0<=x<=4
3*cos(0.4*x+pi), -5<=x<=5
sin(x)+3, -5<=x<=5
x^3, 0<=x<=3
Here is my code
%Volume along x-axis
clc
clear all
syms x y
%fx = input(‘Enter the function : ‘)
xmin = input(‘Enter minimum value of x : ‘)
xmax = input(‘Enter maximum value of x : ‘)
intfx = int((fx)^2,xmin,xmax)
vx = pi*(intfx)
vx = double(vx)
sprintf(‘The volume along x-axis is %d’,vx)
%Volume along y-axis
y_fx_equation_wrt_x = y == fx
x_fy_equation_wrt_y = solve(y_fx_equation_wrt_x, x)
fy = x_fy_equation_wrt_y
ymin = subs(fx,x,xmin)
ymax = subs(fx,x,xmax)
intfy = abs(int(fy^2,ymin,ymax))
vy = pi*(intfy)
vyy = double(vy)
sprintf(‘The volume along y-axis is %d’,vyy)
In output 1 I get an error but on output 2 I don’t.
What am I doing wrong?
Output 1
y = 3*cos(0.4*x+pi)
3*cos(0.4*x+pi)
fx =
-3*cos((2*x)/5)
Enter minimum value of x :
-5
xmin =
-5
Enter maximum value of x :
5
xmax =
5
intfx =
(45*sin(4))/4 + 45
vx =
pi*((45*sin(4))/4 + 45)
vx =
114.6241
ans =
‘The volume along x-axis is 1.146241e+02’
y_fx_equation_wrt_x =
y == -3*cos((2*x)/5)
x_fy_equation_wrt_y =
(5*pi)/2 – (5*acos(y/3))/2
(5*pi)/2 + (5*acos(y/3))/2
fy =
(5*pi)/2 – (5*acos(y/3))/2
(5*pi)/2 + (5*acos(y/3))/2
ymin =
-3*cos(2)
ymax =
-3*cos(2)
Error using ^ (line 442)
Matrix must be square.
Error in Week6classwork1_2 (line 35)
intfy = abs(int(fy^2,ymin,ymax))
Output 2
y = x^(0.5)
Enter the function :
x^(0.5)
fx =
x^(1/2)
Enter minimum value of x :
0
xmin =
0
Enter maximum value of x :
4
xmax =
4
intfx =
8
vx =
8*pi
vx =
25.1327
ans =
‘The volume along x-axis is 2.513274e+01’
y_fx_equation_wrt_x =
y == x^(1/2)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the ‘ReturnConditions’ value as ‘true’.
x_fy_equation_wrt_y =
y^2
fy =
y^2
ymin =
0
ymax =
2
intfy =
32/5
vy =
(32*pi)/5
vyy =
20.1062
ans =
‘The volume along y-axis is 2.010619e+01’ solid of revolution, volume along y-axis, volume, how MATLAB Answers — New Questions
BER of OFDM QPSK modulated
Hello every one.
AS i have seen in this website. the BER code of OFDM 16-QAM and OFDM BPSK are there
can anyone provide me a link of BER of OFDM QPSK ..Hello every one.
AS i have seen in this website. the BER code of OFDM 16-QAM and OFDM BPSK are there
can anyone provide me a link of BER of OFDM QPSK .. Hello every one.
AS i have seen in this website. the BER code of OFDM 16-QAM and OFDM BPSK are there
can anyone provide me a link of BER of OFDM QPSK .. ber, ofdm, qpsk MATLAB Answers — New Questions
How to create white noise and pink noise ?
I would like to know how to make pink noise and white noise.
I would also like to know how to put the created noise on the acquired tunnel current z.
I own DSP System Toolbox and Signal Processing Toolbox.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm * 240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);I would like to know how to make pink noise and white noise.
I would also like to know how to put the created noise on the acquired tunnel current z.
I own DSP System Toolbox and Signal Processing Toolbox.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm * 240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3); I would like to know how to make pink noise and white noise.
I would also like to know how to put the created noise on the acquired tunnel current z.
I own DSP System Toolbox and Signal Processing Toolbox.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm * 240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3); pink noise, white noise, signal processing, matlab, noise, dsp system toolbox, signal processing toolbox MATLAB Answers — New Questions
Are there alternatives to Simulink Real-Time byte packing/unpacking blocks for MacOS?
Hello,
I am working on a project where I need Simulink Real-Time byte packing and unpacking blocks to enable real-time communication via Ethernet with a microcontroller. Unfortunately, this library is not available for macOS.
Does anyone know of any alternative solutions or approaches that could work on macOS?
Thank you in advance for your valuable help!Hello,
I am working on a project where I need Simulink Real-Time byte packing and unpacking blocks to enable real-time communication via Ethernet with a microcontroller. Unfortunately, this library is not available for macOS.
Does anyone know of any alternative solutions or approaches that could work on macOS?
Thank you in advance for your valuable help! Hello,
I am working on a project where I need Simulink Real-Time byte packing and unpacking blocks to enable real-time communication via Ethernet with a microcontroller. Unfortunately, this library is not available for macOS.
Does anyone know of any alternative solutions or approaches that could work on macOS?
Thank you in advance for your valuable help! simulink, byte packing, mac MATLAB Answers — New Questions
How do I know, what simplifying steps MATLAB had taken?
I know that using "simplify" command I can simplify my trignometric matrices. But, can we take output on each simplification step that MATLAB takes to simplify the given expression?
I am trying to simplify this:
if true
% clc
clear all
syms o l1 l2 l0;
A=[ cos(o) -sin(o) 1;
cos(o-(2*pi/3)) -sin(o-(2*pi/3)) 1;
cos(o-(4*pi/3)) -sin(o-(4*pi/3)) 1;]
invA= (2/3)*[cos(o) cos(o-2*pi/3) cos(o-4*pi/3);
-sin(o) -sin(o-2*pi/3) -sin(o-4*pi/3);
0.5 0.5 0.5]
Lss = [l0 + ((l2)*cos(2*o)) (-0.5*l1)+((l2)*cos((2*o)-2*pi/3)) (-0.5*l1)+((l2)*cos((2*o)+2*pi/3));
(-0.5*l1)+((l2)*cos((2*o)-2*pi/3)) l0 + ((l2)*cos(2*(o-2*pi/3))) (-0.5*l1)+((l2)*cos(2*o))
(-0.5*l1)+((l2)*cos((2*o)+2*pi/3)) (-0.5*l1)+((l2)*cos((2*o))) l0 + ((l2)*cos(2*(o-4*pi/3)))]
X=(invA)*(Lss)*(A)
W=simplify(X)
end
and the answer comes to be:
if true
% W =[ l0 + l1/2 + (3*l2)/2, 0, 0]
[ 0, l0 + l1/2 – (3*l2)/2, 0]
[ 0, 0, l0 – l1]
end
which is true. But how do MATLAB got there??I know that using "simplify" command I can simplify my trignometric matrices. But, can we take output on each simplification step that MATLAB takes to simplify the given expression?
I am trying to simplify this:
if true
% clc
clear all
syms o l1 l2 l0;
A=[ cos(o) -sin(o) 1;
cos(o-(2*pi/3)) -sin(o-(2*pi/3)) 1;
cos(o-(4*pi/3)) -sin(o-(4*pi/3)) 1;]
invA= (2/3)*[cos(o) cos(o-2*pi/3) cos(o-4*pi/3);
-sin(o) -sin(o-2*pi/3) -sin(o-4*pi/3);
0.5 0.5 0.5]
Lss = [l0 + ((l2)*cos(2*o)) (-0.5*l1)+((l2)*cos((2*o)-2*pi/3)) (-0.5*l1)+((l2)*cos((2*o)+2*pi/3));
(-0.5*l1)+((l2)*cos((2*o)-2*pi/3)) l0 + ((l2)*cos(2*(o-2*pi/3))) (-0.5*l1)+((l2)*cos(2*o))
(-0.5*l1)+((l2)*cos((2*o)+2*pi/3)) (-0.5*l1)+((l2)*cos((2*o))) l0 + ((l2)*cos(2*(o-4*pi/3)))]
X=(invA)*(Lss)*(A)
W=simplify(X)
end
and the answer comes to be:
if true
% W =[ l0 + l1/2 + (3*l2)/2, 0, 0]
[ 0, l0 + l1/2 – (3*l2)/2, 0]
[ 0, 0, l0 – l1]
end
which is true. But how do MATLAB got there?? I know that using "simplify" command I can simplify my trignometric matrices. But, can we take output on each simplification step that MATLAB takes to simplify the given expression?
I am trying to simplify this:
if true
% clc
clear all
syms o l1 l2 l0;
A=[ cos(o) -sin(o) 1;
cos(o-(2*pi/3)) -sin(o-(2*pi/3)) 1;
cos(o-(4*pi/3)) -sin(o-(4*pi/3)) 1;]
invA= (2/3)*[cos(o) cos(o-2*pi/3) cos(o-4*pi/3);
-sin(o) -sin(o-2*pi/3) -sin(o-4*pi/3);
0.5 0.5 0.5]
Lss = [l0 + ((l2)*cos(2*o)) (-0.5*l1)+((l2)*cos((2*o)-2*pi/3)) (-0.5*l1)+((l2)*cos((2*o)+2*pi/3));
(-0.5*l1)+((l2)*cos((2*o)-2*pi/3)) l0 + ((l2)*cos(2*(o-2*pi/3))) (-0.5*l1)+((l2)*cos(2*o))
(-0.5*l1)+((l2)*cos((2*o)+2*pi/3)) (-0.5*l1)+((l2)*cos((2*o))) l0 + ((l2)*cos(2*(o-4*pi/3)))]
X=(invA)*(Lss)*(A)
W=simplify(X)
end
and the answer comes to be:
if true
% W =[ l0 + l1/2 + (3*l2)/2, 0, 0]
[ 0, l0 + l1/2 – (3*l2)/2, 0]
[ 0, 0, l0 – l1]
end
which is true. But how do MATLAB got there?? simplify, steps, taken, what, how MATLAB Answers — New Questions
Simulink Test: mapping problems when using matrix
hello fellow users,
I request help on the toolbox simulink test, i am using a test harness on a simulink model and one of my entries is a matrix that i want to improt from an Excel however the mapping of the matrix to his root inport is stuck on "Failed to map inputs. Make sure the input port data types match with signal data types specified in the input file. Click here for more information on external input mapping."hello fellow users,
I request help on the toolbox simulink test, i am using a test harness on a simulink model and one of my entries is a matrix that i want to improt from an Excel however the mapping of the matrix to his root inport is stuck on "Failed to map inputs. Make sure the input port data types match with signal data types specified in the input file. Click here for more information on external input mapping." hello fellow users,
I request help on the toolbox simulink test, i am using a test harness on a simulink model and one of my entries is a matrix that i want to improt from an Excel however the mapping of the matrix to his root inport is stuck on "Failed to map inputs. Make sure the input port data types match with signal data types specified in the input file. Click here for more information on external input mapping." simulink test MATLAB Answers — New Questions
How to run a fitlm regression for day of the week dummy variables for financial return data
Hi, I am struggling with how to set up my data to run the fitlm function for day of the week dummy variables.
My data that I have set up in a (2500,6) matrix where C1 is the returns data and C2:C6 are column vectors of zeros and ones where C2 – 1 is for Monday C3 – 1 represents tuesday and so on.
My reults are as follows:
Fitlm:
-1.31153554169770 0.953057779050930 -1.37613434413573 0.169037651868845
-0.131905728387301 0.0695763306138066 -1.89584197993226 0.0582218112735167
0.0843907252336952 0.0872037277677016 0.967742175638410 0.333368798643977
0 0 NaN NaN
-0.0247423867293685 0.0984537148158696 -0.251309834023453 0.801617743803277
0.169341528221423 0.0952957370120605 1.77701053091169 0.0758206160733013
0.460051465197619 0.0967773549107878 4.75370984897974 2.23973346792996e-06
How do i correct my input to replace this row of Nan values?Hi, I am struggling with how to set up my data to run the fitlm function for day of the week dummy variables.
My data that I have set up in a (2500,6) matrix where C1 is the returns data and C2:C6 are column vectors of zeros and ones where C2 – 1 is for Monday C3 – 1 represents tuesday and so on.
My reults are as follows:
Fitlm:
-1.31153554169770 0.953057779050930 -1.37613434413573 0.169037651868845
-0.131905728387301 0.0695763306138066 -1.89584197993226 0.0582218112735167
0.0843907252336952 0.0872037277677016 0.967742175638410 0.333368798643977
0 0 NaN NaN
-0.0247423867293685 0.0984537148158696 -0.251309834023453 0.801617743803277
0.169341528221423 0.0952957370120605 1.77701053091169 0.0758206160733013
0.460051465197619 0.0967773549107878 4.75370984897974 2.23973346792996e-06
How do i correct my input to replace this row of Nan values? Hi, I am struggling with how to set up my data to run the fitlm function for day of the week dummy variables.
My data that I have set up in a (2500,6) matrix where C1 is the returns data and C2:C6 are column vectors of zeros and ones where C2 – 1 is for Monday C3 – 1 represents tuesday and so on.
My reults are as follows:
Fitlm:
-1.31153554169770 0.953057779050930 -1.37613434413573 0.169037651868845
-0.131905728387301 0.0695763306138066 -1.89584197993226 0.0582218112735167
0.0843907252336952 0.0872037277677016 0.967742175638410 0.333368798643977
0 0 NaN NaN
-0.0247423867293685 0.0984537148158696 -0.251309834023453 0.801617743803277
0.169341528221423 0.0952957370120605 1.77701053091169 0.0758206160733013
0.460051465197619 0.0967773549107878 4.75370984897974 2.23973346792996e-06
How do i correct my input to replace this row of Nan values? fitlm, regress, dummy variables, dummyvar, regression, nan, financial returns, financial time series, stocks, stock returns MATLAB Answers — New Questions
‘m_map’ Conversion of longitude and latitude coordinates to xy coordinates.
the range of longitude[110 130] latitude[35 42.2]
How to correspond to xy coordinates.x[1 300] y[1 300]
I want to assign values to each coordinate point, so please help me.the range of longitude[110 130] latitude[35 42.2]
How to correspond to xy coordinates.x[1 300] y[1 300]
I want to assign values to each coordinate point, so please help me. the range of longitude[110 130] latitude[35 42.2]
How to correspond to xy coordinates.x[1 300] y[1 300]
I want to assign values to each coordinate point, so please help me. m_map MATLAB Answers — New Questions
How to find GNSS satellite elevation angle from .obs and .nav data?
Trying to find GNSS/ NavIC satellite elevation angle from obs and nav dataTrying to find GNSS/ NavIC satellite elevation angle from obs and nav data Trying to find GNSS/ NavIC satellite elevation angle from obs and nav data gnss, elevation angle, calculation, .obs, .nav MATLAB Answers — New Questions
How can I use fitdist function
Hello,
I tried to use the function fitdist. The only result is an error:
Undefined function ‘fitdist’ for input arguments of type ‘double’.
Error in FitaNormalDistributiontoDataExample (line 13)
pd = fitdist(x,’Normal’)
This was the result of running the code from help file: C:Users…DocumentsMATLABExamplesFitaNormalDistributiontoDataExampleFitaNormalDistributiontoDataExample.m
%% Fit a Normal Distribution to Data
% Copyright 2015 The MathWorks, Inc.
%%
% Load the sample data. Create a vector containing the patients’ weight data.
load hospital
x = hospital.Weight;
%%
% Create a normal distribution object by fitting it to the data.
pd = fitdist(x,’Normal’)
%%
% Plot the pdf of the distribution.
x_values = 50:1:250;
y = pdf(pd,x_values);
plot(x_values,y,’LineWidth’,2)
What is wrong here?Hello,
I tried to use the function fitdist. The only result is an error:
Undefined function ‘fitdist’ for input arguments of type ‘double’.
Error in FitaNormalDistributiontoDataExample (line 13)
pd = fitdist(x,’Normal’)
This was the result of running the code from help file: C:Users…DocumentsMATLABExamplesFitaNormalDistributiontoDataExampleFitaNormalDistributiontoDataExample.m
%% Fit a Normal Distribution to Data
% Copyright 2015 The MathWorks, Inc.
%%
% Load the sample data. Create a vector containing the patients’ weight data.
load hospital
x = hospital.Weight;
%%
% Create a normal distribution object by fitting it to the data.
pd = fitdist(x,’Normal’)
%%
% Plot the pdf of the distribution.
x_values = 50:1:250;
y = pdf(pd,x_values);
plot(x_values,y,’LineWidth’,2)
What is wrong here? Hello,
I tried to use the function fitdist. The only result is an error:
Undefined function ‘fitdist’ for input arguments of type ‘double’.
Error in FitaNormalDistributiontoDataExample (line 13)
pd = fitdist(x,’Normal’)
This was the result of running the code from help file: C:Users…DocumentsMATLABExamplesFitaNormalDistributiontoDataExampleFitaNormalDistributiontoDataExample.m
%% Fit a Normal Distribution to Data
% Copyright 2015 The MathWorks, Inc.
%%
% Load the sample data. Create a vector containing the patients’ weight data.
load hospital
x = hospital.Weight;
%%
% Create a normal distribution object by fitting it to the data.
pd = fitdist(x,’Normal’)
%%
% Plot the pdf of the distribution.
x_values = 50:1:250;
y = pdf(pd,x_values);
plot(x_values,y,’LineWidth’,2)
What is wrong here? fitdist error MATLAB Answers — New Questions
Problem Saving UIFigures when running in parallel
Attempts to save UIFigure inside a parfor loop using getframe or exportgraphics dont seem to work. Returning the error that these functions cant be used in nodisplay mode. I rely on a 3rd party function ft_topoplot_er to plot certain topographs on my UIFigure and save the resulting video, but these calls take some time done sequentially, so I wished to parallelise them using parfor yet I’m unable to do so.Attempts to save UIFigure inside a parfor loop using getframe or exportgraphics dont seem to work. Returning the error that these functions cant be used in nodisplay mode. I rely on a 3rd party function ft_topoplot_er to plot certain topographs on my UIFigure and save the resulting video, but these calls take some time done sequentially, so I wished to parallelise them using parfor yet I’m unable to do so. Attempts to save UIFigure inside a parfor loop using getframe or exportgraphics dont seem to work. Returning the error that these functions cant be used in nodisplay mode. I rely on a 3rd party function ft_topoplot_er to plot certain topographs on my UIFigure and save the resulting video, but these calls take some time done sequentially, so I wished to parallelise them using parfor yet I’m unable to do so. parfor, uifigure, videowriter MATLAB Answers — New Questions
How many colors with their name present in the image.
I am looking for a way to find the number and name of certain colors present in the image so that I can use them to count for each pixel. I am doing it but actually some other colors or can say mixed colors are also present in the image which when I count are left in the counting and it counts less and as I increase the size of image pixels the uncounted number increase. I am giving the color ranges for the visible 13 colors in the image but their are some other colors present too which I am missing. How can I find them? Thanks in advane for the help, I am stuck with the problem since long time. My image isI am looking for a way to find the number and name of certain colors present in the image so that I can use them to count for each pixel. I am doing it but actually some other colors or can say mixed colors are also present in the image which when I count are left in the counting and it counts less and as I increase the size of image pixels the uncounted number increase. I am giving the color ranges for the visible 13 colors in the image but their are some other colors present too which I am missing. How can I find them? Thanks in advane for the help, I am stuck with the problem since long time. My image is I am looking for a way to find the number and name of certain colors present in the image so that I can use them to count for each pixel. I am doing it but actually some other colors or can say mixed colors are also present in the image which when I count are left in the counting and it counts less and as I increase the size of image pixels the uncounted number increase. I am giving the color ranges for the visible 13 colors in the image but their are some other colors present too which I am missing. How can I find them? Thanks in advane for the help, I am stuck with the problem since long time. My image is all colors number and name, color detection, all unique colors name and count in the image MATLAB Answers — New Questions
How do i connect matlab ui with simulink
i created matlab gui and the simulink model i want it to be combine how can i do those thinki created matlab gui and the simulink model i want it to be combine how can i do those think i created matlab gui and the simulink model i want it to be combine how can i do those think matlab ui, simulink MATLAB Answers — New Questions
Slow initialization at startup during the “Ready” step
I have installed Matlab R2024b on a Kubuntu 24.10 system. I installed only Matlab without an Add-ons and had no trouble during installation. Starting the program results in a long initialization time. I tracked the initialization process with the -timing flag. This results in the following output:
MATLAB Startup Performance Metrics (In Seconds)
total item gap description
=========================================================
0.47 0.47 0.00 MATLAB script
0.66 0.20 -0.00 main
0.71 0.05 0.00 Session Initialize
1.99 0.01 1.27 Toolbox cache load Start
1.99 0.44 0.84 Session Initialize
2.33 0.34 1.99 cachepath
2.50 0.11 2.38 LM Startup
2.60 0.10 0.00 splash
3.03 0.20 0.23 Constant Initialization
3.33 0.73 0.00 Engine Startup
3.52 0.20 0.00 InitSunVM
5.01 1.43 0.06 PostVMInit
5.01 1.68 0.00 mljInit
5.72 0.71 0.00 StartDesktop
5.72 2.39 0.00 Java initialization
5.72 0.00 0.00 psParser
5.72 0.00 0.00 Toolbox cache join
5.74 0.01 0.00 Package Registry initialization
6.17 0.21 0.22 matlabpath
7.08 0.19 0.72 matlabrc
7.09 0.00 0.00 Startup File
9.27 3.55 5.72 Init Desktop
217.84 212.12 5.72 Ready
=========================================================
Items shown account for 99.8% of total startup time
As visible, the last step consumes most of the time. Running the program bare with the -nojvm flag results in a quick start (3.92 s) . I already tried to increase the Java Memory heap space, as suggested in https://de.mathworks.com/matlabcentral/answers/1956139-slow-java-initialization-during-startup and tried several solutions from https://de.mathworks.com/matlabcentral/answers/92566-why-does-matlab-get-stuck-in-the-initializing-or-busy-state-or-take-a-long-time-to-start without improving the starting time.
Thanks in advance for any ideas how to resolve this issue.I have installed Matlab R2024b on a Kubuntu 24.10 system. I installed only Matlab without an Add-ons and had no trouble during installation. Starting the program results in a long initialization time. I tracked the initialization process with the -timing flag. This results in the following output:
MATLAB Startup Performance Metrics (In Seconds)
total item gap description
=========================================================
0.47 0.47 0.00 MATLAB script
0.66 0.20 -0.00 main
0.71 0.05 0.00 Session Initialize
1.99 0.01 1.27 Toolbox cache load Start
1.99 0.44 0.84 Session Initialize
2.33 0.34 1.99 cachepath
2.50 0.11 2.38 LM Startup
2.60 0.10 0.00 splash
3.03 0.20 0.23 Constant Initialization
3.33 0.73 0.00 Engine Startup
3.52 0.20 0.00 InitSunVM
5.01 1.43 0.06 PostVMInit
5.01 1.68 0.00 mljInit
5.72 0.71 0.00 StartDesktop
5.72 2.39 0.00 Java initialization
5.72 0.00 0.00 psParser
5.72 0.00 0.00 Toolbox cache join
5.74 0.01 0.00 Package Registry initialization
6.17 0.21 0.22 matlabpath
7.08 0.19 0.72 matlabrc
7.09 0.00 0.00 Startup File
9.27 3.55 5.72 Init Desktop
217.84 212.12 5.72 Ready
=========================================================
Items shown account for 99.8% of total startup time
As visible, the last step consumes most of the time. Running the program bare with the -nojvm flag results in a quick start (3.92 s) . I already tried to increase the Java Memory heap space, as suggested in https://de.mathworks.com/matlabcentral/answers/1956139-slow-java-initialization-during-startup and tried several solutions from https://de.mathworks.com/matlabcentral/answers/92566-why-does-matlab-get-stuck-in-the-initializing-or-busy-state-or-take-a-long-time-to-start without improving the starting time.
Thanks in advance for any ideas how to resolve this issue. I have installed Matlab R2024b on a Kubuntu 24.10 system. I installed only Matlab without an Add-ons and had no trouble during installation. Starting the program results in a long initialization time. I tracked the initialization process with the -timing flag. This results in the following output:
MATLAB Startup Performance Metrics (In Seconds)
total item gap description
=========================================================
0.47 0.47 0.00 MATLAB script
0.66 0.20 -0.00 main
0.71 0.05 0.00 Session Initialize
1.99 0.01 1.27 Toolbox cache load Start
1.99 0.44 0.84 Session Initialize
2.33 0.34 1.99 cachepath
2.50 0.11 2.38 LM Startup
2.60 0.10 0.00 splash
3.03 0.20 0.23 Constant Initialization
3.33 0.73 0.00 Engine Startup
3.52 0.20 0.00 InitSunVM
5.01 1.43 0.06 PostVMInit
5.01 1.68 0.00 mljInit
5.72 0.71 0.00 StartDesktop
5.72 2.39 0.00 Java initialization
5.72 0.00 0.00 psParser
5.72 0.00 0.00 Toolbox cache join
5.74 0.01 0.00 Package Registry initialization
6.17 0.21 0.22 matlabpath
7.08 0.19 0.72 matlabrc
7.09 0.00 0.00 Startup File
9.27 3.55 5.72 Init Desktop
217.84 212.12 5.72 Ready
=========================================================
Items shown account for 99.8% of total startup time
As visible, the last step consumes most of the time. Running the program bare with the -nojvm flag results in a quick start (3.92 s) . I already tried to increase the Java Memory heap space, as suggested in https://de.mathworks.com/matlabcentral/answers/1956139-slow-java-initialization-during-startup and tried several solutions from https://de.mathworks.com/matlabcentral/answers/92566-why-does-matlab-get-stuck-in-the-initializing-or-busy-state-or-take-a-long-time-to-start without improving the starting time.
Thanks in advance for any ideas how to resolve this issue. initializing, installation, linux, startup time MATLAB Answers — New Questions