Category: Matlab
Category Archives: Matlab
Problem with Imhist method
I have an image Zoom:
Zoom =
326 313 269 237 255 329
332 271 304 256 332 302
330 320 265 215 274 316
233 219 218 224 221 224
260 224 203 226 193 210
272 231 219 227 205 227
when I perform
figure
imhist(Zoom)
the histogram is defaulting in the x-axis to x10^4
<</matlabcentral/answers/uploaded_files/19890/img11.png>>
So the histogram is just a spike.
why does it not autorange the x-axis, and how too?
thanks
JasonI have an image Zoom:
Zoom =
326 313 269 237 255 329
332 271 304 256 332 302
330 320 265 215 274 316
233 219 218 224 221 224
260 224 203 226 193 210
272 231 219 227 205 227
when I perform
figure
imhist(Zoom)
the histogram is defaulting in the x-axis to x10^4
<</matlabcentral/answers/uploaded_files/19890/img11.png>>
So the histogram is just a spike.
why does it not autorange the x-axis, and how too?
thanks
Jason I have an image Zoom:
Zoom =
326 313 269 237 255 329
332 271 304 256 332 302
330 320 265 215 274 316
233 219 218 224 221 224
260 224 203 226 193 210
272 231 219 227 205 227
when I perform
figure
imhist(Zoom)
the histogram is defaulting in the x-axis to x10^4
<</matlabcentral/answers/uploaded_files/19890/img11.png>>
So the histogram is just a spike.
why does it not autorange the x-axis, and how too?
thanks
Jason imhist MATLAB Answers — New Questions
How can I add ‘MISRA C:2023’ to Code Generation Objectives?
How can I add ‘MISRA C:2023’ to Code Generation Objectives?How can I add ‘MISRA C:2023’ to Code Generation Objectives? How can I add ‘MISRA C:2023’ to Code Generation Objectives? misra c:2023, code generation MATLAB Answers — New Questions
Download the entire product offline
How can I download Matlab R2015a so that I don’t need internet connection while installing on any other machine?How can I download Matlab R2015a so that I don’t need internet connection while installing on any other machine? How can I download Matlab R2015a so that I don’t need internet connection while installing on any other machine? offline, download MATLAB Answers — New Questions
Improve convergence of GD with momentum
Hello,
I have made a simple implementation of the GD algorithm with momentum and it seems to me that convergence is very slow, it takes about 15k iterations to reach predefined tolerance.
I feel like there should be an improvement to this code, but I don’t see where.
Please, suggest me a better implementation:
clear all
clc
% Initial guess
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]’;
% Parameters
alpha = 0.001;
beta = 0.4;
max_iter = 10000;
tol = 1e-8;
x = x0; % find the values of x that minimize␣
i = 0;
step = zeros(size(x));
mse = rosenbrock(x);
fprintf(‘Initial MSE = %14.10f x = %sn’, mse, mat2str(x’)); % print initial values
while mse > tol
grad = rosenbrock_gradient(x);
gnorm = norm(grad); % gradient norm
step = -(1-beta)*alpha*grad + beta*step;
x = x + step;
mse = rosenbrock(x); % update the mean squared error
i = i + 1;
end
fprintf(‘iterations = %6dn’, i);
fprintf(‘Final MSE = %14.10f x = %sn’, mse, mat2str(x’));
fprintf(‘gradient = %sn’, mat2str(grad’));
fprintf(‘gradient norm = %fn’, gnorm);
% Define the Rosenbrock function
function [mse] = rosenbrock(x)
mse = sum(100.0 * (x(2:end) – x(1:end-1).^2.0).^2.0 + (1 – x(1:end-1)).^2.0);
end
% Define the gradient of the Rosenbrock function
function [grad] = rosenbrock_gradient(x)
n = length(x);
grad = zeros(n, 1);
grad(1) = -400 * x(1) * (x(2) – x(1)^2) – 2 * (1 – x(1));
grad(2:n-1) = 200 * (x(2:n-1) – x(1:n-2).^2) – 400 * x(2:n-1) .* (x(3:n) – x(2:n-1).^2) – 2 * (1 – x(2:n-1));
grad(n) = 200 * (x(n) – x(n-1)^2);
endHello,
I have made a simple implementation of the GD algorithm with momentum and it seems to me that convergence is very slow, it takes about 15k iterations to reach predefined tolerance.
I feel like there should be an improvement to this code, but I don’t see where.
Please, suggest me a better implementation:
clear all
clc
% Initial guess
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]’;
% Parameters
alpha = 0.001;
beta = 0.4;
max_iter = 10000;
tol = 1e-8;
x = x0; % find the values of x that minimize␣
i = 0;
step = zeros(size(x));
mse = rosenbrock(x);
fprintf(‘Initial MSE = %14.10f x = %sn’, mse, mat2str(x’)); % print initial values
while mse > tol
grad = rosenbrock_gradient(x);
gnorm = norm(grad); % gradient norm
step = -(1-beta)*alpha*grad + beta*step;
x = x + step;
mse = rosenbrock(x); % update the mean squared error
i = i + 1;
end
fprintf(‘iterations = %6dn’, i);
fprintf(‘Final MSE = %14.10f x = %sn’, mse, mat2str(x’));
fprintf(‘gradient = %sn’, mat2str(grad’));
fprintf(‘gradient norm = %fn’, gnorm);
% Define the Rosenbrock function
function [mse] = rosenbrock(x)
mse = sum(100.0 * (x(2:end) – x(1:end-1).^2.0).^2.0 + (1 – x(1:end-1)).^2.0);
end
% Define the gradient of the Rosenbrock function
function [grad] = rosenbrock_gradient(x)
n = length(x);
grad = zeros(n, 1);
grad(1) = -400 * x(1) * (x(2) – x(1)^2) – 2 * (1 – x(1));
grad(2:n-1) = 200 * (x(2:n-1) – x(1:n-2).^2) – 400 * x(2:n-1) .* (x(3:n) – x(2:n-1).^2) – 2 * (1 – x(2:n-1));
grad(n) = 200 * (x(n) – x(n-1)^2);
end Hello,
I have made a simple implementation of the GD algorithm with momentum and it seems to me that convergence is very slow, it takes about 15k iterations to reach predefined tolerance.
I feel like there should be an improvement to this code, but I don’t see where.
Please, suggest me a better implementation:
clear all
clc
% Initial guess
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]’;
% Parameters
alpha = 0.001;
beta = 0.4;
max_iter = 10000;
tol = 1e-8;
x = x0; % find the values of x that minimize␣
i = 0;
step = zeros(size(x));
mse = rosenbrock(x);
fprintf(‘Initial MSE = %14.10f x = %sn’, mse, mat2str(x’)); % print initial values
while mse > tol
grad = rosenbrock_gradient(x);
gnorm = norm(grad); % gradient norm
step = -(1-beta)*alpha*grad + beta*step;
x = x + step;
mse = rosenbrock(x); % update the mean squared error
i = i + 1;
end
fprintf(‘iterations = %6dn’, i);
fprintf(‘Final MSE = %14.10f x = %sn’, mse, mat2str(x’));
fprintf(‘gradient = %sn’, mat2str(grad’));
fprintf(‘gradient norm = %fn’, gnorm);
% Define the Rosenbrock function
function [mse] = rosenbrock(x)
mse = sum(100.0 * (x(2:end) – x(1:end-1).^2.0).^2.0 + (1 – x(1:end-1)).^2.0);
end
% Define the gradient of the Rosenbrock function
function [grad] = rosenbrock_gradient(x)
n = length(x);
grad = zeros(n, 1);
grad(1) = -400 * x(1) * (x(2) – x(1)^2) – 2 * (1 – x(1));
grad(2:n-1) = 200 * (x(2:n-1) – x(1:n-2).^2) – 400 * x(2:n-1) .* (x(3:n) – x(2:n-1).^2) – 2 * (1 – x(2:n-1));
grad(n) = 200 * (x(n) – x(n-1)^2);
end gd with momentum MATLAB Answers — New Questions
FMU export Algebraic loop error
I am getting the below error while exporting the simulink/simscape model to FMU.
I converted all subsytems to atomic to remove similar error/ algebraic
fmu_exp/Solver Configuration/EVAL_KEY/INPUT_1_1_1 (algebraic variable) This algebraic loop may be resolved when the subsystem option ‘Minimize algebraic loop occurrences’ is selected on some or all of the atomic and enabled subsystems in this algebraic loop
Component:Simulink | Category:Model
Algebraic loops are not supported in generated code. Use the ‘ashow’ command in the Simulink Debugger to see the algebraic loopsI am getting the below error while exporting the simulink/simscape model to FMU.
I converted all subsytems to atomic to remove similar error/ algebraic
fmu_exp/Solver Configuration/EVAL_KEY/INPUT_1_1_1 (algebraic variable) This algebraic loop may be resolved when the subsystem option ‘Minimize algebraic loop occurrences’ is selected on some or all of the atomic and enabled subsystems in this algebraic loop
Component:Simulink | Category:Model
Algebraic loops are not supported in generated code. Use the ‘ashow’ command in the Simulink Debugger to see the algebraic loops I am getting the below error while exporting the simulink/simscape model to FMU.
I converted all subsytems to atomic to remove similar error/ algebraic
fmu_exp/Solver Configuration/EVAL_KEY/INPUT_1_1_1 (algebraic variable) This algebraic loop may be resolved when the subsystem option ‘Minimize algebraic loop occurrences’ is selected on some or all of the atomic and enabled subsystems in this algebraic loop
Component:Simulink | Category:Model
Algebraic loops are not supported in generated code. Use the ‘ashow’ command in the Simulink Debugger to see the algebraic loops simulink MATLAB Answers — New Questions
Convolution of two matrixes of PDF values
Hello,
I’m trying to write a function that looks like something like this: convolved_matrix = convolve_matrixes(matrix1, matrix2), where the matrixes are N x 2 large (N rows and 2 columns). These matrixes is containing PDF values where on the first column contains the indexes and the second column contains the probabilities. So my question is how can i obtain a matrix that contains the correct convolution with correct index values and probability values between the inputed matrixes?Hello,
I’m trying to write a function that looks like something like this: convolved_matrix = convolve_matrixes(matrix1, matrix2), where the matrixes are N x 2 large (N rows and 2 columns). These matrixes is containing PDF values where on the first column contains the indexes and the second column contains the probabilities. So my question is how can i obtain a matrix that contains the correct convolution with correct index values and probability values between the inputed matrixes? Hello,
I’m trying to write a function that looks like something like this: convolved_matrix = convolve_matrixes(matrix1, matrix2), where the matrixes are N x 2 large (N rows and 2 columns). These matrixes is containing PDF values where on the first column contains the indexes and the second column contains the probabilities. So my question is how can i obtain a matrix that contains the correct convolution with correct index values and probability values between the inputed matrixes? matrix MATLAB Answers — New Questions
Could MatLAB model be exported to FMU without Simulink?
Is it possible to export an MatLab-Model to FMU for use in an Co-Simulation without SimuLink?
Or is the FMU-Interface a part of SimuLink?
Motivation: We have a set of current equations we want to solve in a co-simulation and want to use FMI/FMU for connecting MatLab with CCM+. We do not want to create an SimuLink-Model but want to use these equation. Is this way to connect the Software-packages possible?Is it possible to export an MatLab-Model to FMU for use in an Co-Simulation without SimuLink?
Or is the FMU-Interface a part of SimuLink?
Motivation: We have a set of current equations we want to solve in a co-simulation and want to use FMI/FMU for connecting MatLab with CCM+. We do not want to create an SimuLink-Model but want to use these equation. Is this way to connect the Software-packages possible? Is it possible to export an MatLab-Model to FMU for use in an Co-Simulation without SimuLink?
Or is the FMU-Interface a part of SimuLink?
Motivation: We have a set of current equations we want to solve in a co-simulation and want to use FMI/FMU for connecting MatLab with CCM+. We do not want to create an SimuLink-Model but want to use these equation. Is this way to connect the Software-packages possible? fmi/fmu, matlab, simulink MATLAB Answers — New Questions
how to plot from CSV files?
Hi all,
I have some data as CSV and want to plot the time (col. 1,2) in x-axis with temperature (col. 3) in y-axis (screenshot)
how to :
access the data
plot the data
thanks!!Hi all,
I have some data as CSV and want to plot the time (col. 1,2) in x-axis with temperature (col. 3) in y-axis (screenshot)
how to :
access the data
plot the data
thanks!! Hi all,
I have some data as CSV and want to plot the time (col. 1,2) in x-axis with temperature (col. 3) in y-axis (screenshot)
how to :
access the data
plot the data
thanks!! time series, csv MATLAB Answers — New Questions
setting radiobutton value by program
I have a panel with several radiobuttons so that only one of them is selected at the time, it works fine with my mouse. However, I want to create a pushbutton that when I push it will select a specific radiobutton on the panel
So for example I have radiobuttons A B and C and I clicked on C at one time then with the pushbutton I want to set A again as if I have clicked A with my mouse.. how can I do that??
Thank you in advance…I have a panel with several radiobuttons so that only one of them is selected at the time, it works fine with my mouse. However, I want to create a pushbutton that when I push it will select a specific radiobutton on the panel
So for example I have radiobuttons A B and C and I clicked on C at one time then with the pushbutton I want to set A again as if I have clicked A with my mouse.. how can I do that??
Thank you in advance… I have a panel with several radiobuttons so that only one of them is selected at the time, it works fine with my mouse. However, I want to create a pushbutton that when I push it will select a specific radiobutton on the panel
So for example I have radiobuttons A B and C and I clicked on C at one time then with the pushbutton I want to set A again as if I have clicked A with my mouse.. how can I do that??
Thank you in advance… gui guide panels MATLAB Answers — New Questions
How to make binary to gray scale
Dear All,
I created the image. My coding as below.
Z = zeros(99); % create square matrix of zeroes
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
imshow(Z); % show the "image"
NOW my pixel number just 1 and 0 (binary).
Do you know how to make the pixel number is gray scale. I mean is the gradient pixel number from center to edge is decending?Dear All,
I created the image. My coding as below.
Z = zeros(99); % create square matrix of zeroes
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
imshow(Z); % show the "image"
NOW my pixel number just 1 and 0 (binary).
Do you know how to make the pixel number is gray scale. I mean is the gradient pixel number from center to edge is decending? Dear All,
I created the image. My coding as below.
Z = zeros(99); % create square matrix of zeroes
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
imshow(Z); % show the "image"
NOW my pixel number just 1 and 0 (binary).
Do you know how to make the pixel number is gray scale. I mean is the gradient pixel number from center to edge is decending? image analysis, image processing, image acquisition, image segmentation, digital image processing MATLAB Answers — New Questions
How to change the graph of frequency domain
Dear all,
I have coding to convert from spatial domain to frequency domain. Below is my coding.
Z = zeros(99); % create square matrix of zeroes
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
Z = im2double(Z)
imshow(Z); % show the "image"
%spatial domain
figure, imtool(Z)
%Frequency Domain
j = fftshift(fft2(Z));
figure, imshow(j)
j1 = log(1+abs(j));
figure ,imshow(j1)
j2 = bar(j1);
My graph frequency domain like this
How to make the graph like belowDear all,
I have coding to convert from spatial domain to frequency domain. Below is my coding.
Z = zeros(99); % create square matrix of zeroes
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
Z = im2double(Z)
imshow(Z); % show the "image"
%spatial domain
figure, imtool(Z)
%Frequency Domain
j = fftshift(fft2(Z));
figure, imshow(j)
j1 = log(1+abs(j));
figure ,imshow(j1)
j2 = bar(j1);
My graph frequency domain like this
How to make the graph like below Dear all,
I have coding to convert from spatial domain to frequency domain. Below is my coding.
Z = zeros(99); % create square matrix of zeroes
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
Z = im2double(Z)
imshow(Z); % show the "image"
%spatial domain
figure, imtool(Z)
%Frequency Domain
j = fftshift(fft2(Z));
figure, imshow(j)
j1 = log(1+abs(j));
figure ,imshow(j1)
j2 = bar(j1);
My graph frequency domain like this
How to make the graph like below image processing, image acquisition, image analysis, image segmentation, digital image processing MATLAB Answers — New Questions
how to detect center of an object in an image and then crop the original image? using original image and green outline region
Hello.
I need to detect an object (suspicious area in an image). Then I need to find its centroid and then crop it the image into 256×256 pixels using image centroid as the centre of bounding box.
img = imread(‘1_245_original.jpg’);
% colorspace
jmg = rgb2gray(img);
jm = mat2gray(jmg(:,:,1));
jm = imcomplement(jm);
% thresh
bw = imbinarize(jm, graythresh(jm));
% filter noise
bw = imopen(bw, strel(‘disk’, 5));
bw = imfill(bw, ‘holes’);
% label every target
[L,num] = bwlabel(bw);
stats = regionprops(L);
figure; imshow(img, []);
for i = 1 : num
% get rect
recti = stats(i).BoundingBox;
% get cen
ceni = stats(i).Centroid;
% crop image
imi = imcrop(img, round(recti));
ims{i} = imi;
% rect and cen
hold on; rectangle(‘Position’, recti, ‘EdgeColor’, ‘c’, ‘LineWidth’, 2);
plot(ceni(1), ceni(2), ‘yp’, ‘MarkerFaceColor’, ‘y’, ‘MarkerSize’, 20);
end
I have tried out this code, but the cropping area was not in 256×256 pixels. and I want it to save at folder after detect the bounding box. Where can I put that code? Thanks.Hello.
I need to detect an object (suspicious area in an image). Then I need to find its centroid and then crop it the image into 256×256 pixels using image centroid as the centre of bounding box.
img = imread(‘1_245_original.jpg’);
% colorspace
jmg = rgb2gray(img);
jm = mat2gray(jmg(:,:,1));
jm = imcomplement(jm);
% thresh
bw = imbinarize(jm, graythresh(jm));
% filter noise
bw = imopen(bw, strel(‘disk’, 5));
bw = imfill(bw, ‘holes’);
% label every target
[L,num] = bwlabel(bw);
stats = regionprops(L);
figure; imshow(img, []);
for i = 1 : num
% get rect
recti = stats(i).BoundingBox;
% get cen
ceni = stats(i).Centroid;
% crop image
imi = imcrop(img, round(recti));
ims{i} = imi;
% rect and cen
hold on; rectangle(‘Position’, recti, ‘EdgeColor’, ‘c’, ‘LineWidth’, 2);
plot(ceni(1), ceni(2), ‘yp’, ‘MarkerFaceColor’, ‘y’, ‘MarkerSize’, 20);
end
I have tried out this code, but the cropping area was not in 256×256 pixels. and I want it to save at folder after detect the bounding box. Where can I put that code? Thanks. Hello.
I need to detect an object (suspicious area in an image). Then I need to find its centroid and then crop it the image into 256×256 pixels using image centroid as the centre of bounding box.
img = imread(‘1_245_original.jpg’);
% colorspace
jmg = rgb2gray(img);
jm = mat2gray(jmg(:,:,1));
jm = imcomplement(jm);
% thresh
bw = imbinarize(jm, graythresh(jm));
% filter noise
bw = imopen(bw, strel(‘disk’, 5));
bw = imfill(bw, ‘holes’);
% label every target
[L,num] = bwlabel(bw);
stats = regionprops(L);
figure; imshow(img, []);
for i = 1 : num
% get rect
recti = stats(i).BoundingBox;
% get cen
ceni = stats(i).Centroid;
% crop image
imi = imcrop(img, round(recti));
ims{i} = imi;
% rect and cen
hold on; rectangle(‘Position’, recti, ‘EdgeColor’, ‘c’, ‘LineWidth’, 2);
plot(ceni(1), ceni(2), ‘yp’, ‘MarkerFaceColor’, ‘y’, ‘MarkerSize’, 20);
end
I have tried out this code, but the cropping area was not in 256×256 pixels. and I want it to save at folder after detect the bounding box. Where can I put that code? Thanks. centroid, crop, automatic, duplicate post MATLAB Answers — New Questions
How to reconstruct SPECT image from sinogram using iterative technique?
I have a raw data of sinogram in dicom file. I have to reconstruct SPECT image. I tried to reconstruct SPECT image from sinogram using radon transform (iradon) in MATLAB but this technique add artifact in the image. I would like to reconstruct by iterative technique. Could anyone help me for the code of iterative reconstruction?
Please advise me. Thank you.I have a raw data of sinogram in dicom file. I have to reconstruct SPECT image. I tried to reconstruct SPECT image from sinogram using radon transform (iradon) in MATLAB but this technique add artifact in the image. I would like to reconstruct by iterative technique. Could anyone help me for the code of iterative reconstruction?
Please advise me. Thank you. I have a raw data of sinogram in dicom file. I have to reconstruct SPECT image. I tried to reconstruct SPECT image from sinogram using radon transform (iradon) in MATLAB but this technique add artifact in the image. I would like to reconstruct by iterative technique. Could anyone help me for the code of iterative reconstruction?
Please advise me. Thank you. iterative reconstruction technique, spect image, sinogram MATLAB Answers — New Questions
contour plot required for this code
K = 0.5; M = 0.5; p1 = 0.01; p2 = 0.01; p3 = 0.0; Pr = 2; Ec = 0.05; Q = 0.05; D = 10; b = 0.05; Bi = 0.15;
p2v = linspace(0,0.2,101);Mv = [1 3 5];
for k = 1:numel(Mv)
M = Mv(k);
for i = 1:length(p2v)
p2 = p2v(i);
Cpf = 4179;rhof = 997;kf = 0.613;sgf = 5.5*10^(-5); Cps1 = 765;rhos1 = 3970;ks1 = 40;sis1 = 10^(-10); Cps2 = 5315;rhos2 = 6320;ks2 = 76.5;sis2 = 2.7*10^(-8); Cps3 = 686.2;rhos3 = 4250;ks3 = 8.9538;sis3 = 6.27*10^(-5);H1 = ((1-p1)*(1-p2)*(1-p3))^-2.5; H2 = (1-p3)*( (1-p2)*( 1-p1 + p1*rhos1/rhof ) + p2*rhos2/rhof ) + p3*rhos3/rhof; H3 = (1-p3)*( (1-p2)*(1-p1 + p1*rhos1*Cps1/(rhof*Cpf)) + p2*rhos2*Cps2/(rhof*Cpf) ) + p3*rhos3*Cps3/(rhof*Cpf);C2 = ( (sis1+2*sgf-2*p1*(sgf-sis1))/(sis1+2*sgf+p1*(sgf-sis1))); C3 = ( (sis2+2*C2-2*p2*(C2-sis2))/(sis2+2*C2+p2*(C2-sis2)) );A3 = ( (sis3+2*C3-2*p3*(C3-sis3))/(sis3+2*C3+p3*(C3-sis3)) ); B1 = ( (ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1)) ); B2 = ( (ks2+2*B1-2*p2*(B1-ks2))/(ks2+2*B1+p2*(B1-ks2)) ); H4 = ( (ks3+2*B2-2*p3*(B2-ks3))/(ks3+2*B2+p3*(B2-ks3)) );
ODE = @(x,y)[y(2); y(3); y(4); M*(x+K).^2*(A3/H1).*(y(2) + (x+K).*y(3)) – 2*y(4)./(x+K) + y(3)./(x+K).^2 – y(2)./(x+K).^3 – (H2/H1)*K*((x+K).^2.*(y(1)*y(4) – y(2)*y(3))) – y(1)*y(2) + (x+K).*(y(1)*y(3)-y(2)^2); y(6); – (Pr/H4)*( Q*(y(5) + exp(-D*x)) + H3*K*y(1)*y(6) + M*Ec*A3*y(2)^2 ) – y(6) ]; BC = @(ya,yb)[ya(1); ya(2)-1-b*(ya(3)-ya(2)/K); ya(6)-Bi*(ya(5)-1); yb([2;3;5])]; xa = 0; xb = 6; x = linspace(xa,xb,101); solinit = bvpinit(x,[0 1 0 1 0 1]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,x);
[X,Y] = meshgrid(p2,S(1,:)); psi(i,:) = X.*Y;
end
end
figure(42),contourf(X,Y,psi,50,’ko’,’ShowText’,’on’,’LineWidth’,1.5),hold on;ax = gca; ax.XColor = ‘blue’; ax.YColor = ‘blue’; ax.XAxis.FontSize = 12; ax.YAxis.FontSize = 12; ax.FontWeight = ‘bold’;
xlabel(‘bfp2′,’color’,’blue’,’FontSize’, 14); ylabel(‘bfpsi’,’color’,’blue’,’FontSize’, 14); % colormap hot
%% I need contourf plot for ‘p2’ versuses ‘psi’ for different values of M = [1 3 5];K = 0.5; M = 0.5; p1 = 0.01; p2 = 0.01; p3 = 0.0; Pr = 2; Ec = 0.05; Q = 0.05; D = 10; b = 0.05; Bi = 0.15;
p2v = linspace(0,0.2,101);Mv = [1 3 5];
for k = 1:numel(Mv)
M = Mv(k);
for i = 1:length(p2v)
p2 = p2v(i);
Cpf = 4179;rhof = 997;kf = 0.613;sgf = 5.5*10^(-5); Cps1 = 765;rhos1 = 3970;ks1 = 40;sis1 = 10^(-10); Cps2 = 5315;rhos2 = 6320;ks2 = 76.5;sis2 = 2.7*10^(-8); Cps3 = 686.2;rhos3 = 4250;ks3 = 8.9538;sis3 = 6.27*10^(-5);H1 = ((1-p1)*(1-p2)*(1-p3))^-2.5; H2 = (1-p3)*( (1-p2)*( 1-p1 + p1*rhos1/rhof ) + p2*rhos2/rhof ) + p3*rhos3/rhof; H3 = (1-p3)*( (1-p2)*(1-p1 + p1*rhos1*Cps1/(rhof*Cpf)) + p2*rhos2*Cps2/(rhof*Cpf) ) + p3*rhos3*Cps3/(rhof*Cpf);C2 = ( (sis1+2*sgf-2*p1*(sgf-sis1))/(sis1+2*sgf+p1*(sgf-sis1))); C3 = ( (sis2+2*C2-2*p2*(C2-sis2))/(sis2+2*C2+p2*(C2-sis2)) );A3 = ( (sis3+2*C3-2*p3*(C3-sis3))/(sis3+2*C3+p3*(C3-sis3)) ); B1 = ( (ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1)) ); B2 = ( (ks2+2*B1-2*p2*(B1-ks2))/(ks2+2*B1+p2*(B1-ks2)) ); H4 = ( (ks3+2*B2-2*p3*(B2-ks3))/(ks3+2*B2+p3*(B2-ks3)) );
ODE = @(x,y)[y(2); y(3); y(4); M*(x+K).^2*(A3/H1).*(y(2) + (x+K).*y(3)) – 2*y(4)./(x+K) + y(3)./(x+K).^2 – y(2)./(x+K).^3 – (H2/H1)*K*((x+K).^2.*(y(1)*y(4) – y(2)*y(3))) – y(1)*y(2) + (x+K).*(y(1)*y(3)-y(2)^2); y(6); – (Pr/H4)*( Q*(y(5) + exp(-D*x)) + H3*K*y(1)*y(6) + M*Ec*A3*y(2)^2 ) – y(6) ]; BC = @(ya,yb)[ya(1); ya(2)-1-b*(ya(3)-ya(2)/K); ya(6)-Bi*(ya(5)-1); yb([2;3;5])]; xa = 0; xb = 6; x = linspace(xa,xb,101); solinit = bvpinit(x,[0 1 0 1 0 1]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,x);
[X,Y] = meshgrid(p2,S(1,:)); psi(i,:) = X.*Y;
end
end
figure(42),contourf(X,Y,psi,50,’ko’,’ShowText’,’on’,’LineWidth’,1.5),hold on;ax = gca; ax.XColor = ‘blue’; ax.YColor = ‘blue’; ax.XAxis.FontSize = 12; ax.YAxis.FontSize = 12; ax.FontWeight = ‘bold’;
xlabel(‘bfp2′,’color’,’blue’,’FontSize’, 14); ylabel(‘bfpsi’,’color’,’blue’,’FontSize’, 14); % colormap hot
%% I need contourf plot for ‘p2’ versuses ‘psi’ for different values of M = [1 3 5]; K = 0.5; M = 0.5; p1 = 0.01; p2 = 0.01; p3 = 0.0; Pr = 2; Ec = 0.05; Q = 0.05; D = 10; b = 0.05; Bi = 0.15;
p2v = linspace(0,0.2,101);Mv = [1 3 5];
for k = 1:numel(Mv)
M = Mv(k);
for i = 1:length(p2v)
p2 = p2v(i);
Cpf = 4179;rhof = 997;kf = 0.613;sgf = 5.5*10^(-5); Cps1 = 765;rhos1 = 3970;ks1 = 40;sis1 = 10^(-10); Cps2 = 5315;rhos2 = 6320;ks2 = 76.5;sis2 = 2.7*10^(-8); Cps3 = 686.2;rhos3 = 4250;ks3 = 8.9538;sis3 = 6.27*10^(-5);H1 = ((1-p1)*(1-p2)*(1-p3))^-2.5; H2 = (1-p3)*( (1-p2)*( 1-p1 + p1*rhos1/rhof ) + p2*rhos2/rhof ) + p3*rhos3/rhof; H3 = (1-p3)*( (1-p2)*(1-p1 + p1*rhos1*Cps1/(rhof*Cpf)) + p2*rhos2*Cps2/(rhof*Cpf) ) + p3*rhos3*Cps3/(rhof*Cpf);C2 = ( (sis1+2*sgf-2*p1*(sgf-sis1))/(sis1+2*sgf+p1*(sgf-sis1))); C3 = ( (sis2+2*C2-2*p2*(C2-sis2))/(sis2+2*C2+p2*(C2-sis2)) );A3 = ( (sis3+2*C3-2*p3*(C3-sis3))/(sis3+2*C3+p3*(C3-sis3)) ); B1 = ( (ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1)) ); B2 = ( (ks2+2*B1-2*p2*(B1-ks2))/(ks2+2*B1+p2*(B1-ks2)) ); H4 = ( (ks3+2*B2-2*p3*(B2-ks3))/(ks3+2*B2+p3*(B2-ks3)) );
ODE = @(x,y)[y(2); y(3); y(4); M*(x+K).^2*(A3/H1).*(y(2) + (x+K).*y(3)) – 2*y(4)./(x+K) + y(3)./(x+K).^2 – y(2)./(x+K).^3 – (H2/H1)*K*((x+K).^2.*(y(1)*y(4) – y(2)*y(3))) – y(1)*y(2) + (x+K).*(y(1)*y(3)-y(2)^2); y(6); – (Pr/H4)*( Q*(y(5) + exp(-D*x)) + H3*K*y(1)*y(6) + M*Ec*A3*y(2)^2 ) – y(6) ]; BC = @(ya,yb)[ya(1); ya(2)-1-b*(ya(3)-ya(2)/K); ya(6)-Bi*(ya(5)-1); yb([2;3;5])]; xa = 0; xb = 6; x = linspace(xa,xb,101); solinit = bvpinit(x,[0 1 0 1 0 1]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,x);
[X,Y] = meshgrid(p2,S(1,:)); psi(i,:) = X.*Y;
end
end
figure(42),contourf(X,Y,psi,50,’ko’,’ShowText’,’on’,’LineWidth’,1.5),hold on;ax = gca; ax.XColor = ‘blue’; ax.YColor = ‘blue’; ax.XAxis.FontSize = 12; ax.YAxis.FontSize = 12; ax.FontWeight = ‘bold’;
xlabel(‘bfp2′,’color’,’blue’,’FontSize’, 14); ylabel(‘bfpsi’,’color’,’blue’,’FontSize’, 14); % colormap hot
%% I need contourf plot for ‘p2’ versuses ‘psi’ for different values of M = [1 3 5]; contour plot required for this code MATLAB Answers — New Questions
How to open VR Sink simulation,with a button in app designer ?
Hello everyone , İ have a question
when i click on the vr sink model ,i can see block parameter properties.
i need to do, open VRSink file simulation in app designer .How can i do it ?
and Can i change ;"open wiever automatically" output from app designer with code ?Hello everyone , İ have a question
when i click on the vr sink model ,i can see block parameter properties.
i need to do, open VRSink file simulation in app designer .How can i do it ?
and Can i change ;"open wiever automatically" output from app designer with code ? Hello everyone , İ have a question
when i click on the vr sink model ,i can see block parameter properties.
i need to do, open VRSink file simulation in app designer .How can i do it ?
and Can i change ;"open wiever automatically" output from app designer with code ? simulink, vr MATLAB Answers — New Questions
Why does Matlab not recognize fieldnames function?
Hi,
Back in the past I used the ‘fieldnames’ function to retrieve fieldnames. But suddenly it´s not working anymore.
Strangely the function works before starting my script as console input. But as soon as I start my script, the function doesn´t get recognized anymore. It also works in other scripts. See code below.
Thank you in advance!
if length(other_data.digitalMap) == 1 || length(results.digitalMap) == 1
fieldnames = fieldnames(results.digitalMap);
for y =1: length(other_data.digitalMap)
for z = 1:length(fieldnames)-1
field_name = fieldnames{z};
results.digitalMap(y).(field_name) = other_data.digitalMap(y).(field_name);
end
end
end
%Strangely the function works before starting my script as console input:
% Create a structure with some fields
myStruct.name = ‘John’;
myStruct.age = 30;
myStruct.occupation = ‘Engineer’;
% Get the field names of the structure
fields = fieldnames(myStruct);Hi,
Back in the past I used the ‘fieldnames’ function to retrieve fieldnames. But suddenly it´s not working anymore.
Strangely the function works before starting my script as console input. But as soon as I start my script, the function doesn´t get recognized anymore. It also works in other scripts. See code below.
Thank you in advance!
if length(other_data.digitalMap) == 1 || length(results.digitalMap) == 1
fieldnames = fieldnames(results.digitalMap);
for y =1: length(other_data.digitalMap)
for z = 1:length(fieldnames)-1
field_name = fieldnames{z};
results.digitalMap(y).(field_name) = other_data.digitalMap(y).(field_name);
end
end
end
%Strangely the function works before starting my script as console input:
% Create a structure with some fields
myStruct.name = ‘John’;
myStruct.age = 30;
myStruct.occupation = ‘Engineer’;
% Get the field names of the structure
fields = fieldnames(myStruct); Hi,
Back in the past I used the ‘fieldnames’ function to retrieve fieldnames. But suddenly it´s not working anymore.
Strangely the function works before starting my script as console input. But as soon as I start my script, the function doesn´t get recognized anymore. It also works in other scripts. See code below.
Thank you in advance!
if length(other_data.digitalMap) == 1 || length(results.digitalMap) == 1
fieldnames = fieldnames(results.digitalMap);
for y =1: length(other_data.digitalMap)
for z = 1:length(fieldnames)-1
field_name = fieldnames{z};
results.digitalMap(y).(field_name) = other_data.digitalMap(y).(field_name);
end
end
end
%Strangely the function works before starting my script as console input:
% Create a structure with some fields
myStruct.name = ‘John’;
myStruct.age = 30;
myStruct.occupation = ‘Engineer’;
% Get the field names of the structure
fields = fieldnames(myStruct); matlab, help, toolbox, function MATLAB Answers — New Questions
C-RNN dual output regression
Hi. I am writing a C-RNN regression learning code with single matrix input – dual scalar output. The loaded "paddedData2.mat" file is saved as paddedData, and it is stored as an N X 3 cell, as shown in the attached image. The input matrix used for training is the 3rd column of paddedData, which is [440 5] double, and the regression variable is the values in the 1st column. With this, I plan to create features of size [436 1] using two [3 3] kernels of convolution and train them using LSTM. The code is as follows. But it doesn’t work and the error code "trainnet (line 46), Error forming mini-batch of targets for network output "fc_1". Data interpreted with format "BC". To specify a different format use the TargetDataFormats option."
How can I modify the code?
clc;
clear all;
load("paddedData2.mat","-mat")
XTrain = paddedData(:,3);
YTrain1 = cell2mat(paddedData(:,1));
YTrain2 = cell2mat(paddedData(:,2));
dsX = arrayDatastore(XTrain, ‘OutputType’, ‘same’);
dsY1 = arrayDatastore(YTrain1, ‘OutputType’, ‘same’);
dsY2 = arrayDatastore(YTrain2, ‘OutputType’, ‘same’);
net = dlnetwork;
tempNet = [
sequenceInputLayer([440 5 1],"Name","sequenceinput")
convolution2dLayer([3 3],8,"Name","conv_A1")
batchNormalizationLayer("Name","batchnorm_A1")
reluLayer("Name","relu_A1")
convolution2dLayer([3 3],8,"Name","conv_2")
batchNormalizationLayer("Name","batchnorm_2")
reluLayer("Name","relu_2")
flattenLayer("Name","flatten")
fullyConnectedLayer(100,"Name","fc")
lstmLayer(100,"Name","lstm","OutputMode","last")];
net = addLayers(net,tempNet);
tempNet = fullyConnectedLayer(1,"Name","fc_1");
net = addLayers(net,tempNet);
tempNet = fullyConnectedLayer(1,"Name","fc_2");
net = addLayers(net,tempNet);
clear tempNet;
net = connectLayers(net,"lstm","fc_1");
net = connectLayers(net,"lstm","fc_2");
net = initialize(net);
options = trainingOptions(‘adam’, …
‘MaxEpochs’, 2000, …
‘MiniBatchSize’, 100, …
‘Shuffle’, ‘every-epoch’, …
‘Plots’, ‘training-progress’);
lossFcn = @(Y1,Y2,dsY1,dsY2) crossentropy(Y1,dsY1) + 0.1*mse(Y2,dsY2);
net = trainnet(dsX, net, lossFcn, options);Hi. I am writing a C-RNN regression learning code with single matrix input – dual scalar output. The loaded "paddedData2.mat" file is saved as paddedData, and it is stored as an N X 3 cell, as shown in the attached image. The input matrix used for training is the 3rd column of paddedData, which is [440 5] double, and the regression variable is the values in the 1st column. With this, I plan to create features of size [436 1] using two [3 3] kernels of convolution and train them using LSTM. The code is as follows. But it doesn’t work and the error code "trainnet (line 46), Error forming mini-batch of targets for network output "fc_1". Data interpreted with format "BC". To specify a different format use the TargetDataFormats option."
How can I modify the code?
clc;
clear all;
load("paddedData2.mat","-mat")
XTrain = paddedData(:,3);
YTrain1 = cell2mat(paddedData(:,1));
YTrain2 = cell2mat(paddedData(:,2));
dsX = arrayDatastore(XTrain, ‘OutputType’, ‘same’);
dsY1 = arrayDatastore(YTrain1, ‘OutputType’, ‘same’);
dsY2 = arrayDatastore(YTrain2, ‘OutputType’, ‘same’);
net = dlnetwork;
tempNet = [
sequenceInputLayer([440 5 1],"Name","sequenceinput")
convolution2dLayer([3 3],8,"Name","conv_A1")
batchNormalizationLayer("Name","batchnorm_A1")
reluLayer("Name","relu_A1")
convolution2dLayer([3 3],8,"Name","conv_2")
batchNormalizationLayer("Name","batchnorm_2")
reluLayer("Name","relu_2")
flattenLayer("Name","flatten")
fullyConnectedLayer(100,"Name","fc")
lstmLayer(100,"Name","lstm","OutputMode","last")];
net = addLayers(net,tempNet);
tempNet = fullyConnectedLayer(1,"Name","fc_1");
net = addLayers(net,tempNet);
tempNet = fullyConnectedLayer(1,"Name","fc_2");
net = addLayers(net,tempNet);
clear tempNet;
net = connectLayers(net,"lstm","fc_1");
net = connectLayers(net,"lstm","fc_2");
net = initialize(net);
options = trainingOptions(‘adam’, …
‘MaxEpochs’, 2000, …
‘MiniBatchSize’, 100, …
‘Shuffle’, ‘every-epoch’, …
‘Plots’, ‘training-progress’);
lossFcn = @(Y1,Y2,dsY1,dsY2) crossentropy(Y1,dsY1) + 0.1*mse(Y2,dsY2);
net = trainnet(dsX, net, lossFcn, options); Hi. I am writing a C-RNN regression learning code with single matrix input – dual scalar output. The loaded "paddedData2.mat" file is saved as paddedData, and it is stored as an N X 3 cell, as shown in the attached image. The input matrix used for training is the 3rd column of paddedData, which is [440 5] double, and the regression variable is the values in the 1st column. With this, I plan to create features of size [436 1] using two [3 3] kernels of convolution and train them using LSTM. The code is as follows. But it doesn’t work and the error code "trainnet (line 46), Error forming mini-batch of targets for network output "fc_1". Data interpreted with format "BC". To specify a different format use the TargetDataFormats option."
How can I modify the code?
clc;
clear all;
load("paddedData2.mat","-mat")
XTrain = paddedData(:,3);
YTrain1 = cell2mat(paddedData(:,1));
YTrain2 = cell2mat(paddedData(:,2));
dsX = arrayDatastore(XTrain, ‘OutputType’, ‘same’);
dsY1 = arrayDatastore(YTrain1, ‘OutputType’, ‘same’);
dsY2 = arrayDatastore(YTrain2, ‘OutputType’, ‘same’);
net = dlnetwork;
tempNet = [
sequenceInputLayer([440 5 1],"Name","sequenceinput")
convolution2dLayer([3 3],8,"Name","conv_A1")
batchNormalizationLayer("Name","batchnorm_A1")
reluLayer("Name","relu_A1")
convolution2dLayer([3 3],8,"Name","conv_2")
batchNormalizationLayer("Name","batchnorm_2")
reluLayer("Name","relu_2")
flattenLayer("Name","flatten")
fullyConnectedLayer(100,"Name","fc")
lstmLayer(100,"Name","lstm","OutputMode","last")];
net = addLayers(net,tempNet);
tempNet = fullyConnectedLayer(1,"Name","fc_1");
net = addLayers(net,tempNet);
tempNet = fullyConnectedLayer(1,"Name","fc_2");
net = addLayers(net,tempNet);
clear tempNet;
net = connectLayers(net,"lstm","fc_1");
net = connectLayers(net,"lstm","fc_2");
net = initialize(net);
options = trainingOptions(‘adam’, …
‘MaxEpochs’, 2000, …
‘MiniBatchSize’, 100, …
‘Shuffle’, ‘every-epoch’, …
‘Plots’, ‘training-progress’);
lossFcn = @(Y1,Y2,dsY1,dsY2) crossentropy(Y1,dsY1) + 0.1*mse(Y2,dsY2);
net = trainnet(dsX, net, lossFcn, options); deep learning, regression, multiple output MATLAB Answers — New Questions
Import to digsilent a dll generated starting from embedded coder in Simulink
Good morning
I read that MathWorks has developed a solution specifically for PowerFactory regarding to dll import.
Do you have some guidelines?
Could you help me?
Thank you for your time.
Regards,
AndreaGood morning
I read that MathWorks has developed a solution specifically for PowerFactory regarding to dll import.
Do you have some guidelines?
Could you help me?
Thank you for your time.
Regards,
Andrea Good morning
I read that MathWorks has developed a solution specifically for PowerFactory regarding to dll import.
Do you have some guidelines?
Could you help me?
Thank you for your time.
Regards,
Andrea dll, digsilent, embedded coder, software interface MATLAB Answers — New Questions
Can I call a Simulink generated DLL file in a Simulink model (Matlab 2018b)?
I have created a .dll file (see fig: PID_win64.dll) and associated headers (see fig: in PID_ert_shrlib_rtw) with the aid of Simulink (see fig: PID.slx). I now want to call it in a simulink model (see fig: test_dll.slx) where I am going to test it. I have read in older posts that I have to use S-Function block. Please let me know if this is the proper route I should follow and if so could you please share with me the exact steps (where should I allocate the name of dll and headers – which headers) ?
The final aim is to import the created .dll file in DIgSILENT POWERFACTORY. If anyone can share any further information regarding this would be highly appreciated.I have created a .dll file (see fig: PID_win64.dll) and associated headers (see fig: in PID_ert_shrlib_rtw) with the aid of Simulink (see fig: PID.slx). I now want to call it in a simulink model (see fig: test_dll.slx) where I am going to test it. I have read in older posts that I have to use S-Function block. Please let me know if this is the proper route I should follow and if so could you please share with me the exact steps (where should I allocate the name of dll and headers – which headers) ?
The final aim is to import the created .dll file in DIgSILENT POWERFACTORY. If anyone can share any further information regarding this would be highly appreciated. I have created a .dll file (see fig: PID_win64.dll) and associated headers (see fig: in PID_ert_shrlib_rtw) with the aid of Simulink (see fig: PID.slx). I now want to call it in a simulink model (see fig: test_dll.slx) where I am going to test it. I have read in older posts that I have to use S-Function block. Please let me know if this is the proper route I should follow and if so could you please share with me the exact steps (where should I allocate the name of dll and headers – which headers) ?
The final aim is to import the created .dll file in DIgSILENT POWERFACTORY. If anyone can share any further information regarding this would be highly appreciated. dll, s-function, 2018b, simulink, digsilent, powerfactory, import, call MATLAB Answers — New Questions
Generate 3D model from a 2D image
Hi friends,
I would like to generate a 3D model from a 2D image but I don’t have any clue.
From some good instruction, I have successfully generated a binary image with my defined masks. Here the reason why I want a binary image is that the 3D printer only accepts binary slices. I would like to just extrude my pixels into a 3D model (all numbers 1 need to be given the same height, but 0 don’t need a height or a neglectable height), and slice them with my printer software. Here is the first section to generate a good binary image. I know there is some other ways we can use to reconstruct a 3D model from a 2D image, but I just want do it in matlab.Hi friends,
I would like to generate a 3D model from a 2D image but I don’t have any clue.
From some good instruction, I have successfully generated a binary image with my defined masks. Here the reason why I want a binary image is that the 3D printer only accepts binary slices. I would like to just extrude my pixels into a 3D model (all numbers 1 need to be given the same height, but 0 don’t need a height or a neglectable height), and slice them with my printer software. Here is the first section to generate a good binary image. I know there is some other ways we can use to reconstruct a 3D model from a 2D image, but I just want do it in matlab. Hi friends,
I would like to generate a 3D model from a 2D image but I don’t have any clue.
From some good instruction, I have successfully generated a binary image with my defined masks. Here the reason why I want a binary image is that the 3D printer only accepts binary slices. I would like to just extrude my pixels into a 3D model (all numbers 1 need to be given the same height, but 0 don’t need a height or a neglectable height), and slice them with my printer software. Here is the first section to generate a good binary image. I know there is some other ways we can use to reconstruct a 3D model from a 2D image, but I just want do it in matlab. 3d plots, grayscale, binary image, digital image processing MATLAB Answers — New Questions