Tag Archives: matlab
Traitement d’image Cheminée Industrielle
Hello,
if anyone can help me on this subject
I’m at engineering school and I’m working on a project where we have to determine the condition of an industrial chimney (presence of rust/cracks). To do this, we capture the chimney and then process the image to determine whether the section photographed has any defects. I tried a first code with different tools:
-Contour detection with Canny Edge
-Segmentation using Thresholding
-Morphological analysis
I didn’t have much success, as some of the photos show welds, but it only detects welds and not cracks.
I’ve started looking into CNNs but I don’t know if it’s necessary.
I enclose a photo of the chimney
Thanks in advanceHello,
if anyone can help me on this subject
I’m at engineering school and I’m working on a project where we have to determine the condition of an industrial chimney (presence of rust/cracks). To do this, we capture the chimney and then process the image to determine whether the section photographed has any defects. I tried a first code with different tools:
-Contour detection with Canny Edge
-Segmentation using Thresholding
-Morphological analysis
I didn’t have much success, as some of the photos show welds, but it only detects welds and not cracks.
I’ve started looking into CNNs but I don’t know if it’s necessary.
I enclose a photo of the chimney
Thanks in advance Hello,
if anyone can help me on this subject
I’m at engineering school and I’m working on a project where we have to determine the condition of an industrial chimney (presence of rust/cracks). To do this, we capture the chimney and then process the image to determine whether the section photographed has any defects. I tried a first code with different tools:
-Contour detection with Canny Edge
-Segmentation using Thresholding
-Morphological analysis
I didn’t have much success, as some of the photos show welds, but it only detects welds and not cracks.
I’ve started looking into CNNs but I don’t know if it’s necessary.
I enclose a photo of the chimney
Thanks in advance transferred MATLAB Answers — New Questions
Problem with Casadi 3.6.5 installation on Matlab r2023b on Mac ARM64
Tried running below code to test Casadi in Matlab.
import casadi.*
x = MX.sym(‘x’)
disp(jacobian(sin(x),x))
Im getting the below error
Unrecognized function or variable ‘casadiMEX’.
Error in casadi.GenMX.sym (line 833)
[varargout{1:nargout}] = casadiMEX(356, varargin{:});Tried running below code to test Casadi in Matlab.
import casadi.*
x = MX.sym(‘x’)
disp(jacobian(sin(x),x))
Im getting the below error
Unrecognized function or variable ‘casadiMEX’.
Error in casadi.GenMX.sym (line 833)
[varargout{1:nargout}] = casadiMEX(356, varargin{:}); Tried running below code to test Casadi in Matlab.
import casadi.*
x = MX.sym(‘x’)
disp(jacobian(sin(x),x))
Im getting the below error
Unrecognized function or variable ‘casadiMEX’.
Error in casadi.GenMX.sym (line 833)
[varargout{1:nargout}] = casadiMEX(356, varargin{:}); casadi, arm64, r2023b MATLAB Answers — New Questions
Generate a time series from power spectral density
I have a force PSD of 2X2X63 acting at 2 points of 63 frequencies defined. For each frequency, there is a 2×2 matrix representing the auto and cross variances of the force. I want to construct a time signal of 2xN size where N is the size of the time signal. How do I do it?I have a force PSD of 2X2X63 acting at 2 points of 63 frequencies defined. For each frequency, there is a 2×2 matrix representing the auto and cross variances of the force. I want to construct a time signal of 2xN size where N is the size of the time signal. How do I do it? I have a force PSD of 2X2X63 acting at 2 points of 63 frequencies defined. For each frequency, there is a 2×2 matrix representing the auto and cross variances of the force. I want to construct a time signal of 2xN size where N is the size of the time signal. How do I do it? psd, fft, ifft MATLAB Answers — New Questions
A moving point plot in MATLAB figure with animation.
My program calculates position of a point on Z plane as (X,Y). I need to plot (X,Y) in Z-plane with a moving point showing location of point over the time in a single MATLAB figure. Please help.My program calculates position of a point on Z plane as (X,Y). I need to plot (X,Y) in Z-plane with a moving point showing location of point over the time in a single MATLAB figure. Please help. My program calculates position of a point on Z plane as (X,Y). I need to plot (X,Y) in Z-plane with a moving point showing location of point over the time in a single MATLAB figure. Please help. plot, animation MATLAB Answers — New Questions
Does Embedded Coder support Infineon Aurix Devices?
Hi There,
I am heading System Applications Team at Infineon India.
Some of our customers are keen to have MATLAB support for our Aurix Microcontrollers.
Would like to know what support is currently available & what are the options?
Thanks,
AvinashHi There,
I am heading System Applications Team at Infineon India.
Some of our customers are keen to have MATLAB support for our Aurix Microcontrollers.
Would like to know what support is currently available & what are the options?
Thanks,
Avinash Hi There,
I am heading System Applications Team at Infineon India.
Some of our customers are keen to have MATLAB support for our Aurix Microcontrollers.
Would like to know what support is currently available & what are the options?
Thanks,
Avinash infineon, aurix MATLAB Answers — New Questions
Problem 56313. Find Air Temperature from Cricket Stridulation Rate
function y = getTemperature_F(nchirps_in_14s)
x=[20 30 40 50]
F=0;
y=x;
y=fliplr(y);
while F<=50
F=F+110;
y=F-y;
end
end
%whats wrong with my answer i am not getting it.function y = getTemperature_F(nchirps_in_14s)
x=[20 30 40 50]
F=0;
y=x;
y=fliplr(y);
while F<=50
F=F+110;
y=F-y;
end
end
%whats wrong with my answer i am not getting it. function y = getTemperature_F(nchirps_in_14s)
x=[20 30 40 50]
F=0;
y=x;
y=fliplr(y);
while F<=50
F=F+110;
y=F-y;
end
end
%whats wrong with my answer i am not getting it. homework MATLAB Answers — New Questions
how to ask to the user to insert a command while a function is being executing?
In a previous version of my code, I implemented a function which reads data from serial port. While the function was storing and managing data received through the serial port, the user can each time insert a command "stop" which advice the connected device to stop the communication. The code was this:
configureCallback(controller,"byte",1,@readData)
%%
val = input(‘Comando: ‘,’s’);
% command start
writeline(controller, val);
%%
val = input(‘Comando: ‘,’s’);
% command stop
writeline(controller, val);
I’m trying to do the same but with my peripheral connected to my pc through bluetooth low energy.
However, I don’t know how to make the funcion works and the script asking for the command simultaneously, it seems like configureCallback function is not working in this case.
%% write START
val = input(‘Comando: ‘,’s’);
% Convert string to uint8 array
val_bytes = uint8(val);
% command start
write(c_write,val_bytes,’WithoutResponse’);
%% read data
if finished==0
% Set the callback function for the characteristic
c_read.DataAvailableFcn = @bleDataReceived;
end
%% write STOP
val = input(‘Comando: ‘,’s’);
% Convert string to uint8 array
val_bytes = uint8(val);
% command start
write(c_write,val_bytes,’WithoutResponse’);
i wrote this, but the function is continuosly reading after command start is sent without letting me the chance to insert the command stop.In a previous version of my code, I implemented a function which reads data from serial port. While the function was storing and managing data received through the serial port, the user can each time insert a command "stop" which advice the connected device to stop the communication. The code was this:
configureCallback(controller,"byte",1,@readData)
%%
val = input(‘Comando: ‘,’s’);
% command start
writeline(controller, val);
%%
val = input(‘Comando: ‘,’s’);
% command stop
writeline(controller, val);
I’m trying to do the same but with my peripheral connected to my pc through bluetooth low energy.
However, I don’t know how to make the funcion works and the script asking for the command simultaneously, it seems like configureCallback function is not working in this case.
%% write START
val = input(‘Comando: ‘,’s’);
% Convert string to uint8 array
val_bytes = uint8(val);
% command start
write(c_write,val_bytes,’WithoutResponse’);
%% read data
if finished==0
% Set the callback function for the characteristic
c_read.DataAvailableFcn = @bleDataReceived;
end
%% write STOP
val = input(‘Comando: ‘,’s’);
% Convert string to uint8 array
val_bytes = uint8(val);
% command start
write(c_write,val_bytes,’WithoutResponse’);
i wrote this, but the function is continuosly reading after command start is sent without letting me the chance to insert the command stop. In a previous version of my code, I implemented a function which reads data from serial port. While the function was storing and managing data received through the serial port, the user can each time insert a command "stop" which advice the connected device to stop the communication. The code was this:
configureCallback(controller,"byte",1,@readData)
%%
val = input(‘Comando: ‘,’s’);
% command start
writeline(controller, val);
%%
val = input(‘Comando: ‘,’s’);
% command stop
writeline(controller, val);
I’m trying to do the same but with my peripheral connected to my pc through bluetooth low energy.
However, I don’t know how to make the funcion works and the script asking for the command simultaneously, it seems like configureCallback function is not working in this case.
%% write START
val = input(‘Comando: ‘,’s’);
% Convert string to uint8 array
val_bytes = uint8(val);
% command start
write(c_write,val_bytes,’WithoutResponse’);
%% read data
if finished==0
% Set the callback function for the characteristic
c_read.DataAvailableFcn = @bleDataReceived;
end
%% write STOP
val = input(‘Comando: ‘,’s’);
% Convert string to uint8 array
val_bytes = uint8(val);
% command start
write(c_write,val_bytes,’WithoutResponse’);
i wrote this, but the function is continuosly reading after command start is sent without letting me the chance to insert the command stop. matlab, functions, function, callback, ble, bluetooth MATLAB Answers — New Questions
Extract certain values in .mat file
Hi,
I have a mat file with 1250×1 data and I want to extract specific values from the 1250. For example I want to extract every 2nd or every 5th values.
As an example, the mat file contains the following values:
-0.13793 -0.114746 -0.204773 -0.224304 -0.181274 -0.192566 -0.159912 -0.174866 -0.134888 -0.148926
For every 2nd I want to read: -0.114746 -0.224304 -0.192566 -0.174866 -0.148926
For every 5th I want to read: -0.181274 -0.148926
What is the best command to do this? Thank you.Hi,
I have a mat file with 1250×1 data and I want to extract specific values from the 1250. For example I want to extract every 2nd or every 5th values.
As an example, the mat file contains the following values:
-0.13793 -0.114746 -0.204773 -0.224304 -0.181274 -0.192566 -0.159912 -0.174866 -0.134888 -0.148926
For every 2nd I want to read: -0.114746 -0.224304 -0.192566 -0.174866 -0.148926
For every 5th I want to read: -0.181274 -0.148926
What is the best command to do this? Thank you. Hi,
I have a mat file with 1250×1 data and I want to extract specific values from the 1250. For example I want to extract every 2nd or every 5th values.
As an example, the mat file contains the following values:
-0.13793 -0.114746 -0.204773 -0.224304 -0.181274 -0.192566 -0.159912 -0.174866 -0.134888 -0.148926
For every 2nd I want to read: -0.114746 -0.224304 -0.192566 -0.174866 -0.148926
For every 5th I want to read: -0.181274 -0.148926
What is the best command to do this? Thank you. extract data MATLAB Answers — New Questions
Function definitions are not permitted in this context.
help me
Function definitions are not permitted in this context.help me
Function definitions are not permitted in this context. help me
Function definitions are not permitted in this context. matlab, matlab 2014b MATLAB Answers — New Questions
Error when installing NCORR Program in MATLAB for DIC
Hello,
I want to use DIC in MATLAB. I tried to import/install NCORR program to MATLAB but I get these two errors (screeshots below) that I need help resolving.
The .cpp files in my PC (screenshot-top) does not appear the same as in the reference tutorial i was seeing (screenshot-bottom).
Can someone pls tell me how to fix it. Thankyou!Hello,
I want to use DIC in MATLAB. I tried to import/install NCORR program to MATLAB but I get these two errors (screeshots below) that I need help resolving.
The .cpp files in my PC (screenshot-top) does not appear the same as in the reference tutorial i was seeing (screenshot-bottom).
Can someone pls tell me how to fix it. Thankyou! Hello,
I want to use DIC in MATLAB. I tried to import/install NCORR program to MATLAB but I get these two errors (screeshots below) that I need help resolving.
The .cpp files in my PC (screenshot-top) does not appear the same as in the reference tutorial i was seeing (screenshot-bottom).
Can someone pls tell me how to fix it. Thankyou! ncorr, compiler MATLAB Answers — New Questions
Error using (function_name). Too many output arguments.
I’m having some issues with this code:
clear
clc
fluido = "aria"
i=0;
for temp = 15:0.1:1500
i=i+1;
temperatura(i)=temp;
vettore_cp(i)=calcolo_cp(temp, fluido);
end
plot(temperatura,vettore_cp,"b-")
title("grafico del calore specifico in funzione della temperatura")
xlabel("temperatura [°C]")
ylabel("calore specifico [J/kg*K]")
The program should plot a diagram using the function calcolo_cp that calculates the specific heat and uses as inputs the temperature of the fluid and what type of fluid we want to examinate ( in this case "aria", "air" in english).
The function calcolo_cp is in the same folder and seems to work fine, the code of this function is:
function calcolo_cp(T,fluido)
if strcmp(fluido, "aria")
indice_riga=1;
elseif strcmp(fluido, "gas")
indice_riga=2;
else
disp("ERRORE FLUIDO")
end
coeff=[1000.61 0.482759e-1 0.462906e-3 -0.454035e-6 0.129112e-9;
1013.71 0.641882e-1 0.452287e-3 -0.444350e-6 0.125765e-9];
for i = 1:5
elementi_cp(i) = coeff(indice_riga,i)*T^(i-1);
end
cp = sum(elementi_cp)
end
I’m here if you need more information about my code.
Thank you all.I’m having some issues with this code:
clear
clc
fluido = "aria"
i=0;
for temp = 15:0.1:1500
i=i+1;
temperatura(i)=temp;
vettore_cp(i)=calcolo_cp(temp, fluido);
end
plot(temperatura,vettore_cp,"b-")
title("grafico del calore specifico in funzione della temperatura")
xlabel("temperatura [°C]")
ylabel("calore specifico [J/kg*K]")
The program should plot a diagram using the function calcolo_cp that calculates the specific heat and uses as inputs the temperature of the fluid and what type of fluid we want to examinate ( in this case "aria", "air" in english).
The function calcolo_cp is in the same folder and seems to work fine, the code of this function is:
function calcolo_cp(T,fluido)
if strcmp(fluido, "aria")
indice_riga=1;
elseif strcmp(fluido, "gas")
indice_riga=2;
else
disp("ERRORE FLUIDO")
end
coeff=[1000.61 0.482759e-1 0.462906e-3 -0.454035e-6 0.129112e-9;
1013.71 0.641882e-1 0.452287e-3 -0.444350e-6 0.125765e-9];
for i = 1:5
elementi_cp(i) = coeff(indice_riga,i)*T^(i-1);
end
cp = sum(elementi_cp)
end
I’m here if you need more information about my code.
Thank you all. I’m having some issues with this code:
clear
clc
fluido = "aria"
i=0;
for temp = 15:0.1:1500
i=i+1;
temperatura(i)=temp;
vettore_cp(i)=calcolo_cp(temp, fluido);
end
plot(temperatura,vettore_cp,"b-")
title("grafico del calore specifico in funzione della temperatura")
xlabel("temperatura [°C]")
ylabel("calore specifico [J/kg*K]")
The program should plot a diagram using the function calcolo_cp that calculates the specific heat and uses as inputs the temperature of the fluid and what type of fluid we want to examinate ( in this case "aria", "air" in english).
The function calcolo_cp is in the same folder and seems to work fine, the code of this function is:
function calcolo_cp(T,fluido)
if strcmp(fluido, "aria")
indice_riga=1;
elseif strcmp(fluido, "gas")
indice_riga=2;
else
disp("ERRORE FLUIDO")
end
coeff=[1000.61 0.482759e-1 0.462906e-3 -0.454035e-6 0.129112e-9;
1013.71 0.641882e-1 0.452287e-3 -0.444350e-6 0.125765e-9];
for i = 1:5
elementi_cp(i) = coeff(indice_riga,i)*T^(i-1);
end
cp = sum(elementi_cp)
end
I’m here if you need more information about my code.
Thank you all. error function, plot, too many output arguments, too many inputs arguments MATLAB Answers — New Questions
How do I assign frequency values to the obtained fft values without plotting . I need to know the value of the peak at 16Hz for further calculations.
clear all
close all
clc
L=10;
n=1.45;
c=2.9979e8;
dt = 6e-12;
T=10*2*L*n/c;
t = (-T/2/dt:1:T/2/dt)*dt;
Nt=round(T/dt);
fsine = 1e9;
vsine = 1;
phi = vsine*sin(2*pi*fsine*t);
EL1t=1.274e7*exp(1i*phi);
FP=fft(phi);
fs=1/dt/Nt;
Fs=(-1/dt/2:fs:1/dt/2-1);
Z=plot(Fs,fftshift(abs(fft(EL1t))));
I need to know the value at 16GHz in the plot.clear all
close all
clc
L=10;
n=1.45;
c=2.9979e8;
dt = 6e-12;
T=10*2*L*n/c;
t = (-T/2/dt:1:T/2/dt)*dt;
Nt=round(T/dt);
fsine = 1e9;
vsine = 1;
phi = vsine*sin(2*pi*fsine*t);
EL1t=1.274e7*exp(1i*phi);
FP=fft(phi);
fs=1/dt/Nt;
Fs=(-1/dt/2:fs:1/dt/2-1);
Z=plot(Fs,fftshift(abs(fft(EL1t))));
I need to know the value at 16GHz in the plot. clear all
close all
clc
L=10;
n=1.45;
c=2.9979e8;
dt = 6e-12;
T=10*2*L*n/c;
t = (-T/2/dt:1:T/2/dt)*dt;
Nt=round(T/dt);
fsine = 1e9;
vsine = 1;
phi = vsine*sin(2*pi*fsine*t);
EL1t=1.274e7*exp(1i*phi);
FP=fft(phi);
fs=1/dt/Nt;
Fs=(-1/dt/2:fs:1/dt/2-1);
Z=plot(Fs,fftshift(abs(fft(EL1t))));
I need to know the value at 16GHz in the plot. fft, plot MATLAB Answers — New Questions
Using c language to call the dll file generated by matlab, there is an error when running
I use matlab to generate a matlab code dll file (including library files and header files), and then write a c program to call this dll file, but the following error:I use matlab to generate a matlab code dll file (including library files and header files), and then write a c program to call this dll file, but the following error: I use matlab to generate a matlab code dll file (including library files and header files), and then write a c program to call this dll file, but the following error: dll MATLAB Answers — New Questions
What caused this error message?
—————————————————————————————————————
% Define the input signal x[n]
n = 0:49;
x = (-1).^n .* (n >= 0);
% Define the length of the input signal
N = length(x);
% Initialize the output signal y[n]
y = zeros(1, N);
% Define the initial conditions
y_minus_1 = 4;
y_minus_2 = -2;
% Calculate the output y[n] using the difference equation
for n = 1:50
if n == 1
y(n) = x(n) + x(n – 1) – (1/4) * y_minus_1 + (1/8) * y_minus_2;
elseif n == 2
y(n) = x(n) + x(n – 1) – (1/4) * y(n – 1) + (1/8) * y_minus_1;
else
y(n) = x(n) + x(n – 1) – (1/4) * y(n – 1) + (1/8) * y(n – 2);
end
end
% Plot the output signal y[n]
stem(0:N-1, y);
grid on;
xlabel(‘n’);
ylabel(‘y[n]’);
title(‘Output of the System’);
——————————————————————————————————————–
Array index should be positive integer or logical value.
Error: HW2_2_59_c (18th line)
y(n) = x(n) + x(n – 1) – (1/4) * y_minus_1 + (1/8) * y_minus_2;—————————————————————————————————————
% Define the input signal x[n]
n = 0:49;
x = (-1).^n .* (n >= 0);
% Define the length of the input signal
N = length(x);
% Initialize the output signal y[n]
y = zeros(1, N);
% Define the initial conditions
y_minus_1 = 4;
y_minus_2 = -2;
% Calculate the output y[n] using the difference equation
for n = 1:50
if n == 1
y(n) = x(n) + x(n – 1) – (1/4) * y_minus_1 + (1/8) * y_minus_2;
elseif n == 2
y(n) = x(n) + x(n – 1) – (1/4) * y(n – 1) + (1/8) * y_minus_1;
else
y(n) = x(n) + x(n – 1) – (1/4) * y(n – 1) + (1/8) * y(n – 2);
end
end
% Plot the output signal y[n]
stem(0:N-1, y);
grid on;
xlabel(‘n’);
ylabel(‘y[n]’);
title(‘Output of the System’);
——————————————————————————————————————–
Array index should be positive integer or logical value.
Error: HW2_2_59_c (18th line)
y(n) = x(n) + x(n – 1) – (1/4) * y_minus_1 + (1/8) * y_minus_2; —————————————————————————————————————
% Define the input signal x[n]
n = 0:49;
x = (-1).^n .* (n >= 0);
% Define the length of the input signal
N = length(x);
% Initialize the output signal y[n]
y = zeros(1, N);
% Define the initial conditions
y_minus_1 = 4;
y_minus_2 = -2;
% Calculate the output y[n] using the difference equation
for n = 1:50
if n == 1
y(n) = x(n) + x(n – 1) – (1/4) * y_minus_1 + (1/8) * y_minus_2;
elseif n == 2
y(n) = x(n) + x(n – 1) – (1/4) * y(n – 1) + (1/8) * y_minus_1;
else
y(n) = x(n) + x(n – 1) – (1/4) * y(n – 1) + (1/8) * y(n – 2);
end
end
% Plot the output signal y[n]
stem(0:N-1, y);
grid on;
xlabel(‘n’);
ylabel(‘y[n]’);
title(‘Output of the System’);
——————————————————————————————————————–
Array index should be positive integer or logical value.
Error: HW2_2_59_c (18th line)
y(n) = x(n) + x(n – 1) – (1/4) * y_minus_1 + (1/8) * y_minus_2; #difference equation, #index error MATLAB Answers — New Questions
Automatic Nuclei Count tif stacks
I am using this borrowed code to automatically count DAPI stained nuclei:
Hs.dirPath = pwd;
[Hs.dataFiles,Hs.dataNums] = getDataFiles(Hs.dirPath);
[Hs.foundChannels,Hs.fileNums,Hs.imgExts] = getImageFiles(Hs.dirPath);
for i = 1:length(Hs.fileNums)
Hs.fileNum = Hs.fileNums(i);
fileName = [‘dapi’ sprintf(‘%03d’,Hs.fileNum) ‘.tif’];
Hs.DI = readmm(fileName);
Hs.DI = Hs.DI.imagedata;
Hs.DI = scale(max(Hs.DI(:,:,round(linspace(10,size(Hs.DI,10),50))),[],3));
binDapi = Hs.DI>adaptthresh(Hs.DI);
masktmp = imclearborder(binDapi | ~Hs.DI);
masktmp = bwareaopen(masktmp,50);
if any(masktmp(:))
binDapi = masktmp;
end
L = bwlabel(binDapi);
numObjects = max(L,[],1:2);
Hs.currObjs = [];
Hs.allMasks = [];
for j = 1:numObjects
fnumStr = sprintf(‘%03d’,Hs.fileNum);
objMask = L == j;
newObj = improc2.buildImageObject(objMask, fnumStr, Hs.dirPath);
Hs.currObjs = [Hs.currObjs, newObj];
Hs.allMasks = cat(3,Hs.allMasks,objMask);
end
objects = Hs.currObjs;
save(sprintf(‘%s%sdata%03d.mat’,Hs.dirPath,filesep,Hs.fileNum),’objects’);
[Hs.dataFiles,Hs.dataNums] = getDataFiles(Hs.dirPath);
clear objects;
Hs.currObjs = [];
end
It ends up fusing nuclei that are on different planes. In the image shown here (Matlab Output on the left and original on the right)there should be 14 nuclei but 1 and 6, 2 and 5 and 3 and 7 end up being counted as the same.
I have tried changing the threshold etc. but it does not help with the stacks.
Any suggestions to modify the code? Thanks.I am using this borrowed code to automatically count DAPI stained nuclei:
Hs.dirPath = pwd;
[Hs.dataFiles,Hs.dataNums] = getDataFiles(Hs.dirPath);
[Hs.foundChannels,Hs.fileNums,Hs.imgExts] = getImageFiles(Hs.dirPath);
for i = 1:length(Hs.fileNums)
Hs.fileNum = Hs.fileNums(i);
fileName = [‘dapi’ sprintf(‘%03d’,Hs.fileNum) ‘.tif’];
Hs.DI = readmm(fileName);
Hs.DI = Hs.DI.imagedata;
Hs.DI = scale(max(Hs.DI(:,:,round(linspace(10,size(Hs.DI,10),50))),[],3));
binDapi = Hs.DI>adaptthresh(Hs.DI);
masktmp = imclearborder(binDapi | ~Hs.DI);
masktmp = bwareaopen(masktmp,50);
if any(masktmp(:))
binDapi = masktmp;
end
L = bwlabel(binDapi);
numObjects = max(L,[],1:2);
Hs.currObjs = [];
Hs.allMasks = [];
for j = 1:numObjects
fnumStr = sprintf(‘%03d’,Hs.fileNum);
objMask = L == j;
newObj = improc2.buildImageObject(objMask, fnumStr, Hs.dirPath);
Hs.currObjs = [Hs.currObjs, newObj];
Hs.allMasks = cat(3,Hs.allMasks,objMask);
end
objects = Hs.currObjs;
save(sprintf(‘%s%sdata%03d.mat’,Hs.dirPath,filesep,Hs.fileNum),’objects’);
[Hs.dataFiles,Hs.dataNums] = getDataFiles(Hs.dirPath);
clear objects;
Hs.currObjs = [];
end
It ends up fusing nuclei that are on different planes. In the image shown here (Matlab Output on the left and original on the right)there should be 14 nuclei but 1 and 6, 2 and 5 and 3 and 7 end up being counted as the same.
I have tried changing the threshold etc. but it does not help with the stacks.
Any suggestions to modify the code? Thanks. I am using this borrowed code to automatically count DAPI stained nuclei:
Hs.dirPath = pwd;
[Hs.dataFiles,Hs.dataNums] = getDataFiles(Hs.dirPath);
[Hs.foundChannels,Hs.fileNums,Hs.imgExts] = getImageFiles(Hs.dirPath);
for i = 1:length(Hs.fileNums)
Hs.fileNum = Hs.fileNums(i);
fileName = [‘dapi’ sprintf(‘%03d’,Hs.fileNum) ‘.tif’];
Hs.DI = readmm(fileName);
Hs.DI = Hs.DI.imagedata;
Hs.DI = scale(max(Hs.DI(:,:,round(linspace(10,size(Hs.DI,10),50))),[],3));
binDapi = Hs.DI>adaptthresh(Hs.DI);
masktmp = imclearborder(binDapi | ~Hs.DI);
masktmp = bwareaopen(masktmp,50);
if any(masktmp(:))
binDapi = masktmp;
end
L = bwlabel(binDapi);
numObjects = max(L,[],1:2);
Hs.currObjs = [];
Hs.allMasks = [];
for j = 1:numObjects
fnumStr = sprintf(‘%03d’,Hs.fileNum);
objMask = L == j;
newObj = improc2.buildImageObject(objMask, fnumStr, Hs.dirPath);
Hs.currObjs = [Hs.currObjs, newObj];
Hs.allMasks = cat(3,Hs.allMasks,objMask);
end
objects = Hs.currObjs;
save(sprintf(‘%s%sdata%03d.mat’,Hs.dirPath,filesep,Hs.fileNum),’objects’);
[Hs.dataFiles,Hs.dataNums] = getDataFiles(Hs.dirPath);
clear objects;
Hs.currObjs = [];
end
It ends up fusing nuclei that are on different planes. In the image shown here (Matlab Output on the left and original on the right)there should be 14 nuclei but 1 and 6, 2 and 5 and 3 and 7 end up being counted as the same.
I have tried changing the threshold etc. but it does not help with the stacks.
Any suggestions to modify the code? Thanks. image processing, image analysis MATLAB Answers — New Questions
How to use ode15s to solve a stiff ode with mass?
Now I get a matlab code using ode15s to solve a function with singular Mass. My question is:
what does it mean (there is no function called ‘M’ in my dir)
opts = odeset(‘Mass’, ‘M’, ‘MassSingular’, ‘yes’);
and why in the ode function, there is an extra input called ‘flag’ ?
The main code is as following:
tf = 200;
x0 = [0 0 0 0 2500 0 0.8 0 50 50 50 50 5];
opts = odeset(‘Mass’, ‘M’, ‘MassSingular’, ‘yes’);
[t, x] = ode15s(‘ff’, [0 tf], x0,opts);
function xdot=Methanol_Water(t,x)
if isempty(flag),
P=1;
x1=x(1);
x2=x(2);
x3=x(3);
x4=x(4);
x0=x(6);
xB=x(7);
T1=x(9);
T2=x(10);
T3=x(11);
T4=x(12);
TB=x(13);
D1=-4617.8;
C1=13.676;
D2=-5042.6;
C2=13.519;
A=0.85;
B=0.48;
R=10;
V=10;
Di=V/(R+1);
L=V-Di;
y1=exp(A*(1-x1^2)/(1-x1+A*x1/B)^2)*exp(C1+D1/(273.15+T1))*x1/P;
y2=exp(A*(1-x2^2)/(1-x2+A*x2/B)^2)*exp(C1+D1/(273.15+T2))*x2/P;
y3=exp(A*(1-x3^2)/(1-x3+A*x3/B)^2)*exp(C1+D1/(273.15+T3))*x3/P;
y4=exp(A*(1-x4^2)/(1-x4+A*x4/B)^2)*exp(C1+D1/(273.15+T4))*x4/P;
yB=exp(A*(1-xB^2)/(1-xB+A*xB/B)^2)*exp(C1+D1/(273.15+TB))*xB/P;
MH0=100;
MH=20;
xdot(1)=1/MH*(L*(x0-x1)+V*(y2-y1));
xdot(2)=1/MH*(L*(x1-x2)+V*(y3-y2));
xdot(3)=1/MH*(L*(x2-x3)+V*(y4-y3));
xdot(4)=1/MH*(L*(x3-x4)+V*(yB-y4));
xdot(5)=L-V;
xdot(6)=(V/MH0*y1-(L+Di)/MH0*x0);
xdot(7)=(L*(x4-xB)-V*(yB-xB));
xdot(8)=Di;
xdot(9)=P-exp(A*(1-x1^2)/(1-x1+A*x1/B)^2)*exp(C1+D1/(273.15+T1))*x1-exp(A*x1^2/(x1+A*(1-x1)/B)^2)*exp(C2+D2/(273.15+T1))*(1-x1);
xdot(10)=P-exp(A*(1-x2^2)/(1-x2+A*x2/B)^2)*exp(C1+D1/(273.15+T2))*x2- exp(A*x2^2/(x2+A*(1-x2)/B)^2)*exp(C2+D2/(273.15+T2))*(1-x2);
xdot(11)=P-exp(A*(1-x3^2)/(1-x3+A*x3/B)^2)*exp(C1+D1/(273.15+T3))*x3-exp(A*x3^2/(x3+A*(1-x3)/B)^2)*exp(C2+D2/(273.15+T3))*(1-x3);
xdot(12)=P-exp(A*(1-x4^2)/(1-x4+A*x4/B)^2)*exp(C1+D1/(273.15+T4))*x4- exp(A*x4^2/(x4+A*(1-x4)/B)^2)*exp(C2+D2/(273.15+T4))*(1-x4);
xdot(13)=P-exp(A*(1-xB^2)/(1-xB+A*xB/B)^2)*exp(C1+D1/(273.15+TB))*xB- exp(A*xB^2/(xB+A*(1-xB)/B)^2)*exp(C2+D2/(273.15+TB))*(1-xB);
xdot = xdot(:);
else
M = zeros(13,13);
M(1,1) = 1;
M(2,2) = 1;
M(3,3) = 1;
M(4,4) = 1;
M(5,5) = 1;
M(6,6) = 1;
M(7,7) = x(5);
M(8,8) = 1;
xdot = M;
endNow I get a matlab code using ode15s to solve a function with singular Mass. My question is:
what does it mean (there is no function called ‘M’ in my dir)
opts = odeset(‘Mass’, ‘M’, ‘MassSingular’, ‘yes’);
and why in the ode function, there is an extra input called ‘flag’ ?
The main code is as following:
tf = 200;
x0 = [0 0 0 0 2500 0 0.8 0 50 50 50 50 5];
opts = odeset(‘Mass’, ‘M’, ‘MassSingular’, ‘yes’);
[t, x] = ode15s(‘ff’, [0 tf], x0,opts);
function xdot=Methanol_Water(t,x)
if isempty(flag),
P=1;
x1=x(1);
x2=x(2);
x3=x(3);
x4=x(4);
x0=x(6);
xB=x(7);
T1=x(9);
T2=x(10);
T3=x(11);
T4=x(12);
TB=x(13);
D1=-4617.8;
C1=13.676;
D2=-5042.6;
C2=13.519;
A=0.85;
B=0.48;
R=10;
V=10;
Di=V/(R+1);
L=V-Di;
y1=exp(A*(1-x1^2)/(1-x1+A*x1/B)^2)*exp(C1+D1/(273.15+T1))*x1/P;
y2=exp(A*(1-x2^2)/(1-x2+A*x2/B)^2)*exp(C1+D1/(273.15+T2))*x2/P;
y3=exp(A*(1-x3^2)/(1-x3+A*x3/B)^2)*exp(C1+D1/(273.15+T3))*x3/P;
y4=exp(A*(1-x4^2)/(1-x4+A*x4/B)^2)*exp(C1+D1/(273.15+T4))*x4/P;
yB=exp(A*(1-xB^2)/(1-xB+A*xB/B)^2)*exp(C1+D1/(273.15+TB))*xB/P;
MH0=100;
MH=20;
xdot(1)=1/MH*(L*(x0-x1)+V*(y2-y1));
xdot(2)=1/MH*(L*(x1-x2)+V*(y3-y2));
xdot(3)=1/MH*(L*(x2-x3)+V*(y4-y3));
xdot(4)=1/MH*(L*(x3-x4)+V*(yB-y4));
xdot(5)=L-V;
xdot(6)=(V/MH0*y1-(L+Di)/MH0*x0);
xdot(7)=(L*(x4-xB)-V*(yB-xB));
xdot(8)=Di;
xdot(9)=P-exp(A*(1-x1^2)/(1-x1+A*x1/B)^2)*exp(C1+D1/(273.15+T1))*x1-exp(A*x1^2/(x1+A*(1-x1)/B)^2)*exp(C2+D2/(273.15+T1))*(1-x1);
xdot(10)=P-exp(A*(1-x2^2)/(1-x2+A*x2/B)^2)*exp(C1+D1/(273.15+T2))*x2- exp(A*x2^2/(x2+A*(1-x2)/B)^2)*exp(C2+D2/(273.15+T2))*(1-x2);
xdot(11)=P-exp(A*(1-x3^2)/(1-x3+A*x3/B)^2)*exp(C1+D1/(273.15+T3))*x3-exp(A*x3^2/(x3+A*(1-x3)/B)^2)*exp(C2+D2/(273.15+T3))*(1-x3);
xdot(12)=P-exp(A*(1-x4^2)/(1-x4+A*x4/B)^2)*exp(C1+D1/(273.15+T4))*x4- exp(A*x4^2/(x4+A*(1-x4)/B)^2)*exp(C2+D2/(273.15+T4))*(1-x4);
xdot(13)=P-exp(A*(1-xB^2)/(1-xB+A*xB/B)^2)*exp(C1+D1/(273.15+TB))*xB- exp(A*xB^2/(xB+A*(1-xB)/B)^2)*exp(C2+D2/(273.15+TB))*(1-xB);
xdot = xdot(:);
else
M = zeros(13,13);
M(1,1) = 1;
M(2,2) = 1;
M(3,3) = 1;
M(4,4) = 1;
M(5,5) = 1;
M(6,6) = 1;
M(7,7) = x(5);
M(8,8) = 1;
xdot = M;
end Now I get a matlab code using ode15s to solve a function with singular Mass. My question is:
what does it mean (there is no function called ‘M’ in my dir)
opts = odeset(‘Mass’, ‘M’, ‘MassSingular’, ‘yes’);
and why in the ode function, there is an extra input called ‘flag’ ?
The main code is as following:
tf = 200;
x0 = [0 0 0 0 2500 0 0.8 0 50 50 50 50 5];
opts = odeset(‘Mass’, ‘M’, ‘MassSingular’, ‘yes’);
[t, x] = ode15s(‘ff’, [0 tf], x0,opts);
function xdot=Methanol_Water(t,x)
if isempty(flag),
P=1;
x1=x(1);
x2=x(2);
x3=x(3);
x4=x(4);
x0=x(6);
xB=x(7);
T1=x(9);
T2=x(10);
T3=x(11);
T4=x(12);
TB=x(13);
D1=-4617.8;
C1=13.676;
D2=-5042.6;
C2=13.519;
A=0.85;
B=0.48;
R=10;
V=10;
Di=V/(R+1);
L=V-Di;
y1=exp(A*(1-x1^2)/(1-x1+A*x1/B)^2)*exp(C1+D1/(273.15+T1))*x1/P;
y2=exp(A*(1-x2^2)/(1-x2+A*x2/B)^2)*exp(C1+D1/(273.15+T2))*x2/P;
y3=exp(A*(1-x3^2)/(1-x3+A*x3/B)^2)*exp(C1+D1/(273.15+T3))*x3/P;
y4=exp(A*(1-x4^2)/(1-x4+A*x4/B)^2)*exp(C1+D1/(273.15+T4))*x4/P;
yB=exp(A*(1-xB^2)/(1-xB+A*xB/B)^2)*exp(C1+D1/(273.15+TB))*xB/P;
MH0=100;
MH=20;
xdot(1)=1/MH*(L*(x0-x1)+V*(y2-y1));
xdot(2)=1/MH*(L*(x1-x2)+V*(y3-y2));
xdot(3)=1/MH*(L*(x2-x3)+V*(y4-y3));
xdot(4)=1/MH*(L*(x3-x4)+V*(yB-y4));
xdot(5)=L-V;
xdot(6)=(V/MH0*y1-(L+Di)/MH0*x0);
xdot(7)=(L*(x4-xB)-V*(yB-xB));
xdot(8)=Di;
xdot(9)=P-exp(A*(1-x1^2)/(1-x1+A*x1/B)^2)*exp(C1+D1/(273.15+T1))*x1-exp(A*x1^2/(x1+A*(1-x1)/B)^2)*exp(C2+D2/(273.15+T1))*(1-x1);
xdot(10)=P-exp(A*(1-x2^2)/(1-x2+A*x2/B)^2)*exp(C1+D1/(273.15+T2))*x2- exp(A*x2^2/(x2+A*(1-x2)/B)^2)*exp(C2+D2/(273.15+T2))*(1-x2);
xdot(11)=P-exp(A*(1-x3^2)/(1-x3+A*x3/B)^2)*exp(C1+D1/(273.15+T3))*x3-exp(A*x3^2/(x3+A*(1-x3)/B)^2)*exp(C2+D2/(273.15+T3))*(1-x3);
xdot(12)=P-exp(A*(1-x4^2)/(1-x4+A*x4/B)^2)*exp(C1+D1/(273.15+T4))*x4- exp(A*x4^2/(x4+A*(1-x4)/B)^2)*exp(C2+D2/(273.15+T4))*(1-x4);
xdot(13)=P-exp(A*(1-xB^2)/(1-xB+A*xB/B)^2)*exp(C1+D1/(273.15+TB))*xB- exp(A*xB^2/(xB+A*(1-xB)/B)^2)*exp(C2+D2/(273.15+TB))*(1-xB);
xdot = xdot(:);
else
M = zeros(13,13);
M(1,1) = 1;
M(2,2) = 1;
M(3,3) = 1;
M(4,4) = 1;
M(5,5) = 1;
M(6,6) = 1;
M(7,7) = x(5);
M(8,8) = 1;
xdot = M;
end ode15s, mass MATLAB Answers — New Questions
Taylor diagram plot method
Hello,
I have to plot taylor diagram in order to compare the results of three models to observations. Could anyone help me how to proceed step by step because I found some solutions in the net but I didn’t understand how it works.
Thanks in advanceHello,
I have to plot taylor diagram in order to compare the results of three models to observations. Could anyone help me how to proceed step by step because I found some solutions in the net but I didn’t understand how it works.
Thanks in advance Hello,
I have to plot taylor diagram in order to compare the results of three models to observations. Could anyone help me how to proceed step by step because I found some solutions in the net but I didn’t understand how it works.
Thanks in advance taylor diagram, comparison, models MATLAB Answers — New Questions
Performance of SystemObject vs Class
Lately, I was introduced to SystemObjects and some of its benefits, for example that one can use them in Matlab as well as in Simulink which is important to me. So I started playing around with SystemObjects and quickly ended up in a scenario where I have a main SystemObject in which I create instances of other SystemObjects which themselves create instances of other SystemObjects. So to say: nested SystemObjects.
Now, for my understanding: If I want to use the main SystemObject only in both Matlab and Simulink then I could replace the other SystemObjects with normal classes. And here comes the question: Would that increase the performance of the generated code?
The reason why I am wondering is the fact that in languages like C++ inheritance from classes with virtual methods cause runtime costs (at least that’s what I understood). I guess in the case of SystemObjects which inherit from the matlab.System class something similar will happen?Lately, I was introduced to SystemObjects and some of its benefits, for example that one can use them in Matlab as well as in Simulink which is important to me. So I started playing around with SystemObjects and quickly ended up in a scenario where I have a main SystemObject in which I create instances of other SystemObjects which themselves create instances of other SystemObjects. So to say: nested SystemObjects.
Now, for my understanding: If I want to use the main SystemObject only in both Matlab and Simulink then I could replace the other SystemObjects with normal classes. And here comes the question: Would that increase the performance of the generated code?
The reason why I am wondering is the fact that in languages like C++ inheritance from classes with virtual methods cause runtime costs (at least that’s what I understood). I guess in the case of SystemObjects which inherit from the matlab.System class something similar will happen? Lately, I was introduced to SystemObjects and some of its benefits, for example that one can use them in Matlab as well as in Simulink which is important to me. So I started playing around with SystemObjects and quickly ended up in a scenario where I have a main SystemObject in which I create instances of other SystemObjects which themselves create instances of other SystemObjects. So to say: nested SystemObjects.
Now, for my understanding: If I want to use the main SystemObject only in both Matlab and Simulink then I could replace the other SystemObjects with normal classes. And here comes the question: Would that increase the performance of the generated code?
The reason why I am wondering is the fact that in languages like C++ inheritance from classes with virtual methods cause runtime costs (at least that’s what I understood). I guess in the case of SystemObjects which inherit from the matlab.System class something similar will happen? performance, systemobject, class, inheritance, matlab.system, code generation MATLAB Answers — New Questions
How to check mixer upconverted output at 2.4GHz?
I am using mixer to upconvert baseband signal of 1-2 MHz to 2.4GHz.
I want to verify this upconverted signal before transmission.
I used ps to simulink block but with that it shows baseband signal only. I would like to know how can I verify that the signal is upconverted to passband signal?I am using mixer to upconvert baseband signal of 1-2 MHz to 2.4GHz.
I want to verify this upconverted signal before transmission.
I used ps to simulink block but with that it shows baseband signal only. I would like to know how can I verify that the signal is upconverted to passband signal? I am using mixer to upconvert baseband signal of 1-2 MHz to 2.4GHz.
I want to verify this upconverted signal before transmission.
I used ps to simulink block but with that it shows baseband signal only. I would like to know how can I verify that the signal is upconverted to passband signal? baseband to passband conversion, mixer, rf MATLAB Answers — New Questions
automation of code for many variables
לק"י
Hi guys,
I got alot of variables due to high amount of samples to analyze. I import csv data from the import tool and then process each variable that was imported.
I want to know, what is the recommended way to run code on several variables and then save the outputs in an ordered way? can you refer me to a page or video that can explain it?
tanks very much!
Amit.לק"י
Hi guys,
I got alot of variables due to high amount of samples to analyze. I import csv data from the import tool and then process each variable that was imported.
I want to know, what is the recommended way to run code on several variables and then save the outputs in an ordered way? can you refer me to a page or video that can explain it?
tanks very much!
Amit. לק"י
Hi guys,
I got alot of variables due to high amount of samples to analyze. I import csv data from the import tool and then process each variable that was imported.
I want to know, what is the recommended way to run code on several variables and then save the outputs in an ordered way? can you refer me to a page or video that can explain it?
tanks very much!
Amit. automation of code, high throughput analysis, automation MATLAB Answers — New Questions