Tag Archives: matlab
Using symbolic solver, I seem to not be able to get a system of equations that give me a desired answer. Does a solution not exist?
syms V1 V2 Vp Vn Vxp Vxn Vpx Vnx
syms Rp Rx Rn positive
Ison=((Vp/((Rp*68220)/(Rp+68220)))-(Vxp/((Rx*68220)/(Rx+68220))));
equ1=Vp==(V1+V2)-Ison*Rn;
Isop=((Vn/((Rn*68220)/(Rn+68220)))-(Vxn/((Rx*68220)/(Rx+68220))));
equ2=Vn==(V1+V2)-Isop*Rp;
Isox=((Vnx/((Rn*68220)/(Rn+68220)))-(Vpx/((Rp*68220)/(Rp+68220))));
equ3= Vpx==V1+Rx*Isox;
[Rn, Rp, Rx] = solve([equ1, equ2,equ3],[Rn , Rp, Rx]);
simplify(Rn)
simplify(Rp)
simplify(Rx)
Rn=vpa(subs(Rn,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
Rp=vpa(subs(Rp,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
Rx=vpa(subs(Rx,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
So I am trying to find values for Rn,Rx and Rp. I have three equations and three unknowns. When I use solve to find symbolic equation, I get equations for each variable. But when I sub real values in, I get an answer that is wrong or doesnt make sense. Adding assume doesnt seem to change anything and the return conditions is the same as the equations. The real values of Rn, Rp and Rx should be 2e6,1.5e6 and 700k. If you were to put these values in the original equations, you can verify that these values are correct. How do I get a system of equations that will give me the desired answer?syms V1 V2 Vp Vn Vxp Vxn Vpx Vnx
syms Rp Rx Rn positive
Ison=((Vp/((Rp*68220)/(Rp+68220)))-(Vxp/((Rx*68220)/(Rx+68220))));
equ1=Vp==(V1+V2)-Ison*Rn;
Isop=((Vn/((Rn*68220)/(Rn+68220)))-(Vxn/((Rx*68220)/(Rx+68220))));
equ2=Vn==(V1+V2)-Isop*Rp;
Isox=((Vnx/((Rn*68220)/(Rn+68220)))-(Vpx/((Rp*68220)/(Rp+68220))));
equ3= Vpx==V1+Rx*Isox;
[Rn, Rp, Rx] = solve([equ1, equ2,equ3],[Rn , Rp, Rx]);
simplify(Rn)
simplify(Rp)
simplify(Rx)
Rn=vpa(subs(Rn,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
Rp=vpa(subs(Rp,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
Rx=vpa(subs(Rx,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
So I am trying to find values for Rn,Rx and Rp. I have three equations and three unknowns. When I use solve to find symbolic equation, I get equations for each variable. But when I sub real values in, I get an answer that is wrong or doesnt make sense. Adding assume doesnt seem to change anything and the return conditions is the same as the equations. The real values of Rn, Rp and Rx should be 2e6,1.5e6 and 700k. If you were to put these values in the original equations, you can verify that these values are correct. How do I get a system of equations that will give me the desired answer? syms V1 V2 Vp Vn Vxp Vxn Vpx Vnx
syms Rp Rx Rn positive
Ison=((Vp/((Rp*68220)/(Rp+68220)))-(Vxp/((Rx*68220)/(Rx+68220))));
equ1=Vp==(V1+V2)-Ison*Rn;
Isop=((Vn/((Rn*68220)/(Rn+68220)))-(Vxn/((Rx*68220)/(Rx+68220))));
equ2=Vn==(V1+V2)-Isop*Rp;
Isox=((Vnx/((Rn*68220)/(Rn+68220)))-(Vpx/((Rp*68220)/(Rp+68220))));
equ3= Vpx==V1+Rx*Isox;
[Rn, Rp, Rx] = solve([equ1, equ2,equ3],[Rn , Rp, Rx]);
simplify(Rn)
simplify(Rp)
simplify(Rx)
Rn=vpa(subs(Rn,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
Rp=vpa(subs(Rp,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
Rx=vpa(subs(Rx,{V1,V2,Vp,Vn,Vxp,Vxn,Vpx,Vnx},{270,270,144.56868,147.38892,125.43132,122.61108,268.58987,271.41013}))
So I am trying to find values for Rn,Rx and Rp. I have three equations and three unknowns. When I use solve to find symbolic equation, I get equations for each variable. But when I sub real values in, I get an answer that is wrong or doesnt make sense. Adding assume doesnt seem to change anything and the return conditions is the same as the equations. The real values of Rn, Rp and Rx should be 2e6,1.5e6 and 700k. If you were to put these values in the original equations, you can verify that these values are correct. How do I get a system of equations that will give me the desired answer? solve, symbolic MATLAB Answers — New Questions
filtfilt provides excessive transient
I observed that ‘filtfilt’ suffers from an undesired behavior when I provide IIR bandpass filters having steep transition bands. Specifically, the output signal exhibits excessive transient response; nevertheless, this behaviour does not emerge if I use a ‘home-made’ version of zerophase filtering based on ‘filter’. I guess that it is not a numerical issue involving the filter coefficients or structure, nor the ‘filter’ function.
% design bandpass filter having transition bandwidth of 200 Hz (Fs = 8000)
bp = designfilt(‘bandpassiir’, ‘StopbandFrequency1’, 50, ‘PassbandFrequency1’, 250,…
‘PassbandFrequency2’, 3600, ‘StopbandFrequency2’, 3700, ‘StopbandAttenuation1’, 30,…
‘PassbandRipple’, 0.1, ‘StopbandAttenuation2’, 30, ‘SampleRate’, 8000, ‘DesignMethod’, ‘cheby2’);
% check stability
assert(isstable(bp),’Unstable filter’);
% apply filtfilt to a random (white) long input signal; output signal shows an undesirable transient
x = randn(2^20,1);
y = filtfilt(bp,x);
% apply ‘home-made’ filtfilt to the same input; output signal shows a more accptable transient
y2 = flipud(filter(bp,flipud(filter(bp,x))));
% compare effects
figure; semilogy(abs(y-y2));
As a rule of thumb, the effect grows as the transition bands get narrower, while it tends to vanish as they get broader.
Where is the problem? Have I missed some recommendations or hints in the function’s help?I observed that ‘filtfilt’ suffers from an undesired behavior when I provide IIR bandpass filters having steep transition bands. Specifically, the output signal exhibits excessive transient response; nevertheless, this behaviour does not emerge if I use a ‘home-made’ version of zerophase filtering based on ‘filter’. I guess that it is not a numerical issue involving the filter coefficients or structure, nor the ‘filter’ function.
% design bandpass filter having transition bandwidth of 200 Hz (Fs = 8000)
bp = designfilt(‘bandpassiir’, ‘StopbandFrequency1’, 50, ‘PassbandFrequency1’, 250,…
‘PassbandFrequency2’, 3600, ‘StopbandFrequency2’, 3700, ‘StopbandAttenuation1’, 30,…
‘PassbandRipple’, 0.1, ‘StopbandAttenuation2’, 30, ‘SampleRate’, 8000, ‘DesignMethod’, ‘cheby2’);
% check stability
assert(isstable(bp),’Unstable filter’);
% apply filtfilt to a random (white) long input signal; output signal shows an undesirable transient
x = randn(2^20,1);
y = filtfilt(bp,x);
% apply ‘home-made’ filtfilt to the same input; output signal shows a more accptable transient
y2 = flipud(filter(bp,flipud(filter(bp,x))));
% compare effects
figure; semilogy(abs(y-y2));
As a rule of thumb, the effect grows as the transition bands get narrower, while it tends to vanish as they get broader.
Where is the problem? Have I missed some recommendations or hints in the function’s help? I observed that ‘filtfilt’ suffers from an undesired behavior when I provide IIR bandpass filters having steep transition bands. Specifically, the output signal exhibits excessive transient response; nevertheless, this behaviour does not emerge if I use a ‘home-made’ version of zerophase filtering based on ‘filter’. I guess that it is not a numerical issue involving the filter coefficients or structure, nor the ‘filter’ function.
% design bandpass filter having transition bandwidth of 200 Hz (Fs = 8000)
bp = designfilt(‘bandpassiir’, ‘StopbandFrequency1’, 50, ‘PassbandFrequency1’, 250,…
‘PassbandFrequency2’, 3600, ‘StopbandFrequency2’, 3700, ‘StopbandAttenuation1’, 30,…
‘PassbandRipple’, 0.1, ‘StopbandAttenuation2’, 30, ‘SampleRate’, 8000, ‘DesignMethod’, ‘cheby2’);
% check stability
assert(isstable(bp),’Unstable filter’);
% apply filtfilt to a random (white) long input signal; output signal shows an undesirable transient
x = randn(2^20,1);
y = filtfilt(bp,x);
% apply ‘home-made’ filtfilt to the same input; output signal shows a more accptable transient
y2 = flipud(filter(bp,flipud(filter(bp,x))));
% compare effects
figure; semilogy(abs(y-y2));
As a rule of thumb, the effect grows as the transition bands get narrower, while it tends to vanish as they get broader.
Where is the problem? Have I missed some recommendations or hints in the function’s help? filtfilt, numerical stability, transient effects MATLAB Answers — New Questions
Reading Bytes from Arduino to MATLAB
I’ve been trying to read data from ESP32S-Dev module to MATLAB sending over the data in bytes to make the transmission quicker. As seen below, I convert float data into bytes and then write the data. MATLAB sees the data and then creates a 1×8 array for each float value instead of just 1 value for each float. I’ve tried other methods, shown in 2nd part of MATLAB code, and it creates 1 value for each float but their wildly off (7-34 orders of magnitude)
I’ve tried different baud rates and even asked for help from the almighty ChatGPT but have not been able to crack the code. Any thoughts.
Arduino IDE code:
#include <SPI.h>
const int CS_SiPM_pot = 34;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //Starting
delay(1000);
SPI.begin();
pinMode(CS_SiPM_pot, OUTPUT);
}
void loop() {
for (int d_pot2 = 55; d_pot2 <= 55; d_pot2 = d_pot2 + 1) //57
{
digitalWrite(CS_SiPM_pot, LOW); //LOW
delay(10); //10
SPI.transfer(d_pot2);
digitalWrite(CS_SiPM_pot, HIGH);
// put your main code here, to run repeatedly:
float newTmp[4] = { 01.00, 02.00, 03.00, 04.00 };
for (int i = 0; i < 4; i++) {
byte *byteData = (byte *)&newTmp[i];
Serial.write(byteData, sizeof(float)); // Send each float as 4 bytes
delay(10);
}
}
}
MATLAB code:
esp = serialport(‘COM5’,152000);
%%
flush(esp)
% Read 16 bytes of data (4 floats * 4 bytes per float)
numBytes = 16;
data = read(esp, numBytes, ‘uint8’);
% Convert each 4-byte sequence to a float
float1 = typecast(data(1:4)), ‘single’);
float2 = typecast(data(5:8), ‘single’);
float3 = typecast(data(9:12), ‘single’);
float4 = typecast(data(13:16), ‘single’);
disp([float1, float2, float3, float4]);
% Convert the bytes back to float values
floatValues = typecast(uint8(data), ‘single’);
% Display the result
disp(‘Float values:’);
disp(floatValues);
disp(‘Raw bytes received:’);
disp(data); % Print the raw bytes
Results from MATLAB:
Float1: 0 0 0 0 0 0 0 0
Float2: 0 3.7480 0 0 0 0 0 0
Float3: 0 2.1250 0 3.7480 0 0 0 0
Float4: 0 0 0 0 0 3.7480 0 0
data: 0 0 0 0 255 0 0 0 3 255 0 0 0 0 255 0I’ve been trying to read data from ESP32S-Dev module to MATLAB sending over the data in bytes to make the transmission quicker. As seen below, I convert float data into bytes and then write the data. MATLAB sees the data and then creates a 1×8 array for each float value instead of just 1 value for each float. I’ve tried other methods, shown in 2nd part of MATLAB code, and it creates 1 value for each float but their wildly off (7-34 orders of magnitude)
I’ve tried different baud rates and even asked for help from the almighty ChatGPT but have not been able to crack the code. Any thoughts.
Arduino IDE code:
#include <SPI.h>
const int CS_SiPM_pot = 34;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //Starting
delay(1000);
SPI.begin();
pinMode(CS_SiPM_pot, OUTPUT);
}
void loop() {
for (int d_pot2 = 55; d_pot2 <= 55; d_pot2 = d_pot2 + 1) //57
{
digitalWrite(CS_SiPM_pot, LOW); //LOW
delay(10); //10
SPI.transfer(d_pot2);
digitalWrite(CS_SiPM_pot, HIGH);
// put your main code here, to run repeatedly:
float newTmp[4] = { 01.00, 02.00, 03.00, 04.00 };
for (int i = 0; i < 4; i++) {
byte *byteData = (byte *)&newTmp[i];
Serial.write(byteData, sizeof(float)); // Send each float as 4 bytes
delay(10);
}
}
}
MATLAB code:
esp = serialport(‘COM5’,152000);
%%
flush(esp)
% Read 16 bytes of data (4 floats * 4 bytes per float)
numBytes = 16;
data = read(esp, numBytes, ‘uint8’);
% Convert each 4-byte sequence to a float
float1 = typecast(data(1:4)), ‘single’);
float2 = typecast(data(5:8), ‘single’);
float3 = typecast(data(9:12), ‘single’);
float4 = typecast(data(13:16), ‘single’);
disp([float1, float2, float3, float4]);
% Convert the bytes back to float values
floatValues = typecast(uint8(data), ‘single’);
% Display the result
disp(‘Float values:’);
disp(floatValues);
disp(‘Raw bytes received:’);
disp(data); % Print the raw bytes
Results from MATLAB:
Float1: 0 0 0 0 0 0 0 0
Float2: 0 3.7480 0 0 0 0 0 0
Float3: 0 2.1250 0 3.7480 0 0 0 0
Float4: 0 0 0 0 0 3.7480 0 0
data: 0 0 0 0 255 0 0 0 3 255 0 0 0 0 255 0 I’ve been trying to read data from ESP32S-Dev module to MATLAB sending over the data in bytes to make the transmission quicker. As seen below, I convert float data into bytes and then write the data. MATLAB sees the data and then creates a 1×8 array for each float value instead of just 1 value for each float. I’ve tried other methods, shown in 2nd part of MATLAB code, and it creates 1 value for each float but their wildly off (7-34 orders of magnitude)
I’ve tried different baud rates and even asked for help from the almighty ChatGPT but have not been able to crack the code. Any thoughts.
Arduino IDE code:
#include <SPI.h>
const int CS_SiPM_pot = 34;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //Starting
delay(1000);
SPI.begin();
pinMode(CS_SiPM_pot, OUTPUT);
}
void loop() {
for (int d_pot2 = 55; d_pot2 <= 55; d_pot2 = d_pot2 + 1) //57
{
digitalWrite(CS_SiPM_pot, LOW); //LOW
delay(10); //10
SPI.transfer(d_pot2);
digitalWrite(CS_SiPM_pot, HIGH);
// put your main code here, to run repeatedly:
float newTmp[4] = { 01.00, 02.00, 03.00, 04.00 };
for (int i = 0; i < 4; i++) {
byte *byteData = (byte *)&newTmp[i];
Serial.write(byteData, sizeof(float)); // Send each float as 4 bytes
delay(10);
}
}
}
MATLAB code:
esp = serialport(‘COM5’,152000);
%%
flush(esp)
% Read 16 bytes of data (4 floats * 4 bytes per float)
numBytes = 16;
data = read(esp, numBytes, ‘uint8’);
% Convert each 4-byte sequence to a float
float1 = typecast(data(1:4)), ‘single’);
float2 = typecast(data(5:8), ‘single’);
float3 = typecast(data(9:12), ‘single’);
float4 = typecast(data(13:16), ‘single’);
disp([float1, float2, float3, float4]);
% Convert the bytes back to float values
floatValues = typecast(uint8(data), ‘single’);
% Display the result
disp(‘Float values:’);
disp(floatValues);
disp(‘Raw bytes received:’);
disp(data); % Print the raw bytes
Results from MATLAB:
Float1: 0 0 0 0 0 0 0 0
Float2: 0 3.7480 0 0 0 0 0 0
Float3: 0 2.1250 0 3.7480 0 0 0 0
Float4: 0 0 0 0 0 3.7480 0 0
data: 0 0 0 0 255 0 0 0 3 255 0 0 0 0 255 0 arduino, esp32, matlab, serialport, float-to-bytes MATLAB Answers — New Questions
When the orientation of the object changed, how to measure the force on each support point?
Thank you for your interest in my question.
If we assume that there is a box with x, y, z-axis lengths of [1, 0.5, 0.2] (m) , weight is m=100kg,
and set the center point as the origin frame. At this time, if we support the force of m*g/4 at each of the four points [0.5, 0.25, -0.1], [0.5, -0.25, -0.1], [-0.5, -0.25, -0.1], [-0.5, 0.25, -0.1], the object will stay statically.
Then, if the box rotates 30 degrees about the x-axis, I can’t measure the force applied at the four corners of the box.
As the box rotates, the coordinate frame of the corner also rotates.
If the box rotates 45 degrees for y-axis after rotating 30 degree for the x-axis,
how should we apply force to each point so that the box stays still?Thank you for your interest in my question.
If we assume that there is a box with x, y, z-axis lengths of [1, 0.5, 0.2] (m) , weight is m=100kg,
and set the center point as the origin frame. At this time, if we support the force of m*g/4 at each of the four points [0.5, 0.25, -0.1], [0.5, -0.25, -0.1], [-0.5, -0.25, -0.1], [-0.5, 0.25, -0.1], the object will stay statically.
Then, if the box rotates 30 degrees about the x-axis, I can’t measure the force applied at the four corners of the box.
As the box rotates, the coordinate frame of the corner also rotates.
If the box rotates 45 degrees for y-axis after rotating 30 degree for the x-axis,
how should we apply force to each point so that the box stays still? Thank you for your interest in my question.
If we assume that there is a box with x, y, z-axis lengths of [1, 0.5, 0.2] (m) , weight is m=100kg,
and set the center point as the origin frame. At this time, if we support the force of m*g/4 at each of the four points [0.5, 0.25, -0.1], [0.5, -0.25, -0.1], [-0.5, -0.25, -0.1], [-0.5, 0.25, -0.1], the object will stay statically.
Then, if the box rotates 30 degrees about the x-axis, I can’t measure the force applied at the four corners of the box.
As the box rotates, the coordinate frame of the corner also rotates.
If the box rotates 45 degrees for y-axis after rotating 30 degree for the x-axis,
how should we apply force to each point so that the box stays still? force, gravity compensation MATLAB Answers — New Questions
Hi! I created a bad script a long time ago (months) and it has essentially destroyed my Matlab Online. I cannot run any other script without that old error occurring
The Summery is essentially it. I created a script four months ago and accidentially used the wrong syntax (&&) and it has corrupted my Matlab Online. I can run scripts with only comments, but as soon as I add anything else I get the errors back.
Help? I am so confused
Script I am running:
%% Problem 1
k1 = 10;
k2 = 5;
k3 = 8;
k4 = 10;
k5 = 20;
L1 = [1 0 0 0;
0 1 0 0]
Error Message:
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to
reduce operands to logical scalar values.
Error in internal.matlab.variableeditor.Actions.struct.EditActionBase/UpdateActionState (line 33)
editable = height(sRows) == 1 && (sRows(2)-sRows(1)+1 == 1);
Error in internal.matlab.variableeditor.VEActionDataService/updateActionStates (line 138)
action.UpdateActionState();
Error in internal.matlab.variableeditor.VEActionDataService/enableListenersAndUpdateActionStates (line 84)
this.updateActionStates();
Error in internal.matlab.variableeditor.VEActionDataService/initActionStates (line 54)
this.enableListenersAndUpdateActionStates();
Error in internal.matlab.datatoolsservices.actiondataservice.ActionManager/initActions (line 55)
this.ActionDataService.initActionStates();
Error in internal.matlab.variableeditor.peer.RemoteManager/callInitActionOnIdle (line 376)
ActionManager.initActions(startPath, classType);
Error in internal.matlab.variableeditor.peer.RemoteManager>@()this.callInitActionOnIdle(actionNamespace,startPath,classType,ActionManager) (line 121)
builtin(‘_dtcallback’, @() this.callInitActionOnIdle(actionNamespace, startPath, classType, ActionManager), …The Summery is essentially it. I created a script four months ago and accidentially used the wrong syntax (&&) and it has corrupted my Matlab Online. I can run scripts with only comments, but as soon as I add anything else I get the errors back.
Help? I am so confused
Script I am running:
%% Problem 1
k1 = 10;
k2 = 5;
k3 = 8;
k4 = 10;
k5 = 20;
L1 = [1 0 0 0;
0 1 0 0]
Error Message:
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to
reduce operands to logical scalar values.
Error in internal.matlab.variableeditor.Actions.struct.EditActionBase/UpdateActionState (line 33)
editable = height(sRows) == 1 && (sRows(2)-sRows(1)+1 == 1);
Error in internal.matlab.variableeditor.VEActionDataService/updateActionStates (line 138)
action.UpdateActionState();
Error in internal.matlab.variableeditor.VEActionDataService/enableListenersAndUpdateActionStates (line 84)
this.updateActionStates();
Error in internal.matlab.variableeditor.VEActionDataService/initActionStates (line 54)
this.enableListenersAndUpdateActionStates();
Error in internal.matlab.datatoolsservices.actiondataservice.ActionManager/initActions (line 55)
this.ActionDataService.initActionStates();
Error in internal.matlab.variableeditor.peer.RemoteManager/callInitActionOnIdle (line 376)
ActionManager.initActions(startPath, classType);
Error in internal.matlab.variableeditor.peer.RemoteManager>@()this.callInitActionOnIdle(actionNamespace,startPath,classType,ActionManager) (line 121)
builtin(‘_dtcallback’, @() this.callInitActionOnIdle(actionNamespace, startPath, classType, ActionManager), … The Summery is essentially it. I created a script four months ago and accidentially used the wrong syntax (&&) and it has corrupted my Matlab Online. I can run scripts with only comments, but as soon as I add anything else I get the errors back.
Help? I am so confused
Script I am running:
%% Problem 1
k1 = 10;
k2 = 5;
k3 = 8;
k4 = 10;
k5 = 20;
L1 = [1 0 0 0;
0 1 0 0]
Error Message:
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to
reduce operands to logical scalar values.
Error in internal.matlab.variableeditor.Actions.struct.EditActionBase/UpdateActionState (line 33)
editable = height(sRows) == 1 && (sRows(2)-sRows(1)+1 == 1);
Error in internal.matlab.variableeditor.VEActionDataService/updateActionStates (line 138)
action.UpdateActionState();
Error in internal.matlab.variableeditor.VEActionDataService/enableListenersAndUpdateActionStates (line 84)
this.updateActionStates();
Error in internal.matlab.variableeditor.VEActionDataService/initActionStates (line 54)
this.enableListenersAndUpdateActionStates();
Error in internal.matlab.datatoolsservices.actiondataservice.ActionManager/initActions (line 55)
this.ActionDataService.initActionStates();
Error in internal.matlab.variableeditor.peer.RemoteManager/callInitActionOnIdle (line 376)
ActionManager.initActions(startPath, classType);
Error in internal.matlab.variableeditor.peer.RemoteManager>@()this.callInitActionOnIdle(actionNamespace,startPath,classType,ActionManager) (line 121)
builtin(‘_dtcallback’, @() this.callInitActionOnIdle(actionNamespace, startPath, classType, ActionManager), … help, persistent error, have i broken matlab? MATLAB Answers — New Questions
HTML file to PDF file, deal with base64,svg picture problem solution.
HTML file to PDF file, error when processing base64,svg imagesHTML file to PDF file, error when processing base64,svg images HTML file to PDF file, error when processing base64,svg images html, simulink, pdf MATLAB Answers — New Questions
Include rows containing specific value
I have a 1400*9 table (1400 rows and 9 columns) in MATLAB workspace. Each column has a different name. I want to select rows containing specific value. For example, how can I create a new table containig all rows with value of 0.456 in the column named "Biology"? I tried to use following code, but it gave error.
newData=[Data(find(Data.Biology == 0.456, :))]I have a 1400*9 table (1400 rows and 9 columns) in MATLAB workspace. Each column has a different name. I want to select rows containing specific value. For example, how can I create a new table containig all rows with value of 0.456 in the column named "Biology"? I tried to use following code, but it gave error.
newData=[Data(find(Data.Biology == 0.456, :))] I have a 1400*9 table (1400 rows and 9 columns) in MATLAB workspace. Each column has a different name. I want to select rows containing specific value. For example, how can I create a new table containig all rows with value of 0.456 in the column named "Biology"? I tried to use following code, but it gave error.
newData=[Data(find(Data.Biology == 0.456, :))] table, find MATLAB Answers — New Questions
Force saved figure to use a specific number of pixels
I am saving different maps, I need to compare some specific pixels, but Matlab somehow adds a line at the bottom (3 pixels) for example when I save my image, which kills everything I try to do later. Is there any method to force exportgraphics to use X pixels horizontally and Y vertically (I mean height and width)? Or when I call my figure to be X and Y dimensions? Force it not to add this line. I tried exportgraphics/export_fig they both fail at it.
It is not random, as only some specific files get the line added and always even if I try to replot, I still did not figure out why this happens, my data have the same resolution/grid.I am saving different maps, I need to compare some specific pixels, but Matlab somehow adds a line at the bottom (3 pixels) for example when I save my image, which kills everything I try to do later. Is there any method to force exportgraphics to use X pixels horizontally and Y vertically (I mean height and width)? Or when I call my figure to be X and Y dimensions? Force it not to add this line. I tried exportgraphics/export_fig they both fail at it.
It is not random, as only some specific files get the line added and always even if I try to replot, I still did not figure out why this happens, my data have the same resolution/grid. I am saving different maps, I need to compare some specific pixels, but Matlab somehow adds a line at the bottom (3 pixels) for example when I save my image, which kills everything I try to do later. Is there any method to force exportgraphics to use X pixels horizontally and Y vertically (I mean height and width)? Or when I call my figure to be X and Y dimensions? Force it not to add this line. I tried exportgraphics/export_fig they both fail at it.
It is not random, as only some specific files get the line added and always even if I try to replot, I still did not figure out why this happens, my data have the same resolution/grid. image-processing, exportgraphics MATLAB Answers — New Questions
Working in Excel with live on MATLAB
On matlab, I am going to import an Excel file and work on it live in real time.
If I change the value in Excel, I want to reflect it in real time in MATLAB.
However, as far as I know, if you modify it without saving the Excel, it cannot be applied in MATLAB right away.
Is there a way to solve this?On matlab, I am going to import an Excel file and work on it live in real time.
If I change the value in Excel, I want to reflect it in real time in MATLAB.
However, as far as I know, if you modify it without saving the Excel, it cannot be applied in MATLAB right away.
Is there a way to solve this? On matlab, I am going to import an Excel file and work on it live in real time.
If I change the value in Excel, I want to reflect it in real time in MATLAB.
However, as far as I know, if you modify it without saving the Excel, it cannot be applied in MATLAB right away.
Is there a way to solve this? excel, live MATLAB Answers — New Questions
Logging cmd in multiple diary
Hi,
i’m facing an issue in logging using the matlab ‘diary’ functionality. In the below pseudo-code i have 2 tools and both use diary to log the command window output and one is calling other. The diary off for 2nd tool is terminating the diary for the 1st tool as well due to which the remaining cmd display is not getting logged anywhere.
Here is how the logs are:
Is there a way to use ‘diary’ or some other functionality that would help is logging the command window output for the beow example ?
logger1();
function logger1()
logName = fullfile(pwd, ‘log1.txt’);
diary(logName);
fprintf(‘Initialzing logger 1n’);
fprintf(‘Display Message 1n’);
logger2;
fprintf(‘Display Message 2n’);
fprintf(‘End Logn’);
diary off
end
function logger2()
logName = fullfile(pwd, ‘log2.txt’);
diary(logName);
fprintf(‘Initialzing logger 2n’);
fprintf(‘Display Message 1n’);
fprintf(‘End Logn’);
diary off
endHi,
i’m facing an issue in logging using the matlab ‘diary’ functionality. In the below pseudo-code i have 2 tools and both use diary to log the command window output and one is calling other. The diary off for 2nd tool is terminating the diary for the 1st tool as well due to which the remaining cmd display is not getting logged anywhere.
Here is how the logs are:
Is there a way to use ‘diary’ or some other functionality that would help is logging the command window output for the beow example ?
logger1();
function logger1()
logName = fullfile(pwd, ‘log1.txt’);
diary(logName);
fprintf(‘Initialzing logger 1n’);
fprintf(‘Display Message 1n’);
logger2;
fprintf(‘Display Message 2n’);
fprintf(‘End Logn’);
diary off
end
function logger2()
logName = fullfile(pwd, ‘log2.txt’);
diary(logName);
fprintf(‘Initialzing logger 2n’);
fprintf(‘Display Message 1n’);
fprintf(‘End Logn’);
diary off
end Hi,
i’m facing an issue in logging using the matlab ‘diary’ functionality. In the below pseudo-code i have 2 tools and both use diary to log the command window output and one is calling other. The diary off for 2nd tool is terminating the diary for the 1st tool as well due to which the remaining cmd display is not getting logged anywhere.
Here is how the logs are:
Is there a way to use ‘diary’ or some other functionality that would help is logging the command window output for the beow example ?
logger1();
function logger1()
logName = fullfile(pwd, ‘log1.txt’);
diary(logName);
fprintf(‘Initialzing logger 1n’);
fprintf(‘Display Message 1n’);
logger2;
fprintf(‘Display Message 2n’);
fprintf(‘End Logn’);
diary off
end
function logger2()
logName = fullfile(pwd, ‘log2.txt’);
diary(logName);
fprintf(‘Initialzing logger 2n’);
fprintf(‘Display Message 1n’);
fprintf(‘End Logn’);
diary off
end diary, logging MATLAB Answers — New Questions
Handling memory when working with very huge data (.mat) files.
I am working with two 5D arrays (A5D and B5D) saved in a big_mat_file.mat file. The size of these arrays is specified in the code below. I want to perform three simple operations on these matrices, as shown in the code. I have access to my university’s computing cluster. When I run the following code with 120 workers and 400GB of memory, I receive the following error
In distcomp/remoteparfor/handleIntervalErrorResult (line 245) In distcomp/remoteparfor/getCompleteIntervals (line 395) In parallel_function>distributed_execution (line 746) In parallel_function (line 578)
Can someone please help me understanding what is causing this error. Is it because of low memory? It there anyother way to do the following operattions?
clear; clc;
load("big_mat_file.mat");
% it has two very huge 5D arrays "A5D" and "B5D", and two small arrays "as" and "bs"
% size of both A5D and B5D is [41 16 8 80 82]
% size of "as" is [1 80] and size of "bs" is [1 82]
xs = -12:0.1:12;
NX = length(xs);
ys = 0:0.4:12;
NY = length(ys);
total_iterations = NX * NY;
results = zeros(total_iterations , 41 , 16, 8);
XXs = zeros(total_iterations, 1);
YYs = zeros(total_iterations, 1);
parfor idx = 1:total_iterations
[ix, iy] = ind2sub([NX, NY], idx);
x = xs(ix);
y = ys(iy);
term1 = 1./(exp(1/y*(A5D-x)) + 10); %operation 1
to_integrate = B5D.*term1; %operation 2
XXs(idx) = x;
YYs(idx) = y;
results(idx, :, :, 🙂 = trapz(as,trapz(bs,to_integrate,5),4); %operation 3
end
XXs = reshape(XXs, [NX, NY]);
YYs = reshape(YYs, [NX, NY]);
results = reshape(results, [NX, NY, 41, 16, 8]);
clear A5D B5D
save(‘saved_data.mat’,’-v7.3′);I am working with two 5D arrays (A5D and B5D) saved in a big_mat_file.mat file. The size of these arrays is specified in the code below. I want to perform three simple operations on these matrices, as shown in the code. I have access to my university’s computing cluster. When I run the following code with 120 workers and 400GB of memory, I receive the following error
In distcomp/remoteparfor/handleIntervalErrorResult (line 245) In distcomp/remoteparfor/getCompleteIntervals (line 395) In parallel_function>distributed_execution (line 746) In parallel_function (line 578)
Can someone please help me understanding what is causing this error. Is it because of low memory? It there anyother way to do the following operattions?
clear; clc;
load("big_mat_file.mat");
% it has two very huge 5D arrays "A5D" and "B5D", and two small arrays "as" and "bs"
% size of both A5D and B5D is [41 16 8 80 82]
% size of "as" is [1 80] and size of "bs" is [1 82]
xs = -12:0.1:12;
NX = length(xs);
ys = 0:0.4:12;
NY = length(ys);
total_iterations = NX * NY;
results = zeros(total_iterations , 41 , 16, 8);
XXs = zeros(total_iterations, 1);
YYs = zeros(total_iterations, 1);
parfor idx = 1:total_iterations
[ix, iy] = ind2sub([NX, NY], idx);
x = xs(ix);
y = ys(iy);
term1 = 1./(exp(1/y*(A5D-x)) + 10); %operation 1
to_integrate = B5D.*term1; %operation 2
XXs(idx) = x;
YYs(idx) = y;
results(idx, :, :, 🙂 = trapz(as,trapz(bs,to_integrate,5),4); %operation 3
end
XXs = reshape(XXs, [NX, NY]);
YYs = reshape(YYs, [NX, NY]);
results = reshape(results, [NX, NY, 41, 16, 8]);
clear A5D B5D
save(‘saved_data.mat’,’-v7.3′); I am working with two 5D arrays (A5D and B5D) saved in a big_mat_file.mat file. The size of these arrays is specified in the code below. I want to perform three simple operations on these matrices, as shown in the code. I have access to my university’s computing cluster. When I run the following code with 120 workers and 400GB of memory, I receive the following error
In distcomp/remoteparfor/handleIntervalErrorResult (line 245) In distcomp/remoteparfor/getCompleteIntervals (line 395) In parallel_function>distributed_execution (line 746) In parallel_function (line 578)
Can someone please help me understanding what is causing this error. Is it because of low memory? It there anyother way to do the following operattions?
clear; clc;
load("big_mat_file.mat");
% it has two very huge 5D arrays "A5D" and "B5D", and two small arrays "as" and "bs"
% size of both A5D and B5D is [41 16 8 80 82]
% size of "as" is [1 80] and size of "bs" is [1 82]
xs = -12:0.1:12;
NX = length(xs);
ys = 0:0.4:12;
NY = length(ys);
total_iterations = NX * NY;
results = zeros(total_iterations , 41 , 16, 8);
XXs = zeros(total_iterations, 1);
YYs = zeros(total_iterations, 1);
parfor idx = 1:total_iterations
[ix, iy] = ind2sub([NX, NY], idx);
x = xs(ix);
y = ys(iy);
term1 = 1./(exp(1/y*(A5D-x)) + 10); %operation 1
to_integrate = B5D.*term1; %operation 2
XXs(idx) = x;
YYs(idx) = y;
results(idx, :, :, 🙂 = trapz(as,trapz(bs,to_integrate,5),4); %operation 3
end
XXs = reshape(XXs, [NX, NY]);
YYs = reshape(YYs, [NX, NY]);
results = reshape(results, [NX, NY, 41, 16, 8]);
clear A5D B5D
save(‘saved_data.mat’,’-v7.3′); parfor, for loop, performance MATLAB Answers — New Questions
MATLAB code for multi-step differential transform method (MsDTM) for solving system of differential equations
By starting from the standard DTM from this link
https://www.mathworks.com/matlabcentral/answers/2107386-how-to-solve-sir-model-with-using-dtm-differential-transform-method?s_tid=srchtitle
Can anyone help me to adapt the code to MsDTM? Thank youBy starting from the standard DTM from this link
https://www.mathworks.com/matlabcentral/answers/2107386-how-to-solve-sir-model-with-using-dtm-differential-transform-method?s_tid=srchtitle
Can anyone help me to adapt the code to MsDTM? Thank you By starting from the standard DTM from this link
https://www.mathworks.com/matlabcentral/answers/2107386-how-to-solve-sir-model-with-using-dtm-differential-transform-method?s_tid=srchtitle
Can anyone help me to adapt the code to MsDTM? Thank you dtm, differential transform method, differential equations MATLAB Answers — New Questions
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
I uses cosimulationConfiguration to create a HDL cosimulation block.
I get the following errors
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Scripts are as follows
%% CosimCommandLineSimulink.m
%% Configure Cosimulation Workflow
% Create a cosimulation configuration object.
%%
c = cosimulationConfiguration(‘Xcelium’,’Simulink’,’top’);
%%
% Set up the HDL file.
%%
c.HDLFiles = {…
‘./src/top.v’, ‘Verilog’,…
‘./src/model.v’, ‘Verilog’,…
};
%%
% Compilation Command
%%
c.HDLCompilationCommand ="xmsc -64bit ./src/model.cpp;" + …
"xmvlog -64bit ./src/top.v ./src/model.v;" + …
"g++ -m64 -o model.o -DNCSC -DCADENCE -D_GLIBCXX_USE_CXX11_ABI=1 " + …
"-DLNX86 -I -I /tools/cds/xceliummain_22.09.004_Linux//tools/systemc/include_pch/64bit " + …
"-I ${TOOL_PATH}/tools/systemc/include/ " + …
"-I ${TOOL_PATH}/tools.lnx86/include " + …
"-I ${TOOL_PATH}/tools/tbsc/include " + …
"-I ${TOOL_PATH}/tools/vic/include " + …
"-c -Wall ./src/*.cpp -fPIC;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so";
%%
% Elaboration
%%
c.HDLElaborationOptions = ‘-64bit -access +wc -messages -loadsc ${PATH}/systemc’;
%%
% Set the clock to a period of 20 ns, and set the reset duration to 15 ns.
%%
specifyClock(c,’clk’,Period=20)
specifyReset(c,’reset’,Duration=15)
specifyInput(c,{‘clk_enable’,’data’,’inv’});
specifyOutput(c,{‘out’});
%%
% Display the port table. It reflects the
% settings just made for output, clock, and reset attributes. The other
% design ports will take on default attributes.
%%
portInterface(c);
%% Generate HDL Cosimulation Block
% Run the workflow to generate an HDL Cosimulation block and the
% accompanying files.
%%
runWorkflow(c);
Complete output when running CosimCommandLineSimulink.m
>> CosimCommandLineSimulink
—– Input Data Ports —–
3×1 table
Name
______________
{‘clk_enable’}
{‘data’ }
{‘inv’ }
—– Output Data Ports —–
2×5 table
Name SampleTime DataType Signed FractionLength
_____________________________ __________ ___________ ______ ______________
{‘default_output_definition’} 1 {‘Inherit’} true 0
{‘out’ } 1 {‘Inherit’} true 0
—– Clock Ports —–
2×3 table
Name Edge Period
____________________________ __________ ______
{‘default_clock_definition’} {‘Rising’} 10
{‘clk’ } {‘Rising’} 20
—– Reset Ports —–
2×3 table
Name InitialValue Duration
____________________________ ____________ ________
{‘default_reset_definition’} 1 8
{‘reset’ } 1 15
—– Unused Ports —–
0×1 empty table
——————– Step 1——————
Select the type of cosimulation you want to do. If the HDL simulator executable you want to use is not on the system path in your environment, you must specify its location.
——————– Step 2——————
Add all VHDL, Verilog, and/or script files to be used in cosimulation to the following table. If the file type cannot be automatically detected or the detection result is incorrect, specify the correct file type in the table. If possible, we will determine the compilation order automatically using HDL simulator provided functionality. Then the HDL files can be added in any order.
——————– Step 3——————
HDL Verifier has automatically generated the following HDL compilation commands. You can customize these commands with optional parameters as specified in the HDL simulator documentation but they are sufficient as shown to compile your HDL code for cosimulation. The HDL files will be compiled when you click Next.
Compiling HDL files. Please wait …
### Compiling HDL design
xmsc(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsc: [TOOL PATH]/tools/cdsgcc/gcc/9.3/bin/g++ -DNCSC -DCADENCE -DLNX86 -D_GLIBCXX_USE_CXX11_ABI=1 -I[TOOL PATH]/systemc/include_pch/64bit -I[TOOL PATH]/tools/systemc/include/tlm2 -I[TOOL PATH]/tools/systemc/include/cci -I[TOOL PATH]/tools/tbsc/include -I[TOOL PATH]/tools/vic/include -c -Wall ./src/model.cpp
xmvlog(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
g++: warning: [TOOL PATH]/tools/systemc/include_pch/64bit: linker input file unused because linking not done
…done
——————– Step 4——————
Specify the name of the HDL module for cosimulation. The Cosimulation Wizard will launch the HDL simulator, load the specified module, and populate the port list of that HDL module before the next step. Use "Shared Memory" communication method if your firewall policy does not allow TCP/IP socket communication.
Elaborating and Loading HDL simulation image. Please wait …
### Elaborating HDL design
### Elaboration command: xmelab -64bit -access +wc -messages -loadsc [PATH]/systemc top
xmelab(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
Elaborating the design hierarchy:
Caching library ‘worklib’ ……. Done
The SystemC(r) Code included in this Product is Copyright 1996 – 2016 by all Contributors. All rights reserved.
The SystemC Code included in this Product has been modified by Cadence Design Systems, Inc. and CoWare, Inc. All such modifications are Copyright (c) 2004-2016 Cadence Design Systems, Inc. and Copyright (c) 2004 CoWare, Inc. All Rights Reserved.
SystemC(r) is a registered trademark of Accellera Systems Initiative, Inc. in the United States and other countries and is used with permission.
Building instance overlay tables: ……………….. Done
Building instance specific data structures.
Loading native compiled code: ……………….. Done
Design hierarchy summary:
Instances Unique
Modules: 2 2
Scalar wires: 6 –
Simulation timescale: 1ns
SystemC Design Summary:
Instances
sc_modules: 1
sc_ports: 5
sc_methods: 1
Writing initial simulation snapshot: worklib.top:module
Waiting for HDL Simulator to startup …
120 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
Waiting for HDL Simulator to startup …
119 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
…done
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Do you have any idea what is reason?
Note: paths of tools and files are hidden in this question.I uses cosimulationConfiguration to create a HDL cosimulation block.
I get the following errors
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Scripts are as follows
%% CosimCommandLineSimulink.m
%% Configure Cosimulation Workflow
% Create a cosimulation configuration object.
%%
c = cosimulationConfiguration(‘Xcelium’,’Simulink’,’top’);
%%
% Set up the HDL file.
%%
c.HDLFiles = {…
‘./src/top.v’, ‘Verilog’,…
‘./src/model.v’, ‘Verilog’,…
};
%%
% Compilation Command
%%
c.HDLCompilationCommand ="xmsc -64bit ./src/model.cpp;" + …
"xmvlog -64bit ./src/top.v ./src/model.v;" + …
"g++ -m64 -o model.o -DNCSC -DCADENCE -D_GLIBCXX_USE_CXX11_ABI=1 " + …
"-DLNX86 -I -I /tools/cds/xceliummain_22.09.004_Linux//tools/systemc/include_pch/64bit " + …
"-I ${TOOL_PATH}/tools/systemc/include/ " + …
"-I ${TOOL_PATH}/tools.lnx86/include " + …
"-I ${TOOL_PATH}/tools/tbsc/include " + …
"-I ${TOOL_PATH}/tools/vic/include " + …
"-c -Wall ./src/*.cpp -fPIC;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so";
%%
% Elaboration
%%
c.HDLElaborationOptions = ‘-64bit -access +wc -messages -loadsc ${PATH}/systemc’;
%%
% Set the clock to a period of 20 ns, and set the reset duration to 15 ns.
%%
specifyClock(c,’clk’,Period=20)
specifyReset(c,’reset’,Duration=15)
specifyInput(c,{‘clk_enable’,’data’,’inv’});
specifyOutput(c,{‘out’});
%%
% Display the port table. It reflects the
% settings just made for output, clock, and reset attributes. The other
% design ports will take on default attributes.
%%
portInterface(c);
%% Generate HDL Cosimulation Block
% Run the workflow to generate an HDL Cosimulation block and the
% accompanying files.
%%
runWorkflow(c);
Complete output when running CosimCommandLineSimulink.m
>> CosimCommandLineSimulink
—– Input Data Ports —–
3×1 table
Name
______________
{‘clk_enable’}
{‘data’ }
{‘inv’ }
—– Output Data Ports —–
2×5 table
Name SampleTime DataType Signed FractionLength
_____________________________ __________ ___________ ______ ______________
{‘default_output_definition’} 1 {‘Inherit’} true 0
{‘out’ } 1 {‘Inherit’} true 0
—– Clock Ports —–
2×3 table
Name Edge Period
____________________________ __________ ______
{‘default_clock_definition’} {‘Rising’} 10
{‘clk’ } {‘Rising’} 20
—– Reset Ports —–
2×3 table
Name InitialValue Duration
____________________________ ____________ ________
{‘default_reset_definition’} 1 8
{‘reset’ } 1 15
—– Unused Ports —–
0×1 empty table
——————– Step 1——————
Select the type of cosimulation you want to do. If the HDL simulator executable you want to use is not on the system path in your environment, you must specify its location.
——————– Step 2——————
Add all VHDL, Verilog, and/or script files to be used in cosimulation to the following table. If the file type cannot be automatically detected or the detection result is incorrect, specify the correct file type in the table. If possible, we will determine the compilation order automatically using HDL simulator provided functionality. Then the HDL files can be added in any order.
——————– Step 3——————
HDL Verifier has automatically generated the following HDL compilation commands. You can customize these commands with optional parameters as specified in the HDL simulator documentation but they are sufficient as shown to compile your HDL code for cosimulation. The HDL files will be compiled when you click Next.
Compiling HDL files. Please wait …
### Compiling HDL design
xmsc(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsc: [TOOL PATH]/tools/cdsgcc/gcc/9.3/bin/g++ -DNCSC -DCADENCE -DLNX86 -D_GLIBCXX_USE_CXX11_ABI=1 -I[TOOL PATH]/systemc/include_pch/64bit -I[TOOL PATH]/tools/systemc/include/tlm2 -I[TOOL PATH]/tools/systemc/include/cci -I[TOOL PATH]/tools/tbsc/include -I[TOOL PATH]/tools/vic/include -c -Wall ./src/model.cpp
xmvlog(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
g++: warning: [TOOL PATH]/tools/systemc/include_pch/64bit: linker input file unused because linking not done
…done
——————– Step 4——————
Specify the name of the HDL module for cosimulation. The Cosimulation Wizard will launch the HDL simulator, load the specified module, and populate the port list of that HDL module before the next step. Use "Shared Memory" communication method if your firewall policy does not allow TCP/IP socket communication.
Elaborating and Loading HDL simulation image. Please wait …
### Elaborating HDL design
### Elaboration command: xmelab -64bit -access +wc -messages -loadsc [PATH]/systemc top
xmelab(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
Elaborating the design hierarchy:
Caching library ‘worklib’ ……. Done
The SystemC(r) Code included in this Product is Copyright 1996 – 2016 by all Contributors. All rights reserved.
The SystemC Code included in this Product has been modified by Cadence Design Systems, Inc. and CoWare, Inc. All such modifications are Copyright (c) 2004-2016 Cadence Design Systems, Inc. and Copyright (c) 2004 CoWare, Inc. All Rights Reserved.
SystemC(r) is a registered trademark of Accellera Systems Initiative, Inc. in the United States and other countries and is used with permission.
Building instance overlay tables: ……………….. Done
Building instance specific data structures.
Loading native compiled code: ……………….. Done
Design hierarchy summary:
Instances Unique
Modules: 2 2
Scalar wires: 6 –
Simulation timescale: 1ns
SystemC Design Summary:
Instances
sc_modules: 1
sc_ports: 5
sc_methods: 1
Writing initial simulation snapshot: worklib.top:module
Waiting for HDL Simulator to startup …
120 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
Waiting for HDL Simulator to startup …
119 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
…done
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Do you have any idea what is reason?
Note: paths of tools and files are hidden in this question. I uses cosimulationConfiguration to create a HDL cosimulation block.
I get the following errors
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Scripts are as follows
%% CosimCommandLineSimulink.m
%% Configure Cosimulation Workflow
% Create a cosimulation configuration object.
%%
c = cosimulationConfiguration(‘Xcelium’,’Simulink’,’top’);
%%
% Set up the HDL file.
%%
c.HDLFiles = {…
‘./src/top.v’, ‘Verilog’,…
‘./src/model.v’, ‘Verilog’,…
};
%%
% Compilation Command
%%
c.HDLCompilationCommand ="xmsc -64bit ./src/model.cpp;" + …
"xmvlog -64bit ./src/top.v ./src/model.v;" + …
"g++ -m64 -o model.o -DNCSC -DCADENCE -D_GLIBCXX_USE_CXX11_ABI=1 " + …
"-DLNX86 -I -I /tools/cds/xceliummain_22.09.004_Linux//tools/systemc/include_pch/64bit " + …
"-I ${TOOL_PATH}/tools/systemc/include/ " + …
"-I ${TOOL_PATH}/tools.lnx86/include " + …
"-I ${TOOL_PATH}/tools/tbsc/include " + …
"-I ${TOOL_PATH}/tools/vic/include " + …
"-c -Wall ./src/*.cpp -fPIC;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so";
%%
% Elaboration
%%
c.HDLElaborationOptions = ‘-64bit -access +wc -messages -loadsc ${PATH}/systemc’;
%%
% Set the clock to a period of 20 ns, and set the reset duration to 15 ns.
%%
specifyClock(c,’clk’,Period=20)
specifyReset(c,’reset’,Duration=15)
specifyInput(c,{‘clk_enable’,’data’,’inv’});
specifyOutput(c,{‘out’});
%%
% Display the port table. It reflects the
% settings just made for output, clock, and reset attributes. The other
% design ports will take on default attributes.
%%
portInterface(c);
%% Generate HDL Cosimulation Block
% Run the workflow to generate an HDL Cosimulation block and the
% accompanying files.
%%
runWorkflow(c);
Complete output when running CosimCommandLineSimulink.m
>> CosimCommandLineSimulink
—– Input Data Ports —–
3×1 table
Name
______________
{‘clk_enable’}
{‘data’ }
{‘inv’ }
—– Output Data Ports —–
2×5 table
Name SampleTime DataType Signed FractionLength
_____________________________ __________ ___________ ______ ______________
{‘default_output_definition’} 1 {‘Inherit’} true 0
{‘out’ } 1 {‘Inherit’} true 0
—– Clock Ports —–
2×3 table
Name Edge Period
____________________________ __________ ______
{‘default_clock_definition’} {‘Rising’} 10
{‘clk’ } {‘Rising’} 20
—– Reset Ports —–
2×3 table
Name InitialValue Duration
____________________________ ____________ ________
{‘default_reset_definition’} 1 8
{‘reset’ } 1 15
—– Unused Ports —–
0×1 empty table
——————– Step 1——————
Select the type of cosimulation you want to do. If the HDL simulator executable you want to use is not on the system path in your environment, you must specify its location.
——————– Step 2——————
Add all VHDL, Verilog, and/or script files to be used in cosimulation to the following table. If the file type cannot be automatically detected or the detection result is incorrect, specify the correct file type in the table. If possible, we will determine the compilation order automatically using HDL simulator provided functionality. Then the HDL files can be added in any order.
——————– Step 3——————
HDL Verifier has automatically generated the following HDL compilation commands. You can customize these commands with optional parameters as specified in the HDL simulator documentation but they are sufficient as shown to compile your HDL code for cosimulation. The HDL files will be compiled when you click Next.
Compiling HDL files. Please wait …
### Compiling HDL design
xmsc(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsc: [TOOL PATH]/tools/cdsgcc/gcc/9.3/bin/g++ -DNCSC -DCADENCE -DLNX86 -D_GLIBCXX_USE_CXX11_ABI=1 -I[TOOL PATH]/systemc/include_pch/64bit -I[TOOL PATH]/tools/systemc/include/tlm2 -I[TOOL PATH]/tools/systemc/include/cci -I[TOOL PATH]/tools/tbsc/include -I[TOOL PATH]/tools/vic/include -c -Wall ./src/model.cpp
xmvlog(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
g++: warning: [TOOL PATH]/tools/systemc/include_pch/64bit: linker input file unused because linking not done
…done
——————– Step 4——————
Specify the name of the HDL module for cosimulation. The Cosimulation Wizard will launch the HDL simulator, load the specified module, and populate the port list of that HDL module before the next step. Use "Shared Memory" communication method if your firewall policy does not allow TCP/IP socket communication.
Elaborating and Loading HDL simulation image. Please wait …
### Elaborating HDL design
### Elaboration command: xmelab -64bit -access +wc -messages -loadsc [PATH]/systemc top
xmelab(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
Elaborating the design hierarchy:
Caching library ‘worklib’ ……. Done
The SystemC(r) Code included in this Product is Copyright 1996 – 2016 by all Contributors. All rights reserved.
The SystemC Code included in this Product has been modified by Cadence Design Systems, Inc. and CoWare, Inc. All such modifications are Copyright (c) 2004-2016 Cadence Design Systems, Inc. and Copyright (c) 2004 CoWare, Inc. All Rights Reserved.
SystemC(r) is a registered trademark of Accellera Systems Initiative, Inc. in the United States and other countries and is used with permission.
Building instance overlay tables: ……………….. Done
Building instance specific data structures.
Loading native compiled code: ……………….. Done
Design hierarchy summary:
Instances Unique
Modules: 2 2
Scalar wires: 6 –
Simulation timescale: 1ns
SystemC Design Summary:
Instances
sc_modules: 1
sc_ports: 5
sc_methods: 1
Writing initial simulation snapshot: worklib.top:module
Waiting for HDL Simulator to startup …
120 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
Waiting for HDL Simulator to startup …
119 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
…done
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Do you have any idea what is reason?
Note: paths of tools and files are hidden in this question. hdlverifier, cosimulationconfiguration, simulink, cadence, xcelium MATLAB Answers — New Questions
MATLAB standalone app installation without administrator
Hi,
I am trying to make some MATLAB apps for people without MATLAB licenses at work. I compiled them as standalone apps with the runtime libraries included in the package so they don’t have to be downloaded and installed separately. However, the app requires admin privileges to install. This isn’t very pleasant since we have to request IT for each installation.
Is there a way to eliminate the need for administrator privileges? I tried moving the installation directory to the user directory instead of Program Files but that didn’t help as well.
Thanks,
AbinavHi,
I am trying to make some MATLAB apps for people without MATLAB licenses at work. I compiled them as standalone apps with the runtime libraries included in the package so they don’t have to be downloaded and installed separately. However, the app requires admin privileges to install. This isn’t very pleasant since we have to request IT for each installation.
Is there a way to eliminate the need for administrator privileges? I tried moving the installation directory to the user directory instead of Program Files but that didn’t help as well.
Thanks,
Abinav Hi,
I am trying to make some MATLAB apps for people without MATLAB licenses at work. I compiled them as standalone apps with the runtime libraries included in the package so they don’t have to be downloaded and installed separately. However, the app requires admin privileges to install. This isn’t very pleasant since we have to request IT for each installation.
Is there a way to eliminate the need for administrator privileges? I tried moving the installation directory to the user directory instead of Program Files but that didn’t help as well.
Thanks,
Abinav matlab app, matlab compiler, administrator MATLAB Answers — New Questions
Where are “files installed for your end user” are saved in the installation directory using compiler?
I have a few matrices that I want to load in the app using the load command.
Temporarily the files are saved like this:
load C:UserssepandDocumentsMATLABBY.mat;
what path should I set them to so that they would be accessible to the main program after compilation?I have a few matrices that I want to load in the app using the load command.
Temporarily the files are saved like this:
load C:UserssepandDocumentsMATLABBY.mat;
what path should I set them to so that they would be accessible to the main program after compilation? I have a few matrices that I want to load in the app using the load command.
Temporarily the files are saved like this:
load C:UserssepandDocumentsMATLABBY.mat;
what path should I set them to so that they would be accessible to the main program after compilation? matlab compiler MATLAB Answers — New Questions
Confirming a confirmed track for GNN tracker
Hi, I am currently working with a GNN tracker with radar data. I have a tracker working for range and angle information.
After gettting the confirmed tracks, I would like to check make another check with some detections and then keep the old track alive. How can I achieve this? I saw that there is a trackStateLogic which is appended with a zero everytime a track does not get a detection. But I was uable to change it for a confirmed track.
Can someone please help me in this?Hi, I am currently working with a GNN tracker with radar data. I have a tracker working for range and angle information.
After gettting the confirmed tracks, I would like to check make another check with some detections and then keep the old track alive. How can I achieve this? I saw that there is a trackStateLogic which is appended with a zero everytime a track does not get a detection. But I was uable to change it for a confirmed track.
Can someone please help me in this? Hi, I am currently working with a GNN tracker with radar data. I have a tracker working for range and angle information.
After gettting the confirmed tracks, I would like to check make another check with some detections and then keep the old track alive. How can I achieve this? I saw that there is a trackStateLogic which is appended with a zero everytime a track does not get a detection. But I was uable to change it for a confirmed track.
Can someone please help me in this? gnn tracker MATLAB Answers — New Questions
Efficient Code for Filling Rows of an Array involving Indices Ranges
Hello,
I have an array A of zeros. I need to set a range of column indices for each row of A to ones. These ranges are determined by elements of another vector B, specifying start and end indices for the ranges for each row. For example, this is what I’m trying to figure out:
<</matlabcentral/answers/uploaded_files/18907/matrixA.jpg>>
<</matlabcentral/answers/uploaded_files/18908/matrixB.jpg>>
<</matlabcentral/answers/uploaded_files/18909/matrixA2.jpg>>
The first row of B indicates that the first row of A should have ones from columns 1 to 3. The second row of B indicates that the second row of A should have ones from columns 2 to 4 etc.
I could code this with a for-loop that goes through each of the rows and creates indices with the colon operator however, I’m hoping for a smarter, more efficient way to do it than that.
Can anyone help me with this or any suggestions?
Thanks.Hello,
I have an array A of zeros. I need to set a range of column indices for each row of A to ones. These ranges are determined by elements of another vector B, specifying start and end indices for the ranges for each row. For example, this is what I’m trying to figure out:
<</matlabcentral/answers/uploaded_files/18907/matrixA.jpg>>
<</matlabcentral/answers/uploaded_files/18908/matrixB.jpg>>
<</matlabcentral/answers/uploaded_files/18909/matrixA2.jpg>>
The first row of B indicates that the first row of A should have ones from columns 1 to 3. The second row of B indicates that the second row of A should have ones from columns 2 to 4 etc.
I could code this with a for-loop that goes through each of the rows and creates indices with the colon operator however, I’m hoping for a smarter, more efficient way to do it than that.
Can anyone help me with this or any suggestions?
Thanks. Hello,
I have an array A of zeros. I need to set a range of column indices for each row of A to ones. These ranges are determined by elements of another vector B, specifying start and end indices for the ranges for each row. For example, this is what I’m trying to figure out:
<</matlabcentral/answers/uploaded_files/18907/matrixA.jpg>>
<</matlabcentral/answers/uploaded_files/18908/matrixB.jpg>>
<</matlabcentral/answers/uploaded_files/18909/matrixA2.jpg>>
The first row of B indicates that the first row of A should have ones from columns 1 to 3. The second row of B indicates that the second row of A should have ones from columns 2 to 4 etc.
I could code this with a for-loop that goes through each of the rows and creates indices with the colon operator however, I’m hoping for a smarter, more efficient way to do it than that.
Can anyone help me with this or any suggestions?
Thanks. matrix manipulation MATLAB Answers — New Questions
Uigetdir to pick multiple directories
I was wondering if anyone knows a simple way how to use uigetdir to select multiple directory paths in a similar way to using uigetfile with ‘multiselect’,’on’
ThanksI was wondering if anyone knows a simple way how to use uigetdir to select multiple directory paths in a similar way to using uigetfile with ‘multiselect’,’on’
Thanks I was wondering if anyone knows a simple way how to use uigetdir to select multiple directory paths in a similar way to using uigetfile with ‘multiselect’,’on’
Thanks uigetdir, uigetfile, multiselect, directory MATLAB Answers — New Questions
Combined 2 files .dat with different size
hello i have 2 files .dat contains enum values but the size of the file one 4000×2 and the second 6000×2 i use "csvread" and "readmatrix" but doesn’t work
Note (enum :enumeration)
can you help me pls
thankshello i have 2 files .dat contains enum values but the size of the file one 4000×2 and the second 6000×2 i use "csvread" and "readmatrix" but doesn’t work
Note (enum :enumeration)
can you help me pls
thanks hello i have 2 files .dat contains enum values but the size of the file one 4000×2 and the second 6000×2 i use "csvread" and "readmatrix" but doesn’t work
Note (enum :enumeration)
can you help me pls
thanks matlab, .dat MATLAB Answers — New Questions
How do I incorporate a feedforward control signal into an MPC block?
I have designed a feedback control system using an Model Predictive Controller block for a DC Motor servomechanism. In order to reduce the steady-state error I want to include a feedforward control signal that I can estimate and predict. The MPC block therefore needs to have knowledge of the feedforward control signal as, I assume, a measured disturbance which is able to be previewed. I have implemented this as below:
I haven’t been able to improve the controller performance with this architecture as I would expect (previous PI + Feedforward works very well), so I wanted to ask whether this was the correct approach to include the feedforward signal into the MPC block?I have designed a feedback control system using an Model Predictive Controller block for a DC Motor servomechanism. In order to reduce the steady-state error I want to include a feedforward control signal that I can estimate and predict. The MPC block therefore needs to have knowledge of the feedforward control signal as, I assume, a measured disturbance which is able to be previewed. I have implemented this as below:
I haven’t been able to improve the controller performance with this architecture as I would expect (previous PI + Feedforward works very well), so I wanted to ask whether this was the correct approach to include the feedforward signal into the MPC block? I have designed a feedback control system using an Model Predictive Controller block for a DC Motor servomechanism. In order to reduce the steady-state error I want to include a feedforward control signal that I can estimate and predict. The MPC block therefore needs to have knowledge of the feedforward control signal as, I assume, a measured disturbance which is able to be previewed. I have implemented this as below:
I haven’t been able to improve the controller performance with this architecture as I would expect (previous PI + Feedforward works very well), so I wanted to ask whether this was the correct approach to include the feedforward signal into the MPC block? mpc, simulink, feedforward, control MATLAB Answers — New Questions