Tag Archives: matlab
I keep installing the Matlab MIN GW 5.3 compiler for Matlab 2017b, but it is showing as uninstalled. HELP
SystemRequirements-Release2017b_SupportedCompilers.pdf (mathworks.com)
This compiler.
An installed compiler was not detected. Certain simulation modes, as well as host-based coder builds require that a compiler be installed. Please install one of the supported compilers for this release as listed at:
I have installed this 3 times now and keep running into this error when creating an sfunction.
Please HELP.SystemRequirements-Release2017b_SupportedCompilers.pdf (mathworks.com)
This compiler.
An installed compiler was not detected. Certain simulation modes, as well as host-based coder builds require that a compiler be installed. Please install one of the supported compilers for this release as listed at:
I have installed this 3 times now and keep running into this error when creating an sfunction.
Please HELP. SystemRequirements-Release2017b_SupportedCompilers.pdf (mathworks.com)
This compiler.
An installed compiler was not detected. Certain simulation modes, as well as host-based coder builds require that a compiler be installed. Please install one of the supported compilers for this release as listed at:
I have installed this 3 times now and keep running into this error when creating an sfunction.
Please HELP. mingw compiler uninstalling MATLAB Answers — New Questions
Wondering if my spline is any good
Honestly, I just want to know what people think of some data fitting I’ve been doing. Simply given two sets of points (xc,thiscp) and (xc1,thiscp1), I’ve managed to come up with the following piece of code:
xclip = xc(~isnan(xc));
[vals Iclip]=unique(xclip,’first’);
%
xcnew = unique(xclip);
cs = pchip(xcnew,thiscp(Iclip));
for n = 1:length(cs.coefs(:,1))
fun = @(x) cs.coefs(n,1)*(x-cs.breaks(n)).^3+cs.coefs(n,2)*(x-cs.breaks(n)).^2+cs.coefs(n,3)*(x-cs.breaks(n))+cs.coefs(n,4);
int = integral(fun,cs.breaks(n),cs.breaks(n+1));
int2(n)=int;
end
xclip1 = xc1(~isnan(xc1));
[vals Iclip1]=unique(xclip1,’first’);
xcnew1 = unique(xclip1);
cs2 = pchip(xcnew1,thiscp1(Iclip1));
for n = 1:length(cs2.coefs(:,1))
fun1 = @(x) cs2.coefs(n,1)*(x-cs2.breaks(n)).^3+cs2.coefs(n,2)*(x-cs2.breaks(n)).^2+cs2.coefs(n,3)*(x-cs2.breaks(n))+cs2.coefs(n,4);
int1 = integral(fun1,cs2.breaks(n),cs2.breaks(n+1));
int3(n)=int1;
end
intall = abs(sum(int2,’all’)-sum(int3,’all’))
This is one of the several methods I’ve devised to evaluate the area between two curves drawn by each set of data points. Currently, I am experiencing some inconsistencies when my data points are greatly vertically spaced – I am wondering if there is any way to remedy this. I am also curious as to how accurate this method is, and need some more experienced minds to comment. Thanks!Honestly, I just want to know what people think of some data fitting I’ve been doing. Simply given two sets of points (xc,thiscp) and (xc1,thiscp1), I’ve managed to come up with the following piece of code:
xclip = xc(~isnan(xc));
[vals Iclip]=unique(xclip,’first’);
%
xcnew = unique(xclip);
cs = pchip(xcnew,thiscp(Iclip));
for n = 1:length(cs.coefs(:,1))
fun = @(x) cs.coefs(n,1)*(x-cs.breaks(n)).^3+cs.coefs(n,2)*(x-cs.breaks(n)).^2+cs.coefs(n,3)*(x-cs.breaks(n))+cs.coefs(n,4);
int = integral(fun,cs.breaks(n),cs.breaks(n+1));
int2(n)=int;
end
xclip1 = xc1(~isnan(xc1));
[vals Iclip1]=unique(xclip1,’first’);
xcnew1 = unique(xclip1);
cs2 = pchip(xcnew1,thiscp1(Iclip1));
for n = 1:length(cs2.coefs(:,1))
fun1 = @(x) cs2.coefs(n,1)*(x-cs2.breaks(n)).^3+cs2.coefs(n,2)*(x-cs2.breaks(n)).^2+cs2.coefs(n,3)*(x-cs2.breaks(n))+cs2.coefs(n,4);
int1 = integral(fun1,cs2.breaks(n),cs2.breaks(n+1));
int3(n)=int1;
end
intall = abs(sum(int2,’all’)-sum(int3,’all’))
This is one of the several methods I’ve devised to evaluate the area between two curves drawn by each set of data points. Currently, I am experiencing some inconsistencies when my data points are greatly vertically spaced – I am wondering if there is any way to remedy this. I am also curious as to how accurate this method is, and need some more experienced minds to comment. Thanks! Honestly, I just want to know what people think of some data fitting I’ve been doing. Simply given two sets of points (xc,thiscp) and (xc1,thiscp1), I’ve managed to come up with the following piece of code:
xclip = xc(~isnan(xc));
[vals Iclip]=unique(xclip,’first’);
%
xcnew = unique(xclip);
cs = pchip(xcnew,thiscp(Iclip));
for n = 1:length(cs.coefs(:,1))
fun = @(x) cs.coefs(n,1)*(x-cs.breaks(n)).^3+cs.coefs(n,2)*(x-cs.breaks(n)).^2+cs.coefs(n,3)*(x-cs.breaks(n))+cs.coefs(n,4);
int = integral(fun,cs.breaks(n),cs.breaks(n+1));
int2(n)=int;
end
xclip1 = xc1(~isnan(xc1));
[vals Iclip1]=unique(xclip1,’first’);
xcnew1 = unique(xclip1);
cs2 = pchip(xcnew1,thiscp1(Iclip1));
for n = 1:length(cs2.coefs(:,1))
fun1 = @(x) cs2.coefs(n,1)*(x-cs2.breaks(n)).^3+cs2.coefs(n,2)*(x-cs2.breaks(n)).^2+cs2.coefs(n,3)*(x-cs2.breaks(n))+cs2.coefs(n,4);
int1 = integral(fun1,cs2.breaks(n),cs2.breaks(n+1));
int3(n)=int1;
end
intall = abs(sum(int2,’all’)-sum(int3,’all’))
This is one of the several methods I’ve devised to evaluate the area between two curves drawn by each set of data points. Currently, I am experiencing some inconsistencies when my data points are greatly vertically spaced – I am wondering if there is any way to remedy this. I am also curious as to how accurate this method is, and need some more experienced minds to comment. Thanks! spline, interpolation, raw data, aerospace MATLAB Answers — New Questions
Problem involving drug delivery and ODE
I am trying to model drug delivery over time using ODE45 to simultaneously solve three differential equations, and it is giving me an exponential decay function, which is what I want. However, I am now trying to model extra doses being applied to the system. For example, I want to increase the concentration of the drug by a set amount at a certain time interval while having the exponential decay still apply. Basically, I want it to look like this:
<<http://www.boomer.org/c/p4/c14/Fig2546.gif>>
What can I do to accomplish this?I am trying to model drug delivery over time using ODE45 to simultaneously solve three differential equations, and it is giving me an exponential decay function, which is what I want. However, I am now trying to model extra doses being applied to the system. For example, I want to increase the concentration of the drug by a set amount at a certain time interval while having the exponential decay still apply. Basically, I want it to look like this:
<<http://www.boomer.org/c/p4/c14/Fig2546.gif>>
What can I do to accomplish this? I am trying to model drug delivery over time using ODE45 to simultaneously solve three differential equations, and it is giving me an exponential decay function, which is what I want. However, I am now trying to model extra doses being applied to the system. For example, I want to increase the concentration of the drug by a set amount at a certain time interval while having the exponential decay still apply. Basically, I want it to look like this:
<<http://www.boomer.org/c/p4/c14/Fig2546.gif>>
What can I do to accomplish this? ode45 MATLAB Answers — New Questions
Are there any alternatives to try/catch statements that are supported by code generation?
I am trying to prepare an application (prepared in App Designer and connected to a Simulink model) to be packaged as a standalone executable.
My Simulink model is fairly simple: using Interpreted MATLAB function blocks as input and output to an s-function block (which is connected to a much larger and complicated external model).
In order to create a standalone executable for an application connected to a Simulink model, I found that I have to use Simulink Compiler, which does not support Interpreted MATLAB functions, so I am trying to convert their functionality to MATLAB function blocks.
As it turns out, MATLAB function blocks are further subject to code generation limitations, which exclude try/catch statements. These try/catch statements are primarily used to catch and pass error code or correct user input with instructions, which is a core functionality of deploying a proprietary application in industry.
Therefore, I was wondering if there are any alternatives to try/catch statements that are supported by code generation? I could not find any simple fix in the documentation. Are there any options besides coding in more input validation?
Thanks!I am trying to prepare an application (prepared in App Designer and connected to a Simulink model) to be packaged as a standalone executable.
My Simulink model is fairly simple: using Interpreted MATLAB function blocks as input and output to an s-function block (which is connected to a much larger and complicated external model).
In order to create a standalone executable for an application connected to a Simulink model, I found that I have to use Simulink Compiler, which does not support Interpreted MATLAB functions, so I am trying to convert their functionality to MATLAB function blocks.
As it turns out, MATLAB function blocks are further subject to code generation limitations, which exclude try/catch statements. These try/catch statements are primarily used to catch and pass error code or correct user input with instructions, which is a core functionality of deploying a proprietary application in industry.
Therefore, I was wondering if there are any alternatives to try/catch statements that are supported by code generation? I could not find any simple fix in the documentation. Are there any options besides coding in more input validation?
Thanks! I am trying to prepare an application (prepared in App Designer and connected to a Simulink model) to be packaged as a standalone executable.
My Simulink model is fairly simple: using Interpreted MATLAB function blocks as input and output to an s-function block (which is connected to a much larger and complicated external model).
In order to create a standalone executable for an application connected to a Simulink model, I found that I have to use Simulink Compiler, which does not support Interpreted MATLAB functions, so I am trying to convert their functionality to MATLAB function blocks.
As it turns out, MATLAB function blocks are further subject to code generation limitations, which exclude try/catch statements. These try/catch statements are primarily used to catch and pass error code or correct user input with instructions, which is a core functionality of deploying a proprietary application in industry.
Therefore, I was wondering if there are any alternatives to try/catch statements that are supported by code generation? I could not find any simple fix in the documentation. Are there any options besides coding in more input validation?
Thanks! code generation, simulink, simulink compiler MATLAB Answers — New Questions
cannot find matlab function wizard add-in in excel
I am not able to find the matlab function wizard excel add in on my C drive. I have followed the directions in the link below but still no luck:
http://www.mathworks.com/help/releases/R2016a/compiler/excel/executing-functions-and-creating-macros-using-the-function-wizard.html
I am stuck on this step:
6. Browse to matlabroot/toolbox/matlabxl/matlabxl/arch, and select FunctionWizard2007.xlam. Click OK
When the browse window pops up I enter C:UsersusernameAppDataRoamingMicrosoftAddInsmatlabroot/toolbox/matlabxl/matlabxl/arch but get nothing…
Can someone help?
ThanksI am not able to find the matlab function wizard excel add in on my C drive. I have followed the directions in the link below but still no luck:
http://www.mathworks.com/help/releases/R2016a/compiler/excel/executing-functions-and-creating-macros-using-the-function-wizard.html
I am stuck on this step:
6. Browse to matlabroot/toolbox/matlabxl/matlabxl/arch, and select FunctionWizard2007.xlam. Click OK
When the browse window pops up I enter C:UsersusernameAppDataRoamingMicrosoftAddInsmatlabroot/toolbox/matlabxl/matlabxl/arch but get nothing…
Can someone help?
Thanks I am not able to find the matlab function wizard excel add in on my C drive. I have followed the directions in the link below but still no luck:
http://www.mathworks.com/help/releases/R2016a/compiler/excel/executing-functions-and-creating-macros-using-the-function-wizard.html
I am stuck on this step:
6. Browse to matlabroot/toolbox/matlabxl/matlabxl/arch, and select FunctionWizard2007.xlam. Click OK
When the browse window pops up I enter C:UsersusernameAppDataRoamingMicrosoftAddInsmatlabroot/toolbox/matlabxl/matlabxl/arch but get nothing…
Can someone help?
Thanks excel, add in, add-in, function wizard MATLAB Answers — New Questions
Running 2 commands at same time
I am working on a data acquisition program. Within that program, i need the following functionality:
1- start recording data on a raspberry pi
2- send a command that triggers an output voltage from the pi, some time after starting recording (say 0.25 sec).
I spoke with a matlab engineer who was totally unfamiliar with what I wanted to do. I don’t really care about the order. If issuing a command first that tells the pi to generate a trigger signal is easier that is easy to adjust the delay time, but the actual trigger has to start after the data collection starts. I’m not really running 2 scripts just 2 commands and I’d like them to be able to run non-sequentially, or parallel.
I don’t really even know enough to ask Mathworks the right question. Any guideance would be helpful.I am working on a data acquisition program. Within that program, i need the following functionality:
1- start recording data on a raspberry pi
2- send a command that triggers an output voltage from the pi, some time after starting recording (say 0.25 sec).
I spoke with a matlab engineer who was totally unfamiliar with what I wanted to do. I don’t really care about the order. If issuing a command first that tells the pi to generate a trigger signal is easier that is easy to adjust the delay time, but the actual trigger has to start after the data collection starts. I’m not really running 2 scripts just 2 commands and I’d like them to be able to run non-sequentially, or parallel.
I don’t really even know enough to ask Mathworks the right question. Any guideance would be helpful. I am working on a data acquisition program. Within that program, i need the following functionality:
1- start recording data on a raspberry pi
2- send a command that triggers an output voltage from the pi, some time after starting recording (say 0.25 sec).
I spoke with a matlab engineer who was totally unfamiliar with what I wanted to do. I don’t really care about the order. If issuing a command first that tells the pi to generate a trigger signal is easier that is easy to adjust the delay time, but the actual trigger has to start after the data collection starts. I’m not really running 2 scripts just 2 commands and I’d like them to be able to run non-sequentially, or parallel.
I don’t really even know enough to ask Mathworks the right question. Any guideance would be helpful. 2 commands, parallel computing MATLAB Answers — New Questions
Last color on legend does not match last color on stem plot, after manually setting color in for loops.
This code generates stem plots for functions of number sequences. The last two plots require for loops to shift the sequences. The plot colors are hard coded in each loop to keep the same color. This works for the plots, but the legend shows the last two funcitons as both green when the last one should be purple. What might be causing this and is there a work-around?
x = [0,1,2,3,4,-4,-3,-2,-1,0];
y = [0,0,-1,0,1,0,-1,0,1,0,0];
longest_sequence = max(numel(x),numel(y));
figure(1)
hold on
stem(x,’LineWidth’,2.0)
stem(5*x,’LineWidth’,2.0)
stem(y,’LineWidth’,2.0)
for n = 2:9
stem(n-1,y(n+1),’LineWidth’,2.0, ‘Color’,’#77AC30′)
end
for n = 2:9
stem(n-1,-2*x(n-1)+3*y(n+2),’LineWidth’,2.0,’Color’,’#7E2F8E’)
end
hold off
title(‘Problem 1’)
xlim([0 longest_sequence+1])
xticks(0:1:11)
yticks(-20:1:20)
xlabel(‘Time’)
ylabel(‘Amplitude’)
set(gca,’FontWeight’,’bold’)
legend(‘x’,’5x’,’y’,’y(n+1)’,’-2x(n-1)+3y(n+2)’)This code generates stem plots for functions of number sequences. The last two plots require for loops to shift the sequences. The plot colors are hard coded in each loop to keep the same color. This works for the plots, but the legend shows the last two funcitons as both green when the last one should be purple. What might be causing this and is there a work-around?
x = [0,1,2,3,4,-4,-3,-2,-1,0];
y = [0,0,-1,0,1,0,-1,0,1,0,0];
longest_sequence = max(numel(x),numel(y));
figure(1)
hold on
stem(x,’LineWidth’,2.0)
stem(5*x,’LineWidth’,2.0)
stem(y,’LineWidth’,2.0)
for n = 2:9
stem(n-1,y(n+1),’LineWidth’,2.0, ‘Color’,’#77AC30′)
end
for n = 2:9
stem(n-1,-2*x(n-1)+3*y(n+2),’LineWidth’,2.0,’Color’,’#7E2F8E’)
end
hold off
title(‘Problem 1’)
xlim([0 longest_sequence+1])
xticks(0:1:11)
yticks(-20:1:20)
xlabel(‘Time’)
ylabel(‘Amplitude’)
set(gca,’FontWeight’,’bold’)
legend(‘x’,’5x’,’y’,’y(n+1)’,’-2x(n-1)+3y(n+2)’) This code generates stem plots for functions of number sequences. The last two plots require for loops to shift the sequences. The plot colors are hard coded in each loop to keep the same color. This works for the plots, but the legend shows the last two funcitons as both green when the last one should be purple. What might be causing this and is there a work-around?
x = [0,1,2,3,4,-4,-3,-2,-1,0];
y = [0,0,-1,0,1,0,-1,0,1,0,0];
longest_sequence = max(numel(x),numel(y));
figure(1)
hold on
stem(x,’LineWidth’,2.0)
stem(5*x,’LineWidth’,2.0)
stem(y,’LineWidth’,2.0)
for n = 2:9
stem(n-1,y(n+1),’LineWidth’,2.0, ‘Color’,’#77AC30′)
end
for n = 2:9
stem(n-1,-2*x(n-1)+3*y(n+2),’LineWidth’,2.0,’Color’,’#7E2F8E’)
end
hold off
title(‘Problem 1’)
xlim([0 longest_sequence+1])
xticks(0:1:11)
yticks(-20:1:20)
xlabel(‘Time’)
ylabel(‘Amplitude’)
set(gca,’FontWeight’,’bold’)
legend(‘x’,’5x’,’y’,’y(n+1)’,’-2x(n-1)+3y(n+2)’) color, legend, for loop MATLAB Answers — New Questions
How do i check for empty cells within a list
How do i check for empty cells within list? I have a list of cells, namelist, and it has 12 values, i need to check if some of the cells are empty. ThanksHow do i check for empty cells within list? I have a list of cells, namelist, and it has 12 values, i need to check if some of the cells are empty. Thanks How do i check for empty cells within list? I have a list of cells, namelist, and it has 12 values, i need to check if some of the cells are empty. Thanks empty, cell MATLAB Answers — New Questions
How to find the position of a number in an array?
If I have a vector, a = [7 8 8 2 5 6], how do I compute the positions of the value 8?
I expect 2 and 3 or (1,2) and (1,3).If I have a vector, a = [7 8 8 2 5 6], how do I compute the positions of the value 8?
I expect 2 and 3 or (1,2) and (1,3). If I have a vector, a = [7 8 8 2 5 6], how do I compute the positions of the value 8?
I expect 2 and 3 or (1,2) and (1,3). array MATLAB Answers — New Questions
Taking the last value of a matrix or vector
Hi. How can I take a last term of a vector – since my vector dimensions change -, and plug it in somewhere else in my code without keep changing the code?
for example right now I do v(6) to get the 6th term. How can I do it for nth term…. ThanksHi. How can I take a last term of a vector – since my vector dimensions change -, and plug it in somewhere else in my code without keep changing the code?
for example right now I do v(6) to get the 6th term. How can I do it for nth term…. Thanks Hi. How can I take a last term of a vector – since my vector dimensions change -, and plug it in somewhere else in my code without keep changing the code?
for example right now I do v(6) to get the 6th term. How can I do it for nth term…. Thanks last term of a vector with n rows MATLAB Answers — New Questions
How to extract columns of a matrix into seperate vectors?
Hallo,
Let’s assume a matrix (100×3). I want to extract out each of the columns, and store them in 3 separate vectors.
The code for the loop is clear, but what’s the right code for storing each column?
—————————-
for i = 1 : 3
vector = matrix(:, i);
end
—————————-
I guess it’s probably simple, but I am still a beginner and couldn’t find much useful information in the documentation so far.
Thank you.
DominikHallo,
Let’s assume a matrix (100×3). I want to extract out each of the columns, and store them in 3 separate vectors.
The code for the loop is clear, but what’s the right code for storing each column?
—————————-
for i = 1 : 3
vector = matrix(:, i);
end
—————————-
I guess it’s probably simple, but I am still a beginner and couldn’t find much useful information in the documentation so far.
Thank you.
Dominik Hallo,
Let’s assume a matrix (100×3). I want to extract out each of the columns, and store them in 3 separate vectors.
The code for the loop is clear, but what’s the right code for storing each column?
—————————-
for i = 1 : 3
vector = matrix(:, i);
end
—————————-
I guess it’s probably simple, but I am still a beginner and couldn’t find much useful information in the documentation so far.
Thank you.
Dominik matrix, column, separate, bad idea MATLAB Answers — New Questions
Error Using MATLAB Data API with C Matrix API is not supported (UE4 visualization)
I’m trying to use Matlab and UE4 together. I strictly follow this tutorial, however, in step 6 I get a compilation error
fatal error C1189: #error: Using MATLAB Data API with C Matrix API is not supported.
that points to the MDArray.hpp file. Please tell me how I can fix this.
(Matlab R2022b, UE4.26, Visual Studio 2019)I’m trying to use Matlab and UE4 together. I strictly follow this tutorial, however, in step 6 I get a compilation error
fatal error C1189: #error: Using MATLAB Data API with C Matrix API is not supported.
that points to the MDArray.hpp file. Please tell me how I can fix this.
(Matlab R2022b, UE4.26, Visual Studio 2019) I’m trying to use Matlab and UE4 together. I strictly follow this tutorial, however, in step 6 I get a compilation error
fatal error C1189: #error: Using MATLAB Data API with C Matrix API is not supported.
that points to the MDArray.hpp file. Please tell me how I can fix this.
(Matlab R2022b, UE4.26, Visual Studio 2019) aerospace blockset, unreal engine MATLAB Answers — New Questions
How to handle multiple devices with an external trigger signal in NI-PXI platform?
I have a NI-PXI chassis(model: 1042Q) and multiple data aquisition devices(PXI-4496) for multi-channel signal acquisition and processing.
With an external digital trigger, how can I connect the trigger signal and make a matlab program. Please let me know the useful code to deal with multiple devices with an external trigger signal in a PXI chassis.I have a NI-PXI chassis(model: 1042Q) and multiple data aquisition devices(PXI-4496) for multi-channel signal acquisition and processing.
With an external digital trigger, how can I connect the trigger signal and make a matlab program. Please let me know the useful code to deal with multiple devices with an external trigger signal in a PXI chassis. I have a NI-PXI chassis(model: 1042Q) and multiple data aquisition devices(PXI-4496) for multi-channel signal acquisition and processing.
With an external digital trigger, how can I connect the trigger signal and make a matlab program. Please let me know the useful code to deal with multiple devices with an external trigger signal in a PXI chassis. ni-pxi, 4496, external trigger MATLAB Answers — New Questions
How do I add Speedgoat target event listeners and callbacks to an SLRT App?
I would like to trigger actions in my App Designer app based on Speedgoat target events, for example, when the target is connected, or the real-time application is loaded, started, stopped, etc.
How do I accomplish this for my Simulink Real-Time (SLRT) App?I would like to trigger actions in my App Designer app based on Speedgoat target events, for example, when the target is connected, or the real-time application is loaded, started, stopped, etc.
How do I accomplish this for my Simulink Real-Time (SLRT) App? I would like to trigger actions in my App Designer app based on Speedgoat target events, for example, when the target is connected, or the real-time application is loaded, started, stopped, etc.
How do I accomplish this for my Simulink Real-Time (SLRT) App? slrt, app, event.listener, listener, addlistener, events MATLAB Answers — New Questions
Not getting a full image from raw data
I am trying to make an Xray image using x, y, and z coordinates of raw data. Here is what I have:
data = readmatrix(‘Chest_XRay_Raw_Data.txt’);
% Extract x, y, z coordinates and grayscale values
x = data(:,1);
y = data(:,2);
z = data(:,3); % If needed, otherwise ignore
grayscale = data(:,4);
%Find bounds
x_range = min(x):max(x);
y_range = min(y):max(y);
% Initialize the image matrix
image = zeros(length(y_range), length(x_range));
% Populate the image matrix with grayscale values
for i = 1:length(x)
x_idx = find(x_range == x(i));
y_idx = find(y_range == y(i));
image(y_idx, x_idx) = grayscale(i);
end
%normalize image
image = mat2gray(image);
% Display the image
imshow(image);
title(‘Reconstructed Image from Raw Data’);
Raw data example:
+4.23789300E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23619400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23449400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23279500E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23109600E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22939700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22769700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22599800E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22429900E+002, +0.00000000E+000, +0.00000000E+000, +420
An image window pops up with only one solid line with a little blank space in the middle. Any suggestions to fix this?I am trying to make an Xray image using x, y, and z coordinates of raw data. Here is what I have:
data = readmatrix(‘Chest_XRay_Raw_Data.txt’);
% Extract x, y, z coordinates and grayscale values
x = data(:,1);
y = data(:,2);
z = data(:,3); % If needed, otherwise ignore
grayscale = data(:,4);
%Find bounds
x_range = min(x):max(x);
y_range = min(y):max(y);
% Initialize the image matrix
image = zeros(length(y_range), length(x_range));
% Populate the image matrix with grayscale values
for i = 1:length(x)
x_idx = find(x_range == x(i));
y_idx = find(y_range == y(i));
image(y_idx, x_idx) = grayscale(i);
end
%normalize image
image = mat2gray(image);
% Display the image
imshow(image);
title(‘Reconstructed Image from Raw Data’);
Raw data example:
+4.23789300E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23619400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23449400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23279500E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23109600E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22939700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22769700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22599800E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22429900E+002, +0.00000000E+000, +0.00000000E+000, +420
An image window pops up with only one solid line with a little blank space in the middle. Any suggestions to fix this? I am trying to make an Xray image using x, y, and z coordinates of raw data. Here is what I have:
data = readmatrix(‘Chest_XRay_Raw_Data.txt’);
% Extract x, y, z coordinates and grayscale values
x = data(:,1);
y = data(:,2);
z = data(:,3); % If needed, otherwise ignore
grayscale = data(:,4);
%Find bounds
x_range = min(x):max(x);
y_range = min(y):max(y);
% Initialize the image matrix
image = zeros(length(y_range), length(x_range));
% Populate the image matrix with grayscale values
for i = 1:length(x)
x_idx = find(x_range == x(i));
y_idx = find(y_range == y(i));
image(y_idx, x_idx) = grayscale(i);
end
%normalize image
image = mat2gray(image);
% Display the image
imshow(image);
title(‘Reconstructed Image from Raw Data’);
Raw data example:
+4.23789300E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23619400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23449400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23279500E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23109600E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22939700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22769700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22599800E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22429900E+002, +0.00000000E+000, +0.00000000E+000, +420
An image window pops up with only one solid line with a little blank space in the middle. Any suggestions to fix this? grayscale, xray, image MATLAB Answers — New Questions
Processing and identifying noises in EEG signal
I’m working on a final project of processing the EEG signal from a 24-day-old infant. The data file is in .edf format, and I’ve extracted and plotted it as a time series. You can find the data file here: https://file.io/3fWPetZYclsH.
The project’s requirements are:
Analyze the data to identify signal and noises.
Design filters to eliminate the DC component, Electricity noise, and others (if contaminated).
My first approach was to use the power spectral density (PSD), but this idea was rejected as my professor wanted us to use more fundamental algorithms like DFT of Hibert-Huang Transform (HHT). Another problem with my prior work was that my filtered data lost all of the data after a a specific frequency, which my professor attributed to using a ‘second-order’ filter. Below is my attempt on creating the filters. The two tasks i need help is:
Use DFT and/or HHT to identify signal and noises. It is strictly required to identify where the noises are.
Designing filters that effectively eliminate noise without losing essential data points.
I’d appreciate any guidance from anyone. Thank you in advance for your assistance!
def highpass_filter(data, sfreq, cutoff=0.5):
nyquist = 0.5 * sfreq
normal_cutoff = cutoff / nyquist
b, a = butter(1, normal_cutoff, btype=’high’, analog=False)
return filtfilt(b, a, data)
def notch_filter(data, sfreq, freq=50.0, quality=30.0):
nyquist = 0.5 * sfreq
notch_freq = freq / nyquist
b, a = iirnotch(notch_freq, quality)
return filtfilt(b, a, data)
def bandpass_filter(data, sfreq, lowcut=0.5, highcut=8.0):
nyquist = 0.5 * sfreq
low = lowcut / nyquist
high = highcut / nyquist
b, a = butter(1, [low, high], btype=’band’)
return filtfilt(b, a, data)I’m working on a final project of processing the EEG signal from a 24-day-old infant. The data file is in .edf format, and I’ve extracted and plotted it as a time series. You can find the data file here: https://file.io/3fWPetZYclsH.
The project’s requirements are:
Analyze the data to identify signal and noises.
Design filters to eliminate the DC component, Electricity noise, and others (if contaminated).
My first approach was to use the power spectral density (PSD), but this idea was rejected as my professor wanted us to use more fundamental algorithms like DFT of Hibert-Huang Transform (HHT). Another problem with my prior work was that my filtered data lost all of the data after a a specific frequency, which my professor attributed to using a ‘second-order’ filter. Below is my attempt on creating the filters. The two tasks i need help is:
Use DFT and/or HHT to identify signal and noises. It is strictly required to identify where the noises are.
Designing filters that effectively eliminate noise without losing essential data points.
I’d appreciate any guidance from anyone. Thank you in advance for your assistance!
def highpass_filter(data, sfreq, cutoff=0.5):
nyquist = 0.5 * sfreq
normal_cutoff = cutoff / nyquist
b, a = butter(1, normal_cutoff, btype=’high’, analog=False)
return filtfilt(b, a, data)
def notch_filter(data, sfreq, freq=50.0, quality=30.0):
nyquist = 0.5 * sfreq
notch_freq = freq / nyquist
b, a = iirnotch(notch_freq, quality)
return filtfilt(b, a, data)
def bandpass_filter(data, sfreq, lowcut=0.5, highcut=8.0):
nyquist = 0.5 * sfreq
low = lowcut / nyquist
high = highcut / nyquist
b, a = butter(1, [low, high], btype=’band’)
return filtfilt(b, a, data) I’m working on a final project of processing the EEG signal from a 24-day-old infant. The data file is in .edf format, and I’ve extracted and plotted it as a time series. You can find the data file here: https://file.io/3fWPetZYclsH.
The project’s requirements are:
Analyze the data to identify signal and noises.
Design filters to eliminate the DC component, Electricity noise, and others (if contaminated).
My first approach was to use the power spectral density (PSD), but this idea was rejected as my professor wanted us to use more fundamental algorithms like DFT of Hibert-Huang Transform (HHT). Another problem with my prior work was that my filtered data lost all of the data after a a specific frequency, which my professor attributed to using a ‘second-order’ filter. Below is my attempt on creating the filters. The two tasks i need help is:
Use DFT and/or HHT to identify signal and noises. It is strictly required to identify where the noises are.
Designing filters that effectively eliminate noise without losing essential data points.
I’d appreciate any guidance from anyone. Thank you in advance for your assistance!
def highpass_filter(data, sfreq, cutoff=0.5):
nyquist = 0.5 * sfreq
normal_cutoff = cutoff / nyquist
b, a = butter(1, normal_cutoff, btype=’high’, analog=False)
return filtfilt(b, a, data)
def notch_filter(data, sfreq, freq=50.0, quality=30.0):
nyquist = 0.5 * sfreq
notch_freq = freq / nyquist
b, a = iirnotch(notch_freq, quality)
return filtfilt(b, a, data)
def bandpass_filter(data, sfreq, lowcut=0.5, highcut=8.0):
nyquist = 0.5 * sfreq
low = lowcut / nyquist
high = highcut / nyquist
b, a = butter(1, [low, high], btype=’band’)
return filtfilt(b, a, data) signal processing, fft, dft, hht, filter, medical, eeg, homework MATLAB Answers — New Questions
I have a function that adds a legend I want to make the legend group certain plots together yet so that instead of a legend with 14 entries there is a legend with 5 entries
I have managed to make a code that automates the plotting of data but I would like the code to group the plots into disticnt groups.
Let us say samples 1,3,5 – is group 1
and 2,4,6- is group 2
7,9,11 group 3
8,10,12 is group 4
and finally 13 & 14 is group 5
this is the code
Nsamples = 7;
%
L = 100; % coupon gauge section (mm)
A = 17; % coupon cross-sectional area (mm^2)
%
figure(1);
hold;
figure(2);
hold
%
for k = 1:Nsamples
%
file_name = [‘Sample’ num2str(k) ‘.csv’];
%
T = readtable(file_name,’VariableNamingRule’,’preserve’);
%
[test(k).disp,test(k).force,test(k).eyy] = post_fun(T);
%
figure(1)
h(k) = plot(test(k).disp,test(k).force);
set(h(k),’LineWidth’,2);
%
figure(2)
g(k) = plot(test(k).eyy*100,1000*test(k).force/A);
set(g(k),’LineWidth’,2);
%
leg_string{k} = [‘Sample ‘ num2str(k)];
%
end
%
figure(1)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Displacement (mm)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Force (kN)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
legend(leg_string,’FontSize’,28,’Interpreter’,’latex’);
%
%
figure(2)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Strain (%)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Stress (MPa)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
legend(leg_string,’FontSize’,28,’Interpreter’,’latex’);
%
%
function [disp,force,eyy] = post_fun(T)
%
disp = table2array(T(:,4));
force = table2array(T(:,end));
eyy = table2array(T(:,10));
%
index = isnan(disp) | isnan(force) | isnan(eyy) | disp < 0 | force < 0 | eyy < 0;
%
disp(index) = [];
force(index) = [];
eyy(index) = [];
%
[~,index] = max(force);
disp(index+1:end) = [];
force(index+1:end) = [];
eyy(index+1:end) = [];
%
end
I have added sample 1-7 . csv but the code doesn’t seem to run on this page.
this is what the figure1+2 looks like
Hopefully you can help.
Thanks
AlexI have managed to make a code that automates the plotting of data but I would like the code to group the plots into disticnt groups.
Let us say samples 1,3,5 – is group 1
and 2,4,6- is group 2
7,9,11 group 3
8,10,12 is group 4
and finally 13 & 14 is group 5
this is the code
Nsamples = 7;
%
L = 100; % coupon gauge section (mm)
A = 17; % coupon cross-sectional area (mm^2)
%
figure(1);
hold;
figure(2);
hold
%
for k = 1:Nsamples
%
file_name = [‘Sample’ num2str(k) ‘.csv’];
%
T = readtable(file_name,’VariableNamingRule’,’preserve’);
%
[test(k).disp,test(k).force,test(k).eyy] = post_fun(T);
%
figure(1)
h(k) = plot(test(k).disp,test(k).force);
set(h(k),’LineWidth’,2);
%
figure(2)
g(k) = plot(test(k).eyy*100,1000*test(k).force/A);
set(g(k),’LineWidth’,2);
%
leg_string{k} = [‘Sample ‘ num2str(k)];
%
end
%
figure(1)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Displacement (mm)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Force (kN)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
legend(leg_string,’FontSize’,28,’Interpreter’,’latex’);
%
%
figure(2)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Strain (%)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Stress (MPa)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
legend(leg_string,’FontSize’,28,’Interpreter’,’latex’);
%
%
function [disp,force,eyy] = post_fun(T)
%
disp = table2array(T(:,4));
force = table2array(T(:,end));
eyy = table2array(T(:,10));
%
index = isnan(disp) | isnan(force) | isnan(eyy) | disp < 0 | force < 0 | eyy < 0;
%
disp(index) = [];
force(index) = [];
eyy(index) = [];
%
[~,index] = max(force);
disp(index+1:end) = [];
force(index+1:end) = [];
eyy(index+1:end) = [];
%
end
I have added sample 1-7 . csv but the code doesn’t seem to run on this page.
this is what the figure1+2 looks like
Hopefully you can help.
Thanks
Alex I have managed to make a code that automates the plotting of data but I would like the code to group the plots into disticnt groups.
Let us say samples 1,3,5 – is group 1
and 2,4,6- is group 2
7,9,11 group 3
8,10,12 is group 4
and finally 13 & 14 is group 5
this is the code
Nsamples = 7;
%
L = 100; % coupon gauge section (mm)
A = 17; % coupon cross-sectional area (mm^2)
%
figure(1);
hold;
figure(2);
hold
%
for k = 1:Nsamples
%
file_name = [‘Sample’ num2str(k) ‘.csv’];
%
T = readtable(file_name,’VariableNamingRule’,’preserve’);
%
[test(k).disp,test(k).force,test(k).eyy] = post_fun(T);
%
figure(1)
h(k) = plot(test(k).disp,test(k).force);
set(h(k),’LineWidth’,2);
%
figure(2)
g(k) = plot(test(k).eyy*100,1000*test(k).force/A);
set(g(k),’LineWidth’,2);
%
leg_string{k} = [‘Sample ‘ num2str(k)];
%
end
%
figure(1)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Displacement (mm)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Force (kN)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
legend(leg_string,’FontSize’,28,’Interpreter’,’latex’);
%
%
figure(2)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Strain (%)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Stress (MPa)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
legend(leg_string,’FontSize’,28,’Interpreter’,’latex’);
%
%
function [disp,force,eyy] = post_fun(T)
%
disp = table2array(T(:,4));
force = table2array(T(:,end));
eyy = table2array(T(:,10));
%
index = isnan(disp) | isnan(force) | isnan(eyy) | disp < 0 | force < 0 | eyy < 0;
%
disp(index) = [];
force(index) = [];
eyy(index) = [];
%
[~,index] = max(force);
disp(index+1:end) = [];
force(index+1:end) = [];
eyy(index+1:end) = [];
%
end
I have added sample 1-7 . csv but the code doesn’t seem to run on this page.
this is what the figure1+2 looks like
Hopefully you can help.
Thanks
Alex plot, figure, legend MATLAB Answers — New Questions
voltage exceed limit of distribution system
do the simulink program can simulate the voltage exceed grid code when solar pv is connected to grid? pls helpdo the simulink program can simulate the voltage exceed grid code when solar pv is connected to grid? pls help do the simulink program can simulate the voltage exceed grid code when solar pv is connected to grid? pls help simulink MATLAB Answers — New Questions
Strict inequalities are not supported (learn why)
Hello everyone
I need your help please , I am student and am working in LQR control by LMI
i face probleme with inequalities , firstly i was thinking that becose the version of matlab 2020 but now i am working with 2024Hello everyone
I need your help please , I am student and am working in LQR control by LMI
i face probleme with inequalities , firstly i was thinking that becose the version of matlab 2020 but now i am working with 2024 Hello everyone
I need your help please , I am student and am working in LQR control by LMI
i face probleme with inequalities , firstly i was thinking that becose the version of matlab 2020 but now i am working with 2024 lmi, inqualities, lqr MATLAB Answers — New Questions
Change Input Force to Input Displacement ODE Solver
I have the following ODE solution:
N = 100;
m = 0.1*ones(N,1);
c = 0.1;
b = 0.1;
k = 4;
gamma = 0.1;
X0 = zeros(2*N, 1);
dt = 0.91; % [s]
scale = 0.0049/2;
epsilon = 0.5; % [m]
escale = 10^-2;
rd = 1;
f = @(t,rd) rd.*scale.*square(t) + epsilon.*escale; % [N]
fun = @(t, X) odefun(t, rd, X, N, marray(m), make_diagonal(X,c,b,N),…
make_diagonal(X, k, gamma, N),f);
tspan_train = [0:dt:100];
[t, X] = ode45(fun, tspan_train, X0);
function dX = odefun(t, rd, X, N, M, C, K, f)
%% Definitions
x = X(1:N); % position state vector
dx = X(N+1:2*N); % velocity state vector
%% Force vector
f_reservoir = f(t,rd);
F = [f_reservoir; zeros(98,1); f_reservoir];
%% Equations of Motion
ddx = M(F – K*x – C*dx);
%% State-space model
dX = [dx; …
ddx];
end
function out = make_diagonal(x, k, gamma, N)
x = x(:);
x = [x(1:N); 0];
ck = circshift(k, -1);
cg = circshift(gamma, -1);
cx = circshift(x, -1);
ccx = circshift(x, 1);
d1 = -3 .* ck .* cg .* cx .^ 2 – ck;
d2 = (k .* gamma + ck .* cg) .* x .^ 2 + k + ck;
d3 = -3 .* k .* ccx .^ 2 – k;
out = full(spdiags([d1 d2 d3], -1:1, N, N));
end
function M = marray(m)
M = diag(m);
end
I would like to change my input force f in Newtons to an input displacement in meters. How do I do this?I have the following ODE solution:
N = 100;
m = 0.1*ones(N,1);
c = 0.1;
b = 0.1;
k = 4;
gamma = 0.1;
X0 = zeros(2*N, 1);
dt = 0.91; % [s]
scale = 0.0049/2;
epsilon = 0.5; % [m]
escale = 10^-2;
rd = 1;
f = @(t,rd) rd.*scale.*square(t) + epsilon.*escale; % [N]
fun = @(t, X) odefun(t, rd, X, N, marray(m), make_diagonal(X,c,b,N),…
make_diagonal(X, k, gamma, N),f);
tspan_train = [0:dt:100];
[t, X] = ode45(fun, tspan_train, X0);
function dX = odefun(t, rd, X, N, M, C, K, f)
%% Definitions
x = X(1:N); % position state vector
dx = X(N+1:2*N); % velocity state vector
%% Force vector
f_reservoir = f(t,rd);
F = [f_reservoir; zeros(98,1); f_reservoir];
%% Equations of Motion
ddx = M(F – K*x – C*dx);
%% State-space model
dX = [dx; …
ddx];
end
function out = make_diagonal(x, k, gamma, N)
x = x(:);
x = [x(1:N); 0];
ck = circshift(k, -1);
cg = circshift(gamma, -1);
cx = circshift(x, -1);
ccx = circshift(x, 1);
d1 = -3 .* ck .* cg .* cx .^ 2 – ck;
d2 = (k .* gamma + ck .* cg) .* x .^ 2 + k + ck;
d3 = -3 .* k .* ccx .^ 2 – k;
out = full(spdiags([d1 d2 d3], -1:1, N, N));
end
function M = marray(m)
M = diag(m);
end
I would like to change my input force f in Newtons to an input displacement in meters. How do I do this? I have the following ODE solution:
N = 100;
m = 0.1*ones(N,1);
c = 0.1;
b = 0.1;
k = 4;
gamma = 0.1;
X0 = zeros(2*N, 1);
dt = 0.91; % [s]
scale = 0.0049/2;
epsilon = 0.5; % [m]
escale = 10^-2;
rd = 1;
f = @(t,rd) rd.*scale.*square(t) + epsilon.*escale; % [N]
fun = @(t, X) odefun(t, rd, X, N, marray(m), make_diagonal(X,c,b,N),…
make_diagonal(X, k, gamma, N),f);
tspan_train = [0:dt:100];
[t, X] = ode45(fun, tspan_train, X0);
function dX = odefun(t, rd, X, N, M, C, K, f)
%% Definitions
x = X(1:N); % position state vector
dx = X(N+1:2*N); % velocity state vector
%% Force vector
f_reservoir = f(t,rd);
F = [f_reservoir; zeros(98,1); f_reservoir];
%% Equations of Motion
ddx = M(F – K*x – C*dx);
%% State-space model
dX = [dx; …
ddx];
end
function out = make_diagonal(x, k, gamma, N)
x = x(:);
x = [x(1:N); 0];
ck = circshift(k, -1);
cg = circshift(gamma, -1);
cx = circshift(x, -1);
ccx = circshift(x, 1);
d1 = -3 .* ck .* cg .* cx .^ 2 – ck;
d2 = (k .* gamma + ck .* cg) .* x .^ 2 + k + ck;
d3 = -3 .* k .* ccx .^ 2 – k;
out = full(spdiags([d1 d2 d3], -1:1, N, N));
end
function M = marray(m)
M = diag(m);
end
I would like to change my input force f in Newtons to an input displacement in meters. How do I do this? ode, ode45, model, solve, fsolve, function MATLAB Answers — New Questions