Category: Matlab
Category Archives: Matlab
How do I publish figures as a pdf so that it shows as it does in MATLAB?
% SIMPLE_PLOT Generate a plot with x and y values as a black line, with labels and a title.
x = linspace(0,2*pi,200);
y = sin(x); % example y values
figure(1)
plot(x,y,’k-‘)
xlabel(‘x (radians)’)
ylabel(‘sin(x)’)
title(‘Black Line: Sine Wave’)
grid on
So as you can see when i run this code in MATLAB it runs and outputs corrrectly but when i go to publish it I am left with it looking like this in the Publish_Example.pdf below.
If you could give me any suggestions or solutions on how to fix this problem it would be greatly appreciated. Thank you!% SIMPLE_PLOT Generate a plot with x and y values as a black line, with labels and a title.
x = linspace(0,2*pi,200);
y = sin(x); % example y values
figure(1)
plot(x,y,’k-‘)
xlabel(‘x (radians)’)
ylabel(‘sin(x)’)
title(‘Black Line: Sine Wave’)
grid on
So as you can see when i run this code in MATLAB it runs and outputs corrrectly but when i go to publish it I am left with it looking like this in the Publish_Example.pdf below.
If you could give me any suggestions or solutions on how to fix this problem it would be greatly appreciated. Thank you! % SIMPLE_PLOT Generate a plot with x and y values as a black line, with labels and a title.
x = linspace(0,2*pi,200);
y = sin(x); % example y values
figure(1)
plot(x,y,’k-‘)
xlabel(‘x (radians)’)
ylabel(‘sin(x)’)
title(‘Black Line: Sine Wave’)
grid on
So as you can see when i run this code in MATLAB it runs and outputs corrrectly but when i go to publish it I am left with it looking like this in the Publish_Example.pdf below.
If you could give me any suggestions or solutions on how to fix this problem it would be greatly appreciated. Thank you! publish, figure, pdf MATLAB Answers — New Questions
How can I use Visual Studio Code to debug my MinGW C/C++ file?
I have a C/C++ MEX file compiled by the MinGW64 compiler with the -g flag. How can I debug my MEX through Visual Studio Code?I have a C/C++ MEX file compiled by the MinGW64 compiler with the -g flag. How can I debug my MEX through Visual Studio Code? I have a C/C++ MEX file compiled by the MinGW64 compiler with the -g flag. How can I debug my MEX through Visual Studio Code? mex, mingw, debugging, vscode, c, c++ MATLAB Answers — New Questions
Push Button block – disappearing Issue
I am using push button in my simulink model to take input from user for button press.
I am using customised Image on top for that button. It works well until I close the model.
Once I repon the model, Push button disappears and only boundary of the Push button remains visible in the same area.
If I click on the button no click action is getting performed but it highlights connected blocks that using its input on click action.
I have checked image path, it is kept at the same path where model is stored.I am using push button in my simulink model to take input from user for button press.
I am using customised Image on top for that button. It works well until I close the model.
Once I repon the model, Push button disappears and only boundary of the Push button remains visible in the same area.
If I click on the button no click action is getting performed but it highlights connected blocks that using its input on click action.
I have checked image path, it is kept at the same path where model is stored. I am using push button in my simulink model to take input from user for button press.
I am using customised Image on top for that button. It works well until I close the model.
Once I repon the model, Push button disappears and only boundary of the Push button remains visible in the same area.
If I click on the button no click action is getting performed but it highlights connected blocks that using its input on click action.
I have checked image path, it is kept at the same path where model is stored. push button MATLAB Answers — New Questions
help with XYZ data file
I am trying to understand a XYZ datafile from a 3D file. Example file.
https://www.dropbox.com/scl/fi/9463jgix2t8bnz356s7ly/1-0331_06_mesh.xyz?rlkey=m73j8q1j9qqufe7xlqbockg68&st=vlsz2eoz&dl=0
I was able to google how to open the XYZ file in matlab and it gave me code that works (provided below) but I would like help manipulating the code. First question, I would like to be able to plot some of the planes of XY with fixed Z values/range. Can this be done direclty from the MATLAB variables XYZ used below? This seems to be making lines, it is some kind of vector data?
figure, imagesc(X(:,1),Y(:,1),Z(100:1000,1))
What is the scatterinterpolant doing? How can i get XY planes for each Z ?
clear
data = readmatrix(‘#1-0331_06_mesh.xyz’, ‘FileType’, ‘text’);
X = data(:,1);
Y = data(:,2);
Z = data(:,3);
% Create a grid
[xq, yq] = meshgrid(linspace(min(X), max(X), 100), linspace(min(Y), max(Y), 100));
% Interpolate Z values onto the grid. Different interploation methods
F = scatteredInterpolant(X, Y, Z);
zq = F(xq, yq);
% Plot the surface
figure, surf(xq, yq, zq);
shading interp; % Smooths the surface
axis equalI am trying to understand a XYZ datafile from a 3D file. Example file.
https://www.dropbox.com/scl/fi/9463jgix2t8bnz356s7ly/1-0331_06_mesh.xyz?rlkey=m73j8q1j9qqufe7xlqbockg68&st=vlsz2eoz&dl=0
I was able to google how to open the XYZ file in matlab and it gave me code that works (provided below) but I would like help manipulating the code. First question, I would like to be able to plot some of the planes of XY with fixed Z values/range. Can this be done direclty from the MATLAB variables XYZ used below? This seems to be making lines, it is some kind of vector data?
figure, imagesc(X(:,1),Y(:,1),Z(100:1000,1))
What is the scatterinterpolant doing? How can i get XY planes for each Z ?
clear
data = readmatrix(‘#1-0331_06_mesh.xyz’, ‘FileType’, ‘text’);
X = data(:,1);
Y = data(:,2);
Z = data(:,3);
% Create a grid
[xq, yq] = meshgrid(linspace(min(X), max(X), 100), linspace(min(Y), max(Y), 100));
% Interpolate Z values onto the grid. Different interploation methods
F = scatteredInterpolant(X, Y, Z);
zq = F(xq, yq);
% Plot the surface
figure, surf(xq, yq, zq);
shading interp; % Smooths the surface
axis equal I am trying to understand a XYZ datafile from a 3D file. Example file.
https://www.dropbox.com/scl/fi/9463jgix2t8bnz356s7ly/1-0331_06_mesh.xyz?rlkey=m73j8q1j9qqufe7xlqbockg68&st=vlsz2eoz&dl=0
I was able to google how to open the XYZ file in matlab and it gave me code that works (provided below) but I would like help manipulating the code. First question, I would like to be able to plot some of the planes of XY with fixed Z values/range. Can this be done direclty from the MATLAB variables XYZ used below? This seems to be making lines, it is some kind of vector data?
figure, imagesc(X(:,1),Y(:,1),Z(100:1000,1))
What is the scatterinterpolant doing? How can i get XY planes for each Z ?
clear
data = readmatrix(‘#1-0331_06_mesh.xyz’, ‘FileType’, ‘text’);
X = data(:,1);
Y = data(:,2);
Z = data(:,3);
% Create a grid
[xq, yq] = meshgrid(linspace(min(X), max(X), 100), linspace(min(Y), max(Y), 100));
% Interpolate Z values onto the grid. Different interploation methods
F = scatteredInterpolant(X, Y, Z);
zq = F(xq, yq);
% Plot the surface
figure, surf(xq, yq, zq);
shading interp; % Smooths the surface
axis equal xyz data, 3d data MATLAB Answers — New Questions
How to Transmit and Receive Simultaneously Using USRP B210 in MATLAB
"I am trying to transmit and receive signals simultaneously using a USRP B210 in MATLAB. I want to continuously transmit a sine wave signal and plot the received signal in real time. I attempted to use comm.SDRuTransmitter and comm.SDRuReceiver in parallel processing, but the reception does not seem to work properly while transmitting. Is it possible to transmit and receive at the same time?"I am trying to transmit and receive signals simultaneously using a USRP B210 in MATLAB. I want to continuously transmit a sine wave signal and plot the received signal in real time. I attempted to use comm.SDRuTransmitter and comm.SDRuReceiver in parallel processing, but the reception does not seem to work properly while transmitting. Is it possible to transmit and receive at the same time? "I am trying to transmit and receive signals simultaneously using a USRP B210 in MATLAB. I want to continuously transmit a sine wave signal and plot the received signal in real time. I attempted to use comm.SDRuTransmitter and comm.SDRuReceiver in parallel processing, but the reception does not seem to work properly while transmitting. Is it possible to transmit and receive at the same time? usrp, matlab, full duplex MATLAB Answers — New Questions
Custom font weight in plot
Since updating from R2021a to R2025a, I can’t seem to be able to use the custom font I want to in plots.
Below is a minimal working example, which used to render the correct font, but which now renders Times.
figure;
plot(0:100,[0:100].^2);
set(gca,’FontName’,’Gill Sans Nova Book’);
xlabel(‘Time (s)’);
ylabel(‘Function, Z (kJ)’);
Notes:
The font name is ‘Gill Sans Nova’ and that ‘Book’ is the weight, similarly to Light or Bold
If I input ‘Gill Sans Nova’ as fontname, it works and depicts Gill Sans Nova Regular
I tried setting the FontWeight to ‘Book’ but that is not a permitted input
If I copy the plot using print(gcf,’-dmeta’) and then copy it in a Word document, the font renders correcly
I am running Windows 10
Font is installed as an administrator
Thanks in advance and best regards,Since updating from R2021a to R2025a, I can’t seem to be able to use the custom font I want to in plots.
Below is a minimal working example, which used to render the correct font, but which now renders Times.
figure;
plot(0:100,[0:100].^2);
set(gca,’FontName’,’Gill Sans Nova Book’);
xlabel(‘Time (s)’);
ylabel(‘Function, Z (kJ)’);
Notes:
The font name is ‘Gill Sans Nova’ and that ‘Book’ is the weight, similarly to Light or Bold
If I input ‘Gill Sans Nova’ as fontname, it works and depicts Gill Sans Nova Regular
I tried setting the FontWeight to ‘Book’ but that is not a permitted input
If I copy the plot using print(gcf,’-dmeta’) and then copy it in a Word document, the font renders correcly
I am running Windows 10
Font is installed as an administrator
Thanks in advance and best regards, Since updating from R2021a to R2025a, I can’t seem to be able to use the custom font I want to in plots.
Below is a minimal working example, which used to render the correct font, but which now renders Times.
figure;
plot(0:100,[0:100].^2);
set(gca,’FontName’,’Gill Sans Nova Book’);
xlabel(‘Time (s)’);
ylabel(‘Function, Z (kJ)’);
Notes:
The font name is ‘Gill Sans Nova’ and that ‘Book’ is the weight, similarly to Light or Bold
If I input ‘Gill Sans Nova’ as fontname, it works and depicts Gill Sans Nova Regular
I tried setting the FontWeight to ‘Book’ but that is not a permitted input
If I copy the plot using print(gcf,’-dmeta’) and then copy it in a Word document, the font renders correcly
I am running Windows 10
Font is installed as an administrator
Thanks in advance and best regards, figure, plot MATLAB Answers — New Questions
How can I optimize RAM, ROM, and stack usage in generated code?
When generating C code from a Simulink model, I notice that the resulting RAM, ROM, or stack usage is higher than expected.
Which configuration options and modeling choices influence memory consumption, and how can I control them to reduce the overall footprint of the generated code?When generating C code from a Simulink model, I notice that the resulting RAM, ROM, or stack usage is higher than expected.
Which configuration options and modeling choices influence memory consumption, and how can I control them to reduce the overall footprint of the generated code? When generating C code from a Simulink model, I notice that the resulting RAM, ROM, or stack usage is higher than expected.
Which configuration options and modeling choices influence memory consumption, and how can I control them to reduce the overall footprint of the generated code? ram, rom, generatedcode MATLAB Answers — New Questions
How to find a rotation vector for use in rotate, if the rotation matrix is rank deficient?
A couple days ago I made a reddit post asking how to find the rotation matrix for an arbitrary 3D rotation, relative to some global coordinate axis. I got a satisfactory answer; methods can be found on that post and on the wiki page for rotation matrices. I am now trying to implement that into MATLAB and failing.
Let us assume the simple case in that reddit post. The global coordinate axes (xyz) and rotated axes (uvw) are simply
x=[1 0 0];
y=[0 1 0];
z=[0 0 1];
u=[0 1 0];
v=[-1 0 0];
w=[0 0 1];
which represents a +90 degree rotation about the z axis at the origin (0 0 0), but let’s pretend we don’t know that. The hand calcs for this is easy and found on the reddit post. I now try and do the same in MATLAB.
linsolve and lsqminnorm require the B vector to be constants, not with variables. Since B is [x y z], we simply subtract the identity from [u;v;w] and use that as A:
A=[u;v;w]-eye(3)
B=[0;0;0]
Now we have to solve this system of equations. Linsolve and lsqminnorm both return nonsense values:
ls=linsolve(A,B)
lsmn=lsqminnorm(A,B)
From the hand calcs, we know the answer should be [0 0 n] with n being any real nonzero value (preferably 1). What is the appropriate way to resolve this? I have also tried to solve this directly with the rotation matrix given in the wiki, but it returns NaN eigenvectors.
IN ADDITION TO THIS SPECIFIC EXAMPLE
The problem also persists for other orthonormal sets of uvw. I’m getting nonsense values (NaNs) or incorrect values (for example, I’m getting something like 166.5 degrees instead of 90.4 from the hand calc using the reddit example). This indicates I’m having a general problem, not just an edge-case one.A couple days ago I made a reddit post asking how to find the rotation matrix for an arbitrary 3D rotation, relative to some global coordinate axis. I got a satisfactory answer; methods can be found on that post and on the wiki page for rotation matrices. I am now trying to implement that into MATLAB and failing.
Let us assume the simple case in that reddit post. The global coordinate axes (xyz) and rotated axes (uvw) are simply
x=[1 0 0];
y=[0 1 0];
z=[0 0 1];
u=[0 1 0];
v=[-1 0 0];
w=[0 0 1];
which represents a +90 degree rotation about the z axis at the origin (0 0 0), but let’s pretend we don’t know that. The hand calcs for this is easy and found on the reddit post. I now try and do the same in MATLAB.
linsolve and lsqminnorm require the B vector to be constants, not with variables. Since B is [x y z], we simply subtract the identity from [u;v;w] and use that as A:
A=[u;v;w]-eye(3)
B=[0;0;0]
Now we have to solve this system of equations. Linsolve and lsqminnorm both return nonsense values:
ls=linsolve(A,B)
lsmn=lsqminnorm(A,B)
From the hand calcs, we know the answer should be [0 0 n] with n being any real nonzero value (preferably 1). What is the appropriate way to resolve this? I have also tried to solve this directly with the rotation matrix given in the wiki, but it returns NaN eigenvectors.
IN ADDITION TO THIS SPECIFIC EXAMPLE
The problem also persists for other orthonormal sets of uvw. I’m getting nonsense values (NaNs) or incorrect values (for example, I’m getting something like 166.5 degrees instead of 90.4 from the hand calc using the reddit example). This indicates I’m having a general problem, not just an edge-case one. A couple days ago I made a reddit post asking how to find the rotation matrix for an arbitrary 3D rotation, relative to some global coordinate axis. I got a satisfactory answer; methods can be found on that post and on the wiki page for rotation matrices. I am now trying to implement that into MATLAB and failing.
Let us assume the simple case in that reddit post. The global coordinate axes (xyz) and rotated axes (uvw) are simply
x=[1 0 0];
y=[0 1 0];
z=[0 0 1];
u=[0 1 0];
v=[-1 0 0];
w=[0 0 1];
which represents a +90 degree rotation about the z axis at the origin (0 0 0), but let’s pretend we don’t know that. The hand calcs for this is easy and found on the reddit post. I now try and do the same in MATLAB.
linsolve and lsqminnorm require the B vector to be constants, not with variables. Since B is [x y z], we simply subtract the identity from [u;v;w] and use that as A:
A=[u;v;w]-eye(3)
B=[0;0;0]
Now we have to solve this system of equations. Linsolve and lsqminnorm both return nonsense values:
ls=linsolve(A,B)
lsmn=lsqminnorm(A,B)
From the hand calcs, we know the answer should be [0 0 n] with n being any real nonzero value (preferably 1). What is the appropriate way to resolve this? I have also tried to solve this directly with the rotation matrix given in the wiki, but it returns NaN eigenvectors.
IN ADDITION TO THIS SPECIFIC EXAMPLE
The problem also persists for other orthonormal sets of uvw. I’m getting nonsense values (NaNs) or incorrect values (for example, I’m getting something like 166.5 degrees instead of 90.4 from the hand calc using the reddit example). This indicates I’m having a general problem, not just an edge-case one. rotation, rank deficient, system of equations MATLAB Answers — New Questions
Even though I followed Matlab instruction, I cannot update it.
following the Matlab instruction for update, I tried to update my Matlab. But it still says that my licence will expire 7 days. How should I do?following the Matlab instruction for update, I tried to update my Matlab. But it still says that my licence will expire 7 days. How should I do? following the Matlab instruction for update, I tried to update my Matlab. But it still says that my licence will expire 7 days. How should I do? license update MATLAB Answers — New Questions
Why do I get a “Target computer software version mismatch” error with Speedgoat and Simulink Real-Time?
I am trying to connect to my Speedgoat target using MATLAB R2020b and R2021a. I confirmed I have migrated the target to work with R2020b and later, and I can connect to the target without an issue using MATLAB R2020b. However, I encountered the following error when using R2021a:
>> tg = slrealtime;
>> tg.connect;
Cannot connect to target ‘TargetPC1’: Target computer software version mismatch. Run update(tg) command.
In newer versions of MATLAB, the error message lists details about the mismatching software components:
Unable to connect to target computer ‘TargetPC1’: Target computer software version mismatch.
The development computer <…> version ‘X’ does not match the target computer <…> version ‘Y’.
The development computer <…> version ‘X’ does not support the target computer <…> version ‘Y’.
Run update(tg) command.
Why do I see this error? How can I resolve this error?I am trying to connect to my Speedgoat target using MATLAB R2020b and R2021a. I confirmed I have migrated the target to work with R2020b and later, and I can connect to the target without an issue using MATLAB R2020b. However, I encountered the following error when using R2021a:
>> tg = slrealtime;
>> tg.connect;
Cannot connect to target ‘TargetPC1’: Target computer software version mismatch. Run update(tg) command.
In newer versions of MATLAB, the error message lists details about the mismatching software components:
Unable to connect to target computer ‘TargetPC1’: Target computer software version mismatch.
The development computer <…> version ‘X’ does not match the target computer <…> version ‘Y’.
The development computer <…> version ‘X’ does not support the target computer <…> version ‘Y’.
Run update(tg) command.
Why do I see this error? How can I resolve this error? I am trying to connect to my Speedgoat target using MATLAB R2020b and R2021a. I confirmed I have migrated the target to work with R2020b and later, and I can connect to the target without an issue using MATLAB R2020b. However, I encountered the following error when using R2021a:
>> tg = slrealtime;
>> tg.connect;
Cannot connect to target ‘TargetPC1’: Target computer software version mismatch. Run update(tg) command.
In newer versions of MATLAB, the error message lists details about the mismatching software components:
Unable to connect to target computer ‘TargetPC1’: Target computer software version mismatch.
The development computer <…> version ‘X’ does not match the target computer <…> version ‘Y’.
The development computer <…> version ‘X’ does not support the target computer <…> version ‘Y’.
Run update(tg) command.
Why do I see this error? How can I resolve this error? speedgoat, slrt, software, mismatch, migration MATLAB Answers — New Questions
Implicit finite difference scheme in MATLAB for 1D Mobile-Immobile Model (MIM) with linear sorption and degradation
I am trying to write a MATLAB code to solve the 1D Mobile-Immobile Model (MIM) for solute transport in porous media. My model includes both linear sorption (retardation) and first-order degradation.
The governing equations are:
Mobile Region:
Immobile Region:
Where:
and are the concentrations in the mobile and immobile regions.
and are retardation factors.
and are volumetric water contents.
and are first-order degradation rates.
is the mass transfer coefficient.
My Goal:
I want to implement a fully implicit finite difference scheme (Backward Euler in time, Central Difference for dispersion, and Upwind for advection) to ensure unconditional numerical stability.
My Issue:
I am comfortable assembling the sparse tridiagonal matrix for a standard Advection-Dispersion Equation (ADE). However, because the MIM equations are coupled, I am unsure of the best practice for assembling the coefficient matrix in MATLAB.
Specifically:
1. Should I decouple the equations by solving the immobile equation first at the current time step and substituting it into the mobile equation?
2. Or is it better to construct a larger block-diagonal sparse matrix to solve and simultaneously at ? If so, how should the indices be structured in MATLAB (`spdiags` or `sparse`) to represent this coupled system efficiently?
Any brief examples or structural advice on setting up the implicit matrix and right-hand side for this coupled system would be greatly appreciated.I am trying to write a MATLAB code to solve the 1D Mobile-Immobile Model (MIM) for solute transport in porous media. My model includes both linear sorption (retardation) and first-order degradation.
The governing equations are:
Mobile Region:
Immobile Region:
Where:
and are the concentrations in the mobile and immobile regions.
and are retardation factors.
and are volumetric water contents.
and are first-order degradation rates.
is the mass transfer coefficient.
My Goal:
I want to implement a fully implicit finite difference scheme (Backward Euler in time, Central Difference for dispersion, and Upwind for advection) to ensure unconditional numerical stability.
My Issue:
I am comfortable assembling the sparse tridiagonal matrix for a standard Advection-Dispersion Equation (ADE). However, because the MIM equations are coupled, I am unsure of the best practice for assembling the coefficient matrix in MATLAB.
Specifically:
1. Should I decouple the equations by solving the immobile equation first at the current time step and substituting it into the mobile equation?
2. Or is it better to construct a larger block-diagonal sparse matrix to solve and simultaneously at ? If so, how should the indices be structured in MATLAB (`spdiags` or `sparse`) to represent this coupled system efficiently?
Any brief examples or structural advice on setting up the implicit matrix and right-hand side for this coupled system would be greatly appreciated. I am trying to write a MATLAB code to solve the 1D Mobile-Immobile Model (MIM) for solute transport in porous media. My model includes both linear sorption (retardation) and first-order degradation.
The governing equations are:
Mobile Region:
Immobile Region:
Where:
and are the concentrations in the mobile and immobile regions.
and are retardation factors.
and are volumetric water contents.
and are first-order degradation rates.
is the mass transfer coefficient.
My Goal:
I want to implement a fully implicit finite difference scheme (Backward Euler in time, Central Difference for dispersion, and Upwind for advection) to ensure unconditional numerical stability.
My Issue:
I am comfortable assembling the sparse tridiagonal matrix for a standard Advection-Dispersion Equation (ADE). However, because the MIM equations are coupled, I am unsure of the best practice for assembling the coefficient matrix in MATLAB.
Specifically:
1. Should I decouple the equations by solving the immobile equation first at the current time step and substituting it into the mobile equation?
2. Or is it better to construct a larger block-diagonal sparse matrix to solve and simultaneously at ? If so, how should the indices be structured in MATLAB (`spdiags` or `sparse`) to represent this coupled system efficiently?
Any brief examples or structural advice on setting up the implicit matrix and right-hand side for this coupled system would be greatly appreciated. matlab, mobile-immobile model MATLAB Answers — New Questions
How do I install MathWorks Products in preparation for a MathWorks Private training event?
How do I install MathWorks Products in preparation for a MathWorks Private training event?How do I install MathWorks Products in preparation for a MathWorks Private training event? How do I install MathWorks Products in preparation for a MathWorks Private training event? MATLAB Answers — New Questions
How to print a line of text with multiple variables
Hello.
I am trying to print out a statement that says something like "The confidence interval for the gauge pressure measured at 10 psi is (9.5048 ± 1.5608) psi." using the values below.
%Initial Uncalibrated Meas.
p_analog_uncal = [20 40 60 80 100 120];
dV_avg_uncal = [1.246378 1.500449 1.763329 2.015415 2.292663 2.567350];
std_dev_uncal = [0.000867 0.000879 0.000885 0.000958 0.000938 0.000956 0.000908];
gain = 76.2710;
offset = 0.9812;
N = 10000;
%Calibrated Meas.
p_analog_cal = [10 30 50 70 90 110];
p_gage = [9.504823 30.232948 50.373663 70.164445 90.059363 109.971692];
std_dev_cal = [0.067066 0.069131 0.067868 0.068035 0.073534 0.071066];
%Calibration Unc
p_pred = (gain.*dV_avg_uncal) – (gain*offset);
p_residual = (p_pred – p_analog_uncal).^2;
s = sum(p_residual, "all");
sy = sqrt(s/4);
t =1.95996;
uc = t*sy;
%First Order Unc
u1 = std_dev_cal./(sqrt(N – 1));
%Overall Uncertainty
uo = sqrt((u1.^2) + (uc^2));
I have tried using:
fprintf(‘The confidence interval for the gauge pressure measured at %d psi is (%7.4f ± %5.4f) psi.n’, p_analog_cal, p_gage, uo)
but it spits out lines that look like this:
The confidence interval for the gauge pressure measured at 10 psi is (30.0000 ± 50.0000) psi.
The confidence interval for the gauge pressure measured at 70 psi is (90.0000 ± 110.0000) psi.
The confidence interval for the gauge pressure measured at 9.504823e+00 psi is (30.2329 ± 50.3737) psi.
How can I fix this so that each pressure corresponds with its confidence interval?Hello.
I am trying to print out a statement that says something like "The confidence interval for the gauge pressure measured at 10 psi is (9.5048 ± 1.5608) psi." using the values below.
%Initial Uncalibrated Meas.
p_analog_uncal = [20 40 60 80 100 120];
dV_avg_uncal = [1.246378 1.500449 1.763329 2.015415 2.292663 2.567350];
std_dev_uncal = [0.000867 0.000879 0.000885 0.000958 0.000938 0.000956 0.000908];
gain = 76.2710;
offset = 0.9812;
N = 10000;
%Calibrated Meas.
p_analog_cal = [10 30 50 70 90 110];
p_gage = [9.504823 30.232948 50.373663 70.164445 90.059363 109.971692];
std_dev_cal = [0.067066 0.069131 0.067868 0.068035 0.073534 0.071066];
%Calibration Unc
p_pred = (gain.*dV_avg_uncal) – (gain*offset);
p_residual = (p_pred – p_analog_uncal).^2;
s = sum(p_residual, "all");
sy = sqrt(s/4);
t =1.95996;
uc = t*sy;
%First Order Unc
u1 = std_dev_cal./(sqrt(N – 1));
%Overall Uncertainty
uo = sqrt((u1.^2) + (uc^2));
I have tried using:
fprintf(‘The confidence interval for the gauge pressure measured at %d psi is (%7.4f ± %5.4f) psi.n’, p_analog_cal, p_gage, uo)
but it spits out lines that look like this:
The confidence interval for the gauge pressure measured at 10 psi is (30.0000 ± 50.0000) psi.
The confidence interval for the gauge pressure measured at 70 psi is (90.0000 ± 110.0000) psi.
The confidence interval for the gauge pressure measured at 9.504823e+00 psi is (30.2329 ± 50.3737) psi.
How can I fix this so that each pressure corresponds with its confidence interval? Hello.
I am trying to print out a statement that says something like "The confidence interval for the gauge pressure measured at 10 psi is (9.5048 ± 1.5608) psi." using the values below.
%Initial Uncalibrated Meas.
p_analog_uncal = [20 40 60 80 100 120];
dV_avg_uncal = [1.246378 1.500449 1.763329 2.015415 2.292663 2.567350];
std_dev_uncal = [0.000867 0.000879 0.000885 0.000958 0.000938 0.000956 0.000908];
gain = 76.2710;
offset = 0.9812;
N = 10000;
%Calibrated Meas.
p_analog_cal = [10 30 50 70 90 110];
p_gage = [9.504823 30.232948 50.373663 70.164445 90.059363 109.971692];
std_dev_cal = [0.067066 0.069131 0.067868 0.068035 0.073534 0.071066];
%Calibration Unc
p_pred = (gain.*dV_avg_uncal) – (gain*offset);
p_residual = (p_pred – p_analog_uncal).^2;
s = sum(p_residual, "all");
sy = sqrt(s/4);
t =1.95996;
uc = t*sy;
%First Order Unc
u1 = std_dev_cal./(sqrt(N – 1));
%Overall Uncertainty
uo = sqrt((u1.^2) + (uc^2));
I have tried using:
fprintf(‘The confidence interval for the gauge pressure measured at %d psi is (%7.4f ± %5.4f) psi.n’, p_analog_cal, p_gage, uo)
but it spits out lines that look like this:
The confidence interval for the gauge pressure measured at 10 psi is (30.0000 ± 50.0000) psi.
The confidence interval for the gauge pressure measured at 70 psi is (90.0000 ± 110.0000) psi.
The confidence interval for the gauge pressure measured at 9.504823e+00 psi is (30.2329 ± 50.3737) psi.
How can I fix this so that each pressure corresponds with its confidence interval? fprinf, sprintf, %f, %d MATLAB Answers — New Questions
Find specified number of points on curve with identical chord length (not arc length)
Hello!
I have the user draw a line and obtain the points on that line:
% Load example image
I = imread(‘peppers.png’);
imshow(I)
% Draw line
roi = drawassisted(‘Closed’, false);
% Obtain positions of points
points_input = roi.Position;
% Number of target points
num_points_target = 10;
% Find these
points_output
I want to find a specified number of points (num_points_target) along the described curve, so that the chord length between the outputs points (points_output) would be identical. I am specifically looking for chord length, not arc length. I have seen this but it uses arc length ( https://uk.mathworks.com/matlabcentral/fileexchange/34874-interparc/files/interparc.m ).
I assume some interpolation – linear would likely be okay – would be in order as, depending on the drawing speed, the points_input might not be spaced very evenly.
Code would obviously be great but if someone felt like just explaining the mathematical approach to this, that would already be very helpful. At the moment, I think I would be able to cobble something dreadful with many loops together myself but it seems to me that there must be an elegant solution to this problem surely.Hello!
I have the user draw a line and obtain the points on that line:
% Load example image
I = imread(‘peppers.png’);
imshow(I)
% Draw line
roi = drawassisted(‘Closed’, false);
% Obtain positions of points
points_input = roi.Position;
% Number of target points
num_points_target = 10;
% Find these
points_output
I want to find a specified number of points (num_points_target) along the described curve, so that the chord length between the outputs points (points_output) would be identical. I am specifically looking for chord length, not arc length. I have seen this but it uses arc length ( https://uk.mathworks.com/matlabcentral/fileexchange/34874-interparc/files/interparc.m ).
I assume some interpolation – linear would likely be okay – would be in order as, depending on the drawing speed, the points_input might not be spaced very evenly.
Code would obviously be great but if someone felt like just explaining the mathematical approach to this, that would already be very helpful. At the moment, I think I would be able to cobble something dreadful with many loops together myself but it seems to me that there must be an elegant solution to this problem surely. Hello!
I have the user draw a line and obtain the points on that line:
% Load example image
I = imread(‘peppers.png’);
imshow(I)
% Draw line
roi = drawassisted(‘Closed’, false);
% Obtain positions of points
points_input = roi.Position;
% Number of target points
num_points_target = 10;
% Find these
points_output
I want to find a specified number of points (num_points_target) along the described curve, so that the chord length between the outputs points (points_output) would be identical. I am specifically looking for chord length, not arc length. I have seen this but it uses arc length ( https://uk.mathworks.com/matlabcentral/fileexchange/34874-interparc/files/interparc.m ).
I assume some interpolation – linear would likely be okay – would be in order as, depending on the drawing speed, the points_input might not be spaced very evenly.
Code would obviously be great but if someone felt like just explaining the mathematical approach to this, that would already be very helpful. At the moment, I think I would be able to cobble something dreadful with many loops together myself but it seems to me that there must be an elegant solution to this problem surely. chord length, even spacing MATLAB Answers — New Questions
6G toolbox installation R2021b
Can I install 6G toolbox in Matlab 2021?Can I install 6G toolbox in Matlab 2021? Can I install 6G toolbox in Matlab 2021? installation, 6g MATLAB Answers — New Questions
im implementing single switched active cel balancing but the soc of both cells are not equal, what is the error in the logic of this code? function [s1,s2,s3,s4] = fcn(SOC1,SO
im implementing single switched active cel balancing but the soc of both cells are not equal, what is the error in the logic of this code? function [s1,s2,s3,s4] = fcn(SOC1,SOC2,P1,P2)
if SOC2<SOC1
s1=P1;
s2=P1;
s3=P2;
s4=P2;
elseif SOC1<SOC2
s1=P1;
s2=P1;
s3=P2;
s4=P2;
else
s1=0;
s2=0;
s3=0;
s4=0;
end
endim implementing single switched active cel balancing but the soc of both cells are not equal, what is the error in the logic of this code? function [s1,s2,s3,s4] = fcn(SOC1,SOC2,P1,P2)
if SOC2<SOC1
s1=P1;
s2=P1;
s3=P2;
s4=P2;
elseif SOC1<SOC2
s1=P1;
s2=P1;
s3=P2;
s4=P2;
else
s1=0;
s2=0;
s3=0;
s4=0;
end
end im implementing single switched active cel balancing but the soc of both cells are not equal, what is the error in the logic of this code? function [s1,s2,s3,s4] = fcn(SOC1,SOC2,P1,P2)
if SOC2<SOC1
s1=P1;
s2=P1;
s3=P2;
s4=P2;
elseif SOC1<SOC2
s1=P1;
s2=P1;
s3=P2;
s4=P2;
else
s1=0;
s2=0;
s3=0;
s4=0;
end
end simulink MATLAB Answers — New Questions
Error using bvp4c: “Warning: Unable to meet the tolerance without using more than 5000 mesh points. The last mesh of 4921 points and the solution are available in the output argument.”
Hello,
I’m using bvp4c to solve for a reaction-diffusion equation. When I set the initial concentration to 100, I get this error saying
"Warning: Unable to meet the tolerance without using more than 5000 mesh points.
The last mesh of 4921 points and the solution are available in the output argument.
The maximum residual is 0.512336, while requested accuracy is 0.001.
> In bvp4c (line 323)
In steady_state_bvp4c_FINAL (line 38)
Warning: Imaginary parts of complex X and/or Y arguments ignored
> In steady_state_bvp4c_FINAL (line 44)
Warning: Imaginary parts of complex X and/or Y arguments ignored
> In steady_state_bvp4c_FINAL (line 50) "
Am I setting my boundary conditions incorrectly? I want the left hand side (at x = 0, C_L = C_L0) and on the right hand side I want the flux to equal to 0 (at x = x_f, dC_L/dx = 0).
function steady_state_bvp4c_FINAL
clear all; clc;
%Diffusion coefficient
D_ij = 30; %3.0*10^-7 cm^2/s -> 30 um^2/s
%Initial concentration at x=0
L0 = 100;
%Total length
x_f = 3500;
%Rate constants
k_1 = 0.00193;
k_2 = 0.00255;
k_3 = 4.09;
d_1 = 0.007;
d_2 = 3.95*10^-5;
d_3 = 2.26;
%Equilibrium constants
K_1 = 3.63;
K_2 = 0.0155;
K_3 = 0.553;
K_4 = 9.01;
K_i = 0.139;
%Total Receptors
N_T =1.7;
L = L0./2;
solinit = bvpinit(linspace(0,x_f,11),[L 0]);
sol = bvp4c(@(x,y)odefcn(x,y,D_ij,k_1,k_2,k_3,d_1,d_2,d_3,K_1,K_2,K_3,K_4,K_i,N_T),@twobc,solinit);
figure(1)
plot(sol.x,(sol.y(1,:)),’LineWidth’,1)
xlabel(‘Distance (mum)’)
ylabel(‘Concentration (nM)’)
axis([0 x_f 0 L0])
figure(2)
plot(sol.x,(sol.y(1,:))./L0,’LineWidth’,1)
xlabel(‘Distance (mum)’)
ylabel(‘Normalized Concentration (C_L/C_L_0)’)
axis([0 x_f 0 1])
function dy = odefcn(x,y,D_ij,k_1,k_2,k_3,d_1,d_2,d_3,K_1,K_2,K_3,K_4,K_i,N_T)
C_L = y(1);
dC_Ldx = y(2);
N_r = (-1 – (C_L./K_1) + sqrt((-1 – (C_L./K_1)).^2 -4.*(-(2./K_4) – ((2.*C_L)./(K_2.*K_4)) – ((2.*C_L)./(K_2.*K_4.*K_i)) – ((2.*C_L.^2)/(K_2.*K_3.*K_4.*K_i))).*N_T))/(4.*((1./K_4) + (C_L./(K_2.*K_4)) + (C_L./(K_2.*K_4.*K_i)) + (C_L.^2./(K_2.*K_3.*K_4.*K_i))));
N_R = (C_L./K_1).*N_r;
N_r2 = (1./K_4).*(N_r).^2;
N_rR = (C_L./(2.*K_2.*K_4)).*(N_r).^2;
N_pR = (C_L./(2.*K_2.*K_4.*K_i)).*(N_r).^2;
N_R2 = ((C_L.^2)./(K_2.*K_3.*K_4.*K_i)).*(N_r).^2;
r = N_T-(2.*N_R2)-(4.*N_pR)-N_R-(4.*N_rR)-(2.*N_r2);
R = N_T-(2.*N_R2)-(4.*N_pR)-N_r-(4.*N_rR)-(2.*N_r2);
r_2 = (N_T./2)-(N_R./2)-N_R2-(2.*N_pR)-(N_r./2)-(2.*N_rR);
rR = (N_T./4)-(N_R./4)-(N_R2./2)-N_pR-(N_r./4)-(N_r2./2);
pR = (N_T./4)-(N_R./4)-(N_R2./2)-(N_r./4)-N_rR-(N_r2./2);
R_2 = (N_T./2)-(N_R./2)-(2.*N_pR)-(N_r./2)-(2.*N_rR)-N_r2;
R_L = (2.*d_1.*(R))-(2.*k_1.*C_L.*r)+…
((2.*d_2.*(rR)))-((k_2.*C_L.*(r_2)))+…
(d_3.*(R_2))-(2.*k_3.*C_L.*(pR));
dy = zeros(2,1);
dy(1) = dC_Ldx;
dy(2) = (-R_L/D_ij);
end
function res = twobc(ya,yb)
res = [ ya(1)-(L0); yb(2) ];
end
endHello,
I’m using bvp4c to solve for a reaction-diffusion equation. When I set the initial concentration to 100, I get this error saying
"Warning: Unable to meet the tolerance without using more than 5000 mesh points.
The last mesh of 4921 points and the solution are available in the output argument.
The maximum residual is 0.512336, while requested accuracy is 0.001.
> In bvp4c (line 323)
In steady_state_bvp4c_FINAL (line 38)
Warning: Imaginary parts of complex X and/or Y arguments ignored
> In steady_state_bvp4c_FINAL (line 44)
Warning: Imaginary parts of complex X and/or Y arguments ignored
> In steady_state_bvp4c_FINAL (line 50) "
Am I setting my boundary conditions incorrectly? I want the left hand side (at x = 0, C_L = C_L0) and on the right hand side I want the flux to equal to 0 (at x = x_f, dC_L/dx = 0).
function steady_state_bvp4c_FINAL
clear all; clc;
%Diffusion coefficient
D_ij = 30; %3.0*10^-7 cm^2/s -> 30 um^2/s
%Initial concentration at x=0
L0 = 100;
%Total length
x_f = 3500;
%Rate constants
k_1 = 0.00193;
k_2 = 0.00255;
k_3 = 4.09;
d_1 = 0.007;
d_2 = 3.95*10^-5;
d_3 = 2.26;
%Equilibrium constants
K_1 = 3.63;
K_2 = 0.0155;
K_3 = 0.553;
K_4 = 9.01;
K_i = 0.139;
%Total Receptors
N_T =1.7;
L = L0./2;
solinit = bvpinit(linspace(0,x_f,11),[L 0]);
sol = bvp4c(@(x,y)odefcn(x,y,D_ij,k_1,k_2,k_3,d_1,d_2,d_3,K_1,K_2,K_3,K_4,K_i,N_T),@twobc,solinit);
figure(1)
plot(sol.x,(sol.y(1,:)),’LineWidth’,1)
xlabel(‘Distance (mum)’)
ylabel(‘Concentration (nM)’)
axis([0 x_f 0 L0])
figure(2)
plot(sol.x,(sol.y(1,:))./L0,’LineWidth’,1)
xlabel(‘Distance (mum)’)
ylabel(‘Normalized Concentration (C_L/C_L_0)’)
axis([0 x_f 0 1])
function dy = odefcn(x,y,D_ij,k_1,k_2,k_3,d_1,d_2,d_3,K_1,K_2,K_3,K_4,K_i,N_T)
C_L = y(1);
dC_Ldx = y(2);
N_r = (-1 – (C_L./K_1) + sqrt((-1 – (C_L./K_1)).^2 -4.*(-(2./K_4) – ((2.*C_L)./(K_2.*K_4)) – ((2.*C_L)./(K_2.*K_4.*K_i)) – ((2.*C_L.^2)/(K_2.*K_3.*K_4.*K_i))).*N_T))/(4.*((1./K_4) + (C_L./(K_2.*K_4)) + (C_L./(K_2.*K_4.*K_i)) + (C_L.^2./(K_2.*K_3.*K_4.*K_i))));
N_R = (C_L./K_1).*N_r;
N_r2 = (1./K_4).*(N_r).^2;
N_rR = (C_L./(2.*K_2.*K_4)).*(N_r).^2;
N_pR = (C_L./(2.*K_2.*K_4.*K_i)).*(N_r).^2;
N_R2 = ((C_L.^2)./(K_2.*K_3.*K_4.*K_i)).*(N_r).^2;
r = N_T-(2.*N_R2)-(4.*N_pR)-N_R-(4.*N_rR)-(2.*N_r2);
R = N_T-(2.*N_R2)-(4.*N_pR)-N_r-(4.*N_rR)-(2.*N_r2);
r_2 = (N_T./2)-(N_R./2)-N_R2-(2.*N_pR)-(N_r./2)-(2.*N_rR);
rR = (N_T./4)-(N_R./4)-(N_R2./2)-N_pR-(N_r./4)-(N_r2./2);
pR = (N_T./4)-(N_R./4)-(N_R2./2)-(N_r./4)-N_rR-(N_r2./2);
R_2 = (N_T./2)-(N_R./2)-(2.*N_pR)-(N_r./2)-(2.*N_rR)-N_r2;
R_L = (2.*d_1.*(R))-(2.*k_1.*C_L.*r)+…
((2.*d_2.*(rR)))-((k_2.*C_L.*(r_2)))+…
(d_3.*(R_2))-(2.*k_3.*C_L.*(pR));
dy = zeros(2,1);
dy(1) = dC_Ldx;
dy(2) = (-R_L/D_ij);
end
function res = twobc(ya,yb)
res = [ ya(1)-(L0); yb(2) ];
end
end Hello,
I’m using bvp4c to solve for a reaction-diffusion equation. When I set the initial concentration to 100, I get this error saying
"Warning: Unable to meet the tolerance without using more than 5000 mesh points.
The last mesh of 4921 points and the solution are available in the output argument.
The maximum residual is 0.512336, while requested accuracy is 0.001.
> In bvp4c (line 323)
In steady_state_bvp4c_FINAL (line 38)
Warning: Imaginary parts of complex X and/or Y arguments ignored
> In steady_state_bvp4c_FINAL (line 44)
Warning: Imaginary parts of complex X and/or Y arguments ignored
> In steady_state_bvp4c_FINAL (line 50) "
Am I setting my boundary conditions incorrectly? I want the left hand side (at x = 0, C_L = C_L0) and on the right hand side I want the flux to equal to 0 (at x = x_f, dC_L/dx = 0).
function steady_state_bvp4c_FINAL
clear all; clc;
%Diffusion coefficient
D_ij = 30; %3.0*10^-7 cm^2/s -> 30 um^2/s
%Initial concentration at x=0
L0 = 100;
%Total length
x_f = 3500;
%Rate constants
k_1 = 0.00193;
k_2 = 0.00255;
k_3 = 4.09;
d_1 = 0.007;
d_2 = 3.95*10^-5;
d_3 = 2.26;
%Equilibrium constants
K_1 = 3.63;
K_2 = 0.0155;
K_3 = 0.553;
K_4 = 9.01;
K_i = 0.139;
%Total Receptors
N_T =1.7;
L = L0./2;
solinit = bvpinit(linspace(0,x_f,11),[L 0]);
sol = bvp4c(@(x,y)odefcn(x,y,D_ij,k_1,k_2,k_3,d_1,d_2,d_3,K_1,K_2,K_3,K_4,K_i,N_T),@twobc,solinit);
figure(1)
plot(sol.x,(sol.y(1,:)),’LineWidth’,1)
xlabel(‘Distance (mum)’)
ylabel(‘Concentration (nM)’)
axis([0 x_f 0 L0])
figure(2)
plot(sol.x,(sol.y(1,:))./L0,’LineWidth’,1)
xlabel(‘Distance (mum)’)
ylabel(‘Normalized Concentration (C_L/C_L_0)’)
axis([0 x_f 0 1])
function dy = odefcn(x,y,D_ij,k_1,k_2,k_3,d_1,d_2,d_3,K_1,K_2,K_3,K_4,K_i,N_T)
C_L = y(1);
dC_Ldx = y(2);
N_r = (-1 – (C_L./K_1) + sqrt((-1 – (C_L./K_1)).^2 -4.*(-(2./K_4) – ((2.*C_L)./(K_2.*K_4)) – ((2.*C_L)./(K_2.*K_4.*K_i)) – ((2.*C_L.^2)/(K_2.*K_3.*K_4.*K_i))).*N_T))/(4.*((1./K_4) + (C_L./(K_2.*K_4)) + (C_L./(K_2.*K_4.*K_i)) + (C_L.^2./(K_2.*K_3.*K_4.*K_i))));
N_R = (C_L./K_1).*N_r;
N_r2 = (1./K_4).*(N_r).^2;
N_rR = (C_L./(2.*K_2.*K_4)).*(N_r).^2;
N_pR = (C_L./(2.*K_2.*K_4.*K_i)).*(N_r).^2;
N_R2 = ((C_L.^2)./(K_2.*K_3.*K_4.*K_i)).*(N_r).^2;
r = N_T-(2.*N_R2)-(4.*N_pR)-N_R-(4.*N_rR)-(2.*N_r2);
R = N_T-(2.*N_R2)-(4.*N_pR)-N_r-(4.*N_rR)-(2.*N_r2);
r_2 = (N_T./2)-(N_R./2)-N_R2-(2.*N_pR)-(N_r./2)-(2.*N_rR);
rR = (N_T./4)-(N_R./4)-(N_R2./2)-N_pR-(N_r./4)-(N_r2./2);
pR = (N_T./4)-(N_R./4)-(N_R2./2)-(N_r./4)-N_rR-(N_r2./2);
R_2 = (N_T./2)-(N_R./2)-(2.*N_pR)-(N_r./2)-(2.*N_rR)-N_r2;
R_L = (2.*d_1.*(R))-(2.*k_1.*C_L.*r)+…
((2.*d_2.*(rR)))-((k_2.*C_L.*(r_2)))+…
(d_3.*(R_2))-(2.*k_3.*C_L.*(pR));
dy = zeros(2,1);
dy(1) = dC_Ldx;
dy(2) = (-R_L/D_ij);
end
function res = twobc(ya,yb)
res = [ ya(1)-(L0); yb(2) ];
end
end bvp4c, tolerance, error MATLAB Answers — New Questions
The item “MATLAB_R2022a” can’t be moved to the Trash because it’s open.
I am trying to remove MATLAB from my MAC, as the macOSX for 2022a installer failed to finish but somehow created the icon on aplications. I want to delete it it and try installing it again. But when I go to aplications and try to move it to trash it says "The item “MATLAB_R2022a” can’t be moved to the Trash because it’s open."
I can delete the installer file but downloading and opening another installer won’t open the installation process.
Please help, what should I do?I am trying to remove MATLAB from my MAC, as the macOSX for 2022a installer failed to finish but somehow created the icon on aplications. I want to delete it it and try installing it again. But when I go to aplications and try to move it to trash it says "The item “MATLAB_R2022a” can’t be moved to the Trash because it’s open."
I can delete the installer file but downloading and opening another installer won’t open the installation process.
Please help, what should I do? I am trying to remove MATLAB from my MAC, as the macOSX for 2022a installer failed to finish but somehow created the icon on aplications. I want to delete it it and try installing it again. But when I go to aplications and try to move it to trash it says "The item “MATLAB_R2022a” can’t be moved to the Trash because it’s open."
I can delete the installer file but downloading and opening another installer won’t open the installation process.
Please help, what should I do? installation, matlab MATLAB Answers — New Questions
ePWM Trip-Zone Issue: PWM only switching when TZ1 pin is floating (C2000/Simulink)
I am experiencing a strange behavior with the Trip-Zone (TZ) submodule in the ePWM block while using a TI C2000 processor. I have configured a Cycle-by-Cycle (CBC) trip on TZ1 to force the PWM output to LOW. The PWM is configured in Center-Aligned mode (Up-Down count) with a fixed 20% Duty Cycle.
The Problem:
The PWM output does not behave as expected when the TZ1 pin is actively driven. Here are the three states I observed:
TZ1 pin tied to HIGH (3.3V): The ePWM output is stuck at a constant HIGH (1) level (no switching).
TZ1 pin tied to LOW (GND): The ePWM output is stuck at a constant LOW (0) level.
TZ1 pin left FLOATING: The PWM works perfectly, switching at the defined 20% Duty Cycle.
Configurations:
Action Qualifier (AQ): * CAU (Up-count): Clear
CAD (Down-count): Set
Trip-Zone (TZ):
CBC TZ1: Enabled.
ePWM1A forced (TZ) to: Low.
Duty Cycle: Fixed at 20% (verified CMPA/PRD ratio).
My Analysis & Questions:
It seems that when the pin is floating, the internal pull-up resistor keeps TZ1 high, and for some reason, the ePWM module only switches in this state.
Why does manually driving the pin HIGH (3.3V) freeze the output at HIGH instead of allowing normal switching?
Could there be a conflict between the Digital Compare (DC) events or a GPIO Mux misconfiguration that causes the Trip-Zone to interpret a "Hard High" differently than a "Pull-up High"?
Is it possible that the Action Qualifier is being overridden by the TZ submodule even when no trip condition is met?
I have attached my Simulink configuration screenshots for reference. Any insights on why the TZ1 pin state is "locking" the AQ logic would be greatly appreciated.I am experiencing a strange behavior with the Trip-Zone (TZ) submodule in the ePWM block while using a TI C2000 processor. I have configured a Cycle-by-Cycle (CBC) trip on TZ1 to force the PWM output to LOW. The PWM is configured in Center-Aligned mode (Up-Down count) with a fixed 20% Duty Cycle.
The Problem:
The PWM output does not behave as expected when the TZ1 pin is actively driven. Here are the three states I observed:
TZ1 pin tied to HIGH (3.3V): The ePWM output is stuck at a constant HIGH (1) level (no switching).
TZ1 pin tied to LOW (GND): The ePWM output is stuck at a constant LOW (0) level.
TZ1 pin left FLOATING: The PWM works perfectly, switching at the defined 20% Duty Cycle.
Configurations:
Action Qualifier (AQ): * CAU (Up-count): Clear
CAD (Down-count): Set
Trip-Zone (TZ):
CBC TZ1: Enabled.
ePWM1A forced (TZ) to: Low.
Duty Cycle: Fixed at 20% (verified CMPA/PRD ratio).
My Analysis & Questions:
It seems that when the pin is floating, the internal pull-up resistor keeps TZ1 high, and for some reason, the ePWM module only switches in this state.
Why does manually driving the pin HIGH (3.3V) freeze the output at HIGH instead of allowing normal switching?
Could there be a conflict between the Digital Compare (DC) events or a GPIO Mux misconfiguration that causes the Trip-Zone to interpret a "Hard High" differently than a "Pull-up High"?
Is it possible that the Action Qualifier is being overridden by the TZ submodule even when no trip condition is met?
I have attached my Simulink configuration screenshots for reference. Any insights on why the TZ1 pin state is "locking" the AQ logic would be greatly appreciated. I am experiencing a strange behavior with the Trip-Zone (TZ) submodule in the ePWM block while using a TI C2000 processor. I have configured a Cycle-by-Cycle (CBC) trip on TZ1 to force the PWM output to LOW. The PWM is configured in Center-Aligned mode (Up-Down count) with a fixed 20% Duty Cycle.
The Problem:
The PWM output does not behave as expected when the TZ1 pin is actively driven. Here are the three states I observed:
TZ1 pin tied to HIGH (3.3V): The ePWM output is stuck at a constant HIGH (1) level (no switching).
TZ1 pin tied to LOW (GND): The ePWM output is stuck at a constant LOW (0) level.
TZ1 pin left FLOATING: The PWM works perfectly, switching at the defined 20% Duty Cycle.
Configurations:
Action Qualifier (AQ): * CAU (Up-count): Clear
CAD (Down-count): Set
Trip-Zone (TZ):
CBC TZ1: Enabled.
ePWM1A forced (TZ) to: Low.
Duty Cycle: Fixed at 20% (verified CMPA/PRD ratio).
My Analysis & Questions:
It seems that when the pin is floating, the internal pull-up resistor keeps TZ1 high, and for some reason, the ePWM module only switches in this state.
Why does manually driving the pin HIGH (3.3V) freeze the output at HIGH instead of allowing normal switching?
Could there be a conflict between the Digital Compare (DC) events or a GPIO Mux misconfiguration that causes the Trip-Zone to interpret a "Hard High" differently than a "Pull-up High"?
Is it possible that the Action Qualifier is being overridden by the TZ submodule even when no trip condition is met?
I have attached my Simulink configuration screenshots for reference. Any insights on why the TZ1 pin state is "locking" the AQ logic would be greatly appreciated. trip – zone MATLAB Answers — New Questions
How can you make multi-line axis labels with TeX not left-justified in R2026a?
I just started using R2026a and encountered a problem with axis labels. In R2025b on a different computer, I don’t have this problem. Multi-line labels that have TeX in them render left justified, .e.g.
xlabel( sprintf( ‘normaln\bfbold’ ) )
whereas those with no TeX render centered as expected
ylabel( sprintf( ‘normalnbold’ ) )
Setting the ‘HorizontalAlignment’ property of the label to ‘center’ after the fact, as suggested by a web search does not fix the problem. I get the same behavior creating a text object with text() as opposed to xlabel(), and can’t think of a workaround other than creating a separate text object for each line, which would make be abandon R2026a for the time being. Has anyone solved this?I just started using R2026a and encountered a problem with axis labels. In R2025b on a different computer, I don’t have this problem. Multi-line labels that have TeX in them render left justified, .e.g.
xlabel( sprintf( ‘normaln\bfbold’ ) )
whereas those with no TeX render centered as expected
ylabel( sprintf( ‘normalnbold’ ) )
Setting the ‘HorizontalAlignment’ property of the label to ‘center’ after the fact, as suggested by a web search does not fix the problem. I get the same behavior creating a text object with text() as opposed to xlabel(), and can’t think of a workaround other than creating a separate text object for each line, which would make be abandon R2026a for the time being. Has anyone solved this? I just started using R2026a and encountered a problem with axis labels. In R2025b on a different computer, I don’t have this problem. Multi-line labels that have TeX in them render left justified, .e.g.
xlabel( sprintf( ‘normaln\bfbold’ ) )
whereas those with no TeX render centered as expected
ylabel( sprintf( ‘normalnbold’ ) )
Setting the ‘HorizontalAlignment’ property of the label to ‘center’ after the fact, as suggested by a web search does not fix the problem. I get the same behavior creating a text object with text() as opposed to xlabel(), and can’t think of a workaround other than creating a separate text object for each line, which would make be abandon R2026a for the time being. Has anyone solved this? tex, horizonalalignment MATLAB Answers — New Questions









