Month: July 2024
Contact angle measurements for droplets with a capillary
Hello everyone
My name is Baraa, I recently started using Matlab (Bigginner), and I need your help in explaining the error I keep making in the following code. The code is supposed to measure the contact angle of a droplet based on defining the edges of the droplet, masking the capillary, dividing the pixels on the edges of the droplet by 2 (so we can have left and right), finding the reflection of each side to define the contact points between the surface and the droplet on each side, and finally connecting the contact points together. The code then fits the pixels to find the tangent and calculates the contact angle between the tangent and the line between the contact points.
The main problem is that the code doesn’t work with all droplets and most of the time I have errors with droplets with high wettability and high volume (the droplets spread on the surface). The error message is as follows:
Index in position 1 exceeds array bounds. Index must not exceed 1113.
Error in findreflection (line 50)
x2=trace(index+n2:index+n-1,2);
Error in contactAngleImageAnalysis (line 104)
[x0L,y0L,indexL]=findreflection([edgeL.x,edgeL.y],70,0); % change the last entry (160) to zero and see what happens
How can I modify the code to make it suitable for any droplet volume?
P.S
The code always fails to read this image (Co-Eth-1, see attached) and it reads probably reads this image (Co-Eth-1b, see attached). Please refer to the two images.
Thank you very much in advance
clc
clear all
close all
addpath(genpath("C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopcodesContact Angle FittingScriptsSubpixel Matlab v2.11"));
addpath(genpath("C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopcodesContact Angle FittingScripts"));
main_path = "C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopIMAGES25.06.24";
output_folder = "C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopsessileDrop_processed";
%these are the coordinates of the polygon to mask the cannula
Xright=3100;%this the X value on the right side of the ploygon and it represents top and bottom if the right side of the polygon.
Xleft=2800;%this is the X value of the left side of the ploygon and it represents both top and bottom x cordinates
Y_top=0;% this is the y value on the top side of the polygon for both left and right side
Y_bottom=2050;% this is the y value of the bottom side of the ploygon for both left and right side
%******************************pixel intensity***************************
pixelValue=255;
%***********************threshold to be used*****************************
trsh_sub=4;
% Read a group of images from a folder
imageFiles = dir(fullfile(main_path, ‘*.png’)); % Assuming images are in PNG format
numImages = input(‘Enter the number of images to work with: ‘);
% Create cell arrays to store data
imageNumbers = zeros(numImages, 1);
CAL_values = zeros(numImages, 1);
CAR_values = zeros(numImages, 1);
for k = 1:numImages
% Load image
filename = imageFiles(k).name;
im_load = fullfile(main_path, filename);
im = imread(im_load);
%—————————————————————–
% Masking the cannula
%—————————————————————–
% Define the coordinates of the four points
maskSize = size(im);
pointCoordinates = [Xleft, Y_bottom; Xright, Y_bottom; Xright, Y_top; Xleft, Y_top];
mask = zeros(maskSize(1), maskSize(2));
mask = poly2mask(pointCoordinates(:, 1), pointCoordinates(:, 2), maskSize(1), maskSize(2));
burnedImage = im;
burnedImage(mask) = pixelValue;
%—————————————————————
% Step 2 Detect boundaries in image
%—————————————————————
[edges, RI] = subpixelEdges(burnedImage, trsh_sub);
im_size=size(burnedImage);
im_size=size(burnedImage);
points = detectHarrisFeatures(burnedImage);
strongest = selectStrongest(points,10);
f2h=figure;
imshow(burnedImage)
hold on
plot(edges.x,edges.y,’r.’,’LineWidth’,2)
% plot(edges.x(1), edges.y(1),’b*’)
% plot(edges.x(im_size(1)),edges.y(im_size(2)),’g*’)
plot(strongest)
set(f2h,’Units’,’normalized’,’Position’,[0.31,0.6,0.3,0.3])
%—————————————————————
% Step 3 Select longes boundary in image
%—————————————————————
longestedge=findlongestedge(edges,size(burnedImage),5);
f3h=figure;
imshow(burnedImage)
hold on
plot(longestedge.x,longestedge.y,’r.’,’LineWidth’,2)
set(f3h,’Units’,’normalized’,’Position’,[0.62,0.6,0.3,0.3])
%—————————————————————
% Step 4 Split edge into left and right and sort it
%—————————————————————
[edgeL,edgeR]=leftrightedges(longestedge);
f4h=figure;
imshow(burnedImage)
hold on
plot(edgeL.x,edgeL.y,’r’,’LineWidth’,2)
plot(edgeR.x,edgeR.y,’b’,’LineWidth’,2)
set(f4h,’Units’,’normalized’,’Position’,[0.0,0.3,0.3,0.3])
%—————————————————————
% Step 5 Find reflection
%—————————————————————
[x0L,y0L,indexL]=findreflection([edgeL.x,edgeL.y],70,0); % change the last entry (160) to zero and see what happens
[x0R,y0R,indexR]=findreflection([edgeR.x,edgeR.y],60,0);
f5h=figure;
imshow(burnedImage)
hold on
plot(edgeL.x,edgeL.y,’r’,’LineWidth’,2)
plot(edgeR.x,edgeR.y,’b’,’LineWidth’,2)
plot(x0L,y0L,’yx’,’MarkerSize’,10,’LineWidth’,2)
plot(x0R,y0R,’yx’,’MarkerSize’,10,’LineWidth’,2)
t=linspace(-3,3);
plot((x0L-x0R)*t+x0R,(y0L-y0R)*t+y0R,’r–‘,’LineWidth’,2)
set(f5h,’Units’,’normalized’,’Position’,[0.31,0.3,0.3,0.3])
%—————————————————————
% Step 6 Fit data to polynomial
%—————————————————————
PolyData=polynomialfit(edgeL,edgeR,[x0L,y0L],[x0R,y0R]);
f6h=figure;
imshow(burnedImage)
hold on
t=linspace(-3,3);
plot((x0L-x0R)*t+x0R,(y0L-y0R)*t+y0R,’r–‘,’LineWidth’,2)
plot(PolyData.EvalPolyL(:,1),PolyData.EvalPolyL(:,2),’r’,’LineWidth’,2)
plot(PolyData.EvalPolyR(:,1),PolyData.EvalPolyR(:,2),’b’,’LineWidth’,2)
radius=500;
tilt=atand((y0R-y0L)/(x0R-x0L));
plot([PolyData.TLL(1),PolyData.TLL(1)+radius*cosd(PolyData.CAL-tilt)],[PolyData.TLL(2),PolyData.TLL(2)-radius*sind(PolyData.CAL-tilt)],’LineWidth’, 2,’color’,’g’)
plot([PolyData.TLR(1),PolyData.TLR(1)-radius*cosd(PolyData.CAR+tilt)],[PolyData.TLR(2),PolyData.TLR(2)-radius*sind(PolyData.CAR+tilt)],’LineWidth’, 2,’color’,’g’)
legend([‘contact angles, CA left= ‘,num2str(PolyData.CAL),’ CA Right= ‘,num2str(PolyData.CAR)])
set(f6h,’Units’,’normalized’,’Position’,[0.62,0.3,0.3,0.3])
display([‘Polynomial fit return the contact angles, CA Left=’,num2str(PolyData.CAL),’ CA Right=’,num2str(PolyData.CAR)])
% % Store data in the table
imageNumbers(k) = k;
CAL_values(k) = PolyData.CAL;
CAR_values(k) = PolyData.CAR;
% Save processed image to a new folder
if ~exist(output_folder, ‘dir’)
mkdir(output_folder);
end
% Save processed image in the specified formats
[~, name, ext] = fileparts(filename);
processed_filename = [name ‘_processed’];
% Check if the filename already exists, if so, append a unique identifier
index = 1;
while exist(fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.jpg’]), ‘file’)
index = index + 1;
end
% Save as JPG
imwrite(burnedImage, fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.jpg’]));
% Save as FIG
saveas(f6h, fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.fig’]));
% Save result to TXT
nsave = fullfile(output_folder, [name, ‘_’, num2str(index), ‘.txt’]);
result_vary = rand(10); % Example data, replace with your actual data
save(nsave, ‘result_vary’, ‘-ASCII’);
disp([‘Processed image saved as: ‘, processed_filename]);
end
% Create table from cell arrays
tableData = table(imageNumbers, CAL_values, CAR_values);
% Save table to a text file
output_filename = fullfile(output_folder, ‘contactAngle_table_data.txt’);
writetable(tableData, output_filename, ‘Delimiter’, ‘t’);
disp([‘Table data saved as: ‘, output_filename]);
% Display the table
disp(tableData);Hello everyone
My name is Baraa, I recently started using Matlab (Bigginner), and I need your help in explaining the error I keep making in the following code. The code is supposed to measure the contact angle of a droplet based on defining the edges of the droplet, masking the capillary, dividing the pixels on the edges of the droplet by 2 (so we can have left and right), finding the reflection of each side to define the contact points between the surface and the droplet on each side, and finally connecting the contact points together. The code then fits the pixels to find the tangent and calculates the contact angle between the tangent and the line between the contact points.
The main problem is that the code doesn’t work with all droplets and most of the time I have errors with droplets with high wettability and high volume (the droplets spread on the surface). The error message is as follows:
Index in position 1 exceeds array bounds. Index must not exceed 1113.
Error in findreflection (line 50)
x2=trace(index+n2:index+n-1,2);
Error in contactAngleImageAnalysis (line 104)
[x0L,y0L,indexL]=findreflection([edgeL.x,edgeL.y],70,0); % change the last entry (160) to zero and see what happens
How can I modify the code to make it suitable for any droplet volume?
P.S
The code always fails to read this image (Co-Eth-1, see attached) and it reads probably reads this image (Co-Eth-1b, see attached). Please refer to the two images.
Thank you very much in advance
clc
clear all
close all
addpath(genpath("C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopcodesContact Angle FittingScriptsSubpixel Matlab v2.11"));
addpath(genpath("C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopcodesContact Angle FittingScripts"));
main_path = "C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopIMAGES25.06.24";
output_folder = "C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopsessileDrop_processed";
%these are the coordinates of the polygon to mask the cannula
Xright=3100;%this the X value on the right side of the ploygon and it represents top and bottom if the right side of the polygon.
Xleft=2800;%this is the X value of the left side of the ploygon and it represents both top and bottom x cordinates
Y_top=0;% this is the y value on the top side of the polygon for both left and right side
Y_bottom=2050;% this is the y value of the bottom side of the ploygon for both left and right side
%******************************pixel intensity***************************
pixelValue=255;
%***********************threshold to be used*****************************
trsh_sub=4;
% Read a group of images from a folder
imageFiles = dir(fullfile(main_path, ‘*.png’)); % Assuming images are in PNG format
numImages = input(‘Enter the number of images to work with: ‘);
% Create cell arrays to store data
imageNumbers = zeros(numImages, 1);
CAL_values = zeros(numImages, 1);
CAR_values = zeros(numImages, 1);
for k = 1:numImages
% Load image
filename = imageFiles(k).name;
im_load = fullfile(main_path, filename);
im = imread(im_load);
%—————————————————————–
% Masking the cannula
%—————————————————————–
% Define the coordinates of the four points
maskSize = size(im);
pointCoordinates = [Xleft, Y_bottom; Xright, Y_bottom; Xright, Y_top; Xleft, Y_top];
mask = zeros(maskSize(1), maskSize(2));
mask = poly2mask(pointCoordinates(:, 1), pointCoordinates(:, 2), maskSize(1), maskSize(2));
burnedImage = im;
burnedImage(mask) = pixelValue;
%—————————————————————
% Step 2 Detect boundaries in image
%—————————————————————
[edges, RI] = subpixelEdges(burnedImage, trsh_sub);
im_size=size(burnedImage);
im_size=size(burnedImage);
points = detectHarrisFeatures(burnedImage);
strongest = selectStrongest(points,10);
f2h=figure;
imshow(burnedImage)
hold on
plot(edges.x,edges.y,’r.’,’LineWidth’,2)
% plot(edges.x(1), edges.y(1),’b*’)
% plot(edges.x(im_size(1)),edges.y(im_size(2)),’g*’)
plot(strongest)
set(f2h,’Units’,’normalized’,’Position’,[0.31,0.6,0.3,0.3])
%—————————————————————
% Step 3 Select longes boundary in image
%—————————————————————
longestedge=findlongestedge(edges,size(burnedImage),5);
f3h=figure;
imshow(burnedImage)
hold on
plot(longestedge.x,longestedge.y,’r.’,’LineWidth’,2)
set(f3h,’Units’,’normalized’,’Position’,[0.62,0.6,0.3,0.3])
%—————————————————————
% Step 4 Split edge into left and right and sort it
%—————————————————————
[edgeL,edgeR]=leftrightedges(longestedge);
f4h=figure;
imshow(burnedImage)
hold on
plot(edgeL.x,edgeL.y,’r’,’LineWidth’,2)
plot(edgeR.x,edgeR.y,’b’,’LineWidth’,2)
set(f4h,’Units’,’normalized’,’Position’,[0.0,0.3,0.3,0.3])
%—————————————————————
% Step 5 Find reflection
%—————————————————————
[x0L,y0L,indexL]=findreflection([edgeL.x,edgeL.y],70,0); % change the last entry (160) to zero and see what happens
[x0R,y0R,indexR]=findreflection([edgeR.x,edgeR.y],60,0);
f5h=figure;
imshow(burnedImage)
hold on
plot(edgeL.x,edgeL.y,’r’,’LineWidth’,2)
plot(edgeR.x,edgeR.y,’b’,’LineWidth’,2)
plot(x0L,y0L,’yx’,’MarkerSize’,10,’LineWidth’,2)
plot(x0R,y0R,’yx’,’MarkerSize’,10,’LineWidth’,2)
t=linspace(-3,3);
plot((x0L-x0R)*t+x0R,(y0L-y0R)*t+y0R,’r–‘,’LineWidth’,2)
set(f5h,’Units’,’normalized’,’Position’,[0.31,0.3,0.3,0.3])
%—————————————————————
% Step 6 Fit data to polynomial
%—————————————————————
PolyData=polynomialfit(edgeL,edgeR,[x0L,y0L],[x0R,y0R]);
f6h=figure;
imshow(burnedImage)
hold on
t=linspace(-3,3);
plot((x0L-x0R)*t+x0R,(y0L-y0R)*t+y0R,’r–‘,’LineWidth’,2)
plot(PolyData.EvalPolyL(:,1),PolyData.EvalPolyL(:,2),’r’,’LineWidth’,2)
plot(PolyData.EvalPolyR(:,1),PolyData.EvalPolyR(:,2),’b’,’LineWidth’,2)
radius=500;
tilt=atand((y0R-y0L)/(x0R-x0L));
plot([PolyData.TLL(1),PolyData.TLL(1)+radius*cosd(PolyData.CAL-tilt)],[PolyData.TLL(2),PolyData.TLL(2)-radius*sind(PolyData.CAL-tilt)],’LineWidth’, 2,’color’,’g’)
plot([PolyData.TLR(1),PolyData.TLR(1)-radius*cosd(PolyData.CAR+tilt)],[PolyData.TLR(2),PolyData.TLR(2)-radius*sind(PolyData.CAR+tilt)],’LineWidth’, 2,’color’,’g’)
legend([‘contact angles, CA left= ‘,num2str(PolyData.CAL),’ CA Right= ‘,num2str(PolyData.CAR)])
set(f6h,’Units’,’normalized’,’Position’,[0.62,0.3,0.3,0.3])
display([‘Polynomial fit return the contact angles, CA Left=’,num2str(PolyData.CAL),’ CA Right=’,num2str(PolyData.CAR)])
% % Store data in the table
imageNumbers(k) = k;
CAL_values(k) = PolyData.CAL;
CAR_values(k) = PolyData.CAR;
% Save processed image to a new folder
if ~exist(output_folder, ‘dir’)
mkdir(output_folder);
end
% Save processed image in the specified formats
[~, name, ext] = fileparts(filename);
processed_filename = [name ‘_processed’];
% Check if the filename already exists, if so, append a unique identifier
index = 1;
while exist(fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.jpg’]), ‘file’)
index = index + 1;
end
% Save as JPG
imwrite(burnedImage, fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.jpg’]));
% Save as FIG
saveas(f6h, fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.fig’]));
% Save result to TXT
nsave = fullfile(output_folder, [name, ‘_’, num2str(index), ‘.txt’]);
result_vary = rand(10); % Example data, replace with your actual data
save(nsave, ‘result_vary’, ‘-ASCII’);
disp([‘Processed image saved as: ‘, processed_filename]);
end
% Create table from cell arrays
tableData = table(imageNumbers, CAL_values, CAR_values);
% Save table to a text file
output_filename = fullfile(output_folder, ‘contactAngle_table_data.txt’);
writetable(tableData, output_filename, ‘Delimiter’, ‘t’);
disp([‘Table data saved as: ‘, output_filename]);
% Display the table
disp(tableData); Hello everyone
My name is Baraa, I recently started using Matlab (Bigginner), and I need your help in explaining the error I keep making in the following code. The code is supposed to measure the contact angle of a droplet based on defining the edges of the droplet, masking the capillary, dividing the pixels on the edges of the droplet by 2 (so we can have left and right), finding the reflection of each side to define the contact points between the surface and the droplet on each side, and finally connecting the contact points together. The code then fits the pixels to find the tangent and calculates the contact angle between the tangent and the line between the contact points.
The main problem is that the code doesn’t work with all droplets and most of the time I have errors with droplets with high wettability and high volume (the droplets spread on the surface). The error message is as follows:
Index in position 1 exceeds array bounds. Index must not exceed 1113.
Error in findreflection (line 50)
x2=trace(index+n2:index+n-1,2);
Error in contactAngleImageAnalysis (line 104)
[x0L,y0L,indexL]=findreflection([edgeL.x,edgeL.y],70,0); % change the last entry (160) to zero and see what happens
How can I modify the code to make it suitable for any droplet volume?
P.S
The code always fails to read this image (Co-Eth-1, see attached) and it reads probably reads this image (Co-Eth-1b, see attached). Please refer to the two images.
Thank you very much in advance
clc
clear all
close all
addpath(genpath("C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopcodesContact Angle FittingScriptsSubpixel Matlab v2.11"));
addpath(genpath("C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopcodesContact Angle FittingScripts"));
main_path = "C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopIMAGES25.06.24";
output_folder = "C:UsersBara’a Al-khateebDesktopOthersStudentsGideon MensahLaptopsessileDrop_processed";
%these are the coordinates of the polygon to mask the cannula
Xright=3100;%this the X value on the right side of the ploygon and it represents top and bottom if the right side of the polygon.
Xleft=2800;%this is the X value of the left side of the ploygon and it represents both top and bottom x cordinates
Y_top=0;% this is the y value on the top side of the polygon for both left and right side
Y_bottom=2050;% this is the y value of the bottom side of the ploygon for both left and right side
%******************************pixel intensity***************************
pixelValue=255;
%***********************threshold to be used*****************************
trsh_sub=4;
% Read a group of images from a folder
imageFiles = dir(fullfile(main_path, ‘*.png’)); % Assuming images are in PNG format
numImages = input(‘Enter the number of images to work with: ‘);
% Create cell arrays to store data
imageNumbers = zeros(numImages, 1);
CAL_values = zeros(numImages, 1);
CAR_values = zeros(numImages, 1);
for k = 1:numImages
% Load image
filename = imageFiles(k).name;
im_load = fullfile(main_path, filename);
im = imread(im_load);
%—————————————————————–
% Masking the cannula
%—————————————————————–
% Define the coordinates of the four points
maskSize = size(im);
pointCoordinates = [Xleft, Y_bottom; Xright, Y_bottom; Xright, Y_top; Xleft, Y_top];
mask = zeros(maskSize(1), maskSize(2));
mask = poly2mask(pointCoordinates(:, 1), pointCoordinates(:, 2), maskSize(1), maskSize(2));
burnedImage = im;
burnedImage(mask) = pixelValue;
%—————————————————————
% Step 2 Detect boundaries in image
%—————————————————————
[edges, RI] = subpixelEdges(burnedImage, trsh_sub);
im_size=size(burnedImage);
im_size=size(burnedImage);
points = detectHarrisFeatures(burnedImage);
strongest = selectStrongest(points,10);
f2h=figure;
imshow(burnedImage)
hold on
plot(edges.x,edges.y,’r.’,’LineWidth’,2)
% plot(edges.x(1), edges.y(1),’b*’)
% plot(edges.x(im_size(1)),edges.y(im_size(2)),’g*’)
plot(strongest)
set(f2h,’Units’,’normalized’,’Position’,[0.31,0.6,0.3,0.3])
%—————————————————————
% Step 3 Select longes boundary in image
%—————————————————————
longestedge=findlongestedge(edges,size(burnedImage),5);
f3h=figure;
imshow(burnedImage)
hold on
plot(longestedge.x,longestedge.y,’r.’,’LineWidth’,2)
set(f3h,’Units’,’normalized’,’Position’,[0.62,0.6,0.3,0.3])
%—————————————————————
% Step 4 Split edge into left and right and sort it
%—————————————————————
[edgeL,edgeR]=leftrightedges(longestedge);
f4h=figure;
imshow(burnedImage)
hold on
plot(edgeL.x,edgeL.y,’r’,’LineWidth’,2)
plot(edgeR.x,edgeR.y,’b’,’LineWidth’,2)
set(f4h,’Units’,’normalized’,’Position’,[0.0,0.3,0.3,0.3])
%—————————————————————
% Step 5 Find reflection
%—————————————————————
[x0L,y0L,indexL]=findreflection([edgeL.x,edgeL.y],70,0); % change the last entry (160) to zero and see what happens
[x0R,y0R,indexR]=findreflection([edgeR.x,edgeR.y],60,0);
f5h=figure;
imshow(burnedImage)
hold on
plot(edgeL.x,edgeL.y,’r’,’LineWidth’,2)
plot(edgeR.x,edgeR.y,’b’,’LineWidth’,2)
plot(x0L,y0L,’yx’,’MarkerSize’,10,’LineWidth’,2)
plot(x0R,y0R,’yx’,’MarkerSize’,10,’LineWidth’,2)
t=linspace(-3,3);
plot((x0L-x0R)*t+x0R,(y0L-y0R)*t+y0R,’r–‘,’LineWidth’,2)
set(f5h,’Units’,’normalized’,’Position’,[0.31,0.3,0.3,0.3])
%—————————————————————
% Step 6 Fit data to polynomial
%—————————————————————
PolyData=polynomialfit(edgeL,edgeR,[x0L,y0L],[x0R,y0R]);
f6h=figure;
imshow(burnedImage)
hold on
t=linspace(-3,3);
plot((x0L-x0R)*t+x0R,(y0L-y0R)*t+y0R,’r–‘,’LineWidth’,2)
plot(PolyData.EvalPolyL(:,1),PolyData.EvalPolyL(:,2),’r’,’LineWidth’,2)
plot(PolyData.EvalPolyR(:,1),PolyData.EvalPolyR(:,2),’b’,’LineWidth’,2)
radius=500;
tilt=atand((y0R-y0L)/(x0R-x0L));
plot([PolyData.TLL(1),PolyData.TLL(1)+radius*cosd(PolyData.CAL-tilt)],[PolyData.TLL(2),PolyData.TLL(2)-radius*sind(PolyData.CAL-tilt)],’LineWidth’, 2,’color’,’g’)
plot([PolyData.TLR(1),PolyData.TLR(1)-radius*cosd(PolyData.CAR+tilt)],[PolyData.TLR(2),PolyData.TLR(2)-radius*sind(PolyData.CAR+tilt)],’LineWidth’, 2,’color’,’g’)
legend([‘contact angles, CA left= ‘,num2str(PolyData.CAL),’ CA Right= ‘,num2str(PolyData.CAR)])
set(f6h,’Units’,’normalized’,’Position’,[0.62,0.3,0.3,0.3])
display([‘Polynomial fit return the contact angles, CA Left=’,num2str(PolyData.CAL),’ CA Right=’,num2str(PolyData.CAR)])
% % Store data in the table
imageNumbers(k) = k;
CAL_values(k) = PolyData.CAL;
CAR_values(k) = PolyData.CAR;
% Save processed image to a new folder
if ~exist(output_folder, ‘dir’)
mkdir(output_folder);
end
% Save processed image in the specified formats
[~, name, ext] = fileparts(filename);
processed_filename = [name ‘_processed’];
% Check if the filename already exists, if so, append a unique identifier
index = 1;
while exist(fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.jpg’]), ‘file’)
index = index + 1;
end
% Save as JPG
imwrite(burnedImage, fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.jpg’]));
% Save as FIG
saveas(f6h, fullfile(output_folder, [processed_filename, ‘_’, num2str(index), ‘.fig’]));
% Save result to TXT
nsave = fullfile(output_folder, [name, ‘_’, num2str(index), ‘.txt’]);
result_vary = rand(10); % Example data, replace with your actual data
save(nsave, ‘result_vary’, ‘-ASCII’);
disp([‘Processed image saved as: ‘, processed_filename]);
end
% Create table from cell arrays
tableData = table(imageNumbers, CAL_values, CAR_values);
% Save table to a text file
output_filename = fullfile(output_folder, ‘contactAngle_table_data.txt’);
writetable(tableData, output_filename, ‘Delimiter’, ‘t’);
disp([‘Table data saved as: ‘, output_filename]);
% Display the table
disp(tableData); droplet, wettability, contact angle MATLAB Answers — New Questions
How can I express all the variables Vcm1, Vcm2, Vcm3, Vcm4 in num2str without getting an error?
annotation(‘textbox’,dim,’String’,((num2str(Vcm1),num2str(Vcm2),num2str(Vcm3),num2str(Vcm4)), ‘FontSize’;15)annotation(‘textbox’,dim,’String’,((num2str(Vcm1),num2str(Vcm2),num2str(Vcm3),num2str(Vcm4)), ‘FontSize’;15) annotation(‘textbox’,dim,’String’,((num2str(Vcm1),num2str(Vcm2),num2str(Vcm3),num2str(Vcm4)), ‘FontSize’;15) num2str MATLAB Answers — New Questions
calculated columns
Hello. I would like to know if sharepoint calculated columns can reference a previous element of that same column or another. In Excel, for example, I can make a formula that is B11=B10+A10.
But in a sharepoint list the column name is referenced to calculate something.
Thanks in advance
Hello. I would like to know if sharepoint calculated columns can reference a previous element of that same column or another. In Excel, for example, I can make a formula that is B11=B10+A10.
But in a sharepoint list the column name is referenced to calculate something.
Thanks in advance Read More
hotmail accounts
I am using e mail with my 2 hotmail accounts on my Apple i phone SE. Recently I have been unable to send mail getting a message saying that account passwords are incorrect. I’m wondering if this is anything related to the message I received from MS about third party platforms. I have read this message several times but am baffled by the jargon.
I am using e mail with my 2 hotmail accounts on my Apple i phone SE. Recently I have been unable to send mail getting a message saying that account passwords are incorrect. I’m wondering if this is anything related to the message I received from MS about third party platforms. I have read this message several times but am baffled by the jargon. Read More
How do I “auto populate” a field on Access Forms
When I select the drop-down menu under ‘Proto category’ I need to have ‘ category time’ auto-populate against what info it has. For example, they both share one table. One scenario would be ‘if the proto category is T1 then the category time is 3 hours’. My table has each row as to what it needs to be per category.
When I select the drop-down menu under ‘Proto category’ I need to have ‘ category time’ auto-populate against what info it has. For example, they both share one table. One scenario would be ‘if the proto category is T1 then the category time is 3 hours’. My table has each row as to what it needs to be per category. Read More
Date formatting
Hi
I need a formula that turns this value 20060323 (YYYMMDD) into a short date – 23/03/2006 (DD/MM/YYY)
I have had a google and a look on this messageboard but I haven’t had much luck.
Thank you
Hi I need a formula that turns this value 20060323 (YYYMMDD) into a short date – 23/03/2006 (DD/MM/YYY) I have had a google and a look on this messageboard but I haven’t had much luck. Thank you Read More
Displaying most recent value in a horizontal array?
Hi,
I have an array full of prices and 1 date column. I need to display the most recent value of each row’s array that are all equal to today’s date. I plan to sum all the numbers eventually.
Ex:
TODAY’S DATE: July 4th 2024
18-May$63.00$86.00
04-Jul$134.00$34.00$50.00 04-Jul$25.00
Output:
78
50
25
(Summed up this would be 153)
Thanks in advance!
Hi,I have an array full of prices and 1 date column. I need to display the most recent value of each row’s array that are all equal to today’s date. I plan to sum all the numbers eventually.Ex:TODAY’S DATE: July 4th 202404-Jul$14.00$45.00 78.0018-May$63.00$86.00$92.00 04-Jul$134.00$34.00$50.00 04-Jul$25.00 Output:785025(Summed up this would be 153)Thanks in advance! Read More
plotting Graph in 3D help
function basic
K=0.2; n=0.3; lam=0.1;
%Defining parameters
sol1 = bvpinit(linspace(0,6,300),[0 0 0 0 0]);
sol = bvp4c(@bvp2D, @bc2D, sol1);
x = sol.x;
y = sol.y;
%%% Plotting of the velocity
figure (1)
plot(x, y(2, 🙂 ,’linewidth’, 1.5);
hold on
xlabel(‘eta’, ‘fontweight’, ‘bold’, ‘fontsize’, 16)
ylabel(‘f^{prime}(eta)’, ‘fontweight’, ‘bold’, ‘fontsize’, 16)
%% Residual of the boundary conditions
function residual = bc2D(y0, yinf)
residual=[y0(1); y0(2) – 1; y0(4)+n*y0(3); yinf(2)-lam; yinf(4)];
end
%% System of First Order ODEs
function yvector = bvp2D(~,y)
yy1 =(1/(1+K))*(-y(1)*y(3)+y(2)^2-K*y(5)-lam^2);
yy2 =(2/(2+K))*(-y(1)*y(5)+y(2)*y(4)+K*(2*y(4)+y(3)));
yvector = [y(2);y(3);yy1; y(5); yy2];
end
end
i want to plot this graph in 3D, how can I?function basic
K=0.2; n=0.3; lam=0.1;
%Defining parameters
sol1 = bvpinit(linspace(0,6,300),[0 0 0 0 0]);
sol = bvp4c(@bvp2D, @bc2D, sol1);
x = sol.x;
y = sol.y;
%%% Plotting of the velocity
figure (1)
plot(x, y(2, 🙂 ,’linewidth’, 1.5);
hold on
xlabel(‘eta’, ‘fontweight’, ‘bold’, ‘fontsize’, 16)
ylabel(‘f^{prime}(eta)’, ‘fontweight’, ‘bold’, ‘fontsize’, 16)
%% Residual of the boundary conditions
function residual = bc2D(y0, yinf)
residual=[y0(1); y0(2) – 1; y0(4)+n*y0(3); yinf(2)-lam; yinf(4)];
end
%% System of First Order ODEs
function yvector = bvp2D(~,y)
yy1 =(1/(1+K))*(-y(1)*y(3)+y(2)^2-K*y(5)-lam^2);
yy2 =(2/(2+K))*(-y(1)*y(5)+y(2)*y(4)+K*(2*y(4)+y(3)));
yvector = [y(2);y(3);yy1; y(5); yy2];
end
end
i want to plot this graph in 3D, how can I? function basic
K=0.2; n=0.3; lam=0.1;
%Defining parameters
sol1 = bvpinit(linspace(0,6,300),[0 0 0 0 0]);
sol = bvp4c(@bvp2D, @bc2D, sol1);
x = sol.x;
y = sol.y;
%%% Plotting of the velocity
figure (1)
plot(x, y(2, 🙂 ,’linewidth’, 1.5);
hold on
xlabel(‘eta’, ‘fontweight’, ‘bold’, ‘fontsize’, 16)
ylabel(‘f^{prime}(eta)’, ‘fontweight’, ‘bold’, ‘fontsize’, 16)
%% Residual of the boundary conditions
function residual = bc2D(y0, yinf)
residual=[y0(1); y0(2) – 1; y0(4)+n*y0(3); yinf(2)-lam; yinf(4)];
end
%% System of First Order ODEs
function yvector = bvp2D(~,y)
yy1 =(1/(1+K))*(-y(1)*y(3)+y(2)^2-K*y(5)-lam^2);
yy2 =(2/(2+K))*(-y(1)*y(5)+y(2)*y(4)+K*(2*y(4)+y(3)));
yvector = [y(2);y(3);yy1; y(5); yy2];
end
end
i want to plot this graph in 3D, how can I? bvp4c, 2d plotting, 3d plotting MATLAB Answers — New Questions
What is Mathworks Service Host?
I’m running Matlab 2023b on Ubuntu.
I’m just curious what this process is that’s been put in .config/autostart//mathworks-service-host.desktop to start at login?
Matlab starts fine without it but when I close Matlab, a process namber MathworksServiceHost keeps running.
It’s not a nice idea of having matlab-related processes running on the system after the application has been shut down. I have not noticed it on other version of Matlab. At least you should notify the user that a process is added to the autostart folder, and what it does.I’m running Matlab 2023b on Ubuntu.
I’m just curious what this process is that’s been put in .config/autostart//mathworks-service-host.desktop to start at login?
Matlab starts fine without it but when I close Matlab, a process namber MathworksServiceHost keeps running.
It’s not a nice idea of having matlab-related processes running on the system after the application has been shut down. I have not noticed it on other version of Matlab. At least you should notify the user that a process is added to the autostart folder, and what it does. I’m running Matlab 2023b on Ubuntu.
I’m just curious what this process is that’s been put in .config/autostart//mathworks-service-host.desktop to start at login?
Matlab starts fine without it but when I close Matlab, a process namber MathworksServiceHost keeps running.
It’s not a nice idea of having matlab-related processes running on the system after the application has been shut down. I have not noticed it on other version of Matlab. At least you should notify the user that a process is added to the autostart folder, and what it does. autostart, mathworksservicehost MATLAB Answers — New Questions
How to determine sampling frequency of wgn?
Hello there,
I’m trying to understand noise analysis and the concept of power spectral density. I’ve found this article:
https://pure.mpg.de/pubman/faces/ViewItemOverviewPage.jsp?itemId=item_152164
Which was really helpful and interesting, but I’ve encountered some problems while trying to put it in practise.
For convenience I wanted to generate white noise (mainly because of its flat spectral density) via wgn funtion and then calculate its PSD. If i understood it correctly, wgn creates discrete samples, which completely lack any relatationship to time.
And here comes my problem – while normalizing the results, equivalent noise bandwidth is dependent on sampling rate and so is PSD:
,
where w are window function values, S are complex results from fft function.
By experimenting with code I came upon sampling rate of 2 samples/s, when mean power of PSD was getting close to 5 dB. Unfortunatelly, I still cannot confidently explain this.
Is there please any way to obtain "realistic" white noise samples in MATLAB? Or do I have to add white noise to (co)sine signal with known sampling? If I’m missing something, please let me know.
Thank you in advance,
Jan
CODE:
% Size parameters
L = pow2(16);
iterations = 100;
% ??? (Guessed value)
fs = 2;
% Frequency resolution
f_res = fs/L;
% Create noise with power of 5 dBW
data = wgn(L,iterations, 5);
% Apply Hann window
h = hann(L);
w = ones(L,iterations) .* h;
data = data .* w;
% Calculate normalizing factor S2
S2 = sum(h.^2);
% Calculate fft
S = fft(data,L,1);
S = S .* conj(S);
% Average power spectrum
for i = 1:L
PSD(i) = mean(S(i,:));
end
% Normalize results
PSD = 2 * PSD / (fs * S2);
% Discard symmectric part
PSD = PSD(1:(L/2+1));
% PSD in dB(W)
PSD = 10*log10(PSD);
% Mean value of PSD
display("Power = " + mean(PSD) + " dB");
% Calculate frequency
f = (0:(L/2)) * f_res;
% Plot data
figure
plot(f,PSD)
xlabel("f [Hz]")
ylabel("PSD [dB/Hz]")Hello there,
I’m trying to understand noise analysis and the concept of power spectral density. I’ve found this article:
https://pure.mpg.de/pubman/faces/ViewItemOverviewPage.jsp?itemId=item_152164
Which was really helpful and interesting, but I’ve encountered some problems while trying to put it in practise.
For convenience I wanted to generate white noise (mainly because of its flat spectral density) via wgn funtion and then calculate its PSD. If i understood it correctly, wgn creates discrete samples, which completely lack any relatationship to time.
And here comes my problem – while normalizing the results, equivalent noise bandwidth is dependent on sampling rate and so is PSD:
,
where w are window function values, S are complex results from fft function.
By experimenting with code I came upon sampling rate of 2 samples/s, when mean power of PSD was getting close to 5 dB. Unfortunatelly, I still cannot confidently explain this.
Is there please any way to obtain "realistic" white noise samples in MATLAB? Or do I have to add white noise to (co)sine signal with known sampling? If I’m missing something, please let me know.
Thank you in advance,
Jan
CODE:
% Size parameters
L = pow2(16);
iterations = 100;
% ??? (Guessed value)
fs = 2;
% Frequency resolution
f_res = fs/L;
% Create noise with power of 5 dBW
data = wgn(L,iterations, 5);
% Apply Hann window
h = hann(L);
w = ones(L,iterations) .* h;
data = data .* w;
% Calculate normalizing factor S2
S2 = sum(h.^2);
% Calculate fft
S = fft(data,L,1);
S = S .* conj(S);
% Average power spectrum
for i = 1:L
PSD(i) = mean(S(i,:));
end
% Normalize results
PSD = 2 * PSD / (fs * S2);
% Discard symmectric part
PSD = PSD(1:(L/2+1));
% PSD in dB(W)
PSD = 10*log10(PSD);
% Mean value of PSD
display("Power = " + mean(PSD) + " dB");
% Calculate frequency
f = (0:(L/2)) * f_res;
% Plot data
figure
plot(f,PSD)
xlabel("f [Hz]")
ylabel("PSD [dB/Hz]") Hello there,
I’m trying to understand noise analysis and the concept of power spectral density. I’ve found this article:
https://pure.mpg.de/pubman/faces/ViewItemOverviewPage.jsp?itemId=item_152164
Which was really helpful and interesting, but I’ve encountered some problems while trying to put it in practise.
For convenience I wanted to generate white noise (mainly because of its flat spectral density) via wgn funtion and then calculate its PSD. If i understood it correctly, wgn creates discrete samples, which completely lack any relatationship to time.
And here comes my problem – while normalizing the results, equivalent noise bandwidth is dependent on sampling rate and so is PSD:
,
where w are window function values, S are complex results from fft function.
By experimenting with code I came upon sampling rate of 2 samples/s, when mean power of PSD was getting close to 5 dB. Unfortunatelly, I still cannot confidently explain this.
Is there please any way to obtain "realistic" white noise samples in MATLAB? Or do I have to add white noise to (co)sine signal with known sampling? If I’m missing something, please let me know.
Thank you in advance,
Jan
CODE:
% Size parameters
L = pow2(16);
iterations = 100;
% ??? (Guessed value)
fs = 2;
% Frequency resolution
f_res = fs/L;
% Create noise with power of 5 dBW
data = wgn(L,iterations, 5);
% Apply Hann window
h = hann(L);
w = ones(L,iterations) .* h;
data = data .* w;
% Calculate normalizing factor S2
S2 = sum(h.^2);
% Calculate fft
S = fft(data,L,1);
S = S .* conj(S);
% Average power spectrum
for i = 1:L
PSD(i) = mean(S(i,:));
end
% Normalize results
PSD = 2 * PSD / (fs * S2);
% Discard symmectric part
PSD = PSD(1:(L/2+1));
% PSD in dB(W)
PSD = 10*log10(PSD);
% Mean value of PSD
display("Power = " + mean(PSD) + " dB");
% Calculate frequency
f = (0:(L/2)) * f_res;
% Plot data
figure
plot(f,PSD)
xlabel("f [Hz]")
ylabel("PSD [dB/Hz]") psd, noise analysis, white noise, wgn, noise, matlab MATLAB Answers — New Questions
File Explorer windows pops up out of nowhere
Since a day or so, at seemingly random moments a File Explorer window pops up in front of everything. This started to happen shortly after I had installed ExplorerPatcher. I am 100% positive that it never happened before, I would have remembered.
This post You’re Not Alone: Windows 11 Is Randomly Opening File Explorer says that this is a Windows 11 issue (which seems unlikely to me as I never saw it before installing EP), and that it does not create a new window but only brings an existing window to the foreground (which is pertinently untrue, it does create a new file explorer window). Some further investigation suggests that it happens when an application that was using full screen switches back to normal display (at least that is how I can reliably reproduce it).
It is not a big deal but it’s annoying, and somewhat spoils my joy in having discovered ExplorerPatcher. Any ideas out there ?
Since a day or so, at seemingly random moments a File Explorer window pops up in front of everything. This started to happen shortly after I had installed ExplorerPatcher. I am 100% positive that it never happened before, I would have remembered. This post You’re Not Alone: Windows 11 Is Randomly Opening File Explorer says that this is a Windows 11 issue (which seems unlikely to me as I never saw it before installing EP), and that it does not create a new window but only brings an existing window to the foreground (which is pertinently untrue, it does create a new file explorer window). Some further investigation suggests that it happens when an application that was using full screen switches back to normal display (at least that is how I can reliably reproduce it). It is not a big deal but it’s annoying, and somewhat spoils my joy in having discovered ExplorerPatcher. Any ideas out there ? Read More
Microsoft Project for the web API
Hello community, I need to work with MS Project for web over api, CRUD projects, CRUD tasks and etc from https://project.microsoft.com/ with using an API.
I searched and couldn’t find any documentation or SDK to do it.
Only one page from offecial source about API here https://learn.microsoft.com/en-us/project-for-the-web/projectforweb-admin-home
that point to https://devblogs.microsoft.com/microsoft365dev/tag/project/
The both links without any API description for Project for the web.
Is there any documentation for an API to integrate with Project for the web?
Thank you
Hello community, I need to work with MS Project for web over api, CRUD projects, CRUD tasks and etc from https://project.microsoft.com/ with using an API. I searched and couldn’t find any documentation or SDK to do it.Only one page from offecial source about API here https://learn.microsoft.com/en-us/project-for-the-web/projectforweb-admin-homethat point to https://devblogs.microsoft.com/microsoft365dev/tag/project/The both links without any API description for Project for the web. Is there any documentation for an API to integrate with Project for the web?Thank you Read More
Here’s what I get when I want to check my operating system build:
Here’s what I get when I want to check my operating system build:
Here’s what I get when I want to check my operating system build:Well actually it is so very tiny and almost unreadable. I can’t figure out how to get the font large enough that I can read it. Read More
Neew outlook
Yesterday New Outlook started asking for a password for I IMAP account email address removed for privacy reasons.
It never did this before and I have no password. can no longer read my email.
Yesterday New Outlook started asking for a password for I IMAP account email address removed for privacy reasons. It never did this before and I have no password. can no longer read my email. Read More
where is my free space on a drive going
I have a redundant storage backup system which consists of a source drive which is copied and synced to 3 other drives of the same size. The source drive and 2 copy drives are the same exact drive brand/model and size, the 3rd drive is a portable SeaGate drive with the same size as the other drives, 2 TB.
I use GoodSync to copy the files in the source drive to each backup drive so according to GoodSync it copies left to right and deletes any files on the storage drives that has changed on the source. For some reason the source drive says I have 1.34 TB of free Space, on the 3 copy drives it say 1.27 TB free space. I can’t see or find any differences.
It’s not that I need the free space, I have plenty and I know my storage system is overkill but it is how I want it.
I just don’t understand why the source drive has 1.34 TB free space and the 3 drives that should have an exact copy of the source dive has 1.27 TB free space.
Is there a best program that would let me look and see any differences on each drive?
I have a redundant storage backup system which consists of a source drive which is copied and synced to 3 other drives of the same size. The source drive and 2 copy drives are the same exact drive brand/model and size, the 3rd drive is a portable SeaGate drive with the same size as the other drives, 2 TB.I use GoodSync to copy the files in the source drive to each backup drive so according to GoodSync it copies left to right and deletes any files on the storage drives that has changed on the source. For some reason the source drive says I have 1.34 TB of free Space, on the 3 copy drives it say 1.27 TB free space. I can’t see or find any differences. It’s not that I need the free space, I have plenty and I know my storage system is overkill but it is how I want it. I just don’t understand why the source drive has 1.34 TB free space and the 3 drives that should have an exact copy of the source dive has 1.27 TB free space. Is there a best program that would let me look and see any differences on each drive? Read More
Two Crashes, Repaired, Crash
Winver 22H2 (OS Build 22631.3085)
Yesterday morning, computer greeted me by saying it had crashed. I restarted it with no problems, so spent some time computing. When I came back, computer had crashed again, so I ran sfc /scannow and DISM repairs; both programs reported having found and fixed difficulties.
I computed off and on for the rest of the day, but was again greeted this morning by another crash notification. I promptly reran yesterday’s problem seekers, neither of which having found any discrepancies. All has been well for some four hours.
What ought I to do to find anything that neither sfc nor DISM found this morn?
Winver 22H2 (OS Build 22631.3085) Yesterday morning, computer greeted me by saying it had crashed. I restarted it with no problems, so spent some time computing. When I came back, computer had crashed again, so I ran sfc /scannow and DISM repairs; both programs reported having found and fixed difficulties. I computed off and on for the rest of the day, but was again greeted this morning by another crash notification. I promptly reran yesterday’s problem seekers, neither of which having found any discrepancies. All has been well for some four hours. What ought I to do to find anything that neither sfc nor DISM found this morn? Read More
Computer is shutting down by itself
My computer is doing some random shutdowns, after some long gaming sessions on when games are alt tabbed.
It happened one time yesterday and one today, the computer shutdown it doesn’t try to restart.
Seems like a force shutdown command is being executed.
On event viewer the only error event is an ID 6008. But there is no weird stuff happening before it.
I also downgraded my AMD driver thinking that could be the culprit but it did not solved the issue.
My computer is doing some random shutdowns, after some long gaming sessions on when games are alt tabbed.It happened one time yesterday and one today, the computer shutdown it doesn’t try to restart.Seems like a force shutdown command is being executed.On event viewer the only error event is an ID 6008. But there is no weird stuff happening before it.I also downgraded my AMD driver thinking that could be the culprit but it did not solved the issue. Read More
Slow (old) Windows context menu for several media files, but not all media file types.
Using the old context menu in Windows 11, or Nilessoft Shell, I experience the context menu to be slow for media files like mp3, mp4, mkv, mpg etc. But not all media, like aiff, that is instant. Changing a mp4 to .aiff, and the menu in instant.
Any idea how to solve this?
Using the old context menu in Windows 11, or Nilessoft Shell, I experience the context menu to be slow for media files like mp3, mp4, mkv, mpg etc. But not all media, like aiff, that is instant. Changing a mp4 to .aiff, and the menu in instant. Any idea how to solve this? Read More