Category: Matlab
Category Archives: Matlab
Are there any methods to remove/reduce shadows in this image?
In this image, the leaves are on a piece of white paper. I wonder in this particular case if there are any effective methods for shadow removal or reduction using Matlab. If it’s not possible to completely remove the shadows, reducing them is also OK. Thank you!In this image, the leaves are on a piece of white paper. I wonder in this particular case if there are any effective methods for shadow removal or reduction using Matlab. If it’s not possible to completely remove the shadows, reducing them is also OK. Thank you! In this image, the leaves are on a piece of white paper. I wonder in this particular case if there are any effective methods for shadow removal or reduction using Matlab. If it’s not possible to completely remove the shadows, reducing them is also OK. Thank you! shadow-removal, shadow-reduction, image enhancement, image processing, image segmentation MATLAB Answers — New Questions
No margins at header photo of report using ActXWord
Hi,
I have created a word report using matlab code (ActXWord).
For the header i import a picture, which i would like to have no margins and cover the header from the upper left corner of page.
ActXWord.Selection.Application.ActiveWindow.View.SeekView = 1; % go to header
ActXWord.Selection.ParagraphFormat.Alignment=0; % left allignment
WordHandle.Sections.Item(1).Headers.Item(1).Range.InlineShapes.AddPicture([pwd ‘header_photo.png’],0,1);
Before i have set the margins of the main body of report:
ActXWord.Selection.Pagesetup.RightMargin=28.34646 * 2;
ActXWord.Selection.Pagesetup.LeftMargin=28.34646 * 2;
ActXWord.Selection.Pagesetup.TopMargin=28.34646 * 2.54;
ActXWord.Selection.Pagesetup.BottomMargin=28.34646 * 2.54;
That way the header photo is complying to main body margins.
How to set different margins for the header photo of word header without changing the main body margins?
Thanks in advance!Hi,
I have created a word report using matlab code (ActXWord).
For the header i import a picture, which i would like to have no margins and cover the header from the upper left corner of page.
ActXWord.Selection.Application.ActiveWindow.View.SeekView = 1; % go to header
ActXWord.Selection.ParagraphFormat.Alignment=0; % left allignment
WordHandle.Sections.Item(1).Headers.Item(1).Range.InlineShapes.AddPicture([pwd ‘header_photo.png’],0,1);
Before i have set the margins of the main body of report:
ActXWord.Selection.Pagesetup.RightMargin=28.34646 * 2;
ActXWord.Selection.Pagesetup.LeftMargin=28.34646 * 2;
ActXWord.Selection.Pagesetup.TopMargin=28.34646 * 2.54;
ActXWord.Selection.Pagesetup.BottomMargin=28.34646 * 2.54;
That way the header photo is complying to main body margins.
How to set different margins for the header photo of word header without changing the main body margins?
Thanks in advance! Hi,
I have created a word report using matlab code (ActXWord).
For the header i import a picture, which i would like to have no margins and cover the header from the upper left corner of page.
ActXWord.Selection.Application.ActiveWindow.View.SeekView = 1; % go to header
ActXWord.Selection.ParagraphFormat.Alignment=0; % left allignment
WordHandle.Sections.Item(1).Headers.Item(1).Range.InlineShapes.AddPicture([pwd ‘header_photo.png’],0,1);
Before i have set the margins of the main body of report:
ActXWord.Selection.Pagesetup.RightMargin=28.34646 * 2;
ActXWord.Selection.Pagesetup.LeftMargin=28.34646 * 2;
ActXWord.Selection.Pagesetup.TopMargin=28.34646 * 2.54;
ActXWord.Selection.Pagesetup.BottomMargin=28.34646 * 2.54;
That way the header photo is complying to main body margins.
How to set different margins for the header photo of word header without changing the main body margins?
Thanks in advance! actxword, header, margins MATLAB Answers — New Questions
How to configure ip address/port with DDS Blockset
I have build the DDS application shapesdemo.exe with DDS Blockset. I have test the communication between shapesdemo.exe with OpenDDS Shapes Demo Application successfully. However, these two DDS Application run on the same desktop computer, I want to communicate shapesdemo.exe with another OpenDDS Shapes Demo Application runing on the different computer.
I want to configure the shapesdemo.exe with the another computer’s ip address/port, such that it can communicate with another computer’s DDS Application, where is the DDS Blockset ip address/port informations saved?I have build the DDS application shapesdemo.exe with DDS Blockset. I have test the communication between shapesdemo.exe with OpenDDS Shapes Demo Application successfully. However, these two DDS Application run on the same desktop computer, I want to communicate shapesdemo.exe with another OpenDDS Shapes Demo Application runing on the different computer.
I want to configure the shapesdemo.exe with the another computer’s ip address/port, such that it can communicate with another computer’s DDS Application, where is the DDS Blockset ip address/port informations saved? I have build the DDS application shapesdemo.exe with DDS Blockset. I have test the communication between shapesdemo.exe with OpenDDS Shapes Demo Application successfully. However, these two DDS Application run on the same desktop computer, I want to communicate shapesdemo.exe with another OpenDDS Shapes Demo Application runing on the different computer.
I want to configure the shapesdemo.exe with the another computer’s ip address/port, such that it can communicate with another computer’s DDS Application, where is the DDS Blockset ip address/port informations saved? dds blockset, shapes demo, simulink MATLAB Answers — New Questions
How to use design verifier with incompatible simulink models?
I have a Simulink model with an integrator block that cannot be stubbed while running the design verifier, rendering the model incompatible with the design verifier. Is there a way to increase the coverage of such a model other than manually building test cases?I have a Simulink model with an integrator block that cannot be stubbed while running the design verifier, rendering the model incompatible with the design verifier. Is there a way to increase the coverage of such a model other than manually building test cases? I have a Simulink model with an integrator block that cannot be stubbed while running the design verifier, rendering the model incompatible with the design verifier. Is there a way to increase the coverage of such a model other than manually building test cases? design verifier, model coverage MATLAB Answers — New Questions
How can I extract data from a specific location?
The scanning tunneling microscope tip is moved to obtain the tunneling current z. The tip is scanned with raster scanning (triangular wave-like behavior) + dither circular motion behavior.
This tunneling current z is then scanned for the time interval Δtm=N(1/fm+j/fm)(N=0, 1, 2, ….. , j=0, 1, 2, 3, 4, 5), we want to extract and draw. j=0, 1, 2, 3, 4, 5 represent the 6 equal positions of the dither circumference. These 6 points are points A, B, C, D, E, and F, which are 210, 330, 90, 30, 150, and 270° of the dither circle, respectively.
How can I extract each tunnel current at each point?
Attached below are images of raster scanning and dither circular motion.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm*240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);
% Plotting Raster Scanning
figure;
plot(x_raster, y_raster, ‘b.-‘);
title(‘Raster Scanning’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on;
% Dither circle plot
figure;
plot(x_dither, y_dither, ‘b.-‘);
title(‘dither circle scanning locus’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on;
%Raster Scanning + dither circle scanning Plot
figure;
plot(x, y, ‘b.-‘);
title(‘Raster scanning + dither circle scanning locus’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on;The scanning tunneling microscope tip is moved to obtain the tunneling current z. The tip is scanned with raster scanning (triangular wave-like behavior) + dither circular motion behavior.
This tunneling current z is then scanned for the time interval Δtm=N(1/fm+j/fm)(N=0, 1, 2, ….. , j=0, 1, 2, 3, 4, 5), we want to extract and draw. j=0, 1, 2, 3, 4, 5 represent the 6 equal positions of the dither circumference. These 6 points are points A, B, C, D, E, and F, which are 210, 330, 90, 30, 150, and 270° of the dither circle, respectively.
How can I extract each tunnel current at each point?
Attached below are images of raster scanning and dither circular motion.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm*240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);
% Plotting Raster Scanning
figure;
plot(x_raster, y_raster, ‘b.-‘);
title(‘Raster Scanning’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on;
% Dither circle plot
figure;
plot(x_dither, y_dither, ‘b.-‘);
title(‘dither circle scanning locus’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on;
%Raster Scanning + dither circle scanning Plot
figure;
plot(x, y, ‘b.-‘);
title(‘Raster scanning + dither circle scanning locus’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on; The scanning tunneling microscope tip is moved to obtain the tunneling current z. The tip is scanned with raster scanning (triangular wave-like behavior) + dither circular motion behavior.
This tunneling current z is then scanned for the time interval Δtm=N(1/fm+j/fm)(N=0, 1, 2, ….. , j=0, 1, 2, 3, 4, 5), we want to extract and draw. j=0, 1, 2, 3, 4, 5 represent the 6 equal positions of the dither circumference. These 6 points are points A, B, C, D, E, and F, which are 210, 330, 90, 30, 150, and 270° of the dither circle, respectively.
How can I extract each tunnel current at each point?
Attached below are images of raster scanning and dither circular motion.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm*240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);
% Plotting Raster Scanning
figure;
plot(x_raster, y_raster, ‘b.-‘);
title(‘Raster Scanning’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on;
% Dither circle plot
figure;
plot(x_dither, y_dither, ‘b.-‘);
title(‘dither circle scanning locus’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on;
%Raster Scanning + dither circle scanning Plot
figure;
plot(x, y, ‘b.-‘);
title(‘Raster scanning + dither circle scanning locus’);
xlabel(‘x coordinate’);
ylabel(‘y coordinate’);
axis equal;
grid on; signal processing, image, matlab MATLAB Answers — New Questions
Not able to plot delay for sine wave using triggered subsystem
I am trying to use delay within the triggered subsystem and I am still getting a flat line as plot , I have tried increasing sample time or adding delay outside of the subsystem but still I am not getting the answer.I am trying to use delay within the triggered subsystem and I am still getting a flat line as plot , I have tried increasing sample time or adding delay outside of the subsystem but still I am not getting the answer. I am trying to use delay within the triggered subsystem and I am still getting a flat line as plot , I have tried increasing sample time or adding delay outside of the subsystem but still I am not getting the answer. delay, simulink MATLAB Answers — New Questions
Gradually Changing LED Intensity
I’m trying to model a system of LEDs with gradually increasing and decreasing intensities. Are there any blocks or add-ons that anyone is aware of that can help me achieve this behavior? Essentially, I want something similar to the Lamp block, but rather than set values and their accompanying colors, I want something that can change based on the value from 0% to 100% intensity. Thanks in advance!I’m trying to model a system of LEDs with gradually increasing and decreasing intensities. Are there any blocks or add-ons that anyone is aware of that can help me achieve this behavior? Essentially, I want something similar to the Lamp block, but rather than set values and their accompanying colors, I want something that can change based on the value from 0% to 100% intensity. Thanks in advance! I’m trying to model a system of LEDs with gradually increasing and decreasing intensities. Are there any blocks or add-ons that anyone is aware of that can help me achieve this behavior? Essentially, I want something similar to the Lamp block, but rather than set values and their accompanying colors, I want something that can change based on the value from 0% to 100% intensity. Thanks in advance! simulink, lamp, intensity, gradual MATLAB Answers — New Questions
Lamp intensity gradually decreases – stateflow logic
Switch ON – Lamp ON, Switch OFF – Lamp intensity decreases upto 30sec after 30sec lamp OFF.: stateflow logicSwitch ON – Lamp ON, Switch OFF – Lamp intensity decreases upto 30sec after 30sec lamp OFF.: stateflow logic Switch ON – Lamp ON, Switch OFF – Lamp intensity decreases upto 30sec after 30sec lamp OFF.: stateflow logic stateflow MATLAB Answers — New Questions
How to find the RMSE? Reposted @torsten
@Torsten
I asked this question on URL: https://www.mathworks.com/matlabcentral/answers/2172760-how-to-find-the-rmse
Even I responded there several times but then I became busy and when I got free to respond there, my response was not recorded. I tried sevral times but in vain. That’s why I am re-posting here.
I used the "rmse code" with my previous code (just added awgn() to add noise ) but it gives me error:
clear;clc
ula = phased.ULA(‘NumElements’,10,’ElementSpacing’,0.5);
angs = [40 -20 20; 0 0 0];% angs=[azimuth; elevation]; My desired angles are 40, -20 and 20.
NumSignals = size(angs,2);
c = physconst(‘LightSpeed’);
fc = 300e6; % Operating frequency
lambda = c/fc;
pos = getElementPosition(ula)/lambda;
Nsamp = 10;%1000;
nPower = 0.01;
rs = rng(2007);
signal = sensorsig(pos,Nsamp,angs,nPower);
signal = awgn(signal,-15);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MUSIC Algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
musicspatialspect = phased.MUSICEstimator(‘SensorArray’,ula,…
‘OperatingFrequency’,fc,’ScanAngles’,-90:90,…
‘DOAOutputPort’,true,’NumSignalsSource’,’Property’,’NumSignals’,NumSignals);
[~,ang] = musicspatialspect(signal)
ymusic = musicspatialspect(signal);
helperPlotDOASpectra(musicspatialspect.ScanAngles,ymusic)% Changed by Me
function helperPlotDOASpectra(x2,y2)% Changed by Me
% Plot spectra in dB normalized to 0 dB at the peak
y2_dB = 20*log10(y2) – max(20*log10(y2));
plot(x2,y2_dB)
xlabel(‘Broadside Angle (degrees)’);
ylabel(‘Power (dB)’);
title(‘DOA Spatial Spectra’)
end
%%%%%%% RMSE
num_runs = 100;
rmse_values = zeros(1, num_runs);
for idx = 1:num_runs
error = angs – ang;
rmse = sqrt(mean(error.^2));
rmse_values(idx) = rmse;
end
figure;
plot(1:num_runs, rmse_values, ‘-o’);
xlabel(‘Run Number’);
ylabel(‘RMSE’);
title(‘RMSE vs Number of Runs’);
grid on;@Torsten
I asked this question on URL: https://www.mathworks.com/matlabcentral/answers/2172760-how-to-find-the-rmse
Even I responded there several times but then I became busy and when I got free to respond there, my response was not recorded. I tried sevral times but in vain. That’s why I am re-posting here.
I used the "rmse code" with my previous code (just added awgn() to add noise ) but it gives me error:
clear;clc
ula = phased.ULA(‘NumElements’,10,’ElementSpacing’,0.5);
angs = [40 -20 20; 0 0 0];% angs=[azimuth; elevation]; My desired angles are 40, -20 and 20.
NumSignals = size(angs,2);
c = physconst(‘LightSpeed’);
fc = 300e6; % Operating frequency
lambda = c/fc;
pos = getElementPosition(ula)/lambda;
Nsamp = 10;%1000;
nPower = 0.01;
rs = rng(2007);
signal = sensorsig(pos,Nsamp,angs,nPower);
signal = awgn(signal,-15);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MUSIC Algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
musicspatialspect = phased.MUSICEstimator(‘SensorArray’,ula,…
‘OperatingFrequency’,fc,’ScanAngles’,-90:90,…
‘DOAOutputPort’,true,’NumSignalsSource’,’Property’,’NumSignals’,NumSignals);
[~,ang] = musicspatialspect(signal)
ymusic = musicspatialspect(signal);
helperPlotDOASpectra(musicspatialspect.ScanAngles,ymusic)% Changed by Me
function helperPlotDOASpectra(x2,y2)% Changed by Me
% Plot spectra in dB normalized to 0 dB at the peak
y2_dB = 20*log10(y2) – max(20*log10(y2));
plot(x2,y2_dB)
xlabel(‘Broadside Angle (degrees)’);
ylabel(‘Power (dB)’);
title(‘DOA Spatial Spectra’)
end
%%%%%%% RMSE
num_runs = 100;
rmse_values = zeros(1, num_runs);
for idx = 1:num_runs
error = angs – ang;
rmse = sqrt(mean(error.^2));
rmse_values(idx) = rmse;
end
figure;
plot(1:num_runs, rmse_values, ‘-o’);
xlabel(‘Run Number’);
ylabel(‘RMSE’);
title(‘RMSE vs Number of Runs’);
grid on; @Torsten
I asked this question on URL: https://www.mathworks.com/matlabcentral/answers/2172760-how-to-find-the-rmse
Even I responded there several times but then I became busy and when I got free to respond there, my response was not recorded. I tried sevral times but in vain. That’s why I am re-posting here.
I used the "rmse code" with my previous code (just added awgn() to add noise ) but it gives me error:
clear;clc
ula = phased.ULA(‘NumElements’,10,’ElementSpacing’,0.5);
angs = [40 -20 20; 0 0 0];% angs=[azimuth; elevation]; My desired angles are 40, -20 and 20.
NumSignals = size(angs,2);
c = physconst(‘LightSpeed’);
fc = 300e6; % Operating frequency
lambda = c/fc;
pos = getElementPosition(ula)/lambda;
Nsamp = 10;%1000;
nPower = 0.01;
rs = rng(2007);
signal = sensorsig(pos,Nsamp,angs,nPower);
signal = awgn(signal,-15);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MUSIC Algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
musicspatialspect = phased.MUSICEstimator(‘SensorArray’,ula,…
‘OperatingFrequency’,fc,’ScanAngles’,-90:90,…
‘DOAOutputPort’,true,’NumSignalsSource’,’Property’,’NumSignals’,NumSignals);
[~,ang] = musicspatialspect(signal)
ymusic = musicspatialspect(signal);
helperPlotDOASpectra(musicspatialspect.ScanAngles,ymusic)% Changed by Me
function helperPlotDOASpectra(x2,y2)% Changed by Me
% Plot spectra in dB normalized to 0 dB at the peak
y2_dB = 20*log10(y2) – max(20*log10(y2));
plot(x2,y2_dB)
xlabel(‘Broadside Angle (degrees)’);
ylabel(‘Power (dB)’);
title(‘DOA Spatial Spectra’)
end
%%%%%%% RMSE
num_runs = 100;
rmse_values = zeros(1, num_runs);
for idx = 1:num_runs
error = angs – ang;
rmse = sqrt(mean(error.^2));
rmse_values(idx) = rmse;
end
figure;
plot(1:num_runs, rmse_values, ‘-o’);
xlabel(‘Run Number’);
ylabel(‘RMSE’);
title(‘RMSE vs Number of Runs’);
grid on; rmse, root mean square error, code error MATLAB Answers — New Questions
advection diffusion reaction modeling with partial differential equations toolbox
I am currently working on modeling an advection-diffusion-reaction (ADR) system using the MATLAB PDE Modeler Toolbox. My specific goal is to simulate the transport and transformation of substances (e.g., nutrients or pollutants) in a 2D domain, accounting for advection, diffusion, and reaction terms.
Challenges:
Incorporating spatially and temporally varying velocity and diffusivity fields.
Defining complex reaction terms and ensuring numerical stability.
Efficiently solving the system over a year-long simulation with hourly time steps.I am currently working on modeling an advection-diffusion-reaction (ADR) system using the MATLAB PDE Modeler Toolbox. My specific goal is to simulate the transport and transformation of substances (e.g., nutrients or pollutants) in a 2D domain, accounting for advection, diffusion, and reaction terms.
Challenges:
Incorporating spatially and temporally varying velocity and diffusivity fields.
Defining complex reaction terms and ensuring numerical stability.
Efficiently solving the system over a year-long simulation with hourly time steps. I am currently working on modeling an advection-diffusion-reaction (ADR) system using the MATLAB PDE Modeler Toolbox. My specific goal is to simulate the transport and transformation of substances (e.g., nutrients or pollutants) in a 2D domain, accounting for advection, diffusion, and reaction terms.
Challenges:
Incorporating spatially and temporally varying velocity and diffusivity fields.
Defining complex reaction terms and ensuring numerical stability.
Efficiently solving the system over a year-long simulation with hourly time steps. advection, diffusion, reaction MATLAB Answers — New Questions
Why does checking for equality sometimes fail when using the Symbolic Toolbox?
Why does checking for equality with ‘isequal’ sometimes fail when using the Symbolic Toolbox? For example:
>> syms x y
>> isequal(x*y+x, x*(y+1))
ans =
logical
0Why does checking for equality with ‘isequal’ sometimes fail when using the Symbolic Toolbox? For example:
>> syms x y
>> isequal(x*y+x, x*(y+1))
ans =
logical
0 Why does checking for equality with ‘isequal’ sometimes fail when using the Symbolic Toolbox? For example:
>> syms x y
>> isequal(x*y+x, x*(y+1))
ans =
logical
0 symbolic, comparison MATLAB Answers — New Questions
Single and Multi-objective optimization
I have a three dimensional design space as shown in figure within which I need to perform single and multi-objective optimization. I cannot define the space with simple upper and lower bounds as such
x_lower = 0.0015;
X_upper = 1.2;
Y_lower = 0.0075;
Y_upper = 0.8;
Z_lower = 0.1;
Z_upper = 0.7;
Is it possible to define the space in a way such that only the space as shown in figure is explored ?I have a three dimensional design space as shown in figure within which I need to perform single and multi-objective optimization. I cannot define the space with simple upper and lower bounds as such
x_lower = 0.0015;
X_upper = 1.2;
Y_lower = 0.0075;
Y_upper = 0.8;
Z_lower = 0.1;
Z_upper = 0.7;
Is it possible to define the space in a way such that only the space as shown in figure is explored ? I have a three dimensional design space as shown in figure within which I need to perform single and multi-objective optimization. I cannot define the space with simple upper and lower bounds as such
x_lower = 0.0015;
X_upper = 1.2;
Y_lower = 0.0075;
Y_upper = 0.8;
Z_lower = 0.1;
Z_upper = 0.7;
Is it possible to define the space in a way such that only the space as shown in figure is explored ? optimization, design space MATLAB Answers — New Questions
Looking for matlab programmer with skills in numerical analysis
I am looking for a MATLAB programmer who has skills in numerical methods. To be more specific, it is about
1) Solving Poisson Equation with some relaxation method
2) Implementing the multigrid method in matlab
If you are interested earning some extra money with that please write me a mail, I will send you all the details.I am looking for a MATLAB programmer who has skills in numerical methods. To be more specific, it is about
1) Solving Poisson Equation with some relaxation method
2) Implementing the multigrid method in matlab
If you are interested earning some extra money with that please write me a mail, I will send you all the details. I am looking for a MATLAB programmer who has skills in numerical methods. To be more specific, it is about
1) Solving Poisson Equation with some relaxation method
2) Implementing the multigrid method in matlab
If you are interested earning some extra money with that please write me a mail, I will send you all the details. programmer, numerical analysis MATLAB Answers — New Questions
Problemas con la configuración de mi cuenta en MATLAB Online
Hola a todos, El año pasado realicé algunos cambios en mi cuenta de MATLAB Online, pero no domino el inglés y no recuerdo exactamente qué modificaciones hice. Ahora estoy teniendo problemas con la sesión y no sé cómo solucionarlos. He intentado algunas soluciones sugeridas por el soporte técnico, pero no han funcionado. Me gustaría saber si es posible reiniciar mi cuenta a su estado inicial, como si nunca hubiera ingresado. Agradezco cualquier ayuda o sugerencia.Hola a todos, El año pasado realicé algunos cambios en mi cuenta de MATLAB Online, pero no domino el inglés y no recuerdo exactamente qué modificaciones hice. Ahora estoy teniendo problemas con la sesión y no sé cómo solucionarlos. He intentado algunas soluciones sugeridas por el soporte técnico, pero no han funcionado. Me gustaría saber si es posible reiniciar mi cuenta a su estado inicial, como si nunca hubiera ingresado. Agradezco cualquier ayuda o sugerencia. Hola a todos, El año pasado realicé algunos cambios en mi cuenta de MATLAB Online, pero no domino el inglés y no recuerdo exactamente qué modificaciones hice. Ahora estoy teniendo problemas con la sesión y no sé cómo solucionarlos. He intentado algunas soluciones sugeridas por el soporte técnico, pero no han funcionado. Me gustaría saber si es posible reiniciar mi cuenta a su estado inicial, como si nunca hubiera ingresado. Agradezco cualquier ayuda o sugerencia. cuenta, configuración, matlab online, problemas, handles MATLAB Answers — New Questions
TON and TOF Timer Blocks in Simulink Ignore Preset Time (PRE)
Hello,
I tried to simulate a very similar PLC model like presented in here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html . The differences are Im using step signal which is converted into boolean for the input, you can see my model in the attached file.
However, it seems like the preset time just doesn’t work. Everytime the switch is on, then the lamp is automatically "on", while it is supposed to be delayed for around 6 seconds (the preset time). I have tried everything, even mirroring every setting and values set in the file from here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html. I have also ensured the initfcn, etc. But still doesnt work as it should be. Im using matlab R2024b. I also put the sceenshots of the windows below.
Thanks for the help.Hello,
I tried to simulate a very similar PLC model like presented in here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html . The differences are Im using step signal which is converted into boolean for the input, you can see my model in the attached file.
However, it seems like the preset time just doesn’t work. Everytime the switch is on, then the lamp is automatically "on", while it is supposed to be delayed for around 6 seconds (the preset time). I have tried everything, even mirroring every setting and values set in the file from here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html. I have also ensured the initfcn, etc. But still doesnt work as it should be. Im using matlab R2024b. I also put the sceenshots of the windows below.
Thanks for the help. Hello,
I tried to simulate a very similar PLC model like presented in here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html . The differences are Im using step signal which is converted into boolean for the input, you can see my model in the attached file.
However, it seems like the preset time just doesn’t work. Everytime the switch is on, then the lamp is automatically "on", while it is supposed to be delayed for around 6 seconds (the preset time). I have tried everything, even mirroring every setting and values set in the file from here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html. I have also ensured the initfcn, etc. But still doesnt work as it should be. Im using matlab R2024b. I also put the sceenshots of the windows below.
Thanks for the help. plc, ton, tof, simulink, studio5000, timer MATLAB Answers — New Questions
Run for loop 1000 times and get distribution of results
I have some code that runs a simulation of an equation in a for loop which results in a 1×128 array. I want to run a large number of these simulations, say 1000, so we have 1000 arrays of 1×128, then get the distribution of the 128th element of each array, say in a histogram.
So run for loop 1000 times, take value of 128th column from each array for 1000 values, then plot histogram of results. The X axis would be 0 to 1 and the Y axis would be frequency of each value (of course).
I’m sure the solution is quite simple, but everything I’ve tried hasn’t worked right and I can’t figure out where I’m going wrong, so I’d appreciate some advice.
Xzero = 0;
T = 1;
N = 2^8;
dt = 1/N;
r=1;
G=0.7;
e=0.5;
M=1000;
dW = sqrt(dt)*randn(M,N);
W = cumsum(dW);
R = 2; Dt = R*dt; L = N/R;
Xem = zeros(1,L);
Xtemp = Xzero;
for j = 1:L
Winc = sum(dW(R*(j-1)+1:R*j));
Xtemp = Dt*r*(G-Xtemp) + sqrt((e*Xtemp)*(1-Xtemp))*Winc;
Xem(j) = Xtemp;
endI have some code that runs a simulation of an equation in a for loop which results in a 1×128 array. I want to run a large number of these simulations, say 1000, so we have 1000 arrays of 1×128, then get the distribution of the 128th element of each array, say in a histogram.
So run for loop 1000 times, take value of 128th column from each array for 1000 values, then plot histogram of results. The X axis would be 0 to 1 and the Y axis would be frequency of each value (of course).
I’m sure the solution is quite simple, but everything I’ve tried hasn’t worked right and I can’t figure out where I’m going wrong, so I’d appreciate some advice.
Xzero = 0;
T = 1;
N = 2^8;
dt = 1/N;
r=1;
G=0.7;
e=0.5;
M=1000;
dW = sqrt(dt)*randn(M,N);
W = cumsum(dW);
R = 2; Dt = R*dt; L = N/R;
Xem = zeros(1,L);
Xtemp = Xzero;
for j = 1:L
Winc = sum(dW(R*(j-1)+1:R*j));
Xtemp = Dt*r*(G-Xtemp) + sqrt((e*Xtemp)*(1-Xtemp))*Winc;
Xem(j) = Xtemp;
end I have some code that runs a simulation of an equation in a for loop which results in a 1×128 array. I want to run a large number of these simulations, say 1000, so we have 1000 arrays of 1×128, then get the distribution of the 128th element of each array, say in a histogram.
So run for loop 1000 times, take value of 128th column from each array for 1000 values, then plot histogram of results. The X axis would be 0 to 1 and the Y axis would be frequency of each value (of course).
I’m sure the solution is quite simple, but everything I’ve tried hasn’t worked right and I can’t figure out where I’m going wrong, so I’d appreciate some advice.
Xzero = 0;
T = 1;
N = 2^8;
dt = 1/N;
r=1;
G=0.7;
e=0.5;
M=1000;
dW = sqrt(dt)*randn(M,N);
W = cumsum(dW);
R = 2; Dt = R*dt; L = N/R;
Xem = zeros(1,L);
Xtemp = Xzero;
for j = 1:L
Winc = sum(dW(R*(j-1)+1:R*j));
Xtemp = Dt*r*(G-Xtemp) + sqrt((e*Xtemp)*(1-Xtemp))*Winc;
Xem(j) = Xtemp;
end for loop, histogram MATLAB Answers — New Questions
Erron on Symbolic calculation [Case 2] : “Empty sym : 0-by-1”
I need the help of people who have excellent talents in calculating using Matlab.
The equations to be implemented through Matlab coding is as follows.
Answer) β = 5.874395, A = 0.000060, b = 0.280599, φ = 5630.329851
The results to be obtained through this coding is written in "Answer) ~" above.
And, the data related to this problem(or eqution) is below.
I have tried with the following coding but kept getting the same results as the title. I would like to get helpful advice on this part.
I would appreciate it if you could give me a guide on the solution or error cause.
clear all
clc
th1 = [378 378 378 378; 0.4 0.4 0.4 0.4; 310 316 329 411]; % [V_i ; U_i ; T_i]
th2 = [378 378 378 378; 0.8 0.8 0.8 0.8; 190 208 230 298];
th3 = [398 398 398 398; 0.4 0.4 0.4 0.4; 108 123 166 200];
syms B;
syms A;
syms phi;
syms b;
%————- equation 1 ————-%
a1_th1 = 0;
a1_th2 = 0;
a1_th3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
a1_th1 = N*(1-(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B)*(log(th1(i+2,j)/A)-(phi/th1(i,j)+b/th1(i+1,j))) + a1_th1 ;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
a1_th2 = N*(1-(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B)*(log(th2(i+2,j)/A)-(phi/th2(i,j)+b/th2(i+1,j))) + a1_th2 ;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
a1_th3 = N*(1-(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B)*(log(th3(i+2,j)/A)-(phi/th3(i,j)+b/th3(i+1,j))) + a1_th3 ;
end
a1 = a1_th1 + a1_th2 + a1_th3;
N = numel(th1(1,:)) + numel(th2(1,:)) + numel(th3(1,:)); % ∂Λ/∂β first term
one = N/B + a1;
% vpa(one,3);
%————- equation 2 ————-%
b1 = 0;
b2 = 0;
b3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
b1 = N*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+b1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
b2 = N*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+b2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
b3 = N*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+b3;
end
N = numel(th1(1,:)) + numel(th2(1,:)) + numel(th3(1,:)); % ∂Λ/∂A first term
two = -B/A*(N + (b1 + b2 + b3));
% vpa(two,3);
%————- equation 3 ————-%
c1 = 0;
c2 = 0;
c3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
c1 = N/th1(i,j)*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+c1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
c2 = N/th2(i,j)*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+c2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
c3 = N/th3(i,j)*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+c3;
end
N_c1 = 0;
N_c2 = 0;
N_c3 = 0;
i = 1;
for j = 1:(numel(th1(i, :)))
N_c1 = numel(th1(i,j))/th1(i,j)+N_c1; % "Stress Lv. 1" in the first term of ∂Λ/∂φ(equation 3)
end
i = 1;
for j = 1:(numel(th2(i, :)))
N_c2 = numel(th2(i,j))/th2(i,j)+N_c2; % "Stress Lv. 2" in the first term of ∂Λ/∂φ(equation 3)
end
i = 1;
for j = 1:(numel(th3(i, :)))
N_c3 = numel(th3(i,j))/th3(i,j)+N_c3; % "Stress Lv. 3" in the first term of ∂Λ/∂φ(equation 3)
end
N_c = N_c1 + N_c2 + N_c3; % ∂Λ/∂φ first term
three = -B*(N_c – (c1 + c2 + c3));
% vpa(three,3);
%————- equation 3 ————-%
d1 = 0;
d2 = 0;
d3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂b(equation 4)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
d1 = N/th1(i+1,j)*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+d1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂b(equation 4)"
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
d2 = N/th2(i+1,j)*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+d2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂b(equation 4)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
d3 = N/th3(i+1,j)*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+d3;
end
N_d1 = 0;
N_d2 = 0;
N_d3 = 0;
i = 1;
for j = 1:(numel(th1(i, :)))
N_d1 = numel(th1(i,j))/th1(i+1,j)+N_d1; % "Stress Lv. 1" in the first term of ∂Λ/∂b(equation 4)
end
i = 1;
for j = 1:(numel(th2(i, :)))
N_d2 = numel(th2(i,j))/th2(i+1,j)+N_d2; % "Stress Lv. 2" in the first term of ∂Λ/∂b(equation 4)
end
i = 1;
for j = 1:(numel(th3(i, :)))
N_d3 = numel(th3(i,j))/th3(i+1,j)+N_d3; % "Stress Lv. 3" in the first term of ∂Λ/∂b(equation 4)
end
N_d = N_d1 + N_d2 + N_d3; % ∂Λ/∂b first term
four = -B*(N_d – (d1 + d2 + d3));
% vpa(four,3);
[B, A, phi, b] = solve(one,two,three,four,’Real’,true)
% eqns = [one == 0, two == 0, three == 0, four == 0];
% vars = [B, A, phi, b];
% [solB, solA, solphi, solb] = solve(eqns, vars, ‘Real’, true)I need the help of people who have excellent talents in calculating using Matlab.
The equations to be implemented through Matlab coding is as follows.
Answer) β = 5.874395, A = 0.000060, b = 0.280599, φ = 5630.329851
The results to be obtained through this coding is written in "Answer) ~" above.
And, the data related to this problem(or eqution) is below.
I have tried with the following coding but kept getting the same results as the title. I would like to get helpful advice on this part.
I would appreciate it if you could give me a guide on the solution or error cause.
clear all
clc
th1 = [378 378 378 378; 0.4 0.4 0.4 0.4; 310 316 329 411]; % [V_i ; U_i ; T_i]
th2 = [378 378 378 378; 0.8 0.8 0.8 0.8; 190 208 230 298];
th3 = [398 398 398 398; 0.4 0.4 0.4 0.4; 108 123 166 200];
syms B;
syms A;
syms phi;
syms b;
%————- equation 1 ————-%
a1_th1 = 0;
a1_th2 = 0;
a1_th3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
a1_th1 = N*(1-(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B)*(log(th1(i+2,j)/A)-(phi/th1(i,j)+b/th1(i+1,j))) + a1_th1 ;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
a1_th2 = N*(1-(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B)*(log(th2(i+2,j)/A)-(phi/th2(i,j)+b/th2(i+1,j))) + a1_th2 ;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
a1_th3 = N*(1-(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B)*(log(th3(i+2,j)/A)-(phi/th3(i,j)+b/th3(i+1,j))) + a1_th3 ;
end
a1 = a1_th1 + a1_th2 + a1_th3;
N = numel(th1(1,:)) + numel(th2(1,:)) + numel(th3(1,:)); % ∂Λ/∂β first term
one = N/B + a1;
% vpa(one,3);
%————- equation 2 ————-%
b1 = 0;
b2 = 0;
b3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
b1 = N*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+b1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
b2 = N*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+b2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
b3 = N*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+b3;
end
N = numel(th1(1,:)) + numel(th2(1,:)) + numel(th3(1,:)); % ∂Λ/∂A first term
two = -B/A*(N + (b1 + b2 + b3));
% vpa(two,3);
%————- equation 3 ————-%
c1 = 0;
c2 = 0;
c3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
c1 = N/th1(i,j)*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+c1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
c2 = N/th2(i,j)*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+c2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
c3 = N/th3(i,j)*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+c3;
end
N_c1 = 0;
N_c2 = 0;
N_c3 = 0;
i = 1;
for j = 1:(numel(th1(i, :)))
N_c1 = numel(th1(i,j))/th1(i,j)+N_c1; % "Stress Lv. 1" in the first term of ∂Λ/∂φ(equation 3)
end
i = 1;
for j = 1:(numel(th2(i, :)))
N_c2 = numel(th2(i,j))/th2(i,j)+N_c2; % "Stress Lv. 2" in the first term of ∂Λ/∂φ(equation 3)
end
i = 1;
for j = 1:(numel(th3(i, :)))
N_c3 = numel(th3(i,j))/th3(i,j)+N_c3; % "Stress Lv. 3" in the first term of ∂Λ/∂φ(equation 3)
end
N_c = N_c1 + N_c2 + N_c3; % ∂Λ/∂φ first term
three = -B*(N_c – (c1 + c2 + c3));
% vpa(three,3);
%————- equation 3 ————-%
d1 = 0;
d2 = 0;
d3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂b(equation 4)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
d1 = N/th1(i+1,j)*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+d1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂b(equation 4)"
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
d2 = N/th2(i+1,j)*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+d2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂b(equation 4)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
d3 = N/th3(i+1,j)*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+d3;
end
N_d1 = 0;
N_d2 = 0;
N_d3 = 0;
i = 1;
for j = 1:(numel(th1(i, :)))
N_d1 = numel(th1(i,j))/th1(i+1,j)+N_d1; % "Stress Lv. 1" in the first term of ∂Λ/∂b(equation 4)
end
i = 1;
for j = 1:(numel(th2(i, :)))
N_d2 = numel(th2(i,j))/th2(i+1,j)+N_d2; % "Stress Lv. 2" in the first term of ∂Λ/∂b(equation 4)
end
i = 1;
for j = 1:(numel(th3(i, :)))
N_d3 = numel(th3(i,j))/th3(i+1,j)+N_d3; % "Stress Lv. 3" in the first term of ∂Λ/∂b(equation 4)
end
N_d = N_d1 + N_d2 + N_d3; % ∂Λ/∂b first term
four = -B*(N_d – (d1 + d2 + d3));
% vpa(four,3);
[B, A, phi, b] = solve(one,two,three,four,’Real’,true)
% eqns = [one == 0, two == 0, three == 0, four == 0];
% vars = [B, A, phi, b];
% [solB, solA, solphi, solb] = solve(eqns, vars, ‘Real’, true) I need the help of people who have excellent talents in calculating using Matlab.
The equations to be implemented through Matlab coding is as follows.
Answer) β = 5.874395, A = 0.000060, b = 0.280599, φ = 5630.329851
The results to be obtained through this coding is written in "Answer) ~" above.
And, the data related to this problem(or eqution) is below.
I have tried with the following coding but kept getting the same results as the title. I would like to get helpful advice on this part.
I would appreciate it if you could give me a guide on the solution or error cause.
clear all
clc
th1 = [378 378 378 378; 0.4 0.4 0.4 0.4; 310 316 329 411]; % [V_i ; U_i ; T_i]
th2 = [378 378 378 378; 0.8 0.8 0.8 0.8; 190 208 230 298];
th3 = [398 398 398 398; 0.4 0.4 0.4 0.4; 108 123 166 200];
syms B;
syms A;
syms phi;
syms b;
%————- equation 1 ————-%
a1_th1 = 0;
a1_th2 = 0;
a1_th3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
a1_th1 = N*(1-(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B)*(log(th1(i+2,j)/A)-(phi/th1(i,j)+b/th1(i+1,j))) + a1_th1 ;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
a1_th2 = N*(1-(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B)*(log(th2(i+2,j)/A)-(phi/th2(i,j)+b/th2(i+1,j))) + a1_th2 ;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂β(equation 1)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
a1_th3 = N*(1-(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B)*(log(th3(i+2,j)/A)-(phi/th3(i,j)+b/th3(i+1,j))) + a1_th3 ;
end
a1 = a1_th1 + a1_th2 + a1_th3;
N = numel(th1(1,:)) + numel(th2(1,:)) + numel(th3(1,:)); % ∂Λ/∂β first term
one = N/B + a1;
% vpa(one,3);
%————- equation 2 ————-%
b1 = 0;
b2 = 0;
b3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
b1 = N*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+b1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
b2 = N*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+b2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂A(equation 2)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
b3 = N*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+b3;
end
N = numel(th1(1,:)) + numel(th2(1,:)) + numel(th3(1,:)); % ∂Λ/∂A first term
two = -B/A*(N + (b1 + b2 + b3));
% vpa(two,3);
%————- equation 3 ————-%
c1 = 0;
c2 = 0;
c3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
c1 = N/th1(i,j)*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+c1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
c2 = N/th2(i,j)*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+c2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂φ(equation 3)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
c3 = N/th3(i,j)*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+c3;
end
N_c1 = 0;
N_c2 = 0;
N_c3 = 0;
i = 1;
for j = 1:(numel(th1(i, :)))
N_c1 = numel(th1(i,j))/th1(i,j)+N_c1; % "Stress Lv. 1" in the first term of ∂Λ/∂φ(equation 3)
end
i = 1;
for j = 1:(numel(th2(i, :)))
N_c2 = numel(th2(i,j))/th2(i,j)+N_c2; % "Stress Lv. 2" in the first term of ∂Λ/∂φ(equation 3)
end
i = 1;
for j = 1:(numel(th3(i, :)))
N_c3 = numel(th3(i,j))/th3(i,j)+N_c3; % "Stress Lv. 3" in the first term of ∂Λ/∂φ(equation 3)
end
N_c = N_c1 + N_c2 + N_c3; % ∂Λ/∂φ first term
three = -B*(N_c – (c1 + c2 + c3));
% vpa(three,3);
%————- equation 3 ————-%
d1 = 0;
d2 = 0;
d3 = 0;
i = 1; % "Stress Lv. 1" in the second term of ∂Λ/∂b(equation 4)
for j = 1:(numel(th1(i, :)))
N = numel(th1(i,j));
d1 = N/th1(i+1,j)*(th1(i+2,j)/A*exp(-(phi/th1(i,j)+b/th1(i+1,j))))^B+d1;
end
i = 1; % "Stress Lv. 2" in the second term of ∂Λ/∂b(equation 4)"
for j = 1:(numel(th2(i, :)))
N = numel(th2(i,j));
d2 = N/th2(i+1,j)*(th2(i+2,j)/A*exp(-(phi/th2(i,j)+b/th2(i+1,j))))^B+d2;
end
i = 1; % "Stress Lv. 3" in the second term of ∂Λ/∂b(equation 4)
for j = 1:(numel(th3(i, :)))
N = numel(th3(i,j));
d3 = N/th3(i+1,j)*(th3(i+2,j)/A*exp(-(phi/th3(i,j)+b/th3(i+1,j))))^B+d3;
end
N_d1 = 0;
N_d2 = 0;
N_d3 = 0;
i = 1;
for j = 1:(numel(th1(i, :)))
N_d1 = numel(th1(i,j))/th1(i+1,j)+N_d1; % "Stress Lv. 1" in the first term of ∂Λ/∂b(equation 4)
end
i = 1;
for j = 1:(numel(th2(i, :)))
N_d2 = numel(th2(i,j))/th2(i+1,j)+N_d2; % "Stress Lv. 2" in the first term of ∂Λ/∂b(equation 4)
end
i = 1;
for j = 1:(numel(th3(i, :)))
N_d3 = numel(th3(i,j))/th3(i+1,j)+N_d3; % "Stress Lv. 3" in the first term of ∂Λ/∂b(equation 4)
end
N_d = N_d1 + N_d2 + N_d3; % ∂Λ/∂b first term
four = -B*(N_d – (d1 + d2 + d3));
% vpa(four,3);
[B, A, phi, b] = solve(one,two,three,four,’Real’,true)
% eqns = [one == 0, two == 0, three == 0, four == 0];
% vars = [B, A, phi, b];
% [solB, solA, solphi, solb] = solve(eqns, vars, ‘Real’, true) symbolic, emptysym, 0-by-1, temperature-humidity, partialdifferentiation MATLAB Answers — New Questions
I have a double input but the CANdbc requires an uint16 in vehicle networking toolbox. This throws up an error.
I have a double input but the CANdbc requires an uint16 datatype specified. I am using a CAN pack block but during the compilation it throws up an error regarding the incorrect datatype. I tried using the data type conversion block but it throwed up an error regarding the round() function. We are using the embedded coder to compile the model.
The constant block image is also shared
This is my CAN pack setup
The exact error I am getting
I am using matlab 2021b for the testing of my codeI have a double input but the CANdbc requires an uint16 datatype specified. I am using a CAN pack block but during the compilation it throws up an error regarding the incorrect datatype. I tried using the data type conversion block but it throwed up an error regarding the round() function. We are using the embedded coder to compile the model.
The constant block image is also shared
This is my CAN pack setup
The exact error I am getting
I am using matlab 2021b for the testing of my code I have a double input but the CANdbc requires an uint16 datatype specified. I am using a CAN pack block but during the compilation it throws up an error regarding the incorrect datatype. I tried using the data type conversion block but it throwed up an error regarding the round() function. We are using the embedded coder to compile the model.
The constant block image is also shared
This is my CAN pack setup
The exact error I am getting
I am using matlab 2021b for the testing of my code simulink, can pack, vehicle networking toolbox MATLAB Answers — New Questions
In App Designer, how can I keep the X and Y Grids on top of an image I display in UIAxes using imshow?
I am creating an app that will display plots on top of an image in a UIAxes object. The issue I’m running into is that once I load the image into UIAxes using imshow, the X and Y Grid lines are covered by the image. If I increase the transparency of the image while debugging I can see that they are still there, but I haven’t been able to figure out how to move them in front of the image.
Data I plot will appear in front of the image, so I feel like there is a layering issue I can’t figure out. I created a quick test app to demonstrate.
The code that creates that updates UIAxes when the button is pressed is:
% Button pushed function: Button
function ButtonPushed(app, event)
%Load Test Image
rgbImage = imread("peppers.png");
%Flip Image so it displays properly
rgbImage = flip(rgbImage);
hold(app.UIAxes,"on");
%Display image in test axes
hImage = imshow(rgbImage, ‘XData’, [0.0, 1.0], ‘YData’, [0.0, 1.0],’Parent’, app.UIAxes);
%return axes to normal position (imshow reverses the direction
%automatically when called)
app.UIAxes.YDir = ‘normal’;
%Turn the axes back on
app.UIAxes.XGrid = ‘on’;
app.UIAxes.YGrid = ‘on’;
%Plot test data to show it appears on top of the image
xData = [0.4,0.6,0.6,0.4];
yData = [0.4,0.6,0.6,0.4];
plot(xData,yData,’parent’,app.UIAxes);
end
Thanks for your help!I am creating an app that will display plots on top of an image in a UIAxes object. The issue I’m running into is that once I load the image into UIAxes using imshow, the X and Y Grid lines are covered by the image. If I increase the transparency of the image while debugging I can see that they are still there, but I haven’t been able to figure out how to move them in front of the image.
Data I plot will appear in front of the image, so I feel like there is a layering issue I can’t figure out. I created a quick test app to demonstrate.
The code that creates that updates UIAxes when the button is pressed is:
% Button pushed function: Button
function ButtonPushed(app, event)
%Load Test Image
rgbImage = imread("peppers.png");
%Flip Image so it displays properly
rgbImage = flip(rgbImage);
hold(app.UIAxes,"on");
%Display image in test axes
hImage = imshow(rgbImage, ‘XData’, [0.0, 1.0], ‘YData’, [0.0, 1.0],’Parent’, app.UIAxes);
%return axes to normal position (imshow reverses the direction
%automatically when called)
app.UIAxes.YDir = ‘normal’;
%Turn the axes back on
app.UIAxes.XGrid = ‘on’;
app.UIAxes.YGrid = ‘on’;
%Plot test data to show it appears on top of the image
xData = [0.4,0.6,0.6,0.4];
yData = [0.4,0.6,0.6,0.4];
plot(xData,yData,’parent’,app.UIAxes);
end
Thanks for your help! I am creating an app that will display plots on top of an image in a UIAxes object. The issue I’m running into is that once I load the image into UIAxes using imshow, the X and Y Grid lines are covered by the image. If I increase the transparency of the image while debugging I can see that they are still there, but I haven’t been able to figure out how to move them in front of the image.
Data I plot will appear in front of the image, so I feel like there is a layering issue I can’t figure out. I created a quick test app to demonstrate.
The code that creates that updates UIAxes when the button is pressed is:
% Button pushed function: Button
function ButtonPushed(app, event)
%Load Test Image
rgbImage = imread("peppers.png");
%Flip Image so it displays properly
rgbImage = flip(rgbImage);
hold(app.UIAxes,"on");
%Display image in test axes
hImage = imshow(rgbImage, ‘XData’, [0.0, 1.0], ‘YData’, [0.0, 1.0],’Parent’, app.UIAxes);
%return axes to normal position (imshow reverses the direction
%automatically when called)
app.UIAxes.YDir = ‘normal’;
%Turn the axes back on
app.UIAxes.XGrid = ‘on’;
app.UIAxes.YGrid = ‘on’;
%Plot test data to show it appears on top of the image
xData = [0.4,0.6,0.6,0.4];
yData = [0.4,0.6,0.6,0.4];
plot(xData,yData,’parent’,app.UIAxes);
end
Thanks for your help! appdesigner, imshow, uiaxes, layers MATLAB Answers — New Questions
How to change the time from seconds to hours of a plot from Simulink
Hi, my knowledge of Matlab is very limited. I have a two signals from Simulink that I want to plot on a Matlab script. I sent my signals to the workspace and they come out as a 1×1 double timeseries. I want to change the timebase of my graphs from seconds to hours, since I’m simulating for 650000 seconds. I just don’t know how to modify the time from my plots. Could someone help please?Hi, my knowledge of Matlab is very limited. I have a two signals from Simulink that I want to plot on a Matlab script. I sent my signals to the workspace and they come out as a 1×1 double timeseries. I want to change the timebase of my graphs from seconds to hours, since I’m simulating for 650000 seconds. I just don’t know how to modify the time from my plots. Could someone help please? Hi, my knowledge of Matlab is very limited. I have a two signals from Simulink that I want to plot on a Matlab script. I sent my signals to the workspace and they come out as a 1×1 double timeseries. I want to change the timebase of my graphs from seconds to hours, since I’m simulating for 650000 seconds. I just don’t know how to modify the time from my plots. Could someone help please? time series, matlab, simulink, simscape MATLAB Answers — New Questions