Tag Archives: matlab
The issue of optimization (minimization) of the average relative error between experimental and calculated data
hello
I want to share the difficulties that I faced. Can someone help
problem statement:
there is a ‘x’ column where the values of the independent variable are written and there is a ‘y’ column where the experimental values of the dependent variable are written.
approximation model is considered:
y_calculate=A*x^B+C,
and based on this model, an objective function is created, which is equal to the average value of the relative deviations between y and y_calculate:
error_function = mean(abs(y – y_calculate)) / y)=mean(abs(y – =A*x^B+C)) / y);
Our goal is to select parameters A,B,C in such a way that ‘error_function’ takes the value of the global minimum.
I calculated the optimal values of A, B, C and got:
A = 85.5880, B = -0.0460, C = 4.8824,
at which error function value for optimized parameters: 0.0285.
but I know in advance the specific values of A, B, C:
A = 1005.6335852931, B = -1.59745963925582, C = 73.54149744754400,
at which error function value for specific parameters: 0.002680472178434,
which is much better than with optimization
Below is the code with visualization, which confirms the above.
clear
close all
% Data
x = [7.3392, 14.6784, 22.0176, 29.3436, 36.6828, 44.0088, 51.3348, 58.674, 66, 73.3392, 80.6652, 88.0044, 95.3304, 102.6696, 109.9956, 117.3348, 124.6608, 132];
y = [115.1079, 87.7698, 80.5755, 78.1611, 76.5743, 75.7074, 74.9375, 74.9453, 74.59, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990];
% Initial guesses for parameters A, B, C
initial_guess = [1, 1, 1];
% Error function
error_function = @(params) mean(abs(y – (params(1) * x.^params(2) + params(3))) ./ y);
% Optimization of parameters
optimized_params = fminsearch(error_function, initial_guess);
% Results of optimization
A_optimized = optimized_params(1);
B_optimized = optimized_params(2);
C_optimized = optimized_params(3);
% Calculation of the fitted function for optimized parameters
y_calculate_optimized = A_optimized * x.^B_optimized + C_optimized;
% Calculate and display the error function value for optimized parameters
value_error_optimized = error_function(optimized_params);
fprintf(‘Optimized parameters:nA = %.4fnB = %.4fnC = %.4fn’, A_optimized, B_optimized, C_optimized);
fprintf(‘ error function value for optimized parameters: %.4fn’, value_error_optimized);
% Other specific parameters A, B, C
A_specific = 1005.63358529310;
B_specific = -1.59745963925582;
C_specific = 73.541497447544;
% Calculation of the fitted function for specific parameters
y_calculate_specific = A_specific * x.^B_specific + C_specific;
% Calculate and display the error function value for specific parameters
value_error_specific = error_function([A_specific, B_specific, C_specific]);
fprintf(‘Specific parameters:nA = %.10fnB = %.14fnC = %.14fn’, A_specific, B_specific, C_specific);
fprintf(‘ error function value for specific parameters: %.4fn’, value_error_specific);
% Visualization
figure;
plot(x, y, ‘bo-‘, ‘DisplayName’, ‘Experimental data’);
hold on;
plot(x, y_calculate_optimized, ‘r–‘, ‘DisplayName’, ‘Fitted model (Optimized)’);
plot(x, y_calculate_specific, ‘g-.’, ‘DisplayName’, ‘Fitted model (Specific)’);
xlabel(‘x’);
ylabel(‘y’);
legend(‘Location’, ‘best’);
title(‘Approximation of experimental data’);
grid on;
Obviously, my optimization code does not lead to a global minimum of the objective function, since there is a better approximation for specific values of A,B,C. Maybe this is caused by a random selection of the initial values of the parameters A=1, B=1, c=1 and therefore my code is stuck in a local minimum?
who can write a code that will select the A,B,C parameters so as to achieve the global minimum of the target function ‘error_function’, for any initial iteration data of the variables A,B,C. Thoughts for testing: the value of the target function ‘error_function’ should not be worse (that is, more) than 0.002680472178434, which is obtained with the specific value of A,B,C: A = 1005.6335852931, B = -1.59745963925582, C = 73.54149744754400hello
I want to share the difficulties that I faced. Can someone help
problem statement:
there is a ‘x’ column where the values of the independent variable are written and there is a ‘y’ column where the experimental values of the dependent variable are written.
approximation model is considered:
y_calculate=A*x^B+C,
and based on this model, an objective function is created, which is equal to the average value of the relative deviations between y and y_calculate:
error_function = mean(abs(y – y_calculate)) / y)=mean(abs(y – =A*x^B+C)) / y);
Our goal is to select parameters A,B,C in such a way that ‘error_function’ takes the value of the global minimum.
I calculated the optimal values of A, B, C and got:
A = 85.5880, B = -0.0460, C = 4.8824,
at which error function value for optimized parameters: 0.0285.
but I know in advance the specific values of A, B, C:
A = 1005.6335852931, B = -1.59745963925582, C = 73.54149744754400,
at which error function value for specific parameters: 0.002680472178434,
which is much better than with optimization
Below is the code with visualization, which confirms the above.
clear
close all
% Data
x = [7.3392, 14.6784, 22.0176, 29.3436, 36.6828, 44.0088, 51.3348, 58.674, 66, 73.3392, 80.6652, 88.0044, 95.3304, 102.6696, 109.9956, 117.3348, 124.6608, 132];
y = [115.1079, 87.7698, 80.5755, 78.1611, 76.5743, 75.7074, 74.9375, 74.9453, 74.59, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990];
% Initial guesses for parameters A, B, C
initial_guess = [1, 1, 1];
% Error function
error_function = @(params) mean(abs(y – (params(1) * x.^params(2) + params(3))) ./ y);
% Optimization of parameters
optimized_params = fminsearch(error_function, initial_guess);
% Results of optimization
A_optimized = optimized_params(1);
B_optimized = optimized_params(2);
C_optimized = optimized_params(3);
% Calculation of the fitted function for optimized parameters
y_calculate_optimized = A_optimized * x.^B_optimized + C_optimized;
% Calculate and display the error function value for optimized parameters
value_error_optimized = error_function(optimized_params);
fprintf(‘Optimized parameters:nA = %.4fnB = %.4fnC = %.4fn’, A_optimized, B_optimized, C_optimized);
fprintf(‘ error function value for optimized parameters: %.4fn’, value_error_optimized);
% Other specific parameters A, B, C
A_specific = 1005.63358529310;
B_specific = -1.59745963925582;
C_specific = 73.541497447544;
% Calculation of the fitted function for specific parameters
y_calculate_specific = A_specific * x.^B_specific + C_specific;
% Calculate and display the error function value for specific parameters
value_error_specific = error_function([A_specific, B_specific, C_specific]);
fprintf(‘Specific parameters:nA = %.10fnB = %.14fnC = %.14fn’, A_specific, B_specific, C_specific);
fprintf(‘ error function value for specific parameters: %.4fn’, value_error_specific);
% Visualization
figure;
plot(x, y, ‘bo-‘, ‘DisplayName’, ‘Experimental data’);
hold on;
plot(x, y_calculate_optimized, ‘r–‘, ‘DisplayName’, ‘Fitted model (Optimized)’);
plot(x, y_calculate_specific, ‘g-.’, ‘DisplayName’, ‘Fitted model (Specific)’);
xlabel(‘x’);
ylabel(‘y’);
legend(‘Location’, ‘best’);
title(‘Approximation of experimental data’);
grid on;
Obviously, my optimization code does not lead to a global minimum of the objective function, since there is a better approximation for specific values of A,B,C. Maybe this is caused by a random selection of the initial values of the parameters A=1, B=1, c=1 and therefore my code is stuck in a local minimum?
who can write a code that will select the A,B,C parameters so as to achieve the global minimum of the target function ‘error_function’, for any initial iteration data of the variables A,B,C. Thoughts for testing: the value of the target function ‘error_function’ should not be worse (that is, more) than 0.002680472178434, which is obtained with the specific value of A,B,C: A = 1005.6335852931, B = -1.59745963925582, C = 73.54149744754400 hello
I want to share the difficulties that I faced. Can someone help
problem statement:
there is a ‘x’ column where the values of the independent variable are written and there is a ‘y’ column where the experimental values of the dependent variable are written.
approximation model is considered:
y_calculate=A*x^B+C,
and based on this model, an objective function is created, which is equal to the average value of the relative deviations between y and y_calculate:
error_function = mean(abs(y – y_calculate)) / y)=mean(abs(y – =A*x^B+C)) / y);
Our goal is to select parameters A,B,C in such a way that ‘error_function’ takes the value of the global minimum.
I calculated the optimal values of A, B, C and got:
A = 85.5880, B = -0.0460, C = 4.8824,
at which error function value for optimized parameters: 0.0285.
but I know in advance the specific values of A, B, C:
A = 1005.6335852931, B = -1.59745963925582, C = 73.54149744754400,
at which error function value for specific parameters: 0.002680472178434,
which is much better than with optimization
Below is the code with visualization, which confirms the above.
clear
close all
% Data
x = [7.3392, 14.6784, 22.0176, 29.3436, 36.6828, 44.0088, 51.3348, 58.674, 66, 73.3392, 80.6652, 88.0044, 95.3304, 102.6696, 109.9956, 117.3348, 124.6608, 132];
y = [115.1079, 87.7698, 80.5755, 78.1611, 76.5743, 75.7074, 74.9375, 74.9453, 74.59, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990, 74.2990];
% Initial guesses for parameters A, B, C
initial_guess = [1, 1, 1];
% Error function
error_function = @(params) mean(abs(y – (params(1) * x.^params(2) + params(3))) ./ y);
% Optimization of parameters
optimized_params = fminsearch(error_function, initial_guess);
% Results of optimization
A_optimized = optimized_params(1);
B_optimized = optimized_params(2);
C_optimized = optimized_params(3);
% Calculation of the fitted function for optimized parameters
y_calculate_optimized = A_optimized * x.^B_optimized + C_optimized;
% Calculate and display the error function value for optimized parameters
value_error_optimized = error_function(optimized_params);
fprintf(‘Optimized parameters:nA = %.4fnB = %.4fnC = %.4fn’, A_optimized, B_optimized, C_optimized);
fprintf(‘ error function value for optimized parameters: %.4fn’, value_error_optimized);
% Other specific parameters A, B, C
A_specific = 1005.63358529310;
B_specific = -1.59745963925582;
C_specific = 73.541497447544;
% Calculation of the fitted function for specific parameters
y_calculate_specific = A_specific * x.^B_specific + C_specific;
% Calculate and display the error function value for specific parameters
value_error_specific = error_function([A_specific, B_specific, C_specific]);
fprintf(‘Specific parameters:nA = %.10fnB = %.14fnC = %.14fn’, A_specific, B_specific, C_specific);
fprintf(‘ error function value for specific parameters: %.4fn’, value_error_specific);
% Visualization
figure;
plot(x, y, ‘bo-‘, ‘DisplayName’, ‘Experimental data’);
hold on;
plot(x, y_calculate_optimized, ‘r–‘, ‘DisplayName’, ‘Fitted model (Optimized)’);
plot(x, y_calculate_specific, ‘g-.’, ‘DisplayName’, ‘Fitted model (Specific)’);
xlabel(‘x’);
ylabel(‘y’);
legend(‘Location’, ‘best’);
title(‘Approximation of experimental data’);
grid on;
Obviously, my optimization code does not lead to a global minimum of the objective function, since there is a better approximation for specific values of A,B,C. Maybe this is caused by a random selection of the initial values of the parameters A=1, B=1, c=1 and therefore my code is stuck in a local minimum?
who can write a code that will select the A,B,C parameters so as to achieve the global minimum of the target function ‘error_function’, for any initial iteration data of the variables A,B,C. Thoughts for testing: the value of the target function ‘error_function’ should not be worse (that is, more) than 0.002680472178434, which is obtained with the specific value of A,B,C: A = 1005.6335852931, B = -1.59745963925582, C = 73.54149744754400 optimization MATLAB Answers — New Questions
Warning: JPEG library error (8 bit), “Invalid SOS parameters for sequential JPEG”.
Hello there!
I am trying to modify the pretrained network, alexnet, for my images, which are in jpg format. The code after creating the datastore is here:
forestzones = imds.Labels;
[trainimgs,testimgs] = splitEachLabel(imds,0.8,’randomized’);
foractual = testimgs.Labels;
trainimgs = augmentedImageDatastore([227 227],trainimgs);
testimgs = augmentedImageDatastore([227 227],testimgs);
anet = alexnet;
layers = anet.Layers;
fc = fullyConnectedLayer(2);
layers(23) = fc;
layers(end) = classificationLayer;
opts = trainingOptions(‘sgdm’,’InitialLearnRate’,0.01);
[fornet,info] = trainNetwork(trainimgs,layers,opts)
I get >> Warning: JPEG library error (8 bit), "Invalid SOS parameters for sequential JPEG".
As a result I am not getting a proper info table.
What is the problem.
Thank you in advance!!Hello there!
I am trying to modify the pretrained network, alexnet, for my images, which are in jpg format. The code after creating the datastore is here:
forestzones = imds.Labels;
[trainimgs,testimgs] = splitEachLabel(imds,0.8,’randomized’);
foractual = testimgs.Labels;
trainimgs = augmentedImageDatastore([227 227],trainimgs);
testimgs = augmentedImageDatastore([227 227],testimgs);
anet = alexnet;
layers = anet.Layers;
fc = fullyConnectedLayer(2);
layers(23) = fc;
layers(end) = classificationLayer;
opts = trainingOptions(‘sgdm’,’InitialLearnRate’,0.01);
[fornet,info] = trainNetwork(trainimgs,layers,opts)
I get >> Warning: JPEG library error (8 bit), "Invalid SOS parameters for sequential JPEG".
As a result I am not getting a proper info table.
What is the problem.
Thank you in advance!! Hello there!
I am trying to modify the pretrained network, alexnet, for my images, which are in jpg format. The code after creating the datastore is here:
forestzones = imds.Labels;
[trainimgs,testimgs] = splitEachLabel(imds,0.8,’randomized’);
foractual = testimgs.Labels;
trainimgs = augmentedImageDatastore([227 227],trainimgs);
testimgs = augmentedImageDatastore([227 227],testimgs);
anet = alexnet;
layers = anet.Layers;
fc = fullyConnectedLayer(2);
layers(23) = fc;
layers(end) = classificationLayer;
opts = trainingOptions(‘sgdm’,’InitialLearnRate’,0.01);
[fornet,info] = trainNetwork(trainimgs,layers,opts)
I get >> Warning: JPEG library error (8 bit), "Invalid SOS parameters for sequential JPEG".
As a result I am not getting a proper info table.
What is the problem.
Thank you in advance!! deep learning, image processing MATLAB Answers — New Questions
How can I efficiently save and access large arrays generated in nested loops?
I need to run nested for-loops over the variables J1 and J2. The range for J1 is 1 to 41, and the range for J2 is 1 to 9. Inside these loops, I evaluate 16 functions, each of which returns an array of complex numbers with a size of 500 by 502.
I used the following given method to save the data, and it produced an 11 GB file, which seems very large. Is this normal? What is an efficient way to save this data at the end of the calculation?
What I want to do with this data afterward:
I will need to access the 16 arrays, A1 to A16, within the same J1 and J2 loop to perform other operations. Therefore, I want to store the data in a way that allows easy access to these 16 arrays within the loops.
My method to store data:
all_data = cell(41,9);
for J1 = 1:41
for J2 = 1:9
%evaluate 16 function to get 16 arrays (A1 to A16) of size 500 x 502:
all_data{J1,J2} = struct("A1", A1,…
"A2", A2,…
"A3", A3,…
"A4", A4,…
"A5", A5,…
"A6", A6,…
"A7", A7,…
"A8", A8,…
"A9", A9,…
"A10", A10,…
"A11", A11,…
"A12", A12,…
"A13", A13,…
"A14", A14,…
"A15", A15,…
"A16", A16);
end
end
save(‘Saved_Data.mat’,’-v7.3′);I need to run nested for-loops over the variables J1 and J2. The range for J1 is 1 to 41, and the range for J2 is 1 to 9. Inside these loops, I evaluate 16 functions, each of which returns an array of complex numbers with a size of 500 by 502.
I used the following given method to save the data, and it produced an 11 GB file, which seems very large. Is this normal? What is an efficient way to save this data at the end of the calculation?
What I want to do with this data afterward:
I will need to access the 16 arrays, A1 to A16, within the same J1 and J2 loop to perform other operations. Therefore, I want to store the data in a way that allows easy access to these 16 arrays within the loops.
My method to store data:
all_data = cell(41,9);
for J1 = 1:41
for J2 = 1:9
%evaluate 16 function to get 16 arrays (A1 to A16) of size 500 x 502:
all_data{J1,J2} = struct("A1", A1,…
"A2", A2,…
"A3", A3,…
"A4", A4,…
"A5", A5,…
"A6", A6,…
"A7", A7,…
"A8", A8,…
"A9", A9,…
"A10", A10,…
"A11", A11,…
"A12", A12,…
"A13", A13,…
"A14", A14,…
"A15", A15,…
"A16", A16);
end
end
save(‘Saved_Data.mat’,’-v7.3′); I need to run nested for-loops over the variables J1 and J2. The range for J1 is 1 to 41, and the range for J2 is 1 to 9. Inside these loops, I evaluate 16 functions, each of which returns an array of complex numbers with a size of 500 by 502.
I used the following given method to save the data, and it produced an 11 GB file, which seems very large. Is this normal? What is an efficient way to save this data at the end of the calculation?
What I want to do with this data afterward:
I will need to access the 16 arrays, A1 to A16, within the same J1 and J2 loop to perform other operations. Therefore, I want to store the data in a way that allows easy access to these 16 arrays within the loops.
My method to store data:
all_data = cell(41,9);
for J1 = 1:41
for J2 = 1:9
%evaluate 16 function to get 16 arrays (A1 to A16) of size 500 x 502:
all_data{J1,J2} = struct("A1", A1,…
"A2", A2,…
"A3", A3,…
"A4", A4,…
"A5", A5,…
"A6", A6,…
"A7", A7,…
"A8", A8,…
"A9", A9,…
"A10", A10,…
"A11", A11,…
"A12", A12,…
"A13", A13,…
"A14", A14,…
"A15", A15,…
"A16", A16);
end
end
save(‘Saved_Data.mat’,’-v7.3′); storage, data, big data, matlab MATLAB Answers — New Questions
License installation key for 2022A
I need a LIK License Installation Key for 2022A.I need a LIK License Installation Key for 2022A. I need a LIK License Installation Key for 2022A. license installation key MATLAB Answers — New Questions
Return cursor to commandline after plotting
I just upgraded to R2024a and am using dark mode. Previously, in my R2023b release, if I used the plot function in the command line (e.g. "plot(randn(1, 100))") a figure would pop up, but the cursor would remain active in the command window. This was helpful for rapid data exploration – I could type a plot command, look at the results, then programatically close it in the command line and continue on.
Now, after a plotting function is called, the command window is no longer active. I have to manually select the command window using the cursor if I want to continue entering commands. This really slows me down. Is there some setting or preference that can be flipped to return control back to the command window? I tried using keyboard shortcuts to return to the command window (ctrl-0, from Use Keyboard Shortcuts to Navigate MATLAB – MATLAB & Simulink (mathworks.com)), but this does nothing. Thanks,I just upgraded to R2024a and am using dark mode. Previously, in my R2023b release, if I used the plot function in the command line (e.g. "plot(randn(1, 100))") a figure would pop up, but the cursor would remain active in the command window. This was helpful for rapid data exploration – I could type a plot command, look at the results, then programatically close it in the command line and continue on.
Now, after a plotting function is called, the command window is no longer active. I have to manually select the command window using the cursor if I want to continue entering commands. This really slows me down. Is there some setting or preference that can be flipped to return control back to the command window? I tried using keyboard shortcuts to return to the command window (ctrl-0, from Use Keyboard Shortcuts to Navigate MATLAB – MATLAB & Simulink (mathworks.com)), but this does nothing. Thanks, I just upgraded to R2024a and am using dark mode. Previously, in my R2023b release, if I used the plot function in the command line (e.g. "plot(randn(1, 100))") a figure would pop up, but the cursor would remain active in the command window. This was helpful for rapid data exploration – I could type a plot command, look at the results, then programatically close it in the command line and continue on.
Now, after a plotting function is called, the command window is no longer active. I have to manually select the command window using the cursor if I want to continue entering commands. This really slows me down. Is there some setting or preference that can be flipped to return control back to the command window? I tried using keyboard shortcuts to return to the command window (ctrl-0, from Use Keyboard Shortcuts to Navigate MATLAB – MATLAB & Simulink (mathworks.com)), but this does nothing. Thanks, plotting, command window, keyboard shortcuts MATLAB Answers — New Questions
How can I define the temperature in 2D domain at location x,y [rather than nodal locations] for steady state or transient solution?
I have been able to duplicate the results for the steady state and transient responses for the problem defined at
https://www.mathworks.com/help/pde/ug/heat-transfer-problem-with-temperature-dependent-properties.html
This example includes code to plot the temperature at a specific point in the block, in this case near the center of the right edge, as a function of time.
I would be interested to define the temperature and temperature history at any x,y location for the defined block with the slot in it- for example at the top right corner of the slot.I have been able to duplicate the results for the steady state and transient responses for the problem defined at
https://www.mathworks.com/help/pde/ug/heat-transfer-problem-with-temperature-dependent-properties.html
This example includes code to plot the temperature at a specific point in the block, in this case near the center of the right edge, as a function of time.
I would be interested to define the temperature and temperature history at any x,y location for the defined block with the slot in it- for example at the top right corner of the slot. I have been able to duplicate the results for the steady state and transient responses for the problem defined at
https://www.mathworks.com/help/pde/ug/heat-transfer-problem-with-temperature-dependent-properties.html
This example includes code to plot the temperature at a specific point in the block, in this case near the center of the right edge, as a function of time.
I would be interested to define the temperature and temperature history at any x,y location for the defined block with the slot in it- for example at the top right corner of the slot. 2d, temperature, specific location, xy MATLAB Answers — New Questions
How to preserve transparent edges in images after image processing?
Hello, everyone!
I’m facing a problem related to the processing of .png images with transparent edges obtained in a simulation software. Whenever I convert the image (RGB) to grayscale, together with a Graussian filter, the transparent edges become white, and this hinders the reading and training of the neural network model I’m using.
for i = 1:length(files)
img = imread(fullfile(path, files(i).name));
[~, name, ext] = fileparts(files(i).name);
if size(img, 3) == 3
grayImg = rgb2gray(img);
else
grayImg = img;
end
mean=0; variance=0.01;
noisedImg = imnoise(grayImg, ‘gaussian’, mean, variance);
imgDeformed = elasticDeform(noisedImg, 8, 30);
file(:, :, 1, i) = imresize(imgDeformed, fileSize);
separatorIndex = strfind(name, ‘-‘);
depth(i, 1) = round(str2double(name(1:separatorIndex-1)), 2);
time(i, 1) = round(str2double(name(separatorIndex+1:end)));
end
[train_idx, ~, val_idx] = dividerand(numFiles, 0.7, 0, 0.3);
XTrain = file(:, :, 1, train_idx);
YTrain = depth(train_idx, 1);
XVal = file(:, :, 1, val_idx);
YVal = depth(val_idx, 1);
save(‘data.mat’, ‘XTrain’, ‘XVal’, ‘YTrain’, ‘YVal’);
Where elasticDeform is:
function imgDeformed = elasticDeform(img, alpha, sigma)
[rows, cols] = size(img);
dx = alpha * randn(rows, cols);
dy = alpha * randn(rows, cols);
dx = imgaussfilt(dx, sigma);
dy = imgaussfilt(dy, sigma);
[X, Y] = meshgrid(1:cols, 1:rows);
X_new = X + dx; Y_new = Y + dy;
imgDeformed = interp2(X, Y, double(img), X_new, Y_new, ‘linear’, 0);
imgDeformed = uint8(imgDeformed);
end
The product of the image processing is therefore:
You can see that in the images there are white edgesHello, everyone!
I’m facing a problem related to the processing of .png images with transparent edges obtained in a simulation software. Whenever I convert the image (RGB) to grayscale, together with a Graussian filter, the transparent edges become white, and this hinders the reading and training of the neural network model I’m using.
for i = 1:length(files)
img = imread(fullfile(path, files(i).name));
[~, name, ext] = fileparts(files(i).name);
if size(img, 3) == 3
grayImg = rgb2gray(img);
else
grayImg = img;
end
mean=0; variance=0.01;
noisedImg = imnoise(grayImg, ‘gaussian’, mean, variance);
imgDeformed = elasticDeform(noisedImg, 8, 30);
file(:, :, 1, i) = imresize(imgDeformed, fileSize);
separatorIndex = strfind(name, ‘-‘);
depth(i, 1) = round(str2double(name(1:separatorIndex-1)), 2);
time(i, 1) = round(str2double(name(separatorIndex+1:end)));
end
[train_idx, ~, val_idx] = dividerand(numFiles, 0.7, 0, 0.3);
XTrain = file(:, :, 1, train_idx);
YTrain = depth(train_idx, 1);
XVal = file(:, :, 1, val_idx);
YVal = depth(val_idx, 1);
save(‘data.mat’, ‘XTrain’, ‘XVal’, ‘YTrain’, ‘YVal’);
Where elasticDeform is:
function imgDeformed = elasticDeform(img, alpha, sigma)
[rows, cols] = size(img);
dx = alpha * randn(rows, cols);
dy = alpha * randn(rows, cols);
dx = imgaussfilt(dx, sigma);
dy = imgaussfilt(dy, sigma);
[X, Y] = meshgrid(1:cols, 1:rows);
X_new = X + dx; Y_new = Y + dy;
imgDeformed = interp2(X, Y, double(img), X_new, Y_new, ‘linear’, 0);
imgDeformed = uint8(imgDeformed);
end
The product of the image processing is therefore:
You can see that in the images there are white edges Hello, everyone!
I’m facing a problem related to the processing of .png images with transparent edges obtained in a simulation software. Whenever I convert the image (RGB) to grayscale, together with a Graussian filter, the transparent edges become white, and this hinders the reading and training of the neural network model I’m using.
for i = 1:length(files)
img = imread(fullfile(path, files(i).name));
[~, name, ext] = fileparts(files(i).name);
if size(img, 3) == 3
grayImg = rgb2gray(img);
else
grayImg = img;
end
mean=0; variance=0.01;
noisedImg = imnoise(grayImg, ‘gaussian’, mean, variance);
imgDeformed = elasticDeform(noisedImg, 8, 30);
file(:, :, 1, i) = imresize(imgDeformed, fileSize);
separatorIndex = strfind(name, ‘-‘);
depth(i, 1) = round(str2double(name(1:separatorIndex-1)), 2);
time(i, 1) = round(str2double(name(separatorIndex+1:end)));
end
[train_idx, ~, val_idx] = dividerand(numFiles, 0.7, 0, 0.3);
XTrain = file(:, :, 1, train_idx);
YTrain = depth(train_idx, 1);
XVal = file(:, :, 1, val_idx);
YVal = depth(val_idx, 1);
save(‘data.mat’, ‘XTrain’, ‘XVal’, ‘YTrain’, ‘YVal’);
Where elasticDeform is:
function imgDeformed = elasticDeform(img, alpha, sigma)
[rows, cols] = size(img);
dx = alpha * randn(rows, cols);
dy = alpha * randn(rows, cols);
dx = imgaussfilt(dx, sigma);
dy = imgaussfilt(dy, sigma);
[X, Y] = meshgrid(1:cols, 1:rows);
X_new = X + dx; Y_new = Y + dy;
imgDeformed = interp2(X, Y, double(img), X_new, Y_new, ‘linear’, 0);
imgDeformed = uint8(imgDeformed);
end
The product of the image processing is therefore:
You can see that in the images there are white edges image processing, neural networks, computer vision MATLAB Answers — New Questions
deadspace in UIaxes near image
Trying to create a clean looking GUI
Inserting image into UIaxes
there seems to always be dead space around the image that i dont understand (Shown below)
Trying to read the image size to resize UI axes but getting extra space on both sides.
Can someone check this ?
There seems to be 2 properteis UI figure and UI axes, am I using the right one (both in forms initilization)?
% Button pushed function: LoadImageFileButton
function openfile(app, event)
[file,path]=uigetfile({‘*.jpg’;’*.bmp’;’*.gif’;’*.tiff’}, ‘Select file’);
app.a= double(imread(file));
app.a= -(0.0316*app.a) +8.3;
app.b = app.a;
%app.UIAxes.Positon = [ 100 , 100 , size(app.a,1), size(app.a,2)]
app.UIAxes.Position = [400 100 size(app.a,1)/10 size(app.a,2)/10];
% app.UIFigure.Position = [100 100 size(app.a,1)/3 size(app.a,2)/3];
imagesc(app.a,’Parent’,app.UIAxes);
colorbarupdate(app, event);
endTrying to create a clean looking GUI
Inserting image into UIaxes
there seems to always be dead space around the image that i dont understand (Shown below)
Trying to read the image size to resize UI axes but getting extra space on both sides.
Can someone check this ?
There seems to be 2 properteis UI figure and UI axes, am I using the right one (both in forms initilization)?
% Button pushed function: LoadImageFileButton
function openfile(app, event)
[file,path]=uigetfile({‘*.jpg’;’*.bmp’;’*.gif’;’*.tiff’}, ‘Select file’);
app.a= double(imread(file));
app.a= -(0.0316*app.a) +8.3;
app.b = app.a;
%app.UIAxes.Positon = [ 100 , 100 , size(app.a,1), size(app.a,2)]
app.UIAxes.Position = [400 100 size(app.a,1)/10 size(app.a,2)/10];
% app.UIFigure.Position = [100 100 size(app.a,1)/3 size(app.a,2)/3];
imagesc(app.a,’Parent’,app.UIAxes);
colorbarupdate(app, event);
end Trying to create a clean looking GUI
Inserting image into UIaxes
there seems to always be dead space around the image that i dont understand (Shown below)
Trying to read the image size to resize UI axes but getting extra space on both sides.
Can someone check this ?
There seems to be 2 properteis UI figure and UI axes, am I using the right one (both in forms initilization)?
% Button pushed function: LoadImageFileButton
function openfile(app, event)
[file,path]=uigetfile({‘*.jpg’;’*.bmp’;’*.gif’;’*.tiff’}, ‘Select file’);
app.a= double(imread(file));
app.a= -(0.0316*app.a) +8.3;
app.b = app.a;
%app.UIAxes.Positon = [ 100 , 100 , size(app.a,1), size(app.a,2)]
app.UIAxes.Position = [400 100 size(app.a,1)/10 size(app.a,2)/10];
% app.UIFigure.Position = [100 100 size(app.a,1)/3 size(app.a,2)/3];
imagesc(app.a,’Parent’,app.UIAxes);
colorbarupdate(app, event);
end uiaxes MATLAB Answers — New Questions
Can I save the “simout” while running “parsim” after each worker completes its simulation?
Can I save the variables to a MAT file while running "parsim" after each worker completes its simulation?Can I save the variables to a MAT file while running "parsim" after each worker completes its simulation? Can I save the variables to a MAT file while running "parsim" after each worker completes its simulation? setmodelparameter, save, simulationoutput, simulationinput, logging MATLAB Answers — New Questions
Different behaviour when using symbolic simplification on norm() for scalars and vectors?
I’m building quite a lengthy differential equation (through many substitutions, etc) that involves a norm of the difference between two vectors. I am then trying to use odeToVectorField() and matlabFunction() to convert it into an integration problem. I run into the following error:
Error using symengine
Unable to generate code for piecewise for use in anonymous functions.
Error in sym/matlabFunction>mup2mat (line 431)
res1 = mupadmex(‘symobj::generateMATLAB’,r.s,ano,spa,splitIt);
I don’t think I can write the equation out here because it is far, far too long, but while trying to debug the issue, I found that if I change the following term (which is used several times for different eta and a in constructing the equation):
d_eta = norm(eta-a); %Both eta and a are defined as real vectors, e.g. syms eta [N 1] real
into
d_eta = ( ((eta(1)-a(1))^2) + ((eta(2)-a(2))^2) ) ^ (0.5);
then matlabFunction() is able to finish execution and the subsequent integration works fine (well, at least it runs, I’m still trying to come up with a verification case). This is obviously not an ideal solution as I’d like to be able to handle the n-dimensional case, so I’m trying to understand what is happening under the hood in the norm function.
I think the abs() function that is used in the norm() function is what is causing the issue – MATLAB is trying to create piecewise functions for it. What is the best way to have MATLAB understand that eta and a are real, and it can remove the abs() function?
For instance, why does the following work in simplifying norm:
>> syms a b real
>> c = norm(a-b)
c =
(abs(a – b)^2)^(1/2)
>> simplify(c)
ans =
abs(a – b)
But not this?:
>> syms a [2 1] real
>> syms b [2 1] real
>> c = norm(a-b)
c =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
>> simplify(c)
ans =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
However, this works:
>> syms a [2 1] real
>> syms b [2 1] real
>> syms c
>> c = norm(a-b)
c =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
>> rewrite(c,"sqrt")
ans =
((a1 – b1)^2 + (a2 – b2)^2)^(1/2)
Would it be "safe" to use rewrite to overcome this issue? Are there any nuanced differences between these (particularly which could impact the subsequent integration)?I’m building quite a lengthy differential equation (through many substitutions, etc) that involves a norm of the difference between two vectors. I am then trying to use odeToVectorField() and matlabFunction() to convert it into an integration problem. I run into the following error:
Error using symengine
Unable to generate code for piecewise for use in anonymous functions.
Error in sym/matlabFunction>mup2mat (line 431)
res1 = mupadmex(‘symobj::generateMATLAB’,r.s,ano,spa,splitIt);
I don’t think I can write the equation out here because it is far, far too long, but while trying to debug the issue, I found that if I change the following term (which is used several times for different eta and a in constructing the equation):
d_eta = norm(eta-a); %Both eta and a are defined as real vectors, e.g. syms eta [N 1] real
into
d_eta = ( ((eta(1)-a(1))^2) + ((eta(2)-a(2))^2) ) ^ (0.5);
then matlabFunction() is able to finish execution and the subsequent integration works fine (well, at least it runs, I’m still trying to come up with a verification case). This is obviously not an ideal solution as I’d like to be able to handle the n-dimensional case, so I’m trying to understand what is happening under the hood in the norm function.
I think the abs() function that is used in the norm() function is what is causing the issue – MATLAB is trying to create piecewise functions for it. What is the best way to have MATLAB understand that eta and a are real, and it can remove the abs() function?
For instance, why does the following work in simplifying norm:
>> syms a b real
>> c = norm(a-b)
c =
(abs(a – b)^2)^(1/2)
>> simplify(c)
ans =
abs(a – b)
But not this?:
>> syms a [2 1] real
>> syms b [2 1] real
>> c = norm(a-b)
c =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
>> simplify(c)
ans =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
However, this works:
>> syms a [2 1] real
>> syms b [2 1] real
>> syms c
>> c = norm(a-b)
c =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
>> rewrite(c,"sqrt")
ans =
((a1 – b1)^2 + (a2 – b2)^2)^(1/2)
Would it be "safe" to use rewrite to overcome this issue? Are there any nuanced differences between these (particularly which could impact the subsequent integration)? I’m building quite a lengthy differential equation (through many substitutions, etc) that involves a norm of the difference between two vectors. I am then trying to use odeToVectorField() and matlabFunction() to convert it into an integration problem. I run into the following error:
Error using symengine
Unable to generate code for piecewise for use in anonymous functions.
Error in sym/matlabFunction>mup2mat (line 431)
res1 = mupadmex(‘symobj::generateMATLAB’,r.s,ano,spa,splitIt);
I don’t think I can write the equation out here because it is far, far too long, but while trying to debug the issue, I found that if I change the following term (which is used several times for different eta and a in constructing the equation):
d_eta = norm(eta-a); %Both eta and a are defined as real vectors, e.g. syms eta [N 1] real
into
d_eta = ( ((eta(1)-a(1))^2) + ((eta(2)-a(2))^2) ) ^ (0.5);
then matlabFunction() is able to finish execution and the subsequent integration works fine (well, at least it runs, I’m still trying to come up with a verification case). This is obviously not an ideal solution as I’d like to be able to handle the n-dimensional case, so I’m trying to understand what is happening under the hood in the norm function.
I think the abs() function that is used in the norm() function is what is causing the issue – MATLAB is trying to create piecewise functions for it. What is the best way to have MATLAB understand that eta and a are real, and it can remove the abs() function?
For instance, why does the following work in simplifying norm:
>> syms a b real
>> c = norm(a-b)
c =
(abs(a – b)^2)^(1/2)
>> simplify(c)
ans =
abs(a – b)
But not this?:
>> syms a [2 1] real
>> syms b [2 1] real
>> c = norm(a-b)
c =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
>> simplify(c)
ans =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
However, this works:
>> syms a [2 1] real
>> syms b [2 1] real
>> syms c
>> c = norm(a-b)
c =
(abs(a1 – b1)^2 + abs(a2 – b2)^2)^(1/2)
>> rewrite(c,"sqrt")
ans =
((a1 – b1)^2 + (a2 – b2)^2)^(1/2)
Would it be "safe" to use rewrite to overcome this issue? Are there any nuanced differences between these (particularly which could impact the subsequent integration)? symbolic, mathematics, differential equations MATLAB Answers — New Questions
MEX files do not work on a network drive on Windows
I am trying to develop MEX files using the IDE within Microsoft Visual Studio 2022. I am using the templates provided by https://marketplace.visualstudio.com/items?itemName=gharveymn.MEXFunctionTemplates. I am starting with a simple MEX file – I have tried "C:Program FilesMATLABR2024aexternexamplescpp_mexarrayProduct.cpp" and "C:Program FilesMATLABR2024aexternexamplesmexarrayProduct.c". I successfully build the .mexw64 file and copy it to an empty directory on my C drive. The MEX file works as expected.
However, if instead I copy the .mexw64 file to a network directory and then add that directory to the Matlab path, the MEX file does not work. Matlab seemingly hangs along with the rest of Windows. My only path to recovery is a hard reset via the power button. I have tried mapping the network directory to a drive letter to no avail.
Any suggestions for a fix would be greatly appreciated. I realize I could build these simple MEX files with the mex command in Matlab, but my goal is to next build a MEX file that calls other libraries. Developing within Visual Studio has worked well for me in the past (pre-2017). The ability to provide additional include directories, additional library directories, additional library filenames, etc. within the IDE is valuable. I also have previously been able to perform debugging within VS as well. But right now I can’t get even these very basic MEX files to compile without adding the additional stuff in.
Thanks!I am trying to develop MEX files using the IDE within Microsoft Visual Studio 2022. I am using the templates provided by https://marketplace.visualstudio.com/items?itemName=gharveymn.MEXFunctionTemplates. I am starting with a simple MEX file – I have tried "C:Program FilesMATLABR2024aexternexamplescpp_mexarrayProduct.cpp" and "C:Program FilesMATLABR2024aexternexamplesmexarrayProduct.c". I successfully build the .mexw64 file and copy it to an empty directory on my C drive. The MEX file works as expected.
However, if instead I copy the .mexw64 file to a network directory and then add that directory to the Matlab path, the MEX file does not work. Matlab seemingly hangs along with the rest of Windows. My only path to recovery is a hard reset via the power button. I have tried mapping the network directory to a drive letter to no avail.
Any suggestions for a fix would be greatly appreciated. I realize I could build these simple MEX files with the mex command in Matlab, but my goal is to next build a MEX file that calls other libraries. Developing within Visual Studio has worked well for me in the past (pre-2017). The ability to provide additional include directories, additional library directories, additional library filenames, etc. within the IDE is valuable. I also have previously been able to perform debugging within VS as well. But right now I can’t get even these very basic MEX files to compile without adding the additional stuff in.
Thanks! I am trying to develop MEX files using the IDE within Microsoft Visual Studio 2022. I am using the templates provided by https://marketplace.visualstudio.com/items?itemName=gharveymn.MEXFunctionTemplates. I am starting with a simple MEX file – I have tried "C:Program FilesMATLABR2024aexternexamplescpp_mexarrayProduct.cpp" and "C:Program FilesMATLABR2024aexternexamplesmexarrayProduct.c". I successfully build the .mexw64 file and copy it to an empty directory on my C drive. The MEX file works as expected.
However, if instead I copy the .mexw64 file to a network directory and then add that directory to the Matlab path, the MEX file does not work. Matlab seemingly hangs along with the rest of Windows. My only path to recovery is a hard reset via the power button. I have tried mapping the network directory to a drive letter to no avail.
Any suggestions for a fix would be greatly appreciated. I realize I could build these simple MEX files with the mex command in Matlab, but my goal is to next build a MEX file that calls other libraries. Developing within Visual Studio has worked well for me in the past (pre-2017). The ability to provide additional include directories, additional library directories, additional library filenames, etc. within the IDE is valuable. I also have previously been able to perform debugging within VS as well. But right now I can’t get even these very basic MEX files to compile without adding the additional stuff in.
Thanks! mex, visual studio MATLAB Answers — New Questions
The radar auto driving example could not get the result I expected
Hi, experts,
I am using R2024a and trying to run the example of AutomatedDrivingRadarSimulationExample by running the two commands below in the Command Window of matlab:
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
After running the example, I observed a plot (see SNRplot.png attached), but could not see the radar image (see RadarImage.png attached) which I expected. Any expert knows if I missed anything? How should I do (Do I need to modify matlab script in the example), in order to see the radar image (RadarImage.png attached)?
Running the attached matlab code got the same result: you can see a SNR plot, but not the radar images.
Many thanks!Hi, experts,
I am using R2024a and trying to run the example of AutomatedDrivingRadarSimulationExample by running the two commands below in the Command Window of matlab:
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
After running the example, I observed a plot (see SNRplot.png attached), but could not see the radar image (see RadarImage.png attached) which I expected. Any expert knows if I missed anything? How should I do (Do I need to modify matlab script in the example), in order to see the radar image (RadarImage.png attached)?
Running the attached matlab code got the same result: you can see a SNR plot, but not the radar images.
Many thanks! Hi, experts,
I am using R2024a and trying to run the example of AutomatedDrivingRadarSimulationExample by running the two commands below in the Command Window of matlab:
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
After running the example, I observed a plot (see SNRplot.png attached), but could not see the radar image (see RadarImage.png attached) which I expected. Any expert knows if I missed anything? How should I do (Do I need to modify matlab script in the example), in order to see the radar image (RadarImage.png attached)?
Running the attached matlab code got the same result: you can see a SNR plot, but not the radar images.
Many thanks! radar, autodriving MATLAB Answers — New Questions
MATLAB 2024a readtable error
Error Message:
This is a similar error as discussed here for MATLAB 2018b.
I have a script using readtable(‘data.csv’) running on MATLAB 2024a that is producing this error if I modify my path from the MATLAB default (set by restoredefaultpath):
Error using readtable (line 517)
inputs must be a string array, character vector, or cell array of character vectors.
Trouble Shooting I’ve Tried:
If I run restoredefaultpath and then execute T = readtable(‘data.csv’) it runs OK.
T = readtable(‘data.csv’)
It seems like MATLAB can find readtable.m but cannot find readData.m:
which readTable -all` returns C:Program FilesMATLABR2024atoolboxmatlabiofunreadtable.m
and
which readData -all returns ‘readdata’ not found
both with the default path and my modified path.
I’ve tried uninstalling and then reinstalling MATLAB 2024a to no sucess.
Requested Help:
However, I need to be able to modify my path so that my script can access the m-files it needs. What can I do to fix this problem? Thank you for your help!Error Message:
This is a similar error as discussed here for MATLAB 2018b.
I have a script using readtable(‘data.csv’) running on MATLAB 2024a that is producing this error if I modify my path from the MATLAB default (set by restoredefaultpath):
Error using readtable (line 517)
inputs must be a string array, character vector, or cell array of character vectors.
Trouble Shooting I’ve Tried:
If I run restoredefaultpath and then execute T = readtable(‘data.csv’) it runs OK.
T = readtable(‘data.csv’)
It seems like MATLAB can find readtable.m but cannot find readData.m:
which readTable -all` returns C:Program FilesMATLABR2024atoolboxmatlabiofunreadtable.m
and
which readData -all returns ‘readdata’ not found
both with the default path and my modified path.
I’ve tried uninstalling and then reinstalling MATLAB 2024a to no sucess.
Requested Help:
However, I need to be able to modify my path so that my script can access the m-files it needs. What can I do to fix this problem? Thank you for your help! Error Message:
This is a similar error as discussed here for MATLAB 2018b.
I have a script using readtable(‘data.csv’) running on MATLAB 2024a that is producing this error if I modify my path from the MATLAB default (set by restoredefaultpath):
Error using readtable (line 517)
inputs must be a string array, character vector, or cell array of character vectors.
Trouble Shooting I’ve Tried:
If I run restoredefaultpath and then execute T = readtable(‘data.csv’) it runs OK.
T = readtable(‘data.csv’)
It seems like MATLAB can find readtable.m but cannot find readData.m:
which readTable -all` returns C:Program FilesMATLABR2024atoolboxmatlabiofunreadtable.m
and
which readData -all returns ‘readdata’ not found
both with the default path and my modified path.
I’ve tried uninstalling and then reinstalling MATLAB 2024a to no sucess.
Requested Help:
However, I need to be able to modify my path so that my script can access the m-files it needs. What can I do to fix this problem? Thank you for your help! readtable, readdata MATLAB Answers — New Questions
How can I connect MATLAB to GAMS?
My aim is to import selected data from a GAMS *.gdx-file to MATLAB and vice versa. It seems that there was a workflow that worked (at least in the past). I found a few older posts on this matter but it does not work for me. Especially I wonder whether the MATLAB-commands "rgdx/wgdx" have been removed from MATLAB as I can’t find information in the online documentation.
I am running GAMS Studio 36 and MATLAB R2020b on a Macbook Air 2017.
Thank you for any useful suggestions.My aim is to import selected data from a GAMS *.gdx-file to MATLAB and vice versa. It seems that there was a workflow that worked (at least in the past). I found a few older posts on this matter but it does not work for me. Especially I wonder whether the MATLAB-commands "rgdx/wgdx" have been removed from MATLAB as I can’t find information in the online documentation.
I am running GAMS Studio 36 and MATLAB R2020b on a Macbook Air 2017.
Thank you for any useful suggestions. My aim is to import selected data from a GAMS *.gdx-file to MATLAB and vice versa. It seems that there was a workflow that worked (at least in the past). I found a few older posts on this matter but it does not work for me. Especially I wonder whether the MATLAB-commands "rgdx/wgdx" have been removed from MATLAB as I can’t find information in the online documentation.
I am running GAMS Studio 36 and MATLAB R2020b on a Macbook Air 2017.
Thank you for any useful suggestions. gams, gdx, import, export MATLAB Answers — New Questions
Will multiple instances of a C++ S-function in Simulink sharing the same memory pool cause issues with static variables?
I have written an S-function with a C++ class with static attributes. Given how static variables share a common memory space across instances, if I have multiple copies of the S-function, will changes to the static attributes affect the rest of the S-function instances?
How do I create a separate memory space for each S-Function?I have written an S-function with a C++ class with static attributes. Given how static variables share a common memory space across instances, if I have multiple copies of the S-function, will changes to the static attributes affect the rest of the S-function instances?
How do I create a separate memory space for each S-Function? I have written an S-function with a C++ class with static attributes. Given how static variables share a common memory space across instances, if I have multiple copies of the S-function, will changes to the static attributes affect the rest of the S-function instances?
How do I create a separate memory space for each S-Function? static, attribute, class, cpp, sfunction, workvector MATLAB Answers — New Questions
Attempting to fit data with a sigmoid curve, but not an option in curvefitter toolbox
I am working on fitting data with a sigmoidal curve, but my CurveFitter toolbox does not have the sigmoidal option under fit types. I have tried a custom fit, but it is not giving me any useable fits.
eqn:
‘a/(1+exp(-b*(x-c)))’I am working on fitting data with a sigmoidal curve, but my CurveFitter toolbox does not have the sigmoidal option under fit types. I have tried a custom fit, but it is not giving me any useable fits.
eqn:
‘a/(1+exp(-b*(x-c)))’ I am working on fitting data with a sigmoidal curve, but my CurveFitter toolbox does not have the sigmoidal option under fit types. I have tried a custom fit, but it is not giving me any useable fits.
eqn:
‘a/(1+exp(-b*(x-c)))’ curvefitter, sigmoid MATLAB Answers — New Questions
matlab code to design and analyze Racetrack resonator
How to design an ractrack resonator in matlab for biosensing applicationsHow to design an ractrack resonator in matlab for biosensing applications How to design an ractrack resonator in matlab for biosensing applications integrated photonics MATLAB Answers — New Questions
Help Index exceeds the number of array elements?
The error i am recieving is:
Index exceeds the number of array elements. Index must not exceed 0.
Error Line 39: disp([‘Book 1: ‘, num2str(x(1))]);
I bellive the issues might be occuring in:
Line 34: options = optimoptions(‘linprog’, ‘Display’, ‘off’); or
Line 35 [x, fval] = linprog(f, A, b, [], [], lb, [], options);
But can’t find what is causing the error.The error i am recieving is:
Index exceeds the number of array elements. Index must not exceed 0.
Error Line 39: disp([‘Book 1: ‘, num2str(x(1))]);
I bellive the issues might be occuring in:
Line 34: options = optimoptions(‘linprog’, ‘Display’, ‘off’); or
Line 35 [x, fval] = linprog(f, A, b, [], [], lb, [], options);
But can’t find what is causing the error. The error i am recieving is:
Index exceeds the number of array elements. Index must not exceed 0.
Error Line 39: disp([‘Book 1: ‘, num2str(x(1))]);
I bellive the issues might be occuring in:
Line 34: options = optimoptions(‘linprog’, ‘Display’, ‘off’); or
Line 35 [x, fval] = linprog(f, A, b, [], [], lb, [], options);
But can’t find what is causing the error. optimization, index MATLAB Answers — New Questions
How to resolve error showing ‘Unexpected matlab expression’?????
I am getting an error as Unexpected matlab expreesion; but i am neither be able to find out which expreesion is wrong and nor be able to resolve this error. Please help me…I am getting an error as Unexpected matlab expreesion; but i am neither be able to find out which expreesion is wrong and nor be able to resolve this error. Please help me… I am getting an error as Unexpected matlab expreesion; but i am neither be able to find out which expreesion is wrong and nor be able to resolve this error. Please help me… unexpected matlab expression MATLAB Answers — New Questions
Using system composer, it is possible to create a report with the sequence diagrams?
I´m using system composer, and i want to create a report with the views and sequence diagrams that i have. I have this code to generate the report and add the views, but i don´t know if there is a way to add too the sequence diagrams because there is nothing like "SequenceDiagramFinder".
Here is the code for the views:
model = systemcomposer.loadModel(model_name);
rpt = slreportgen.report.Report(output="ViewFinderReport",…
CompileModelBeforeReporting=false);
viewFinder = ViewFinder(model_name);
chapter = Chapter("Title","Views");
while hasNext(viewFinder)
view = next(viewFinder);
sect = Section("Title",view.Name);
add(sect,view);
add(chapter,sect);
endI´m using system composer, and i want to create a report with the views and sequence diagrams that i have. I have this code to generate the report and add the views, but i don´t know if there is a way to add too the sequence diagrams because there is nothing like "SequenceDiagramFinder".
Here is the code for the views:
model = systemcomposer.loadModel(model_name);
rpt = slreportgen.report.Report(output="ViewFinderReport",…
CompileModelBeforeReporting=false);
viewFinder = ViewFinder(model_name);
chapter = Chapter("Title","Views");
while hasNext(viewFinder)
view = next(viewFinder);
sect = Section("Title",view.Name);
add(sect,view);
add(chapter,sect);
end I´m using system composer, and i want to create a report with the views and sequence diagrams that i have. I have this code to generate the report and add the views, but i don´t know if there is a way to add too the sequence diagrams because there is nothing like "SequenceDiagramFinder".
Here is the code for the views:
model = systemcomposer.loadModel(model_name);
rpt = slreportgen.report.Report(output="ViewFinderReport",…
CompileModelBeforeReporting=false);
viewFinder = ViewFinder(model_name);
chapter = Chapter("Title","Views");
while hasNext(viewFinder)
view = next(viewFinder);
sect = Section("Title",view.Name);
add(sect,view);
add(chapter,sect);
end system composer, views, sequence diagrams MATLAB Answers — New Questions