Category: Matlab
Category Archives: Matlab
How to achieve better edge enhancement?
Any suggestion how to enhance the image edges clearly?
I = imread(‘317.jpg’);
% A = rgb2gray(I2);
figure;
imshow(I)
title(‘Original Image’)
%%
% Gaussian LPF
F = fspecial(‘gaussian’);
G = imfilter(I,F);
figure(‘Name’, ‘Gaussian Blur’), imshow(G); title(‘G Image’);
%% Threshold
bw = im2bw(G,0.35);
figure(‘Name’, ‘Binary Image’)
imshow(bw)
% Enhance binary image
kernel = -1*ones(1);
kernel(2,2) = 4;
enhancedImage = imfilter(bw, kernel);
figure(‘Name’, ‘Enhanced’), imshow(enhancedImage); title(‘enhancedImage Image’);
% Crop
D = im2uint8(enhancedImage);
I2 = imcrop(D,[50 68 130 112]);
figure(‘Name’, ‘Cropped’);
imshow(I2)
% User define ROI
r = drawrectangle;
mask = createMask(r);
bw2 = activecontour(I2,mask,30,’Chan-Vese’);
figure(‘Name’, ‘Active Contour’)
imshow(bw2);
hold on;
visboundaries(bw2,’Color’,’r’);
figure(‘Name’, ‘labelOverlay’)
imshow(labeloverlay(I2,bw2));Any suggestion how to enhance the image edges clearly?
I = imread(‘317.jpg’);
% A = rgb2gray(I2);
figure;
imshow(I)
title(‘Original Image’)
%%
% Gaussian LPF
F = fspecial(‘gaussian’);
G = imfilter(I,F);
figure(‘Name’, ‘Gaussian Blur’), imshow(G); title(‘G Image’);
%% Threshold
bw = im2bw(G,0.35);
figure(‘Name’, ‘Binary Image’)
imshow(bw)
% Enhance binary image
kernel = -1*ones(1);
kernel(2,2) = 4;
enhancedImage = imfilter(bw, kernel);
figure(‘Name’, ‘Enhanced’), imshow(enhancedImage); title(‘enhancedImage Image’);
% Crop
D = im2uint8(enhancedImage);
I2 = imcrop(D,[50 68 130 112]);
figure(‘Name’, ‘Cropped’);
imshow(I2)
% User define ROI
r = drawrectangle;
mask = createMask(r);
bw2 = activecontour(I2,mask,30,’Chan-Vese’);
figure(‘Name’, ‘Active Contour’)
imshow(bw2);
hold on;
visboundaries(bw2,’Color’,’r’);
figure(‘Name’, ‘labelOverlay’)
imshow(labeloverlay(I2,bw2)); Any suggestion how to enhance the image edges clearly?
I = imread(‘317.jpg’);
% A = rgb2gray(I2);
figure;
imshow(I)
title(‘Original Image’)
%%
% Gaussian LPF
F = fspecial(‘gaussian’);
G = imfilter(I,F);
figure(‘Name’, ‘Gaussian Blur’), imshow(G); title(‘G Image’);
%% Threshold
bw = im2bw(G,0.35);
figure(‘Name’, ‘Binary Image’)
imshow(bw)
% Enhance binary image
kernel = -1*ones(1);
kernel(2,2) = 4;
enhancedImage = imfilter(bw, kernel);
figure(‘Name’, ‘Enhanced’), imshow(enhancedImage); title(‘enhancedImage Image’);
% Crop
D = im2uint8(enhancedImage);
I2 = imcrop(D,[50 68 130 112]);
figure(‘Name’, ‘Cropped’);
imshow(I2)
% User define ROI
r = drawrectangle;
mask = createMask(r);
bw2 = activecontour(I2,mask,30,’Chan-Vese’);
figure(‘Name’, ‘Active Contour’)
imshow(bw2);
hold on;
visboundaries(bw2,’Color’,’r’);
figure(‘Name’, ‘labelOverlay’)
imshow(labeloverlay(I2,bw2)); image segmentation, edge enhancement, canny, unsharp masking MATLAB Answers — New Questions
Error implementing Newton’s Method
Tried implementing Newton’s Method in MATLAB, but receiving this error regarding indexing. Not sure what this means or how to fix it.Tried implementing Newton’s Method in MATLAB, but receiving this error regarding indexing. Not sure what this means or how to fix it. Tried implementing Newton’s Method in MATLAB, but receiving this error regarding indexing. Not sure what this means or how to fix it. function, matlab code, matlab, error MATLAB Answers — New Questions
cross correlation using ‘xcorr’ in the presence of NaN or missing values
Hi I am trying to calculate cross correlation of two time-series at different lags but my data have a lot of NaN values. When I calculate cross correlation as below, it gives all NaNs in the corln.
[corln, lags] = xcorr (ave_precp_india (:), aod_all (:, 1), 15);
I want to specify something like ‘rows’, ‘pairwise’ in calculating correlation so that NaNs are ignored. How can I specify ‘rows’, ‘pairwise’ option in xcorr?Hi I am trying to calculate cross correlation of two time-series at different lags but my data have a lot of NaN values. When I calculate cross correlation as below, it gives all NaNs in the corln.
[corln, lags] = xcorr (ave_precp_india (:), aod_all (:, 1), 15);
I want to specify something like ‘rows’, ‘pairwise’ in calculating correlation so that NaNs are ignored. How can I specify ‘rows’, ‘pairwise’ option in xcorr? Hi I am trying to calculate cross correlation of two time-series at different lags but my data have a lot of NaN values. When I calculate cross correlation as below, it gives all NaNs in the corln.
[corln, lags] = xcorr (ave_precp_india (:), aod_all (:, 1), 15);
I want to specify something like ‘rows’, ‘pairwise’ in calculating correlation so that NaNs are ignored. How can I specify ‘rows’, ‘pairwise’ option in xcorr? xcorr, nan MATLAB Answers — New Questions
How do I validate my parallel cluster profile in MATLAB?
I cannot start a parallel pool in MATLAB.
How can I validate that my cluster profile is configured correctly?I cannot start a parallel pool in MATLAB.
How can I validate that my cluster profile is configured correctly? I cannot start a parallel pool in MATLAB.
How can I validate that my cluster profile is configured correctly? MATLAB Answers — New Questions
Can’t connect to NI DAQ USB6003 on Windows 11/Matlab 2024a
Hello All,
On my previous computer (Windows 10), I used Matlab to interface with an NI USB-6003 device. My new computer is Windows 11 and I am now using Matlab R2024a. When I try to run the same code I used previously, I get an error trying to add the device. I searched around online but did not see anything particularly helpful, as I am not sure what is causing the error.
I’ve attached screenshots of the error as well as my computer recognizing the device in device settings.Hello All,
On my previous computer (Windows 10), I used Matlab to interface with an NI USB-6003 device. My new computer is Windows 11 and I am now using Matlab R2024a. When I try to run the same code I used previously, I get an error trying to add the device. I searched around online but did not see anything particularly helpful, as I am not sure what is causing the error.
I’ve attached screenshots of the error as well as my computer recognizing the device in device settings. Hello All,
On my previous computer (Windows 10), I used Matlab to interface with an NI USB-6003 device. My new computer is Windows 11 and I am now using Matlab R2024a. When I try to run the same code I used previously, I get an error trying to add the device. I searched around online but did not see anything particularly helpful, as I am not sure what is causing the error.
I’ve attached screenshots of the error as well as my computer recognizing the device in device settings. data acquisition MATLAB Answers — New Questions
Running AutoCAD from MatLAB
Hello, \trying to run AutoCAD from MATLAB.
Tried the code proposed here
https://www.mathworks.com/matlabcentral/answers/1921990-using-the-matlab-net-interface-to-interact-with-autocad
Unfortunately I got this error
Error using dotnetAutoCADExample
Message: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
Source: Autodesk.AutoCAD.Interop
HelpLink: None
The topic was closed so I was not able to ask questions there.
Any useas?
What I need to do is plot some objects based on numbers calculated in a loop in MATLAB
Thank youHello, \trying to run AutoCAD from MATLAB.
Tried the code proposed here
https://www.mathworks.com/matlabcentral/answers/1921990-using-the-matlab-net-interface-to-interact-with-autocad
Unfortunately I got this error
Error using dotnetAutoCADExample
Message: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
Source: Autodesk.AutoCAD.Interop
HelpLink: None
The topic was closed so I was not able to ask questions there.
Any useas?
What I need to do is plot some objects based on numbers calculated in a loop in MATLAB
Thank you Hello, \trying to run AutoCAD from MATLAB.
Tried the code proposed here
https://www.mathworks.com/matlabcentral/answers/1921990-using-the-matlab-net-interface-to-interact-with-autocad
Unfortunately I got this error
Error using dotnetAutoCADExample
Message: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
Source: Autodesk.AutoCAD.Interop
HelpLink: None
The topic was closed so I was not able to ask questions there.
Any useas?
What I need to do is plot some objects based on numbers calculated in a loop in MATLAB
Thank you matlab, autocad, api MATLAB Answers — New Questions
How does MATLAB Parallel Server check out seats?
How does MATLAB Parallel Server check out seats?How does MATLAB Parallel Server check out seats? How does MATLAB Parallel Server check out seats? MATLAB Answers — New Questions
Binning matrix data (negative and positive decimals): mean of each 100 rows and create a new matrix
I have a A= 7382300X12 matrix. I want to reduce it by averaging every 1000 rows in all columns. So at the end I will have a B= 73823X12 matrix.
The matrix A have negative and positive decimals, so blockproc() didn’t work for me.
How can I do it?I have a A= 7382300X12 matrix. I want to reduce it by averaging every 1000 rows in all columns. So at the end I will have a B= 73823X12 matrix.
The matrix A have negative and positive decimals, so blockproc() didn’t work for me.
How can I do it? I have a A= 7382300X12 matrix. I want to reduce it by averaging every 1000 rows in all columns. So at the end I will have a B= 73823X12 matrix.
The matrix A have negative and positive decimals, so blockproc() didn’t work for me.
How can I do it? matrix manipulation MATLAB Answers — New Questions
Configuring 2×2 Antenna Setup with 2 CSI-RS Ports in MATLAB’s 5G Toolbox for CQI Reporting Test Compliance
I am working on implementing the table from TS138.101 Table 6.2.2.1.1.1-1: CQI reporting definition test using MATLAB’s 5G toolbox example, "NR PDSCH Throughput Using Channel State Information Feedback". The table specifies that the number of CSI-RS ports (X) should be 2, with an antenna configuration of 2×2.
In the MATLAB example, setting the panel dimensions to 2×2 results in NTxAnt becoming 8, which corresponds to the number of CSI-RS ports. However, according to the test table, to set the number of CSI-RS ports (X) to 2, the row number should be set to 3. When attempting to do this, MATLAB returns an error stating that the row number must be 6 or above. How can I correctly configure the antenna to 2×2 while ensuring the number of CSI-RS ports is set to 2, as required by the test table?I am working on implementing the table from TS138.101 Table 6.2.2.1.1.1-1: CQI reporting definition test using MATLAB’s 5G toolbox example, "NR PDSCH Throughput Using Channel State Information Feedback". The table specifies that the number of CSI-RS ports (X) should be 2, with an antenna configuration of 2×2.
In the MATLAB example, setting the panel dimensions to 2×2 results in NTxAnt becoming 8, which corresponds to the number of CSI-RS ports. However, according to the test table, to set the number of CSI-RS ports (X) to 2, the row number should be set to 3. When attempting to do this, MATLAB returns an error stating that the row number must be 6 or above. How can I correctly configure the antenna to 2×2 while ensuring the number of CSI-RS ports is set to 2, as required by the test table? I am working on implementing the table from TS138.101 Table 6.2.2.1.1.1-1: CQI reporting definition test using MATLAB’s 5G toolbox example, "NR PDSCH Throughput Using Channel State Information Feedback". The table specifies that the number of CSI-RS ports (X) should be 2, with an antenna configuration of 2×2.
In the MATLAB example, setting the panel dimensions to 2×2 results in NTxAnt becoming 8, which corresponds to the number of CSI-RS ports. However, according to the test table, to set the number of CSI-RS ports (X) to 2, the row number should be set to 3. When attempting to do this, MATLAB returns an error stating that the row number must be 6 or above. How can I correctly configure the antenna to 2×2 while ensuring the number of CSI-RS ports is set to 2, as required by the test table? 5g, cqi MATLAB Answers — New Questions
How can I generate a 32-bit SO for a Simulink model on 64-bit Linux?
How can I generate a 32-bit SO file with a supported GCC compiler for a Simulink model on 64-bit Linux? I have followed this example to generate a 32-bit DLL on Windows, but I couldn’t find an example for Linux environment:
https://www.mathworks.com/help/coder/ug/build-32-bit-dll-on-64-bit-windows-platform-using-msvc-toolchain.htmlHow can I generate a 32-bit SO file with a supported GCC compiler for a Simulink model on 64-bit Linux? I have followed this example to generate a 32-bit DLL on Windows, but I couldn’t find an example for Linux environment:
https://www.mathworks.com/help/coder/ug/build-32-bit-dll-on-64-bit-windows-platform-using-msvc-toolchain.html How can I generate a 32-bit SO file with a supported GCC compiler for a Simulink model on 64-bit Linux? I have followed this example to generate a 32-bit DLL on Windows, but I couldn’t find an example for Linux environment:
https://www.mathworks.com/help/coder/ug/build-32-bit-dll-on-64-bit-windows-platform-using-msvc-toolchain.html 32-bit, so, shared, library, linux MATLAB Answers — New Questions
Why do I receive License Manager Error -101?
When trying to launch MATLAB or attempting to use a toolbox I receive the following license manager error message:
License Manager Error -101
All licenses are reserved for others.
How can I resolve this error so that I can use MATLAB?When trying to launch MATLAB or attempting to use a toolbox I receive the following license manager error message:
License Manager Error -101
All licenses are reserved for others.
How can I resolve this error so that I can use MATLAB? When trying to launch MATLAB or attempting to use a toolbox I receive the following license manager error message:
License Manager Error -101
All licenses are reserved for others.
How can I resolve this error so that I can use MATLAB? MATLAB Answers — New Questions
Why do I receive a License Manager Error -4 in Polyspace?
Why do I receive a License Manager Error -4 when running a job in Polyspace Bug Finder, either locally or on a remote Code Prover server?Why do I receive a License Manager Error -4 when running a job in Polyspace Bug Finder, either locally or on a remote Code Prover server? Why do I receive a License Manager Error -4 when running a job in Polyspace Bug Finder, either locally or on a remote Code Prover server? MATLAB Answers — New Questions
How to properly read a csv saved cell array.
Hi,
I am new with Matlab and I would like to know why I am not reading a cell array as I saved it. i.e. I have a cell of arrays (3834×1) and I saved it as csv file.
writecell(X_train_past, …
strcat(train_data_path, ‘past_features.csv’), …
"Delimiter",";")
However, when reading the cell I got a cell of 926×864, totally different of the saved cell array. Is there any way to get the same shape when reading a cell as it was writen ?
opts = detectImportOptions(test_path);
opts.LineEnding = ‘n’;
C = readcell(test_path,opts);
Thanks a lot in advance,
RafaHi,
I am new with Matlab and I would like to know why I am not reading a cell array as I saved it. i.e. I have a cell of arrays (3834×1) and I saved it as csv file.
writecell(X_train_past, …
strcat(train_data_path, ‘past_features.csv’), …
"Delimiter",";")
However, when reading the cell I got a cell of 926×864, totally different of the saved cell array. Is there any way to get the same shape when reading a cell as it was writen ?
opts = detectImportOptions(test_path);
opts.LineEnding = ‘n’;
C = readcell(test_path,opts);
Thanks a lot in advance,
Rafa Hi,
I am new with Matlab and I would like to know why I am not reading a cell array as I saved it. i.e. I have a cell of arrays (3834×1) and I saved it as csv file.
writecell(X_train_past, …
strcat(train_data_path, ‘past_features.csv’), …
"Delimiter",";")
However, when reading the cell I got a cell of 926×864, totally different of the saved cell array. Is there any way to get the same shape when reading a cell as it was writen ?
opts = detectImportOptions(test_path);
opts.LineEnding = ‘n’;
C = readcell(test_path,opts);
Thanks a lot in advance,
Rafa cell arrays MATLAB Answers — New Questions
Do graphs work in Custom Components?
I built a custom component (first time I’ve tried this) containing two Axes objects as well as some text fields. Here’s a picture. I’ve been having some problems.
1. These graphs appear one size in the editor, and larger when an instance of my component is inserted into my app. (Compare the relative size of the graph to the text fields, in the picture above in the picture below.)
2. Some fraction of the time, when I run the app, the Axes objects don’t appear at all, although the other parts of the custom component do.
Is this a known bug? Is this usage of Axes objects a hopeless mess? Or is there some way I can tweak it to get around this problem.
Component embedded in app:
App running:I built a custom component (first time I’ve tried this) containing two Axes objects as well as some text fields. Here’s a picture. I’ve been having some problems.
1. These graphs appear one size in the editor, and larger when an instance of my component is inserted into my app. (Compare the relative size of the graph to the text fields, in the picture above in the picture below.)
2. Some fraction of the time, when I run the app, the Axes objects don’t appear at all, although the other parts of the custom component do.
Is this a known bug? Is this usage of Axes objects a hopeless mess? Or is there some way I can tweak it to get around this problem.
Component embedded in app:
App running: I built a custom component (first time I’ve tried this) containing two Axes objects as well as some text fields. Here’s a picture. I’ve been having some problems.
1. These graphs appear one size in the editor, and larger when an instance of my component is inserted into my app. (Compare the relative size of the graph to the text fields, in the picture above in the picture below.)
2. Some fraction of the time, when I run the app, the Axes objects don’t appear at all, although the other parts of the custom component do.
Is this a known bug? Is this usage of Axes objects a hopeless mess? Or is there some way I can tweak it to get around this problem.
Component embedded in app:
App running: appdesigner, customcomponent, axes MATLAB Answers — New Questions
How does the regionprops calculate the area or the eccentricity of an object?
Hi,
I have been reading a lot about image segmentation lately and know that some algorithms are based on the region and some are based on the boundary of a pixel.
I am wondering now how the regionprops function in MATLAB calculates the properties of an object and if there is any proper reference paper on the function to learn how the alogrithm of the regionprops work?
With regionprops () circles can be found by calculating the eccentricity or the roundness of an object. Another method is the Hough Transform to detect lines and circles.
What are the advantages for regionprops in comparison to the Hough Transform?Hi,
I have been reading a lot about image segmentation lately and know that some algorithms are based on the region and some are based on the boundary of a pixel.
I am wondering now how the regionprops function in MATLAB calculates the properties of an object and if there is any proper reference paper on the function to learn how the alogrithm of the regionprops work?
With regionprops () circles can be found by calculating the eccentricity or the roundness of an object. Another method is the Hough Transform to detect lines and circles.
What are the advantages for regionprops in comparison to the Hough Transform? Hi,
I have been reading a lot about image segmentation lately and know that some algorithms are based on the region and some are based on the boundary of a pixel.
I am wondering now how the regionprops function in MATLAB calculates the properties of an object and if there is any proper reference paper on the function to learn how the alogrithm of the regionprops work?
With regionprops () circles can be found by calculating the eccentricity or the roundness of an object. Another method is the Hough Transform to detect lines and circles.
What are the advantages for regionprops in comparison to the Hough Transform? image analysis, image processing, regionprops, ellipse, eccentricity MATLAB Answers — New Questions
Trying to understand why my graphs are all flipped
My ohmic overpotential curve, concentration overpotential curve and cell j-v curve are suppose to be flipped meaning my voltage is meant to decrease when my current density increases (negative gradient)
clc;
clear;
%Variables
m=15;
k = 15;
a_anode = 0.54; %transfer coefficient at anode
a_cathode = 0.52; %transfer coeffiecent at cathode
R = 8.314;%Gas constant
F = 96485;%Faraday constant
T = 300; %Temperature of cell
A_electrodes = 2; %area of electrodes
R_in = A_electrodes*2.5; %Internal resistance of the cell
n_anode = 2; %moles per reactant at the anode
n_cathode =4;%moles per reactant at the cathode
D_anode = 2.4e-6; %diffusion coefficient of glucose in bird
D_cathode = 1.8e-5;%diffusion coefficient of oxygen in bird
d_l_a = 0.005; %diffsuion layer thickness anode
d_l_c= 0.005 ;%diffsuion layer thickness cathode
j = linspace(0.0e-3,0.7e-3,k);%Current density of the cell
jT = j’;
C_s_anode = 5.55e-8; %concentration of reactant at the catalyst
C_s_cathode = 1.71e-8; %concentration of reactant at the catalyst
A_anode = 2; %active area of electrode
A_cathode = 2; %active area of electrode
row = 0.005; %diffusion distance
e = 0.4;%porosity of the structure
D_ij_anode = 9.5e-6; %binary diffusion coefficient(glucose in human dura mater)
D_ij_cathode = 1.8e-5;%Diffsuion coefficent of oxyegen in plain medium
i_ref_a = 3.5e-3; %anode reference exchange current density
L_anode = 0.3; %catalyst loading anode
P_anode = 2130; %Pressure at anode
P_ref_anode = 1.2; %reference pressure at the anode
T_ref_anode = 298; %reference temperature at anode
i_ref_c = 1.95e5; %anode reference exchange current density
L_cathode = 0.3; %catalyst loading anode
P_cathode = 50; %Pressure at anode
P_ref_cathode = 700; %reference pressure at the anode
T_ref_cathode = 298; %reference temperature at anode
%————————————————————————–
%Effective exchange current density
%Anode
i0_a = i_ref_a * A_anode * L_anode *(P_anode/P_ref_anode)^0.5 *(-(130/R*T)*(1-(T/T_ref_anode)));
%Cathode
i0_c = i_ref_c * A_cathode * L_cathode *(P_cathode/P_ref_cathode)^1 *(-(66/R*T)*(1-(T/T_ref_cathode)));
%————————————————————————–
%Activation Overpotential
%Anode
V_act_a = (R*T)/(a_anode*n_anode*F)*log(j/i0_a);%activation potential at anode
V_act_anode = abs(V_act_a);
display(V_act_anode)
%Cathode
V_act_c = (R*T)/(a_cathode*n_cathode*F)*log(j/i0_c);%activation potential at cathode
V_act_cathode = abs(V_act_c);
display(V_act_cathode)
%Total activation overpotential
V_act = V_act_cathode + V_act_anode;
display(V_act)
%J-V curve
figure
plot(j,V_act)
title(‘J-V Vact curve’)
xlabel(‘Current density’)
ylabel(‘Activation overpotential’)
%————————————————————————–
%Ohmic overpotential
%R_cell_anode = Rin .* A_anode; %resisitance of fuel cell
%R_cell_cathode = Rin .* A_cathode; %resisitance of fuel cell
%R_cell = R_cell_anode + R_cell_cathode;
V_ohm = j .* R_in;%ohmic overpotential of cell
display(V_ohm)
%J-V curve
figure
plot(j,V_ohm)
title(‘J-V ohmic curve’)
xlabel(‘Current density’)
ylabel(‘Ohmic overpotential’)
%————————————————————————–
%Determining glucose concentration
%Anode
J_diff_anode = j/(n_anode*F);%diffusion flux of reactants
display(J_diff_anode)
D_eff_anode = (e^1.5) * D_ij_anode;%effective reactant diffusivity
display(D_eff_anode)
C_b_anode = -((J_diff_anode*row)/-D_eff_anode)+ C_s_anode;
C_b_anodeT = C_b_anode’;
Glucose_conc = (C_b_anodeT * 180.156)*100000;
%Cathode
J_diff_cathode = j/(n_cathode*F);%diffusion flux of reactants
display(J_diff_cathode)
D_eff_cathode = (e^1.5) * D_ij_cathode;%effective reactant diffusivity
display(D_eff_cathode)
C_b_cathode = -((J_diff_cathode*row)/-D_eff_cathode)+ C_s_cathode;
%bulk concentration of reactant(oxygen)
display(C_b_cathode)
%————————————————————————–
%Concentration overpotential
%limiting current at anode
i_L_a = (n_anode*F*D_eff_anode*C_b_anode)/d_l_a;
%limiting current at cathode
i_L_c = (n_cathode*F*D_eff_cathode*C_b_cathode)/d_l_c;
%concentration overpotential at anode
V_conc_anode = (R*T)/(n_anode*F)*log(i_L_a./(i_L_a-j));
%concentration overpotential at cathode
V_conc_cathode = (R*T)/(n_cathode*F)*log(i_L_c./(i_L_c-j));
%concentration overpotential
V_conc =V_conc_cathode + V_conc_anode;
%J-V curve
figure
plot(j,V_conc)
title(‘J-V Vconc curve’)
xlabel(‘Current density’)
ylabel(‘Cocnetration overpotential’)
%————————————————————————–
%Cell potential
Et =1.3; %thermodynamic potential of fuel cell
%Fuel cell voltage
V_cell1 = Et – V_act – V_conc – V_ohm;
V_cell = abs(V_cell1);
%————————————————————————–
%Power of fuel cell
P_cell = V_cell .* j;
P_cell1 = abs(P_cell);
%————————————————————————–
%J-V curve
figure
plot(j,V_cell)
title(‘J-V curve’)
xlabel(‘Current density’)
ylabel(‘Cell voltage’)My ohmic overpotential curve, concentration overpotential curve and cell j-v curve are suppose to be flipped meaning my voltage is meant to decrease when my current density increases (negative gradient)
clc;
clear;
%Variables
m=15;
k = 15;
a_anode = 0.54; %transfer coefficient at anode
a_cathode = 0.52; %transfer coeffiecent at cathode
R = 8.314;%Gas constant
F = 96485;%Faraday constant
T = 300; %Temperature of cell
A_electrodes = 2; %area of electrodes
R_in = A_electrodes*2.5; %Internal resistance of the cell
n_anode = 2; %moles per reactant at the anode
n_cathode =4;%moles per reactant at the cathode
D_anode = 2.4e-6; %diffusion coefficient of glucose in bird
D_cathode = 1.8e-5;%diffusion coefficient of oxygen in bird
d_l_a = 0.005; %diffsuion layer thickness anode
d_l_c= 0.005 ;%diffsuion layer thickness cathode
j = linspace(0.0e-3,0.7e-3,k);%Current density of the cell
jT = j’;
C_s_anode = 5.55e-8; %concentration of reactant at the catalyst
C_s_cathode = 1.71e-8; %concentration of reactant at the catalyst
A_anode = 2; %active area of electrode
A_cathode = 2; %active area of electrode
row = 0.005; %diffusion distance
e = 0.4;%porosity of the structure
D_ij_anode = 9.5e-6; %binary diffusion coefficient(glucose in human dura mater)
D_ij_cathode = 1.8e-5;%Diffsuion coefficent of oxyegen in plain medium
i_ref_a = 3.5e-3; %anode reference exchange current density
L_anode = 0.3; %catalyst loading anode
P_anode = 2130; %Pressure at anode
P_ref_anode = 1.2; %reference pressure at the anode
T_ref_anode = 298; %reference temperature at anode
i_ref_c = 1.95e5; %anode reference exchange current density
L_cathode = 0.3; %catalyst loading anode
P_cathode = 50; %Pressure at anode
P_ref_cathode = 700; %reference pressure at the anode
T_ref_cathode = 298; %reference temperature at anode
%————————————————————————–
%Effective exchange current density
%Anode
i0_a = i_ref_a * A_anode * L_anode *(P_anode/P_ref_anode)^0.5 *(-(130/R*T)*(1-(T/T_ref_anode)));
%Cathode
i0_c = i_ref_c * A_cathode * L_cathode *(P_cathode/P_ref_cathode)^1 *(-(66/R*T)*(1-(T/T_ref_cathode)));
%————————————————————————–
%Activation Overpotential
%Anode
V_act_a = (R*T)/(a_anode*n_anode*F)*log(j/i0_a);%activation potential at anode
V_act_anode = abs(V_act_a);
display(V_act_anode)
%Cathode
V_act_c = (R*T)/(a_cathode*n_cathode*F)*log(j/i0_c);%activation potential at cathode
V_act_cathode = abs(V_act_c);
display(V_act_cathode)
%Total activation overpotential
V_act = V_act_cathode + V_act_anode;
display(V_act)
%J-V curve
figure
plot(j,V_act)
title(‘J-V Vact curve’)
xlabel(‘Current density’)
ylabel(‘Activation overpotential’)
%————————————————————————–
%Ohmic overpotential
%R_cell_anode = Rin .* A_anode; %resisitance of fuel cell
%R_cell_cathode = Rin .* A_cathode; %resisitance of fuel cell
%R_cell = R_cell_anode + R_cell_cathode;
V_ohm = j .* R_in;%ohmic overpotential of cell
display(V_ohm)
%J-V curve
figure
plot(j,V_ohm)
title(‘J-V ohmic curve’)
xlabel(‘Current density’)
ylabel(‘Ohmic overpotential’)
%————————————————————————–
%Determining glucose concentration
%Anode
J_diff_anode = j/(n_anode*F);%diffusion flux of reactants
display(J_diff_anode)
D_eff_anode = (e^1.5) * D_ij_anode;%effective reactant diffusivity
display(D_eff_anode)
C_b_anode = -((J_diff_anode*row)/-D_eff_anode)+ C_s_anode;
C_b_anodeT = C_b_anode’;
Glucose_conc = (C_b_anodeT * 180.156)*100000;
%Cathode
J_diff_cathode = j/(n_cathode*F);%diffusion flux of reactants
display(J_diff_cathode)
D_eff_cathode = (e^1.5) * D_ij_cathode;%effective reactant diffusivity
display(D_eff_cathode)
C_b_cathode = -((J_diff_cathode*row)/-D_eff_cathode)+ C_s_cathode;
%bulk concentration of reactant(oxygen)
display(C_b_cathode)
%————————————————————————–
%Concentration overpotential
%limiting current at anode
i_L_a = (n_anode*F*D_eff_anode*C_b_anode)/d_l_a;
%limiting current at cathode
i_L_c = (n_cathode*F*D_eff_cathode*C_b_cathode)/d_l_c;
%concentration overpotential at anode
V_conc_anode = (R*T)/(n_anode*F)*log(i_L_a./(i_L_a-j));
%concentration overpotential at cathode
V_conc_cathode = (R*T)/(n_cathode*F)*log(i_L_c./(i_L_c-j));
%concentration overpotential
V_conc =V_conc_cathode + V_conc_anode;
%J-V curve
figure
plot(j,V_conc)
title(‘J-V Vconc curve’)
xlabel(‘Current density’)
ylabel(‘Cocnetration overpotential’)
%————————————————————————–
%Cell potential
Et =1.3; %thermodynamic potential of fuel cell
%Fuel cell voltage
V_cell1 = Et – V_act – V_conc – V_ohm;
V_cell = abs(V_cell1);
%————————————————————————–
%Power of fuel cell
P_cell = V_cell .* j;
P_cell1 = abs(P_cell);
%————————————————————————–
%J-V curve
figure
plot(j,V_cell)
title(‘J-V curve’)
xlabel(‘Current density’)
ylabel(‘Cell voltage’) My ohmic overpotential curve, concentration overpotential curve and cell j-v curve are suppose to be flipped meaning my voltage is meant to decrease when my current density increases (negative gradient)
clc;
clear;
%Variables
m=15;
k = 15;
a_anode = 0.54; %transfer coefficient at anode
a_cathode = 0.52; %transfer coeffiecent at cathode
R = 8.314;%Gas constant
F = 96485;%Faraday constant
T = 300; %Temperature of cell
A_electrodes = 2; %area of electrodes
R_in = A_electrodes*2.5; %Internal resistance of the cell
n_anode = 2; %moles per reactant at the anode
n_cathode =4;%moles per reactant at the cathode
D_anode = 2.4e-6; %diffusion coefficient of glucose in bird
D_cathode = 1.8e-5;%diffusion coefficient of oxygen in bird
d_l_a = 0.005; %diffsuion layer thickness anode
d_l_c= 0.005 ;%diffsuion layer thickness cathode
j = linspace(0.0e-3,0.7e-3,k);%Current density of the cell
jT = j’;
C_s_anode = 5.55e-8; %concentration of reactant at the catalyst
C_s_cathode = 1.71e-8; %concentration of reactant at the catalyst
A_anode = 2; %active area of electrode
A_cathode = 2; %active area of electrode
row = 0.005; %diffusion distance
e = 0.4;%porosity of the structure
D_ij_anode = 9.5e-6; %binary diffusion coefficient(glucose in human dura mater)
D_ij_cathode = 1.8e-5;%Diffsuion coefficent of oxyegen in plain medium
i_ref_a = 3.5e-3; %anode reference exchange current density
L_anode = 0.3; %catalyst loading anode
P_anode = 2130; %Pressure at anode
P_ref_anode = 1.2; %reference pressure at the anode
T_ref_anode = 298; %reference temperature at anode
i_ref_c = 1.95e5; %anode reference exchange current density
L_cathode = 0.3; %catalyst loading anode
P_cathode = 50; %Pressure at anode
P_ref_cathode = 700; %reference pressure at the anode
T_ref_cathode = 298; %reference temperature at anode
%————————————————————————–
%Effective exchange current density
%Anode
i0_a = i_ref_a * A_anode * L_anode *(P_anode/P_ref_anode)^0.5 *(-(130/R*T)*(1-(T/T_ref_anode)));
%Cathode
i0_c = i_ref_c * A_cathode * L_cathode *(P_cathode/P_ref_cathode)^1 *(-(66/R*T)*(1-(T/T_ref_cathode)));
%————————————————————————–
%Activation Overpotential
%Anode
V_act_a = (R*T)/(a_anode*n_anode*F)*log(j/i0_a);%activation potential at anode
V_act_anode = abs(V_act_a);
display(V_act_anode)
%Cathode
V_act_c = (R*T)/(a_cathode*n_cathode*F)*log(j/i0_c);%activation potential at cathode
V_act_cathode = abs(V_act_c);
display(V_act_cathode)
%Total activation overpotential
V_act = V_act_cathode + V_act_anode;
display(V_act)
%J-V curve
figure
plot(j,V_act)
title(‘J-V Vact curve’)
xlabel(‘Current density’)
ylabel(‘Activation overpotential’)
%————————————————————————–
%Ohmic overpotential
%R_cell_anode = Rin .* A_anode; %resisitance of fuel cell
%R_cell_cathode = Rin .* A_cathode; %resisitance of fuel cell
%R_cell = R_cell_anode + R_cell_cathode;
V_ohm = j .* R_in;%ohmic overpotential of cell
display(V_ohm)
%J-V curve
figure
plot(j,V_ohm)
title(‘J-V ohmic curve’)
xlabel(‘Current density’)
ylabel(‘Ohmic overpotential’)
%————————————————————————–
%Determining glucose concentration
%Anode
J_diff_anode = j/(n_anode*F);%diffusion flux of reactants
display(J_diff_anode)
D_eff_anode = (e^1.5) * D_ij_anode;%effective reactant diffusivity
display(D_eff_anode)
C_b_anode = -((J_diff_anode*row)/-D_eff_anode)+ C_s_anode;
C_b_anodeT = C_b_anode’;
Glucose_conc = (C_b_anodeT * 180.156)*100000;
%Cathode
J_diff_cathode = j/(n_cathode*F);%diffusion flux of reactants
display(J_diff_cathode)
D_eff_cathode = (e^1.5) * D_ij_cathode;%effective reactant diffusivity
display(D_eff_cathode)
C_b_cathode = -((J_diff_cathode*row)/-D_eff_cathode)+ C_s_cathode;
%bulk concentration of reactant(oxygen)
display(C_b_cathode)
%————————————————————————–
%Concentration overpotential
%limiting current at anode
i_L_a = (n_anode*F*D_eff_anode*C_b_anode)/d_l_a;
%limiting current at cathode
i_L_c = (n_cathode*F*D_eff_cathode*C_b_cathode)/d_l_c;
%concentration overpotential at anode
V_conc_anode = (R*T)/(n_anode*F)*log(i_L_a./(i_L_a-j));
%concentration overpotential at cathode
V_conc_cathode = (R*T)/(n_cathode*F)*log(i_L_c./(i_L_c-j));
%concentration overpotential
V_conc =V_conc_cathode + V_conc_anode;
%J-V curve
figure
plot(j,V_conc)
title(‘J-V Vconc curve’)
xlabel(‘Current density’)
ylabel(‘Cocnetration overpotential’)
%————————————————————————–
%Cell potential
Et =1.3; %thermodynamic potential of fuel cell
%Fuel cell voltage
V_cell1 = Et – V_act – V_conc – V_ohm;
V_cell = abs(V_cell1);
%————————————————————————–
%Power of fuel cell
P_cell = V_cell .* j;
P_cell1 = abs(P_cell);
%————————————————————————–
%J-V curve
figure
plot(j,V_cell)
title(‘J-V curve’)
xlabel(‘Current density’)
ylabel(‘Cell voltage’) matlab, fuelcell MATLAB Answers — New Questions
Why doesn’t saving a model change my mask parameter in Simulink?
I have a mask parameter that changes during model update but not during model save in Simulink. Why does this occur?I have a mask parameter that changes during model update but not during model save in Simulink. Why does this occur? I have a mask parameter that changes during model update but not during model save in Simulink. Why does this occur? dirty, callback, model, mask, block, autosar MATLAB Answers — New Questions
Why does the view zoom in and out randomly when I try to rotate around my 3-D image?
Why does the view zoom in and out randomly when I try to rotate around my 3-D image?
I have created a 3-D image and want to rotate my view around the image. As it rotates, the perspective seems to zoom in and out causing an undesired bouncing effect. The following code illustrates this effect:
% This part of the code draws an arbitrary image
figure(‘renderer’,’zbuffer’,’color’,’k’)
[x,y,z]=sphere;
hold on
for j=[-1 1],
patch([-1 -1 1 1],[-1 1 1 -1],[j j j j],’b’)
patch([-1 -1 1 1],[j j j j],[-1 1 1 -1],’r’)
patch([j j j j],[-1 -1 1 1],[-1 1 1 -1],’g’)
surf(x+3*j,y,z)
surf(x,y+3*j,z)
end
axis([-5 5 -6 6 -5 5],’off’)
view(3)
% Get the current view angle
[az,el]=view;
el=el+15;
% Now rotate around the image
for j=10:10:360,
view(az+j,el)
pause(0.1)
end
How can I stabilize the view so that I can rotate the camera smoothly around my image?Why does the view zoom in and out randomly when I try to rotate around my 3-D image?
I have created a 3-D image and want to rotate my view around the image. As it rotates, the perspective seems to zoom in and out causing an undesired bouncing effect. The following code illustrates this effect:
% This part of the code draws an arbitrary image
figure(‘renderer’,’zbuffer’,’color’,’k’)
[x,y,z]=sphere;
hold on
for j=[-1 1],
patch([-1 -1 1 1],[-1 1 1 -1],[j j j j],’b’)
patch([-1 -1 1 1],[j j j j],[-1 1 1 -1],’r’)
patch([j j j j],[-1 -1 1 1],[-1 1 1 -1],’g’)
surf(x+3*j,y,z)
surf(x,y+3*j,z)
end
axis([-5 5 -6 6 -5 5],’off’)
view(3)
% Get the current view angle
[az,el]=view;
el=el+15;
% Now rotate around the image
for j=10:10:360,
view(az+j,el)
pause(0.1)
end
How can I stabilize the view so that I can rotate the camera smoothly around my image? Why does the view zoom in and out randomly when I try to rotate around my 3-D image?
I have created a 3-D image and want to rotate my view around the image. As it rotates, the perspective seems to zoom in and out causing an undesired bouncing effect. The following code illustrates this effect:
% This part of the code draws an arbitrary image
figure(‘renderer’,’zbuffer’,’color’,’k’)
[x,y,z]=sphere;
hold on
for j=[-1 1],
patch([-1 -1 1 1],[-1 1 1 -1],[j j j j],’b’)
patch([-1 -1 1 1],[j j j j],[-1 1 1 -1],’r’)
patch([j j j j],[-1 -1 1 1],[-1 1 1 -1],’g’)
surf(x+3*j,y,z)
surf(x,y+3*j,z)
end
axis([-5 5 -6 6 -5 5],’off’)
view(3)
% Get the current view angle
[az,el]=view;
el=el+15;
% Now rotate around the image
for j=10:10:360,
view(az+j,el)
pause(0.1)
end
How can I stabilize the view so that I can rotate the camera smoothly around my image? rotate, 3d, 3-d, cameraposition, view, angle MATLAB Answers — New Questions
Integers can only be combined with integers of the same class, or scalar doubles
Error using –
Integers can only be combined with integers of the same class, or scalar doubles.
Error in Code (line 27)
data = data – repmat(mn,1,N);
Here is the code snip, where I am subtracting off the mean of some matrices:
mn = mean(data,2);
data = data – repmat(mn,1,N);
I tried casting the new data matrix to an int16 but that gave the same error, not sure what to cast it to, to avoid error.Error using –
Integers can only be combined with integers of the same class, or scalar doubles.
Error in Code (line 27)
data = data – repmat(mn,1,N);
Here is the code snip, where I am subtracting off the mean of some matrices:
mn = mean(data,2);
data = data – repmat(mn,1,N);
I tried casting the new data matrix to an int16 but that gave the same error, not sure what to cast it to, to avoid error. Error using –
Integers can only be combined with integers of the same class, or scalar doubles.
Error in Code (line 27)
data = data – repmat(mn,1,N);
Here is the code snip, where I am subtracting off the mean of some matrices:
mn = mean(data,2);
data = data – repmat(mn,1,N);
I tried casting the new data matrix to an int16 but that gave the same error, not sure what to cast it to, to avoid error. image processing, image analysis, code MATLAB Answers — New Questions
Method for Measuring Forces Due to Mass in 6 Degrees of Freedom Motion
Hello, I am currently conducting research on the control of a Stewart platform. I am planning to add a mass of a certain weight to the upper platform and measure the forces acting on the upper plate due to the motion. However, I am unsure about which sensors to use for this purpose. I would greatly appreciate any advice you can provide.
The mass will be added to the corners of the upper platform.
I found the Ideal Force Sensor block, but there are no examples of how to use it. I would appreciate it if you could also explain how to use this block.Hello, I am currently conducting research on the control of a Stewart platform. I am planning to add a mass of a certain weight to the upper platform and measure the forces acting on the upper plate due to the motion. However, I am unsure about which sensors to use for this purpose. I would greatly appreciate any advice you can provide.
The mass will be added to the corners of the upper platform.
I found the Ideal Force Sensor block, but there are no examples of how to use it. I would appreciate it if you could also explain how to use this block. Hello, I am currently conducting research on the control of a Stewart platform. I am planning to add a mass of a certain weight to the upper platform and measure the forces acting on the upper plate due to the motion. However, I am unsure about which sensors to use for this purpose. I would greatly appreciate any advice you can provide.
The mass will be added to the corners of the upper platform.
I found the Ideal Force Sensor block, but there are no examples of how to use it. I would appreciate it if you could also explain how to use this block. simulink, simscape MATLAB Answers — New Questions