Category: Matlab
Category Archives: Matlab
Matlab To Snowflake Data Warehouse
Any recommendations or best practices for how best to connect Matlab to Snowflake date wareshouse.Any recommendations or best practices for how best to connect Matlab to Snowflake date wareshouse. Any recommendations or best practices for how best to connect Matlab to Snowflake date wareshouse. database, odbc, jdbc MATLAB Answers — New Questions
What is the reference for the power/frequency scale bar on the right in Spectrogram?
Dear experts,
Can anyone help me how to get the power/frequency scale in Spectrogram using STFT?
What is the reference for the power/frequency scale bar on the right?
Additionally, how to plot actual time interval? I want it to plot on the time axis from for exp. 5083s time span but using the spectrogram built in function plots from 0 s as seen below.
I appreciate if anyone can help me with this.Dear experts,
Can anyone help me how to get the power/frequency scale in Spectrogram using STFT?
What is the reference for the power/frequency scale bar on the right?
Additionally, how to plot actual time interval? I want it to plot on the time axis from for exp. 5083s time span but using the spectrogram built in function plots from 0 s as seen below.
I appreciate if anyone can help me with this. Dear experts,
Can anyone help me how to get the power/frequency scale in Spectrogram using STFT?
What is the reference for the power/frequency scale bar on the right?
Additionally, how to plot actual time interval? I want it to plot on the time axis from for exp. 5083s time span but using the spectrogram built in function plots from 0 s as seen below.
I appreciate if anyone can help me with this. spectrogram, stft, actual time interval, power/frequency reference MATLAB Answers — New Questions
The estimation error is strangely obtained from Simpson’s 1/3 rule
Hello, I am looking for the estimation error of Simpson’s rule of thirds. When dx is 1.01, the integral value is 2908800 and the error is 0.01, but the estimation error is 5.5567e-09. Where did it go wrong?
clc; clear all; close all;
a = -1.93317553181561E-24;
b = 3.788630291530091e-21;
c = -2.3447910280083294e-18
d = -0.019531249999999518;
e = 18.74999999999999
fun = @(t) a.*t.^5 + b.*t.^4 + c.*t.^3 + d.*t.^2+e.*t
x = 0:0.1:960;
fx =fun(x);
n=960;
dx=1.01
int=0;
for i =1:n
plot(x, fx,’k’,’linewidth’,2);
mid=((i-1)+i)/2;
fx_mid = fun(mid);
fx_left = fun(i-1);
fx_right = fun(i);
area_temp = dx/6*(fx_left +4*fx_mid+fx_right);
int = int + area_temp;
x_segment = linspace(i-1, i,100);
Px = fx_left * ((x_segment-mid).*(x_segment-i))/((i-1-mid)*(i-1-i))…
+ fx_mid*((x_segment-i+1)).*(x_segment-i)/((mid-i+1)*(mid-i))…
+ fx_right * ((x_segment-i+1).*(x_segment-mid))/((i-i+1)*(i-mid));
area(x_segment,Px); hold on;
end
C=480;
E_a = -((960.^5)/(2880.*1.01.^4)).*(a.*120.*C+24.*b);%Is there a problem here?
disp(‘E_a’);
disp(E_a);
disp(int);
int_true = 2880000
rel_error=norm(int_true-int)/norm(int_true);
disp(‘rel_error’);
disp(rel_error);Hello, I am looking for the estimation error of Simpson’s rule of thirds. When dx is 1.01, the integral value is 2908800 and the error is 0.01, but the estimation error is 5.5567e-09. Where did it go wrong?
clc; clear all; close all;
a = -1.93317553181561E-24;
b = 3.788630291530091e-21;
c = -2.3447910280083294e-18
d = -0.019531249999999518;
e = 18.74999999999999
fun = @(t) a.*t.^5 + b.*t.^4 + c.*t.^3 + d.*t.^2+e.*t
x = 0:0.1:960;
fx =fun(x);
n=960;
dx=1.01
int=0;
for i =1:n
plot(x, fx,’k’,’linewidth’,2);
mid=((i-1)+i)/2;
fx_mid = fun(mid);
fx_left = fun(i-1);
fx_right = fun(i);
area_temp = dx/6*(fx_left +4*fx_mid+fx_right);
int = int + area_temp;
x_segment = linspace(i-1, i,100);
Px = fx_left * ((x_segment-mid).*(x_segment-i))/((i-1-mid)*(i-1-i))…
+ fx_mid*((x_segment-i+1)).*(x_segment-i)/((mid-i+1)*(mid-i))…
+ fx_right * ((x_segment-i+1).*(x_segment-mid))/((i-i+1)*(i-mid));
area(x_segment,Px); hold on;
end
C=480;
E_a = -((960.^5)/(2880.*1.01.^4)).*(a.*120.*C+24.*b);%Is there a problem here?
disp(‘E_a’);
disp(E_a);
disp(int);
int_true = 2880000
rel_error=norm(int_true-int)/norm(int_true);
disp(‘rel_error’);
disp(rel_error); Hello, I am looking for the estimation error of Simpson’s rule of thirds. When dx is 1.01, the integral value is 2908800 and the error is 0.01, but the estimation error is 5.5567e-09. Where did it go wrong?
clc; clear all; close all;
a = -1.93317553181561E-24;
b = 3.788630291530091e-21;
c = -2.3447910280083294e-18
d = -0.019531249999999518;
e = 18.74999999999999
fun = @(t) a.*t.^5 + b.*t.^4 + c.*t.^3 + d.*t.^2+e.*t
x = 0:0.1:960;
fx =fun(x);
n=960;
dx=1.01
int=0;
for i =1:n
plot(x, fx,’k’,’linewidth’,2);
mid=((i-1)+i)/2;
fx_mid = fun(mid);
fx_left = fun(i-1);
fx_right = fun(i);
area_temp = dx/6*(fx_left +4*fx_mid+fx_right);
int = int + area_temp;
x_segment = linspace(i-1, i,100);
Px = fx_left * ((x_segment-mid).*(x_segment-i))/((i-1-mid)*(i-1-i))…
+ fx_mid*((x_segment-i+1)).*(x_segment-i)/((mid-i+1)*(mid-i))…
+ fx_right * ((x_segment-i+1).*(x_segment-mid))/((i-i+1)*(i-mid));
area(x_segment,Px); hold on;
end
C=480;
E_a = -((960.^5)/(2880.*1.01.^4)).*(a.*120.*C+24.*b);%Is there a problem here?
disp(‘E_a’);
disp(E_a);
disp(int);
int_true = 2880000
rel_error=norm(int_true-int)/norm(int_true);
disp(‘rel_error’);
disp(rel_error); simpson’s 1/3 rule, estimation error MATLAB Answers — New Questions
why are the results different from moist air domain(MA) using only dry air and gas domain(G)? – simscape
Hello, I used Simscape to model with the constant volume chamber, local restriction, and controlled heat flow rate source blocks. I used the semi-ideal gas and now I’m trying to switch to the moist air domain to include gases with different properties. I modeled it the same way as before and set the humidity ratio to 0 to ensure there is no water vapor. However, the results are significantly different. Are there any conditions I might have overlooked?Hello, I used Simscape to model with the constant volume chamber, local restriction, and controlled heat flow rate source blocks. I used the semi-ideal gas and now I’m trying to switch to the moist air domain to include gases with different properties. I modeled it the same way as before and set the humidity ratio to 0 to ensure there is no water vapor. However, the results are significantly different. Are there any conditions I might have overlooked? Hello, I used Simscape to model with the constant volume chamber, local restriction, and controlled heat flow rate source blocks. I used the semi-ideal gas and now I’m trying to switch to the moist air domain to include gases with different properties. I modeled it the same way as before and set the humidity ratio to 0 to ensure there is no water vapor. However, the results are significantly different. Are there any conditions I might have overlooked? ma, trace gas MATLAB Answers — New Questions
Trying to merge two tables, using time stamps as keys in outerjoin(), getting ‘incorrect data type or missing argument’ error.
Hi!
I have two tables, each with two rows. One is ‘raw’, and has each possible time stamp and corresponding data. The other is ‘valid’, and only has time stamps corresponding to valid data. I want to have a third table, that contains all time stamps but NaNs where there isn’t both raw and valid data.
So, for example, these would go into outerjoin()
valid = ‘t_ms’ ‘val_dat’
[ 1 55
2 50
4 52 ]
raw = [ 1 49
2 37
3 51
4 52 ]
And I’d get a table that’s the length of ‘raw’, and ‘valid’ containing NaNs. Instead, I get the error:
‘Check for incorrect argument data type or missing argument in call to outerjoin.’
I’ve quadruple checked that I’m inputting tables, and the key variables have the exact same name, and I’ve tried pretty much every optional argument into outerjoin() I can, no dice.
Any help would be much appreciated, embarrassingly enough I’m stumped!
ThanksHi!
I have two tables, each with two rows. One is ‘raw’, and has each possible time stamp and corresponding data. The other is ‘valid’, and only has time stamps corresponding to valid data. I want to have a third table, that contains all time stamps but NaNs where there isn’t both raw and valid data.
So, for example, these would go into outerjoin()
valid = ‘t_ms’ ‘val_dat’
[ 1 55
2 50
4 52 ]
raw = [ 1 49
2 37
3 51
4 52 ]
And I’d get a table that’s the length of ‘raw’, and ‘valid’ containing NaNs. Instead, I get the error:
‘Check for incorrect argument data type or missing argument in call to outerjoin.’
I’ve quadruple checked that I’m inputting tables, and the key variables have the exact same name, and I’ve tried pretty much every optional argument into outerjoin() I can, no dice.
Any help would be much appreciated, embarrassingly enough I’m stumped!
Thanks Hi!
I have two tables, each with two rows. One is ‘raw’, and has each possible time stamp and corresponding data. The other is ‘valid’, and only has time stamps corresponding to valid data. I want to have a third table, that contains all time stamps but NaNs where there isn’t both raw and valid data.
So, for example, these would go into outerjoin()
valid = ‘t_ms’ ‘val_dat’
[ 1 55
2 50
4 52 ]
raw = [ 1 49
2 37
3 51
4 52 ]
And I’d get a table that’s the length of ‘raw’, and ‘valid’ containing NaNs. Instead, I get the error:
‘Check for incorrect argument data type or missing argument in call to outerjoin.’
I’ve quadruple checked that I’m inputting tables, and the key variables have the exact same name, and I’ve tried pretty much every optional argument into outerjoin() I can, no dice.
Any help would be much appreciated, embarrassingly enough I’m stumped!
Thanks outerjoin, tables, datatype MATLAB Answers — New Questions
I’d like to make several ‘figure’ window
I want to add two figure windows, but <figure 2> window doesn’t show up.
<code>
%상태 방정식
%Dx1 = -x1 – x2 + u1 + u2
%Dx2 = 6.5*x1 + u1
%y1 = x1
%y2 = x2
t = 0:0.01:15;
A = [-1 -1;6.5 0];
B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
sys = ss(A,B,C,D);
impulse(sys,t);
[y,t,x] = impulse(sys,t);
y1 = [1 0]*y(:,:,1)’ + [1 0]*y(:,:,2)’;
y2 = [0 1]*y(:,:,1)’ + [0 1]*y(:,:,2)’;
figure(1)
plot(t,sys)
xlabel(‘Time,(s)’)
ylabel(‘y’)
grid;
legend(‘y’)
figure(2)
subplot(211);
plot(t, y1); grid
ylabel(‘y_1’)
subplot(212);
plot(t, y2); grid
xlabel(‘t (sec)’); ylabel(‘y_2’)I want to add two figure windows, but <figure 2> window doesn’t show up.
<code>
%상태 방정식
%Dx1 = -x1 – x2 + u1 + u2
%Dx2 = 6.5*x1 + u1
%y1 = x1
%y2 = x2
t = 0:0.01:15;
A = [-1 -1;6.5 0];
B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
sys = ss(A,B,C,D);
impulse(sys,t);
[y,t,x] = impulse(sys,t);
y1 = [1 0]*y(:,:,1)’ + [1 0]*y(:,:,2)’;
y2 = [0 1]*y(:,:,1)’ + [0 1]*y(:,:,2)’;
figure(1)
plot(t,sys)
xlabel(‘Time,(s)’)
ylabel(‘y’)
grid;
legend(‘y’)
figure(2)
subplot(211);
plot(t, y1); grid
ylabel(‘y_1’)
subplot(212);
plot(t, y2); grid
xlabel(‘t (sec)’); ylabel(‘y_2’) I want to add two figure windows, but <figure 2> window doesn’t show up.
<code>
%상태 방정식
%Dx1 = -x1 – x2 + u1 + u2
%Dx2 = 6.5*x1 + u1
%y1 = x1
%y2 = x2
t = 0:0.01:15;
A = [-1 -1;6.5 0];
B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
sys = ss(A,B,C,D);
impulse(sys,t);
[y,t,x] = impulse(sys,t);
y1 = [1 0]*y(:,:,1)’ + [1 0]*y(:,:,2)’;
y2 = [0 1]*y(:,:,1)’ + [0 1]*y(:,:,2)’;
figure(1)
plot(t,sys)
xlabel(‘Time,(s)’)
ylabel(‘y’)
grid;
legend(‘y’)
figure(2)
subplot(211);
plot(t, y1); grid
ylabel(‘y_1’)
subplot(212);
plot(t, y2); grid
xlabel(‘t (sec)’); ylabel(‘y_2’) matlab MATLAB Answers — New Questions
An optimization with fmincon
Hello everyone, sorry for the inconvenience. I would have a problem with the optimization via the fmincon function. I wanted to ask, kindly, if anyone could help me. I need to get 3 parameters (x1, x2, x3 = 0.4242 0.2928 0.2830; max = 319). Thanks to who will answer me. Good day.
%% FITTING MODEL
%———————————————–
clc, clear
global x1s x2s x3s rs
global betax
data = [100 0 0 265
0 100 0 170
0 0 100 119
50 50 0 252
50 0 50 247
0 50 50 222
66.67 16.67 16.67 310
16.67 66.67 16.67 244
16.67 16.67 66.67 239
33.33 33.33 33.33 322
100 0 0 257
0 100 0 181
0 0 100 127];
x1s = data(:,1)/100; % values of x1
x2s = data(:,2)/100; % values of x2
x3s = data(:,3)/100; % values of x1
rs = data(:,4); % values of residual
% function
beta0 = [62.8 173.1 122.6 131.0 228.2 274.2 1597.9];
beta=lsqnonlin(‘funzione’,beta0);
for j=1:length(rs)
rc(j)= modello(x1s(j),x2s(j),x3s(j));
res(j) = rc(j) – rs(j);
end
%% data calculation
betax = beta;
ndat=10000;
for j=1:ndat
x1c(j) = rand(1,1);
x2c(j) = rand(1,1)*(1-x1c(j));
x3c(j) = 1-x1c(j)-x2c(j);
risp(j) = modello(x1c(j),x2c(j),x3c(j));
end
%% diagram
figure(1);
% plot of data
% colour
% test surface response
colormap (jet)
[hg,htick,hcb] = tersurf(x1c,x2c,x3c,risp);
% axes label
hlabels = terlabel(‘x1′,’x2′,’x3’);
%% experiment
figure(2)
%– Plot axis
[h,hg,htick] = terplot;
%– Plot data
hter = ternaryc(x1s,x2s,x3s);
set(hter,’marker’,’o’,’markerfacecolor’,’blue’,’markersize’,’8′)
hlabels = terlabel(‘x1′,’x2′,’x3’);
%% residual plot
figure(3)
plot(x1s,res,’ro’)
xlabel(‘x1’)
ylabel(‘residui’)
grid
%% NORMAL PROBABILITY GRAPH
figure(4)
res_sort = sort(res);
for j = 1:length(res)
xj(j) = j/(length(res)-1);
end
semilogy(res_sort,xj,’ko’)
grid
%% SEARCH FOR THE MINIMUM
x0 = [0.3 0.3 0.3]; % punto centrale
lb = [0 0 0]; % limite inferiore
ub = [1 1 1]; % limite superiore
Aeq = [1 1 1];
beq = 1;
y = fmincon(‘funz’,x0,[],[],Aeq,beq,lb,ub)
modello(xmax(1),xmax(2),xmax(3))
function [z] = funz (x1s,x2s,x3s)
global x1s x2s x3s
z = 62.8.*x1s+173.1.*x2s+122.6.*x3s+131.0.*x1s*x2s+228.2.*x1s*x3s+274.2.*x2s*x3s+1597.9.*x1s*x2s*x3s;
endHello everyone, sorry for the inconvenience. I would have a problem with the optimization via the fmincon function. I wanted to ask, kindly, if anyone could help me. I need to get 3 parameters (x1, x2, x3 = 0.4242 0.2928 0.2830; max = 319). Thanks to who will answer me. Good day.
%% FITTING MODEL
%———————————————–
clc, clear
global x1s x2s x3s rs
global betax
data = [100 0 0 265
0 100 0 170
0 0 100 119
50 50 0 252
50 0 50 247
0 50 50 222
66.67 16.67 16.67 310
16.67 66.67 16.67 244
16.67 16.67 66.67 239
33.33 33.33 33.33 322
100 0 0 257
0 100 0 181
0 0 100 127];
x1s = data(:,1)/100; % values of x1
x2s = data(:,2)/100; % values of x2
x3s = data(:,3)/100; % values of x1
rs = data(:,4); % values of residual
% function
beta0 = [62.8 173.1 122.6 131.0 228.2 274.2 1597.9];
beta=lsqnonlin(‘funzione’,beta0);
for j=1:length(rs)
rc(j)= modello(x1s(j),x2s(j),x3s(j));
res(j) = rc(j) – rs(j);
end
%% data calculation
betax = beta;
ndat=10000;
for j=1:ndat
x1c(j) = rand(1,1);
x2c(j) = rand(1,1)*(1-x1c(j));
x3c(j) = 1-x1c(j)-x2c(j);
risp(j) = modello(x1c(j),x2c(j),x3c(j));
end
%% diagram
figure(1);
% plot of data
% colour
% test surface response
colormap (jet)
[hg,htick,hcb] = tersurf(x1c,x2c,x3c,risp);
% axes label
hlabels = terlabel(‘x1′,’x2′,’x3’);
%% experiment
figure(2)
%– Plot axis
[h,hg,htick] = terplot;
%– Plot data
hter = ternaryc(x1s,x2s,x3s);
set(hter,’marker’,’o’,’markerfacecolor’,’blue’,’markersize’,’8′)
hlabels = terlabel(‘x1′,’x2′,’x3’);
%% residual plot
figure(3)
plot(x1s,res,’ro’)
xlabel(‘x1’)
ylabel(‘residui’)
grid
%% NORMAL PROBABILITY GRAPH
figure(4)
res_sort = sort(res);
for j = 1:length(res)
xj(j) = j/(length(res)-1);
end
semilogy(res_sort,xj,’ko’)
grid
%% SEARCH FOR THE MINIMUM
x0 = [0.3 0.3 0.3]; % punto centrale
lb = [0 0 0]; % limite inferiore
ub = [1 1 1]; % limite superiore
Aeq = [1 1 1];
beq = 1;
y = fmincon(‘funz’,x0,[],[],Aeq,beq,lb,ub)
modello(xmax(1),xmax(2),xmax(3))
function [z] = funz (x1s,x2s,x3s)
global x1s x2s x3s
z = 62.8.*x1s+173.1.*x2s+122.6.*x3s+131.0.*x1s*x2s+228.2.*x1s*x3s+274.2.*x2s*x3s+1597.9.*x1s*x2s*x3s;
end Hello everyone, sorry for the inconvenience. I would have a problem with the optimization via the fmincon function. I wanted to ask, kindly, if anyone could help me. I need to get 3 parameters (x1, x2, x3 = 0.4242 0.2928 0.2830; max = 319). Thanks to who will answer me. Good day.
%% FITTING MODEL
%———————————————–
clc, clear
global x1s x2s x3s rs
global betax
data = [100 0 0 265
0 100 0 170
0 0 100 119
50 50 0 252
50 0 50 247
0 50 50 222
66.67 16.67 16.67 310
16.67 66.67 16.67 244
16.67 16.67 66.67 239
33.33 33.33 33.33 322
100 0 0 257
0 100 0 181
0 0 100 127];
x1s = data(:,1)/100; % values of x1
x2s = data(:,2)/100; % values of x2
x3s = data(:,3)/100; % values of x1
rs = data(:,4); % values of residual
% function
beta0 = [62.8 173.1 122.6 131.0 228.2 274.2 1597.9];
beta=lsqnonlin(‘funzione’,beta0);
for j=1:length(rs)
rc(j)= modello(x1s(j),x2s(j),x3s(j));
res(j) = rc(j) – rs(j);
end
%% data calculation
betax = beta;
ndat=10000;
for j=1:ndat
x1c(j) = rand(1,1);
x2c(j) = rand(1,1)*(1-x1c(j));
x3c(j) = 1-x1c(j)-x2c(j);
risp(j) = modello(x1c(j),x2c(j),x3c(j));
end
%% diagram
figure(1);
% plot of data
% colour
% test surface response
colormap (jet)
[hg,htick,hcb] = tersurf(x1c,x2c,x3c,risp);
% axes label
hlabels = terlabel(‘x1′,’x2′,’x3’);
%% experiment
figure(2)
%– Plot axis
[h,hg,htick] = terplot;
%– Plot data
hter = ternaryc(x1s,x2s,x3s);
set(hter,’marker’,’o’,’markerfacecolor’,’blue’,’markersize’,’8′)
hlabels = terlabel(‘x1′,’x2′,’x3’);
%% residual plot
figure(3)
plot(x1s,res,’ro’)
xlabel(‘x1’)
ylabel(‘residui’)
grid
%% NORMAL PROBABILITY GRAPH
figure(4)
res_sort = sort(res);
for j = 1:length(res)
xj(j) = j/(length(res)-1);
end
semilogy(res_sort,xj,’ko’)
grid
%% SEARCH FOR THE MINIMUM
x0 = [0.3 0.3 0.3]; % punto centrale
lb = [0 0 0]; % limite inferiore
ub = [1 1 1]; % limite superiore
Aeq = [1 1 1];
beq = 1;
y = fmincon(‘funz’,x0,[],[],Aeq,beq,lb,ub)
modello(xmax(1),xmax(2),xmax(3))
function [z] = funz (x1s,x2s,x3s)
global x1s x2s x3s
z = 62.8.*x1s+173.1.*x2s+122.6.*x3s+131.0.*x1s*x2s+228.2.*x1s*x3s+274.2.*x2s*x3s+1597.9.*x1s*x2s*x3s;
end help fmincon, help-fmincon MATLAB Answers — New Questions
Ethernet-Based AXI Manager Error
Hello,
I am trying to implement MathWorks example described in: https://www.mathworks.com/help/hdlverifier/xilinxfpgaboards/ug/access-fpga-mem-using-ethernet-aximaster.html
The board I am trying to use is the Xilinx AC701. Reading throughout MathWorks documentation there is nothing that indicates the example could not work for this board. It is just not part of the supported boards but the specifications are very similar to the one being used in that example (KC705).
I was able to implement the example in my board’s FPGA and I can see the ethernet port alive in my PC using WireShark. However, I am not able to create an aximanager ethernet object as the following error appears:
Error using hdlverifier.AXIManagerUDP
Unable to ping the device. Please check the hardware IP address, the Ethernet cable connection, and the configuration of the
Network Interface Card.
Error in hdlverifier.AXIManagerUDP
Error in aximanager
I set the PC IP to 192.168.0.10 and the gateway to 192.168.0.2
This is what I se on the ethernet status:
The code I am using to create the aximanager object is:
hDDR = aximanager(‘Xilinx’,’interface’,’Ethernet’, …
‘DeviceAddress’,’192.168.0.2′);
writememory(hDDR,’00000000′,100);
readmemory(hDDR,’00000000′,1);
The erro I am receiving is:
I am using Matalab R2023b and Vivado 2022.1
Any idea of what I am doing wrong and why I am receiving this error?
Thank you,Hello,
I am trying to implement MathWorks example described in: https://www.mathworks.com/help/hdlverifier/xilinxfpgaboards/ug/access-fpga-mem-using-ethernet-aximaster.html
The board I am trying to use is the Xilinx AC701. Reading throughout MathWorks documentation there is nothing that indicates the example could not work for this board. It is just not part of the supported boards but the specifications are very similar to the one being used in that example (KC705).
I was able to implement the example in my board’s FPGA and I can see the ethernet port alive in my PC using WireShark. However, I am not able to create an aximanager ethernet object as the following error appears:
Error using hdlverifier.AXIManagerUDP
Unable to ping the device. Please check the hardware IP address, the Ethernet cable connection, and the configuration of the
Network Interface Card.
Error in hdlverifier.AXIManagerUDP
Error in aximanager
I set the PC IP to 192.168.0.10 and the gateway to 192.168.0.2
This is what I se on the ethernet status:
The code I am using to create the aximanager object is:
hDDR = aximanager(‘Xilinx’,’interface’,’Ethernet’, …
‘DeviceAddress’,’192.168.0.2′);
writememory(hDDR,’00000000′,100);
readmemory(hDDR,’00000000′,1);
The erro I am receiving is:
I am using Matalab R2023b and Vivado 2022.1
Any idea of what I am doing wrong and why I am receiving this error?
Thank you, Hello,
I am trying to implement MathWorks example described in: https://www.mathworks.com/help/hdlverifier/xilinxfpgaboards/ug/access-fpga-mem-using-ethernet-aximaster.html
The board I am trying to use is the Xilinx AC701. Reading throughout MathWorks documentation there is nothing that indicates the example could not work for this board. It is just not part of the supported boards but the specifications are very similar to the one being used in that example (KC705).
I was able to implement the example in my board’s FPGA and I can see the ethernet port alive in my PC using WireShark. However, I am not able to create an aximanager ethernet object as the following error appears:
Error using hdlverifier.AXIManagerUDP
Unable to ping the device. Please check the hardware IP address, the Ethernet cable connection, and the configuration of the
Network Interface Card.
Error in hdlverifier.AXIManagerUDP
Error in aximanager
I set the PC IP to 192.168.0.10 and the gateway to 192.168.0.2
This is what I se on the ethernet status:
The code I am using to create the aximanager object is:
hDDR = aximanager(‘Xilinx’,’interface’,’Ethernet’, …
‘DeviceAddress’,’192.168.0.2′);
writememory(hDDR,’00000000′,100);
readmemory(hDDR,’00000000′,1);
The erro I am receiving is:
I am using Matalab R2023b and Vivado 2022.1
Any idea of what I am doing wrong and why I am receiving this error?
Thank you, aximanager, matlab MATLAB Answers — New Questions
How can I declare an implicit variable, y(t), after I have used it in a symbolically defined function?
I’m writing a scheme that solves an ODE and in doing so I declare a symbolic function:
syms t y(t)
f = t^(-2) * (sin(2*t) – 2*t*y)
At one point I have to take a total derivative, so I need to be be implicit in the expression, but I also need to evalute at a specific value of and . I attempt to do this in the following lines.
y(t) = wi;
out(1) = f(ti);
However, I am prompted with the following error.
The following error occurred converting from sym to double:
Unable to convert expression containing remaining symbolic
function calls into double array. Argument must be
expression that evaluates to number.
Error in DiffEq_alt (line 13)
out(1) = f(ti);
Ultimately, I need to be able to be able to declare explicitly, but also treat it implicitly for when I differentiate the function with respect to .I’m writing a scheme that solves an ODE and in doing so I declare a symbolic function:
syms t y(t)
f = t^(-2) * (sin(2*t) – 2*t*y)
At one point I have to take a total derivative, so I need to be be implicit in the expression, but I also need to evalute at a specific value of and . I attempt to do this in the following lines.
y(t) = wi;
out(1) = f(ti);
However, I am prompted with the following error.
The following error occurred converting from sym to double:
Unable to convert expression containing remaining symbolic
function calls into double array. Argument must be
expression that evaluates to number.
Error in DiffEq_alt (line 13)
out(1) = f(ti);
Ultimately, I need to be able to be able to declare explicitly, but also treat it implicitly for when I differentiate the function with respect to . I’m writing a scheme that solves an ODE and in doing so I declare a symbolic function:
syms t y(t)
f = t^(-2) * (sin(2*t) – 2*t*y)
At one point I have to take a total derivative, so I need to be be implicit in the expression, but I also need to evalute at a specific value of and . I attempt to do this in the following lines.
y(t) = wi;
out(1) = f(ti);
However, I am prompted with the following error.
The following error occurred converting from sym to double:
Unable to convert expression containing remaining symbolic
function calls into double array. Argument must be
expression that evaluates to number.
Error in DiffEq_alt (line 13)
out(1) = f(ti);
Ultimately, I need to be able to be able to declare explicitly, but also treat it implicitly for when I differentiate the function with respect to . symbolic, differential equations, r2020b MATLAB Answers — New Questions
How can i bring this equation into matlab?
Hi, I want to make a equation solver with matlab.
what i want to make is attatched down below.
here, i have a thousand of data point with alpha and temperature.
also i have A, E, and R value.
here, what i tried is like this.
g_alpha = A/beta*cumtrapz(exp(-E./(R*T(2:length(T),:))));
and
n = 2;
G_alpha = [];
while n < 1000;
g_alpha = A/beta*int(exp(-E./(R*T(n+1,:))),[T(2,:) T(n+1,:)]);
G_alpha = [G_alpha; g_alpha];
n = n + 1;
end
but both of these aren’t work well.
do i miss something?
can anyone help me to make this completely?Hi, I want to make a equation solver with matlab.
what i want to make is attatched down below.
here, i have a thousand of data point with alpha and temperature.
also i have A, E, and R value.
here, what i tried is like this.
g_alpha = A/beta*cumtrapz(exp(-E./(R*T(2:length(T),:))));
and
n = 2;
G_alpha = [];
while n < 1000;
g_alpha = A/beta*int(exp(-E./(R*T(n+1,:))),[T(2,:) T(n+1,:)]);
G_alpha = [G_alpha; g_alpha];
n = n + 1;
end
but both of these aren’t work well.
do i miss something?
can anyone help me to make this completely? Hi, I want to make a equation solver with matlab.
what i want to make is attatched down below.
here, i have a thousand of data point with alpha and temperature.
also i have A, E, and R value.
here, what i tried is like this.
g_alpha = A/beta*cumtrapz(exp(-E./(R*T(2:length(T),:))));
and
n = 2;
G_alpha = [];
while n < 1000;
g_alpha = A/beta*int(exp(-E./(R*T(n+1,:))),[T(2,:) T(n+1,:)]);
G_alpha = [G_alpha; g_alpha];
n = n + 1;
end
but both of these aren’t work well.
do i miss something?
can anyone help me to make this completely? integration, data point, int, integral, data set, cumtrapz, trapz MATLAB Answers — New Questions
multivariate regression with multi dimensional variables
Dear Reader,
I’m having trouble with implementing a regression.
I have the following:
I have a 3D matrix results_demands(24,1,n) and a 3D matrix results_han(24,3,n)
Where 24 are the time steps and n are the observations.
I want to model the regression between the (24,1) vector results_demands and (24,3) matrix results_han
What I already tried is splitting up the results_han such that I have a matrix with n rows(observations) and 3 columns and every input is a (24,1) vector.
So that we have 3 response variables and 1 explanatory variable(results_demands) all variables in form of a vector.
How do I need to implement such extra dimensional case.
A visualization of the 3D matrices.
results_han : (24,3,n):
[ [vec_i] [vec_i] [vec_i]
[vec_i] [vec_i] [vec_i]
………………….
…………………. ]
with vec_i a (24,1) column vector
results_demands: (24,1,n):
[ [vec_k]
[vec_k]
……….]
with vec_k a (24,1) column vector
Thank you in advance!Dear Reader,
I’m having trouble with implementing a regression.
I have the following:
I have a 3D matrix results_demands(24,1,n) and a 3D matrix results_han(24,3,n)
Where 24 are the time steps and n are the observations.
I want to model the regression between the (24,1) vector results_demands and (24,3) matrix results_han
What I already tried is splitting up the results_han such that I have a matrix with n rows(observations) and 3 columns and every input is a (24,1) vector.
So that we have 3 response variables and 1 explanatory variable(results_demands) all variables in form of a vector.
How do I need to implement such extra dimensional case.
A visualization of the 3D matrices.
results_han : (24,3,n):
[ [vec_i] [vec_i] [vec_i]
[vec_i] [vec_i] [vec_i]
………………….
…………………. ]
with vec_i a (24,1) column vector
results_demands: (24,1,n):
[ [vec_k]
[vec_k]
……….]
with vec_k a (24,1) column vector
Thank you in advance! Dear Reader,
I’m having trouble with implementing a regression.
I have the following:
I have a 3D matrix results_demands(24,1,n) and a 3D matrix results_han(24,3,n)
Where 24 are the time steps and n are the observations.
I want to model the regression between the (24,1) vector results_demands and (24,3) matrix results_han
What I already tried is splitting up the results_han such that I have a matrix with n rows(observations) and 3 columns and every input is a (24,1) vector.
So that we have 3 response variables and 1 explanatory variable(results_demands) all variables in form of a vector.
How do I need to implement such extra dimensional case.
A visualization of the 3D matrices.
results_han : (24,3,n):
[ [vec_i] [vec_i] [vec_i]
[vec_i] [vec_i] [vec_i]
………………….
…………………. ]
with vec_i a (24,1) column vector
results_demands: (24,1,n):
[ [vec_k]
[vec_k]
……….]
with vec_k a (24,1) column vector
Thank you in advance! multivariate regression, regression, mvregress MATLAB Answers — New Questions
Matlab include files giving compilation errors
Hello,
I have seen many related questions but no one could answer my case I think.
I’m trying to call the Matlab Engine in a cpp code.
I includes the header files in the code and I made the following simple makefile:
Test: Test.cpp
g++ -g Test.cpp -I/matlabroot/extern/include/ -L/matlabroot/extern/bin/maci64/ -lMatlabDataArray -lMatlabEngine -o Test
However the compilation fails. I get a lot of errors and warnings that seem to suggest that the matlab files contain mistakes?
For example I get errors like this:
/matlabroot/extern/include/MatlabDataArray/GetArrayType.hpp:50:61: error: a space is required between consecutive right angle brackets (use ‘> >’)
template<> struct GetArrayType<std::complex<uint16_t>> { static const ArrayType type = ArrayType::COMPLEX_UINT16; };
I think a similar problem was met in this thread: https://www.mathworks.com/matlabcentral/answers/463726-error-with-matlab-engine-data-api-for-c-edit-resolved
In that case it was resolved by changing the Conformance Mode parameter in Visual Studio but I’m using Mac and I don’t know how I should modify my makefile. I couldn’t find much information about what the conformance mode actually means.
Also it’s worth noting that the compilation works fine on Matlab with the command mex. However I plan to add more libraries to my cpp code and I don’t think I can include them from Matlab.
Btw, I’m a physics student and I have very little background in these matters so please excuse me if I’m doing some obvious mistake.Hello,
I have seen many related questions but no one could answer my case I think.
I’m trying to call the Matlab Engine in a cpp code.
I includes the header files in the code and I made the following simple makefile:
Test: Test.cpp
g++ -g Test.cpp -I/matlabroot/extern/include/ -L/matlabroot/extern/bin/maci64/ -lMatlabDataArray -lMatlabEngine -o Test
However the compilation fails. I get a lot of errors and warnings that seem to suggest that the matlab files contain mistakes?
For example I get errors like this:
/matlabroot/extern/include/MatlabDataArray/GetArrayType.hpp:50:61: error: a space is required between consecutive right angle brackets (use ‘> >’)
template<> struct GetArrayType<std::complex<uint16_t>> { static const ArrayType type = ArrayType::COMPLEX_UINT16; };
I think a similar problem was met in this thread: https://www.mathworks.com/matlabcentral/answers/463726-error-with-matlab-engine-data-api-for-c-edit-resolved
In that case it was resolved by changing the Conformance Mode parameter in Visual Studio but I’m using Mac and I don’t know how I should modify my makefile. I couldn’t find much information about what the conformance mode actually means.
Also it’s worth noting that the compilation works fine on Matlab with the command mex. However I plan to add more libraries to my cpp code and I don’t think I can include them from Matlab.
Btw, I’m a physics student and I have very little background in these matters so please excuse me if I’m doing some obvious mistake. Hello,
I have seen many related questions but no one could answer my case I think.
I’m trying to call the Matlab Engine in a cpp code.
I includes the header files in the code and I made the following simple makefile:
Test: Test.cpp
g++ -g Test.cpp -I/matlabroot/extern/include/ -L/matlabroot/extern/bin/maci64/ -lMatlabDataArray -lMatlabEngine -o Test
However the compilation fails. I get a lot of errors and warnings that seem to suggest that the matlab files contain mistakes?
For example I get errors like this:
/matlabroot/extern/include/MatlabDataArray/GetArrayType.hpp:50:61: error: a space is required between consecutive right angle brackets (use ‘> >’)
template<> struct GetArrayType<std::complex<uint16_t>> { static const ArrayType type = ArrayType::COMPLEX_UINT16; };
I think a similar problem was met in this thread: https://www.mathworks.com/matlabcentral/answers/463726-error-with-matlab-engine-data-api-for-c-edit-resolved
In that case it was resolved by changing the Conformance Mode parameter in Visual Studio but I’m using Mac and I don’t know how I should modify my makefile. I couldn’t find much information about what the conformance mode actually means.
Also it’s worth noting that the compilation works fine on Matlab with the command mex. However I plan to add more libraries to my cpp code and I don’t think I can include them from Matlab.
Btw, I’m a physics student and I have very little background in these matters so please excuse me if I’m doing some obvious mistake. matlab engine, c++, compiler MATLAB Answers — New Questions
End to End Bluetooth and WLAN simulation
I am trying to generate spectrograms of coexisting Bluetooth and WLAN packets. Task required to have multiple transmitters, one receiver, path loss and AWGN noise. MATLAB offers some related examples,
https://au.mathworks.com/help/comm/ug/End-to-end-Bluetooth-BR-EDR-PHY-Simulation-with-WLAN-Interference-and-Adaptive-Frequency-Hopping.html
https://au.mathworks.com/help/comm/ug/End-to-end-BLE-PHY-Simulation-Using-PathLoss-Model-RF-Impairments-and-AWGN.html
However, they both cannot be directly used for the required purpose due to two reasons.
The first example considers continuous WLAN interference where as I need random WLAN packets (spreaded across the spectrogram)
The second example provides only one bluetooth packet, where as I need multiple packets spreaded across the spectrogram
I tried adopting components from both examples to do what I need, however I face below problems
nextHop funtion in MATLAB gives the channel index for next hop and it is used as an input to the bleWaveformGenerator function. However the output from bleWaveformGenerator does not contain the required carrier (center) frequency. All the packets are centered around 0 Hz.
The main file is copied below. This will need multiple support files from MATLAB–>examples–>bluetooth—>main
% Trying to spread bluetooth packets across the spectrogram and then add
% WLAN packets
commSupportPackageCheck(‘BLUETOOTH’);
pathLossModel = ‘Free space’; % Path loss model
rxSensitivity = -70 ; % Receiver sensitivity in dBm
txPower = 0; % Transmit power in dBm
txAntennaGain = 0; % Transmitter antenna gain in dB
rxAntennaGain = 0; % Receiver antenna gain in dB
linkMargin = 15; % Link margin(dB) assumed in the simulation
channelIndex=0;
samplesPerSymbol = 88;
symbolRate = 1e6;
sampleRate = symbolRate*samplesPerSymbol;
% samplesPerSymbol = 8; % Samples per symbol
dataLen = 254; % Data length in bytes
phyMode = ‘LE1M’; % PHY transmission mode
% Default access address for periodic advertising channels
accessAdd = [0 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 0 0 0 1]’;
slotValue = 1*2;%phyTx.slotsRequired(packetType)
inputClock = 0;
clockTicks = slotValue*2;
numSlots=20;
numMasterTxSlots = floor(numSlots/slotValue);
hopIndex = zeros(1, numMasterTxSlots);
% Index to hop index vector
hopIdx = 1;
fh = bluetoothFrequencyHop;
fh.SequenceType = ‘Connection basic’;
scope2 = dsp.SpectrumAnalyzer(…
‘ViewType’,’spectrogram’, …
‘SpectrumType’,’Power density’, …
‘TimeResolutionSource’,’Property’, …
‘TimeResolution’,0.0005, …
‘SampleRate’,sampleRate, …
‘TimeSpanSource’,’Property’, …
‘TimeSpan’, 0.05, …
‘FrequencyResolutionMethod’, ‘WindowLength’, …
‘WindowLength’, 512, …
‘AxesLayout’, ‘Horizontal’,…
‘FrequencyOffset’,(2402+channelIndex)*1e6);
sprev = rng(‘default’); % Set random number generator seed
rx=[];
for slotIdx = 0:slotValue:numSlots-slotValue
% % Update clock
inputClock = inputClock + clockTicks
% Frequency hopping
[channelIndex,~] = nextHop(fh,inputClock);
channelIndex=round(channelIndex/2)
txBits = randi([0 1],dataLen*8,1,’int8′);
fc = (2*channelIndex+2402)*1e6; % Center frequency in Hz
txWaveform = bleWaveformGenerator(txBits,’Mode’,phyMode,…
‘SamplesPerSymbol’,samplesPerSymbol,…
‘ChannelIndex’,channelIndex,…
‘AccessAddress’,accessAdd);
NF = 6; % Noise figure (dB)
T = 290; % Ambient temperature (K)
dBm2dBFactor = 30; % Factor for converting dBm to dB
% Symbol rate based on the PHY transmission mode
symbolRate = 1e6;
if strcmp(phyMode,’LE2M’)
symbolRate = 2e6;
end
BW = samplesPerSymbol*symbolRate; % Bandwidth (Hz)
k = 1.3806e-23; % Boltzmann constant (J/K)
noiseFloor = 10*log10(k*T*BW)+NF; % Nosie floor in dB
% Measure signal power at the receiver based on the receiver sensitivity and
% assumed link margin
measuredPowerVector = rxSensitivity – dBm2dBFactor+linkMargin;
snrdB = measuredPowerVector – noiseFloor; % SNR in dB
% Create and configure the System objects for impairments
initImp = helperBLEImpairmentsInit(phyMode,samplesPerSymbol);
% Configure RF impairments
initImp.pfo.FrequencyOffset = 5800; % Frequency offset in Hz
initImp.pfo.PhaseOffset = 5; % Phase offset in degrees
initoff = 0.15*samplesPerSymbol; % Static timing offset
stepsize = 20*1e-6; % Timing drift in ppm, Max range is +/- 50 ppm
initImp.vdelay = (initoff:stepsize:initoff+stepsize*(length(txWaveform)-1))’;
initImp.dc = 20; % Percentage related to maximum amplitude value
% Pass generated BLE waveform through RF impairments
txImpairedWfm = helperBLEImpairmentsAddition(txWaveform,initImp);
% Obtain the path loss value in dB
pldB = txPower-dBm2dBFactor+rxAntennaGain+txAntennaGain-measuredPowerVector;
plLinear = 10^(pldB/20); % Convert from dB to linear scale
% Attenuate BLE waveform
attenWaveform = txImpairedWfm./plLinear;
% Add WGN to the attenuated BLE waveform
rxWaveform = awgn(attenWaveform,snrdB,’measured’);
% Create and configure the receiver System objects
initRxParams = helperBLEReceiverInit(phyMode,samplesPerSymbol,accessAdd);
% Recover data bits using practical receiver
[rxBits,accessAddress] = helperBLEPracticalReceiver(rxWaveform,initRxParams,channelIndex);
% Obtain BER by comparing the transmitted and recovered bits
ber = [];
if(length(txBits) == length(rxBits))
ber = (sum(xor(txBits,rxBits))/length(txBits));
end
% Estimate the distance between the transmitter and the receiver based on the path loss value and the environment
if any(strcmp(pathLossModel,{‘Free space’,’Log distance’,’Log normal shadowing’}))
% Center frequency is required only for these path loss models
distance = helperBluetoothEstimateDistance(pathLossModel,pldB,fc);
else
distance = helperBluetoothEstimateDistance(pathLossModel,pldB);
end
hopIndex(hopIdx) = channelIndex;
hopIdx = hopIdx + 1;
scope2(rxWaveform);
pause(0.01);%original 0.01
endI am trying to generate spectrograms of coexisting Bluetooth and WLAN packets. Task required to have multiple transmitters, one receiver, path loss and AWGN noise. MATLAB offers some related examples,
https://au.mathworks.com/help/comm/ug/End-to-end-Bluetooth-BR-EDR-PHY-Simulation-with-WLAN-Interference-and-Adaptive-Frequency-Hopping.html
https://au.mathworks.com/help/comm/ug/End-to-end-BLE-PHY-Simulation-Using-PathLoss-Model-RF-Impairments-and-AWGN.html
However, they both cannot be directly used for the required purpose due to two reasons.
The first example considers continuous WLAN interference where as I need random WLAN packets (spreaded across the spectrogram)
The second example provides only one bluetooth packet, where as I need multiple packets spreaded across the spectrogram
I tried adopting components from both examples to do what I need, however I face below problems
nextHop funtion in MATLAB gives the channel index for next hop and it is used as an input to the bleWaveformGenerator function. However the output from bleWaveformGenerator does not contain the required carrier (center) frequency. All the packets are centered around 0 Hz.
The main file is copied below. This will need multiple support files from MATLAB–>examples–>bluetooth—>main
% Trying to spread bluetooth packets across the spectrogram and then add
% WLAN packets
commSupportPackageCheck(‘BLUETOOTH’);
pathLossModel = ‘Free space’; % Path loss model
rxSensitivity = -70 ; % Receiver sensitivity in dBm
txPower = 0; % Transmit power in dBm
txAntennaGain = 0; % Transmitter antenna gain in dB
rxAntennaGain = 0; % Receiver antenna gain in dB
linkMargin = 15; % Link margin(dB) assumed in the simulation
channelIndex=0;
samplesPerSymbol = 88;
symbolRate = 1e6;
sampleRate = symbolRate*samplesPerSymbol;
% samplesPerSymbol = 8; % Samples per symbol
dataLen = 254; % Data length in bytes
phyMode = ‘LE1M’; % PHY transmission mode
% Default access address for periodic advertising channels
accessAdd = [0 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 0 0 0 1]’;
slotValue = 1*2;%phyTx.slotsRequired(packetType)
inputClock = 0;
clockTicks = slotValue*2;
numSlots=20;
numMasterTxSlots = floor(numSlots/slotValue);
hopIndex = zeros(1, numMasterTxSlots);
% Index to hop index vector
hopIdx = 1;
fh = bluetoothFrequencyHop;
fh.SequenceType = ‘Connection basic’;
scope2 = dsp.SpectrumAnalyzer(…
‘ViewType’,’spectrogram’, …
‘SpectrumType’,’Power density’, …
‘TimeResolutionSource’,’Property’, …
‘TimeResolution’,0.0005, …
‘SampleRate’,sampleRate, …
‘TimeSpanSource’,’Property’, …
‘TimeSpan’, 0.05, …
‘FrequencyResolutionMethod’, ‘WindowLength’, …
‘WindowLength’, 512, …
‘AxesLayout’, ‘Horizontal’,…
‘FrequencyOffset’,(2402+channelIndex)*1e6);
sprev = rng(‘default’); % Set random number generator seed
rx=[];
for slotIdx = 0:slotValue:numSlots-slotValue
% % Update clock
inputClock = inputClock + clockTicks
% Frequency hopping
[channelIndex,~] = nextHop(fh,inputClock);
channelIndex=round(channelIndex/2)
txBits = randi([0 1],dataLen*8,1,’int8′);
fc = (2*channelIndex+2402)*1e6; % Center frequency in Hz
txWaveform = bleWaveformGenerator(txBits,’Mode’,phyMode,…
‘SamplesPerSymbol’,samplesPerSymbol,…
‘ChannelIndex’,channelIndex,…
‘AccessAddress’,accessAdd);
NF = 6; % Noise figure (dB)
T = 290; % Ambient temperature (K)
dBm2dBFactor = 30; % Factor for converting dBm to dB
% Symbol rate based on the PHY transmission mode
symbolRate = 1e6;
if strcmp(phyMode,’LE2M’)
symbolRate = 2e6;
end
BW = samplesPerSymbol*symbolRate; % Bandwidth (Hz)
k = 1.3806e-23; % Boltzmann constant (J/K)
noiseFloor = 10*log10(k*T*BW)+NF; % Nosie floor in dB
% Measure signal power at the receiver based on the receiver sensitivity and
% assumed link margin
measuredPowerVector = rxSensitivity – dBm2dBFactor+linkMargin;
snrdB = measuredPowerVector – noiseFloor; % SNR in dB
% Create and configure the System objects for impairments
initImp = helperBLEImpairmentsInit(phyMode,samplesPerSymbol);
% Configure RF impairments
initImp.pfo.FrequencyOffset = 5800; % Frequency offset in Hz
initImp.pfo.PhaseOffset = 5; % Phase offset in degrees
initoff = 0.15*samplesPerSymbol; % Static timing offset
stepsize = 20*1e-6; % Timing drift in ppm, Max range is +/- 50 ppm
initImp.vdelay = (initoff:stepsize:initoff+stepsize*(length(txWaveform)-1))’;
initImp.dc = 20; % Percentage related to maximum amplitude value
% Pass generated BLE waveform through RF impairments
txImpairedWfm = helperBLEImpairmentsAddition(txWaveform,initImp);
% Obtain the path loss value in dB
pldB = txPower-dBm2dBFactor+rxAntennaGain+txAntennaGain-measuredPowerVector;
plLinear = 10^(pldB/20); % Convert from dB to linear scale
% Attenuate BLE waveform
attenWaveform = txImpairedWfm./plLinear;
% Add WGN to the attenuated BLE waveform
rxWaveform = awgn(attenWaveform,snrdB,’measured’);
% Create and configure the receiver System objects
initRxParams = helperBLEReceiverInit(phyMode,samplesPerSymbol,accessAdd);
% Recover data bits using practical receiver
[rxBits,accessAddress] = helperBLEPracticalReceiver(rxWaveform,initRxParams,channelIndex);
% Obtain BER by comparing the transmitted and recovered bits
ber = [];
if(length(txBits) == length(rxBits))
ber = (sum(xor(txBits,rxBits))/length(txBits));
end
% Estimate the distance between the transmitter and the receiver based on the path loss value and the environment
if any(strcmp(pathLossModel,{‘Free space’,’Log distance’,’Log normal shadowing’}))
% Center frequency is required only for these path loss models
distance = helperBluetoothEstimateDistance(pathLossModel,pldB,fc);
else
distance = helperBluetoothEstimateDistance(pathLossModel,pldB);
end
hopIndex(hopIdx) = channelIndex;
hopIdx = hopIdx + 1;
scope2(rxWaveform);
pause(0.01);%original 0.01
end I am trying to generate spectrograms of coexisting Bluetooth and WLAN packets. Task required to have multiple transmitters, one receiver, path loss and AWGN noise. MATLAB offers some related examples,
https://au.mathworks.com/help/comm/ug/End-to-end-Bluetooth-BR-EDR-PHY-Simulation-with-WLAN-Interference-and-Adaptive-Frequency-Hopping.html
https://au.mathworks.com/help/comm/ug/End-to-end-BLE-PHY-Simulation-Using-PathLoss-Model-RF-Impairments-and-AWGN.html
However, they both cannot be directly used for the required purpose due to two reasons.
The first example considers continuous WLAN interference where as I need random WLAN packets (spreaded across the spectrogram)
The second example provides only one bluetooth packet, where as I need multiple packets spreaded across the spectrogram
I tried adopting components from both examples to do what I need, however I face below problems
nextHop funtion in MATLAB gives the channel index for next hop and it is used as an input to the bleWaveformGenerator function. However the output from bleWaveformGenerator does not contain the required carrier (center) frequency. All the packets are centered around 0 Hz.
The main file is copied below. This will need multiple support files from MATLAB–>examples–>bluetooth—>main
% Trying to spread bluetooth packets across the spectrogram and then add
% WLAN packets
commSupportPackageCheck(‘BLUETOOTH’);
pathLossModel = ‘Free space’; % Path loss model
rxSensitivity = -70 ; % Receiver sensitivity in dBm
txPower = 0; % Transmit power in dBm
txAntennaGain = 0; % Transmitter antenna gain in dB
rxAntennaGain = 0; % Receiver antenna gain in dB
linkMargin = 15; % Link margin(dB) assumed in the simulation
channelIndex=0;
samplesPerSymbol = 88;
symbolRate = 1e6;
sampleRate = symbolRate*samplesPerSymbol;
% samplesPerSymbol = 8; % Samples per symbol
dataLen = 254; % Data length in bytes
phyMode = ‘LE1M’; % PHY transmission mode
% Default access address for periodic advertising channels
accessAdd = [0 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 0 0 0 1]’;
slotValue = 1*2;%phyTx.slotsRequired(packetType)
inputClock = 0;
clockTicks = slotValue*2;
numSlots=20;
numMasterTxSlots = floor(numSlots/slotValue);
hopIndex = zeros(1, numMasterTxSlots);
% Index to hop index vector
hopIdx = 1;
fh = bluetoothFrequencyHop;
fh.SequenceType = ‘Connection basic’;
scope2 = dsp.SpectrumAnalyzer(…
‘ViewType’,’spectrogram’, …
‘SpectrumType’,’Power density’, …
‘TimeResolutionSource’,’Property’, …
‘TimeResolution’,0.0005, …
‘SampleRate’,sampleRate, …
‘TimeSpanSource’,’Property’, …
‘TimeSpan’, 0.05, …
‘FrequencyResolutionMethod’, ‘WindowLength’, …
‘WindowLength’, 512, …
‘AxesLayout’, ‘Horizontal’,…
‘FrequencyOffset’,(2402+channelIndex)*1e6);
sprev = rng(‘default’); % Set random number generator seed
rx=[];
for slotIdx = 0:slotValue:numSlots-slotValue
% % Update clock
inputClock = inputClock + clockTicks
% Frequency hopping
[channelIndex,~] = nextHop(fh,inputClock);
channelIndex=round(channelIndex/2)
txBits = randi([0 1],dataLen*8,1,’int8′);
fc = (2*channelIndex+2402)*1e6; % Center frequency in Hz
txWaveform = bleWaveformGenerator(txBits,’Mode’,phyMode,…
‘SamplesPerSymbol’,samplesPerSymbol,…
‘ChannelIndex’,channelIndex,…
‘AccessAddress’,accessAdd);
NF = 6; % Noise figure (dB)
T = 290; % Ambient temperature (K)
dBm2dBFactor = 30; % Factor for converting dBm to dB
% Symbol rate based on the PHY transmission mode
symbolRate = 1e6;
if strcmp(phyMode,’LE2M’)
symbolRate = 2e6;
end
BW = samplesPerSymbol*symbolRate; % Bandwidth (Hz)
k = 1.3806e-23; % Boltzmann constant (J/K)
noiseFloor = 10*log10(k*T*BW)+NF; % Nosie floor in dB
% Measure signal power at the receiver based on the receiver sensitivity and
% assumed link margin
measuredPowerVector = rxSensitivity – dBm2dBFactor+linkMargin;
snrdB = measuredPowerVector – noiseFloor; % SNR in dB
% Create and configure the System objects for impairments
initImp = helperBLEImpairmentsInit(phyMode,samplesPerSymbol);
% Configure RF impairments
initImp.pfo.FrequencyOffset = 5800; % Frequency offset in Hz
initImp.pfo.PhaseOffset = 5; % Phase offset in degrees
initoff = 0.15*samplesPerSymbol; % Static timing offset
stepsize = 20*1e-6; % Timing drift in ppm, Max range is +/- 50 ppm
initImp.vdelay = (initoff:stepsize:initoff+stepsize*(length(txWaveform)-1))’;
initImp.dc = 20; % Percentage related to maximum amplitude value
% Pass generated BLE waveform through RF impairments
txImpairedWfm = helperBLEImpairmentsAddition(txWaveform,initImp);
% Obtain the path loss value in dB
pldB = txPower-dBm2dBFactor+rxAntennaGain+txAntennaGain-measuredPowerVector;
plLinear = 10^(pldB/20); % Convert from dB to linear scale
% Attenuate BLE waveform
attenWaveform = txImpairedWfm./plLinear;
% Add WGN to the attenuated BLE waveform
rxWaveform = awgn(attenWaveform,snrdB,’measured’);
% Create and configure the receiver System objects
initRxParams = helperBLEReceiverInit(phyMode,samplesPerSymbol,accessAdd);
% Recover data bits using practical receiver
[rxBits,accessAddress] = helperBLEPracticalReceiver(rxWaveform,initRxParams,channelIndex);
% Obtain BER by comparing the transmitted and recovered bits
ber = [];
if(length(txBits) == length(rxBits))
ber = (sum(xor(txBits,rxBits))/length(txBits));
end
% Estimate the distance between the transmitter and the receiver based on the path loss value and the environment
if any(strcmp(pathLossModel,{‘Free space’,’Log distance’,’Log normal shadowing’}))
% Center frequency is required only for these path loss models
distance = helperBluetoothEstimateDistance(pathLossModel,pldB,fc);
else
distance = helperBluetoothEstimateDistance(pathLossModel,pldB);
end
hopIndex(hopIdx) = channelIndex;
hopIdx = hopIdx + 1;
scope2(rxWaveform);
pause(0.01);%original 0.01
end bluetooth, wlan, packets MATLAB Answers — New Questions
Can I store and access a data with two different sampling time (First store adequate data and the fetch with higher speed) in real time in Simulink?
I need to stora a data (real number) for entire time of simulation with 2 milliseconds of sampling time. After a certain time of simulation I need the data in FIFO mode to be used in a faster loop of say 0.2 milliseconds. Queue block of simulation does not support Push and Pop operation with two sampling rate i suppose and so can not use it. Please suggest me a solution. I hope this can be done in Simulink.I need to stora a data (real number) for entire time of simulation with 2 milliseconds of sampling time. After a certain time of simulation I need the data in FIFO mode to be used in a faster loop of say 0.2 milliseconds. Queue block of simulation does not support Push and Pop operation with two sampling rate i suppose and so can not use it. Please suggest me a solution. I hope this can be done in Simulink. I need to stora a data (real number) for entire time of simulation with 2 milliseconds of sampling time. After a certain time of simulation I need the data in FIFO mode to be used in a faster loop of say 0.2 milliseconds. Queue block of simulation does not support Push and Pop operation with two sampling rate i suppose and so can not use it. Please suggest me a solution. I hope this can be done in Simulink. memory, store, two sampling rate, real time MATLAB Answers — New Questions
The graph doesn’t disply
Sorry for repeating the question so many times. I try to display the graph, but the marked part does not appear. Can you help me?
clc; clear all; close all;
fun =@(t) (1/200).*t.^2+(1/500).*exp(-0.2.*t)+5;
dgraph = @(point, dfda, t) dfda*t + (fun(point)-dfda*point);
est_point=150;
da=2;
dfda_true=(1/100).*(150)+(-0.2./500).*exp(-0.2.*(150));
dfda_forward = (fun(est_point+da)-fun(est_point))./da;
dfda_backforward=(fun(est_point)-fun(est_point-da))./da;
dfda_center=(fun(est_point+da)-fun(est_point-da))./(2.*da)
a=-50:0.01:150;
figure(1)
plot(a,fun(a),’k’); hold on;
plot(a, dgraph(est_point,dfda_true,a),’b’); hold on; %dosen’t work
plot(a, dgraph(est_point,dfda_center,a),’r’); hold on;Sorry for repeating the question so many times. I try to display the graph, but the marked part does not appear. Can you help me?
clc; clear all; close all;
fun =@(t) (1/200).*t.^2+(1/500).*exp(-0.2.*t)+5;
dgraph = @(point, dfda, t) dfda*t + (fun(point)-dfda*point);
est_point=150;
da=2;
dfda_true=(1/100).*(150)+(-0.2./500).*exp(-0.2.*(150));
dfda_forward = (fun(est_point+da)-fun(est_point))./da;
dfda_backforward=(fun(est_point)-fun(est_point-da))./da;
dfda_center=(fun(est_point+da)-fun(est_point-da))./(2.*da)
a=-50:0.01:150;
figure(1)
plot(a,fun(a),’k’); hold on;
plot(a, dgraph(est_point,dfda_true,a),’b’); hold on; %dosen’t work
plot(a, dgraph(est_point,dfda_center,a),’r’); hold on; Sorry for repeating the question so many times. I try to display the graph, but the marked part does not appear. Can you help me?
clc; clear all; close all;
fun =@(t) (1/200).*t.^2+(1/500).*exp(-0.2.*t)+5;
dgraph = @(point, dfda, t) dfda*t + (fun(point)-dfda*point);
est_point=150;
da=2;
dfda_true=(1/100).*(150)+(-0.2./500).*exp(-0.2.*(150));
dfda_forward = (fun(est_point+da)-fun(est_point))./da;
dfda_backforward=(fun(est_point)-fun(est_point-da))./da;
dfda_center=(fun(est_point+da)-fun(est_point-da))./(2.*da)
a=-50:0.01:150;
figure(1)
plot(a,fun(a),’k’); hold on;
plot(a, dgraph(est_point,dfda_true,a),’b’); hold on; %dosen’t work
plot(a, dgraph(est_point,dfda_center,a),’r’); hold on; graph, disply, matlab, function MATLAB Answers — New Questions
Thermal Model of PCB Fuse Trace
I would like to model a Fuse Trace on a PCB, simulate a current similar to inductor discharging through the Fuse trace ( ~ Peak Current of 700A) and validate the temperature rise of the Fuse Trace and understand if it could trip or not.
Heatsink modelling isnt needed.
I tried to recreate this with RF toolbox but it is not capable of simulating 700A of current .
Below is tthe fuse trace that i built with the RF toolboxI would like to model a Fuse Trace on a PCB, simulate a current similar to inductor discharging through the Fuse trace ( ~ Peak Current of 700A) and validate the temperature rise of the Fuse Trace and understand if it could trip or not.
Heatsink modelling isnt needed.
I tried to recreate this with RF toolbox but it is not capable of simulating 700A of current .
Below is tthe fuse trace that i built with the RF toolbox I would like to model a Fuse Trace on a PCB, simulate a current similar to inductor discharging through the Fuse trace ( ~ Peak Current of 700A) and validate the temperature rise of the Fuse Trace and understand if it could trip or not.
Heatsink modelling isnt needed.
I tried to recreate this with RF toolbox but it is not capable of simulating 700A of current .
Below is tthe fuse trace that i built with the RF toolbox fuse trace, thermal modelling MATLAB Answers — New Questions
clearing a persistent variable makes it no longer persistent
This is something that keeps catching me out. I do not think it is explicitly documented anywhere, though it could be implied in the matlab instructions to clear persistent variables by clearing the function.
If you clear a persistent variable using clear variablename from within the function, it ceases to be persistent.
Something like this would be handy to have as there are situations where I want to clear some, but not all persistent variables in a function. Clear allows you to do it all in one line. The alternative is to set them all to [], which is a bit more verbose.This is something that keeps catching me out. I do not think it is explicitly documented anywhere, though it could be implied in the matlab instructions to clear persistent variables by clearing the function.
If you clear a persistent variable using clear variablename from within the function, it ceases to be persistent.
Something like this would be handy to have as there are situations where I want to clear some, but not all persistent variables in a function. Clear allows you to do it all in one line. The alternative is to set them all to [], which is a bit more verbose. This is something that keeps catching me out. I do not think it is explicitly documented anywhere, though it could be implied in the matlab instructions to clear persistent variables by clearing the function.
If you clear a persistent variable using clear variablename from within the function, it ceases to be persistent.
Something like this would be handy to have as there are situations where I want to clear some, but not all persistent variables in a function. Clear allows you to do it all in one line. The alternative is to set them all to [], which is a bit more verbose. clear peristent MATLAB Answers — New Questions
At time 0.00022 for transient initialization, the solution for consistent states and modes fails to converge
Post Content Post Content buck_conventer, simscape, solution MATLAB Answers — New Questions
bisection method for y=100e^-20t
if y=0,
a) y=100e^-20t
b) y=10e^t-600
c)y=(x+2)^2+4
d0 y=2-(x+3)^3if y=0,
a) y=100e^-20t
b) y=10e^t-600
c)y=(x+2)^2+4
d0 y=2-(x+3)^3 if y=0,
a) y=100e^-20t
b) y=10e^t-600
c)y=(x+2)^2+4
d0 y=2-(x+3)^3 bisection method MATLAB Answers — New Questions
Matlab got this wrong: Limit as n goes to infinity: (1+(i/n))^(n^2). Matlab says it’s exp(2), which is wrong. Pls confirm.
Mathlab got this wrong: Limit as n goes to infinity: (1+(i/n))^(n^2). Mathlab says it’s exp(2), which is wrong. Once you confirm, my email is mosesjike@gmail.com.Mathlab got this wrong: Limit as n goes to infinity: (1+(i/n))^(n^2). Mathlab says it’s exp(2), which is wrong. Once you confirm, my email is mosesjike@gmail.com. Mathlab got this wrong: Limit as n goes to infinity: (1+(i/n))^(n^2). Mathlab says it’s exp(2), which is wrong. Once you confirm, my email is mosesjike@gmail.com. matlab MATLAB Answers — New Questions