Author: PuTI
How to send one array element at a time to a subsystem every 0.5 seconds in Simulink?
Hi all, I’m working on a Simulink model where a MATLAB Function block outputs an array of control commands (the command array is generated once at the start of simulation). I’d like to send one command at a time from this array to a subsystem input, with a rate of 2 Hz (i.e., one value every 0.5 seconds).
What’s the best way to implement this?
Thanks in advance!Hi all, I’m working on a Simulink model where a MATLAB Function block outputs an array of control commands (the command array is generated once at the start of simulation). I’d like to send one command at a time from this array to a subsystem input, with a rate of 2 Hz (i.e., one value every 0.5 seconds).
What’s the best way to implement this?
Thanks in advance! Hi all, I’m working on a Simulink model where a MATLAB Function block outputs an array of control commands (the command array is generated once at the start of simulation). I’d like to send one command at a time from this array to a subsystem input, with a rate of 2 Hz (i.e., one value every 0.5 seconds).
What’s the best way to implement this?
Thanks in advance! simulink MATLAB Answers — New Questions
How to do recursive least square for online parameter estimation
I have stucked in this details for months now
I have constructed my simulink model which is a little complicated (containing a PV array + DC/DC converter ) using simscape
the simulation is working for this first stage
The second stage is to use online parameter estimation to estimate the time varying parameter of the PV cell
i have the simulated data Pmpp and the experimetal data Pmpp
now i want to do it online to update comtimuosly the parameters
the problem is that most of the apps and blocks in simulink support using an Autoregressive models like ARX ARMA …
But iwant to do it with my simulink model
Any helpI have stucked in this details for months now
I have constructed my simulink model which is a little complicated (containing a PV array + DC/DC converter ) using simscape
the simulation is working for this first stage
The second stage is to use online parameter estimation to estimate the time varying parameter of the PV cell
i have the simulated data Pmpp and the experimetal data Pmpp
now i want to do it online to update comtimuosly the parameters
the problem is that most of the apps and blocks in simulink support using an Autoregressive models like ARX ARMA …
But iwant to do it with my simulink model
Any help I have stucked in this details for months now
I have constructed my simulink model which is a little complicated (containing a PV array + DC/DC converter ) using simscape
the simulation is working for this first stage
The second stage is to use online parameter estimation to estimate the time varying parameter of the PV cell
i have the simulated data Pmpp and the experimetal data Pmpp
now i want to do it online to update comtimuosly the parameters
the problem is that most of the apps and blocks in simulink support using an Autoregressive models like ARX ARMA …
But iwant to do it with my simulink model
Any help recursive, least square, parameter estimation, online MATLAB Answers — New Questions
Average Optical Flow vectors and plot over multiple frames
Hello,
I am trying to get the average optical flow vectors for a whole video (e.g. for a 10 second video). Currently I am using the opticalFlowFarneback method from Estimate optical flow example with the Computer Vision Toolbox (https://www.mathworks.com/help/vision/ref/opticalflowhs.estimateflow.html):
%% Estimating Optical Flow
% This example uses the Farneback Method to to estimate the direction and speed of moving
% cars in the video
% Copyright 2018 The MathWorks, Inc.
%% Read the video into MATLAB
vidReader = VideoReader(‘visiontraffic.avi’);
opticFlow = opticalFlowFarneback;
%% Estimate Optical Flow of each frame
while hasFrame(vidReader)
frameRGB = readFrame(vidReader);
frameGray = rgb2gray(frameRGB);
flow = estimateFlow(opticFlow,frameGray);
imshow(frameRGB)
hold on
% Plot the flow vectors
plot(flow,’DecimationFactor’,[25 25],’ScaleFactor’, 2)
% Find the handle to the quiver object
q = findobj(gca,’type’,’Quiver’);
% Change the color of the arrows to red
q.Color = ‘r’;
drawnow
hold off
end
Although this produces a nice visualization of flow vectors between two frames (see attached image), I need more like an average of flow vectors across all frames of the video. I am quite new to MatLab, I would be super thankful for any feedback how to change abovementioned code.Hello,
I am trying to get the average optical flow vectors for a whole video (e.g. for a 10 second video). Currently I am using the opticalFlowFarneback method from Estimate optical flow example with the Computer Vision Toolbox (https://www.mathworks.com/help/vision/ref/opticalflowhs.estimateflow.html):
%% Estimating Optical Flow
% This example uses the Farneback Method to to estimate the direction and speed of moving
% cars in the video
% Copyright 2018 The MathWorks, Inc.
%% Read the video into MATLAB
vidReader = VideoReader(‘visiontraffic.avi’);
opticFlow = opticalFlowFarneback;
%% Estimate Optical Flow of each frame
while hasFrame(vidReader)
frameRGB = readFrame(vidReader);
frameGray = rgb2gray(frameRGB);
flow = estimateFlow(opticFlow,frameGray);
imshow(frameRGB)
hold on
% Plot the flow vectors
plot(flow,’DecimationFactor’,[25 25],’ScaleFactor’, 2)
% Find the handle to the quiver object
q = findobj(gca,’type’,’Quiver’);
% Change the color of the arrows to red
q.Color = ‘r’;
drawnow
hold off
end
Although this produces a nice visualization of flow vectors between two frames (see attached image), I need more like an average of flow vectors across all frames of the video. I am quite new to MatLab, I would be super thankful for any feedback how to change abovementioned code. Hello,
I am trying to get the average optical flow vectors for a whole video (e.g. for a 10 second video). Currently I am using the opticalFlowFarneback method from Estimate optical flow example with the Computer Vision Toolbox (https://www.mathworks.com/help/vision/ref/opticalflowhs.estimateflow.html):
%% Estimating Optical Flow
% This example uses the Farneback Method to to estimate the direction and speed of moving
% cars in the video
% Copyright 2018 The MathWorks, Inc.
%% Read the video into MATLAB
vidReader = VideoReader(‘visiontraffic.avi’);
opticFlow = opticalFlowFarneback;
%% Estimate Optical Flow of each frame
while hasFrame(vidReader)
frameRGB = readFrame(vidReader);
frameGray = rgb2gray(frameRGB);
flow = estimateFlow(opticFlow,frameGray);
imshow(frameRGB)
hold on
% Plot the flow vectors
plot(flow,’DecimationFactor’,[25 25],’ScaleFactor’, 2)
% Find the handle to the quiver object
q = findobj(gca,’type’,’Quiver’);
% Change the color of the arrows to red
q.Color = ‘r’;
drawnow
hold off
end
Although this produces a nice visualization of flow vectors between two frames (see attached image), I need more like an average of flow vectors across all frames of the video. I am quite new to MatLab, I would be super thankful for any feedback how to change abovementioned code. optical flow, plot, plotting, quiver, video processing, video, vector, vectors MATLAB Answers — New Questions
How to create multiple Fuzzy Inference Systems (FIS) simultaneously without using a for-loop
I am continuously changing my membership function values in my code. I can run a loop and create as many Fuzzy Inference systems(FISs) as I want. But I want to create all of them simultaneously so that I can cut down on the execution time. I looked up the codes of many inbuilt functions like newfis,addvar etc. They support the creation of one FIS at a time. So is there any other way of solving this problem without having to modify the inbuilt functions?
Thanks in advance.I am continuously changing my membership function values in my code. I can run a loop and create as many Fuzzy Inference systems(FISs) as I want. But I want to create all of them simultaneously so that I can cut down on the execution time. I looked up the codes of many inbuilt functions like newfis,addvar etc. They support the creation of one FIS at a time. So is there any other way of solving this problem without having to modify the inbuilt functions?
Thanks in advance. I am continuously changing my membership function values in my code. I can run a loop and create as many Fuzzy Inference systems(FISs) as I want. But I want to create all of them simultaneously so that I can cut down on the execution time. I looked up the codes of many inbuilt functions like newfis,addvar etc. They support the creation of one FIS at a time. So is there any other way of solving this problem without having to modify the inbuilt functions?
Thanks in advance. fuzzy logic MATLAB Answers — New Questions
Error with addpath in MATLAB Runtime when Using ROS 2 Custom Messages in a Deployed Application
I am developing a MATLAB application that uses ROS 2 and requires custom messages. The code works fine in the MATLAB development environment, but when I compile it using MATLAB Compiler and try to run the deployed application, I encounter the following error:
Error using matlabpath
Modifying the search path is not supported by MATLAB Compiler. Remove functions that modify the search path from your MATLAB code. To make files visible to your deployed application, add the parent folder to your MATLAB session.
Error in path (line 109)
Error in addpath>doPathAddition (line 126)
Error in addpath (line 90)
Error in ros.internal.getEmptyMessage>getCachedMap (line 53)
Error in ros.internal.getEmptyMessage (line 33)
Error in ros.internal.utilities.findMsgDepends (line 17)
Error in ros.internal.utilities.getPathOfDependentDlls (line 16)
Error in ros2publisher/createPublisher (line 460)
Error in ros2publisher (line 267)
How can I properly include the custom ROS 2 messages in a deployed MATLAB application without triggering this error? Is there a way to avoid the dynamic modification of the path or preload the required dependencies before deployment?
Any guidance on handling custom ROS 2 messages in MATLAB Runtime would be greatly appreciated.I am developing a MATLAB application that uses ROS 2 and requires custom messages. The code works fine in the MATLAB development environment, but when I compile it using MATLAB Compiler and try to run the deployed application, I encounter the following error:
Error using matlabpath
Modifying the search path is not supported by MATLAB Compiler. Remove functions that modify the search path from your MATLAB code. To make files visible to your deployed application, add the parent folder to your MATLAB session.
Error in path (line 109)
Error in addpath>doPathAddition (line 126)
Error in addpath (line 90)
Error in ros.internal.getEmptyMessage>getCachedMap (line 53)
Error in ros.internal.getEmptyMessage (line 33)
Error in ros.internal.utilities.findMsgDepends (line 17)
Error in ros.internal.utilities.getPathOfDependentDlls (line 16)
Error in ros2publisher/createPublisher (line 460)
Error in ros2publisher (line 267)
How can I properly include the custom ROS 2 messages in a deployed MATLAB application without triggering this error? Is there a way to avoid the dynamic modification of the path or preload the required dependencies before deployment?
Any guidance on handling custom ROS 2 messages in MATLAB Runtime would be greatly appreciated. I am developing a MATLAB application that uses ROS 2 and requires custom messages. The code works fine in the MATLAB development environment, but when I compile it using MATLAB Compiler and try to run the deployed application, I encounter the following error:
Error using matlabpath
Modifying the search path is not supported by MATLAB Compiler. Remove functions that modify the search path from your MATLAB code. To make files visible to your deployed application, add the parent folder to your MATLAB session.
Error in path (line 109)
Error in addpath>doPathAddition (line 126)
Error in addpath (line 90)
Error in ros.internal.getEmptyMessage>getCachedMap (line 53)
Error in ros.internal.getEmptyMessage (line 33)
Error in ros.internal.utilities.findMsgDepends (line 17)
Error in ros.internal.utilities.getPathOfDependentDlls (line 16)
Error in ros2publisher/createPublisher (line 460)
Error in ros2publisher (line 267)
How can I properly include the custom ROS 2 messages in a deployed MATLAB application without triggering this error? Is there a way to avoid the dynamic modification of the path or preload the required dependencies before deployment?
Any guidance on handling custom ROS 2 messages in MATLAB Runtime would be greatly appreciated. ros2, matlab-runtime, custom-messages, path, error MATLAB Answers — New Questions
finding longest length
Hi ,I have a matrix as follows
I =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 1 0 1 0 0 0 1 0
0 1 0 1 1 0 1 0 0 1
1 0 0 0 1 0 1 1 0 0
0 0 0 0 1 0 1 0 0 0
0 1 1 1 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
I need the output as follows:
I =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 1 0
0 1 0 1 0 0 0 0 0 1
1 0 0 0 0 0 0 1 0 0
0 0 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
i.e only the longest length of pixel that touches two opposite boundary.can any body help please?ThanksHi ,I have a matrix as follows
I =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 1 0 1 0 0 0 1 0
0 1 0 1 1 0 1 0 0 1
1 0 0 0 1 0 1 1 0 0
0 0 0 0 1 0 1 0 0 0
0 1 1 1 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
I need the output as follows:
I =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 1 0
0 1 0 1 0 0 0 0 0 1
1 0 0 0 0 0 0 1 0 0
0 0 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
i.e only the longest length of pixel that touches two opposite boundary.can any body help please?Thanks Hi ,I have a matrix as follows
I =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 1 0 1 0 0 0 1 0
0 1 0 1 1 0 1 0 0 1
1 0 0 0 1 0 1 1 0 0
0 0 0 0 1 0 1 0 0 0
0 1 1 1 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
I need the output as follows:
I =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 1 0
0 1 0 1 0 0 0 0 0 1
1 0 0 0 0 0 0 1 0 0
0 0 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
i.e only the longest length of pixel that touches two opposite boundary.can any body help please?Thanks pixel, lenght MATLAB Answers — New Questions
The settling time in matlab differs from the calculated value
Hi,
Why does Matlab calculate the settling time which measures the time for the error to fall below 2% of the peak value of the error for the closed-loop function T given below differently from the calculated value?
Cheers,
T= 4/( s^2 + 1.6 s+4)
Calculated settling time=4/(wn*zeta)=5 s;
where wn=2, zeta=0.4.
s = stepinfo(T)
s =
struct with fields:
RiseTime: 0.7326
TransientTime: 4.2047
SettlingTime: 4.2047
SettlingMin: 0.9065
SettlingMax: 1.2537
Overshoot: 25.3741
Undershoot: 0
Peak: 1.2537
PeakTime: 1.7269Hi,
Why does Matlab calculate the settling time which measures the time for the error to fall below 2% of the peak value of the error for the closed-loop function T given below differently from the calculated value?
Cheers,
T= 4/( s^2 + 1.6 s+4)
Calculated settling time=4/(wn*zeta)=5 s;
where wn=2, zeta=0.4.
s = stepinfo(T)
s =
struct with fields:
RiseTime: 0.7326
TransientTime: 4.2047
SettlingTime: 4.2047
SettlingMin: 0.9065
SettlingMax: 1.2537
Overshoot: 25.3741
Undershoot: 0
Peak: 1.2537
PeakTime: 1.7269 Hi,
Why does Matlab calculate the settling time which measures the time for the error to fall below 2% of the peak value of the error for the closed-loop function T given below differently from the calculated value?
Cheers,
T= 4/( s^2 + 1.6 s+4)
Calculated settling time=4/(wn*zeta)=5 s;
where wn=2, zeta=0.4.
s = stepinfo(T)
s =
struct with fields:
RiseTime: 0.7326
TransientTime: 4.2047
SettlingTime: 4.2047
SettlingMin: 0.9065
SettlingMax: 1.2537
Overshoot: 25.3741
Undershoot: 0
Peak: 1.2537
PeakTime: 1.7269 the settling time in matlab differs MATLAB Answers — New Questions
Connect line using add_line command to same port connections
While I tried to collect lines in paralel, an error popup:
>> Battery_Array_tmp
Error using Battery_Array_tmp (line 33)
The first port already has a line connection
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
Can someone assist to solve it?
I adding part of rellevant script:
%%%% Scriptto creat top design – withot Batteries/
%%%% only to speedup simulation time during debug Block connections
open_system(‘Battery_arc_tmp’)
mdl = ‘Battery_arc_tmp’;
battery_model = find_system(mdl,’FindAll’,’on’,’Name’,’Battery_arc_tmp’);
numRows = 3;
% Get handle to existing (external) POS and NEG ports
Plus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
Minus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
%%% add MC_cube – basic String_unit:
for i=1:2 %% set two columns
colPos = 500; %% spaces between columns
for v=1:numRows %% loop for 5 String per column
nl=num2str(v + numRows*(i-1));
if i==1
% Add_MC_cube(v) = add_block(‘MC_Cube/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
else
% Add_MC_cube(v) = add_block(‘MC_Cube2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
end
posc = get(Add_MC_cube(v),’Position’);
set(Add_MC_cube(v),’Position’,posc + [100+(i-1)*colPos 100*(v-1)+45 100+(i-1)*colPos 100*(v-1)+45])
PH_Add_MC_cube{v,i}=get(Add_MC_cube(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
end
end
while connecting 2 module there is no problem/
But when increase above 2 module i gos an error message (above)..
please, see pic attached…
Thank for assist.
TommyWhile I tried to collect lines in paralel, an error popup:
>> Battery_Array_tmp
Error using Battery_Array_tmp (line 33)
The first port already has a line connection
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
Can someone assist to solve it?
I adding part of rellevant script:
%%%% Scriptto creat top design – withot Batteries/
%%%% only to speedup simulation time during debug Block connections
open_system(‘Battery_arc_tmp’)
mdl = ‘Battery_arc_tmp’;
battery_model = find_system(mdl,’FindAll’,’on’,’Name’,’Battery_arc_tmp’);
numRows = 3;
% Get handle to existing (external) POS and NEG ports
Plus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
Minus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
%%% add MC_cube – basic String_unit:
for i=1:2 %% set two columns
colPos = 500; %% spaces between columns
for v=1:numRows %% loop for 5 String per column
nl=num2str(v + numRows*(i-1));
if i==1
% Add_MC_cube(v) = add_block(‘MC_Cube/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
else
% Add_MC_cube(v) = add_block(‘MC_Cube2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
end
posc = get(Add_MC_cube(v),’Position’);
set(Add_MC_cube(v),’Position’,posc + [100+(i-1)*colPos 100*(v-1)+45 100+(i-1)*colPos 100*(v-1)+45])
PH_Add_MC_cube{v,i}=get(Add_MC_cube(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
end
end
while connecting 2 module there is no problem/
But when increase above 2 module i gos an error message (above)..
please, see pic attached…
Thank for assist.
Tommy While I tried to collect lines in paralel, an error popup:
>> Battery_Array_tmp
Error using Battery_Array_tmp (line 33)
The first port already has a line connection
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
Can someone assist to solve it?
I adding part of rellevant script:
%%%% Scriptto creat top design – withot Batteries/
%%%% only to speedup simulation time during debug Block connections
open_system(‘Battery_arc_tmp’)
mdl = ‘Battery_arc_tmp’;
battery_model = find_system(mdl,’FindAll’,’on’,’Name’,’Battery_arc_tmp’);
numRows = 3;
% Get handle to existing (external) POS and NEG ports
Plus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
Minus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
%%% add MC_cube – basic String_unit:
for i=1:2 %% set two columns
colPos = 500; %% spaces between columns
for v=1:numRows %% loop for 5 String per column
nl=num2str(v + numRows*(i-1));
if i==1
% Add_MC_cube(v) = add_block(‘MC_Cube/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
else
% Add_MC_cube(v) = add_block(‘MC_Cube2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
end
posc = get(Add_MC_cube(v),’Position’);
set(Add_MC_cube(v),’Position’,posc + [100+(i-1)*colPos 100*(v-1)+45 100+(i-1)*colPos 100*(v-1)+45])
PH_Add_MC_cube{v,i}=get(Add_MC_cube(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
end
end
while connecting 2 module there is no problem/
But when increase above 2 module i gos an error message (above)..
please, see pic attached…
Thank for assist.
Tommy matlab, simulink MATLAB Answers — New Questions
quadgk AbsTol/RelTol parameters combinations
Dear network.
I am having trouble getting the desired result of an integral involving Bessel functions Jo and Yo.
Need your help with a powerful set of combinations of the AbsTol/RelTol parameters that will help me get a low-error result
This is the equation I am trying to solve, with t as a parameter:Dear network.
I am having trouble getting the desired result of an integral involving Bessel functions Jo and Yo.
Need your help with a powerful set of combinations of the AbsTol/RelTol parameters that will help me get a low-error result
This is the equation I am trying to solve, with t as a parameter: Dear network.
I am having trouble getting the desired result of an integral involving Bessel functions Jo and Yo.
Need your help with a powerful set of combinations of the AbsTol/RelTol parameters that will help me get a low-error result
This is the equation I am trying to solve, with t as a parameter: quadgk abstol reltol MATLAB Answers — New Questions
Problems encountered when using sph2cart
Here is the code:
clear all
clc
close all
load angles.mat
load vertices.mat
[vectors(:,1), vectors(:,2), vectors(:,3)] = sph2cart(angle_phi_theta(:,1), angle_phi_theta(:,2), 1);
quiver3(vertex_segment(:,1),vertex_segment(:,2),vertex_segment(:,3),…
vectors(:,1),vectors(:,2),vectors(:,3),0.8,’Color’,’green’,’LineWidth’,1);hold on;
The results:
Problem: I think the resulting vectors should converge uniformly or diverge uniformly, but why do they alternate like this? What went wrong?Here is the code:
clear all
clc
close all
load angles.mat
load vertices.mat
[vectors(:,1), vectors(:,2), vectors(:,3)] = sph2cart(angle_phi_theta(:,1), angle_phi_theta(:,2), 1);
quiver3(vertex_segment(:,1),vertex_segment(:,2),vertex_segment(:,3),…
vectors(:,1),vectors(:,2),vectors(:,3),0.8,’Color’,’green’,’LineWidth’,1);hold on;
The results:
Problem: I think the resulting vectors should converge uniformly or diverge uniformly, but why do they alternate like this? What went wrong? Here is the code:
clear all
clc
close all
load angles.mat
load vertices.mat
[vectors(:,1), vectors(:,2), vectors(:,3)] = sph2cart(angle_phi_theta(:,1), angle_phi_theta(:,2), 1);
quiver3(vertex_segment(:,1),vertex_segment(:,2),vertex_segment(:,3),…
vectors(:,1),vectors(:,2),vectors(:,3),0.8,’Color’,’green’,’LineWidth’,1);hold on;
The results:
Problem: I think the resulting vectors should converge uniformly or diverge uniformly, but why do they alternate like this? What went wrong? coordinate transformation, sph2cart, vectors MATLAB Answers — New Questions
i need help in solving this documentation in mathlab “Fault Detection and Localization in Three-Phase Power Transmission Using Deep Signal Anomaly Detector in Simulink” thanks
i am trying to build the exact modle listed on the site but finding challenges navigating through the steps provided .the topic is" Fault Detection and Localization in Three-Phase Power Transmission Using Deep Signal Anomaly Detector in Simulink". i would be very glad if someone can assist me do it. or if anyone has already done it. the person can kindly share his file to assist me. thank youi am trying to build the exact modle listed on the site but finding challenges navigating through the steps provided .the topic is" Fault Detection and Localization in Three-Phase Power Transmission Using Deep Signal Anomaly Detector in Simulink". i would be very glad if someone can assist me do it. or if anyone has already done it. the person can kindly share his file to assist me. thank you i am trying to build the exact modle listed on the site but finding challenges navigating through the steps provided .the topic is" Fault Detection and Localization in Three-Phase Power Transmission Using Deep Signal Anomaly Detector in Simulink". i would be very glad if someone can assist me do it. or if anyone has already done it. the person can kindly share his file to assist me. thank you #simulink, #deep signal anomaly detector #matlab MATLAB Answers — New Questions
Cannot get simulation to run after 2024 upgrade from 2023.
I upgraded from MATLAB/SIMULINK 2023 to 2024. When trying to rerun the simulation that had run in 2023 I get:
"
Error:Unable to update models referenced by ‘plant’.
Caused by:
The corresponding ‘decay_heat_SF.tlc’ file for the MATLAB S-function ‘decay_heat_SF’ in block ‘decay_heat/Level-2 MATLAB S-Function’ must be located in the current working directory, the MATLAB S-function directory ‘D:OneDriveUSNCControl DesignDecay Heat’, or the directory ‘D:OneDriveUSNCControl DesignDecay Heattlc_c’
"
Under 2023b no "decay_heat_SF.tlc" was generated or needed.
When running "decay_heat_SF" as a standalone model it runs. When added as a sub-model in "plant" it gives this error.
Can someone help?I upgraded from MATLAB/SIMULINK 2023 to 2024. When trying to rerun the simulation that had run in 2023 I get:
"
Error:Unable to update models referenced by ‘plant’.
Caused by:
The corresponding ‘decay_heat_SF.tlc’ file for the MATLAB S-function ‘decay_heat_SF’ in block ‘decay_heat/Level-2 MATLAB S-Function’ must be located in the current working directory, the MATLAB S-function directory ‘D:OneDriveUSNCControl DesignDecay Heat’, or the directory ‘D:OneDriveUSNCControl DesignDecay Heattlc_c’
"
Under 2023b no "decay_heat_SF.tlc" was generated or needed.
When running "decay_heat_SF" as a standalone model it runs. When added as a sub-model in "plant" it gives this error.
Can someone help? I upgraded from MATLAB/SIMULINK 2023 to 2024. When trying to rerun the simulation that had run in 2023 I get:
"
Error:Unable to update models referenced by ‘plant’.
Caused by:
The corresponding ‘decay_heat_SF.tlc’ file for the MATLAB S-function ‘decay_heat_SF’ in block ‘decay_heat/Level-2 MATLAB S-Function’ must be located in the current working directory, the MATLAB S-function directory ‘D:OneDriveUSNCControl DesignDecay Heat’, or the directory ‘D:OneDriveUSNCControl DesignDecay Heattlc_c’
"
Under 2023b no "decay_heat_SF.tlc" was generated or needed.
When running "decay_heat_SF" as a standalone model it runs. When added as a sub-model in "plant" it gives this error.
Can someone help? upgrade, tlc MATLAB Answers — New Questions
Bayesian neural network for nonlinear model identification
Hello everyone,
I’m interested in using Bayesian neural networks to model a dynamical system, similar to the examples presented here: https://www.mathworks.com/help/ident/nonlinear-model-identification.html.
So far, the only relevant resource I’ve found is this page: https://www.mathworks.com/help/deeplearning/ug/train-bayesian-neural-network.html, which demonstrates how to train a Bayesian neural network to predict the rotation of handwritten digits.
Would the methodology and functions shown in that example be suitable for my case? Specifically, can they be adapted to train a model using time series data—i.e., sequences of input and output over time?
Thank you in advance for your support!
MarcoHello everyone,
I’m interested in using Bayesian neural networks to model a dynamical system, similar to the examples presented here: https://www.mathworks.com/help/ident/nonlinear-model-identification.html.
So far, the only relevant resource I’ve found is this page: https://www.mathworks.com/help/deeplearning/ug/train-bayesian-neural-network.html, which demonstrates how to train a Bayesian neural network to predict the rotation of handwritten digits.
Would the methodology and functions shown in that example be suitable for my case? Specifically, can they be adapted to train a model using time series data—i.e., sequences of input and output over time?
Thank you in advance for your support!
Marco Hello everyone,
I’m interested in using Bayesian neural networks to model a dynamical system, similar to the examples presented here: https://www.mathworks.com/help/ident/nonlinear-model-identification.html.
So far, the only relevant resource I’ve found is this page: https://www.mathworks.com/help/deeplearning/ug/train-bayesian-neural-network.html, which demonstrates how to train a Bayesian neural network to predict the rotation of handwritten digits.
Would the methodology and functions shown in that example be suitable for my case? Specifically, can they be adapted to train a model using time series data—i.e., sequences of input and output over time?
Thank you in advance for your support!
Marco bayes, neural networks, system identification, deep learning, uncertainty quantification MATLAB Answers — New Questions
How to disable Tab completion in MATLAB Editor and Command Window
Is it possible to disable Tab completion in the MATLAB Editor and Command Window?Is it possible to disable Tab completion in the MATLAB Editor and Command Window? Is it possible to disable Tab completion in the MATLAB Editor and Command Window? disable, tab, completion MATLAB Answers — New Questions
assigning values with []
[a,b]=[1,2]
Why doesn’t this work? How to rewrite into what is easier and more succinct than a=1; b=2?[a,b]=[1,2]
Why doesn’t this work? How to rewrite into what is easier and more succinct than a=1; b=2? [a,b]=[1,2]
Why doesn’t this work? How to rewrite into what is easier and more succinct than a=1; b=2? matlab MATLAB Answers — New Questions
Unknown error during installation MATLAB2015a
During the installation of Matlab 2015a, at a level of 99% a pop-up window appeared with the following notification: " Unknown Error. The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at C:users…Tempmathworks_cform.log".
Why does this error appear during installation?
How can I solve that?During the installation of Matlab 2015a, at a level of 99% a pop-up window appeared with the following notification: " Unknown Error. The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at C:users…Tempmathworks_cform.log".
Why does this error appear during installation?
How can I solve that? During the installation of Matlab 2015a, at a level of 99% a pop-up window appeared with the following notification: " Unknown Error. The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at C:users…Tempmathworks_cform.log".
Why does this error appear during installation?
How can I solve that? error, installation MATLAB Answers — New Questions
Minor mistake Writing a function but error
Hello just a quick question, I am writing a code but an error keeps poping up for the function I entered
By any chance would you know why it keeps coming up as a red warning
f=@ (1./x)+(sqrt(x).*exp(x));Hello just a quick question, I am writing a code but an error keeps poping up for the function I entered
By any chance would you know why it keeps coming up as a red warning
f=@ (1./x)+(sqrt(x).*exp(x)); Hello just a quick question, I am writing a code but an error keeps poping up for the function I entered
By any chance would you know why it keeps coming up as a red warning
f=@ (1./x)+(sqrt(x).*exp(x)); function, error, display MATLAB Answers — New Questions
Trying to add callback function in class
I am attempting to create a class the will have two line ROI objects. This class should have a callback function for when the lines are moved by the user. I am able to add a listener to the lines but only if the callback function is static.
Is it possible to do this without using a static method? Ultimatly I would like to use the callback method to compare the positions of the two lines as one of them is moved.
classdef imageRange < handle
properties
region double
line1
line2
rect
X double
end
methods
function obj = imageRange(axes, dataAxes)
x = dataAxes{1,4};
y = dataAxes{2,4};
midpoint = mean([x(1),x(3)]);
obj.X = floor(midpoint);
obj.rect = rectangle(axes,’Position’,[obj.X,y(1),…
ceil(midpoint)-floor(midpoint), y(3) – y(1)]);
obj.rect.EdgeColor = [0,0,0,0];
obj.rect.FaceColor = [.5,.5,.5];
obj.rect.FaceAlpha = .1;
obj.line1 = drawline(axes,’Position’,[floor(midpoint), y(1); …
floor(midpoint), y(3)],’Color’,[0.6350 0.0780 0.1840], …
‘InteractionsAllowed’,’translate’, …
‘MarkerSize’,.1, …
‘LineWidth’,1);
addlistener(obj.line1, ‘MovingROI’, @(src,event)obj.allevents(src,event));
obj.line2 = drawline(axes,’Position’,[ceil(midpoint), y(1); …
ceil(midpoint), y(3)],’Color’,[0 0.4470 0.7410], …
‘InteractionsAllowed’,’translate’, …
‘MarkerSize’,.1, …
‘LineWidth’,1);
obj.region = dataAxes{1,5};
end
end
methods (Static)
function allevents(src,event)
event.PreviousPosition(1,1)
end
end
endI am attempting to create a class the will have two line ROI objects. This class should have a callback function for when the lines are moved by the user. I am able to add a listener to the lines but only if the callback function is static.
Is it possible to do this without using a static method? Ultimatly I would like to use the callback method to compare the positions of the two lines as one of them is moved.
classdef imageRange < handle
properties
region double
line1
line2
rect
X double
end
methods
function obj = imageRange(axes, dataAxes)
x = dataAxes{1,4};
y = dataAxes{2,4};
midpoint = mean([x(1),x(3)]);
obj.X = floor(midpoint);
obj.rect = rectangle(axes,’Position’,[obj.X,y(1),…
ceil(midpoint)-floor(midpoint), y(3) – y(1)]);
obj.rect.EdgeColor = [0,0,0,0];
obj.rect.FaceColor = [.5,.5,.5];
obj.rect.FaceAlpha = .1;
obj.line1 = drawline(axes,’Position’,[floor(midpoint), y(1); …
floor(midpoint), y(3)],’Color’,[0.6350 0.0780 0.1840], …
‘InteractionsAllowed’,’translate’, …
‘MarkerSize’,.1, …
‘LineWidth’,1);
addlistener(obj.line1, ‘MovingROI’, @(src,event)obj.allevents(src,event));
obj.line2 = drawline(axes,’Position’,[ceil(midpoint), y(1); …
ceil(midpoint), y(3)],’Color’,[0 0.4470 0.7410], …
‘InteractionsAllowed’,’translate’, …
‘MarkerSize’,.1, …
‘LineWidth’,1);
obj.region = dataAxes{1,5};
end
end
methods (Static)
function allevents(src,event)
event.PreviousPosition(1,1)
end
end
end I am attempting to create a class the will have two line ROI objects. This class should have a callback function for when the lines are moved by the user. I am able to add a listener to the lines but only if the callback function is static.
Is it possible to do this without using a static method? Ultimatly I would like to use the callback method to compare the positions of the two lines as one of them is moved.
classdef imageRange < handle
properties
region double
line1
line2
rect
X double
end
methods
function obj = imageRange(axes, dataAxes)
x = dataAxes{1,4};
y = dataAxes{2,4};
midpoint = mean([x(1),x(3)]);
obj.X = floor(midpoint);
obj.rect = rectangle(axes,’Position’,[obj.X,y(1),…
ceil(midpoint)-floor(midpoint), y(3) – y(1)]);
obj.rect.EdgeColor = [0,0,0,0];
obj.rect.FaceColor = [.5,.5,.5];
obj.rect.FaceAlpha = .1;
obj.line1 = drawline(axes,’Position’,[floor(midpoint), y(1); …
floor(midpoint), y(3)],’Color’,[0.6350 0.0780 0.1840], …
‘InteractionsAllowed’,’translate’, …
‘MarkerSize’,.1, …
‘LineWidth’,1);
addlistener(obj.line1, ‘MovingROI’, @(src,event)obj.allevents(src,event));
obj.line2 = drawline(axes,’Position’,[ceil(midpoint), y(1); …
ceil(midpoint), y(3)],’Color’,[0 0.4470 0.7410], …
‘InteractionsAllowed’,’translate’, …
‘MarkerSize’,.1, …
‘LineWidth’,1);
obj.region = dataAxes{1,5};
end
end
methods (Static)
function allevents(src,event)
event.PreviousPosition(1,1)
end
end
end static methods, class MATLAB Answers — New Questions
Reverse 2D-lookup table in Simulink
I tried to implement a reverse 2D lookup table in Simulink according to the following description by Fangjun Jiang:
https://de.mathworks.com/matlabcentral/answers/12809-reverse-2d-lookup-table?s_tid=sug_su
First, I wrote the following Matlab code for testing and it does exactly what I expect:
% Absolute eccentricity range
e = 0:1e-06:1.5e-05;
% Piston phase angle range
rad = 0:2*pi/400:2*pi;
% Load capacity matrix
load(‘Tragkraft_alpha_AK_kpl_V03.mat’);
load_cap = Tragkraft_alpha_AK_kpl_V03;
% Instant piston phase angle
rad_dyn = 3.12588469032184;
% Reverse 2D lookup table for load capacity
lookup = interp2(e,rad,load_cap,e,rad_dyn);
% Instant load capacity
load_dyn = 659.331131439451;
% Instant absolute eccentricity
e_dyn = interp1(lookup,e,load_dyn);
After that, I tried to implement it in Simulink using a MATLAB function block with the following code:
function e_dyn = fcn(rad_dyn, load_dyn, load_cap)
% absolute eccentricity range
e = 0:1e-06:1.5e-05;
% piston phase angle range
rad = 0:2*pi/400:2*pi;
% 2D lookup table for load capacity
lookup = interp2(e,rad,load_cap,e,rad_dyn);
% instant absolute eccentricity
e_dyn=interp1(lookup,e,load_dyn);
However, this leads to the following error message that I don’t really understand. In my understanding the Simulink model should do exactly the same as the Matlab code. Can anybody tell me how to fix that in Simulink?I tried to implement a reverse 2D lookup table in Simulink according to the following description by Fangjun Jiang:
https://de.mathworks.com/matlabcentral/answers/12809-reverse-2d-lookup-table?s_tid=sug_su
First, I wrote the following Matlab code for testing and it does exactly what I expect:
% Absolute eccentricity range
e = 0:1e-06:1.5e-05;
% Piston phase angle range
rad = 0:2*pi/400:2*pi;
% Load capacity matrix
load(‘Tragkraft_alpha_AK_kpl_V03.mat’);
load_cap = Tragkraft_alpha_AK_kpl_V03;
% Instant piston phase angle
rad_dyn = 3.12588469032184;
% Reverse 2D lookup table for load capacity
lookup = interp2(e,rad,load_cap,e,rad_dyn);
% Instant load capacity
load_dyn = 659.331131439451;
% Instant absolute eccentricity
e_dyn = interp1(lookup,e,load_dyn);
After that, I tried to implement it in Simulink using a MATLAB function block with the following code:
function e_dyn = fcn(rad_dyn, load_dyn, load_cap)
% absolute eccentricity range
e = 0:1e-06:1.5e-05;
% piston phase angle range
rad = 0:2*pi/400:2*pi;
% 2D lookup table for load capacity
lookup = interp2(e,rad,load_cap,e,rad_dyn);
% instant absolute eccentricity
e_dyn=interp1(lookup,e,load_dyn);
However, this leads to the following error message that I don’t really understand. In my understanding the Simulink model should do exactly the same as the Matlab code. Can anybody tell me how to fix that in Simulink? I tried to implement a reverse 2D lookup table in Simulink according to the following description by Fangjun Jiang:
https://de.mathworks.com/matlabcentral/answers/12809-reverse-2d-lookup-table?s_tid=sug_su
First, I wrote the following Matlab code for testing and it does exactly what I expect:
% Absolute eccentricity range
e = 0:1e-06:1.5e-05;
% Piston phase angle range
rad = 0:2*pi/400:2*pi;
% Load capacity matrix
load(‘Tragkraft_alpha_AK_kpl_V03.mat’);
load_cap = Tragkraft_alpha_AK_kpl_V03;
% Instant piston phase angle
rad_dyn = 3.12588469032184;
% Reverse 2D lookup table for load capacity
lookup = interp2(e,rad,load_cap,e,rad_dyn);
% Instant load capacity
load_dyn = 659.331131439451;
% Instant absolute eccentricity
e_dyn = interp1(lookup,e,load_dyn);
After that, I tried to implement it in Simulink using a MATLAB function block with the following code:
function e_dyn = fcn(rad_dyn, load_dyn, load_cap)
% absolute eccentricity range
e = 0:1e-06:1.5e-05;
% piston phase angle range
rad = 0:2*pi/400:2*pi;
% 2D lookup table for load capacity
lookup = interp2(e,rad,load_cap,e,rad_dyn);
% instant absolute eccentricity
e_dyn=interp1(lookup,e,load_dyn);
However, this leads to the following error message that I don’t really understand. In my understanding the Simulink model should do exactly the same as the Matlab code. Can anybody tell me how to fix that in Simulink? lookup table, reverse, simulink MATLAB Answers — New Questions
Invalid initial condition error
I have to solve the sistem of differential equation odesys with the condition imposed in bc vector. I obtain the "Invalid Initial Condition" at the line where v is defined, even if the domain for the boundary condition is correct. I must keep it a symbolic solution and a0 is a costant.
%% ANALYTICAL MODEL FOR A DCB SPECIMEN UNDER THE CONDITION OF PRESCRIBED DISPLACEMENTS
%% Linear Elastic Phase
%———
syms x d v0(x) v1(x) v2(x) Lcz
%———
phi0 = -diff(v0,x);
M0 = E*I*diff(v0,x,2);
T0 = E*I*diff(v0,x,3);
phi1 = -diff(v1,x);
M1 = E*I*diff(v1,x,2);
T1 = E*I*diff(v1,x,3);
phi2 = -diff(v2,x);
M2 = E*I*diff(v2,x,2);
T2 = E*I*diff(v2,x,3);
%———
ode_0 = diff(v0,x,4) == 0;
ode_1 = diff(v1,x,4) – 2*w*(lambda^2)*diff(v1,x,2) + (lambda^4)*v1 == 0;
ode_2 = diff(v2,x,4) + 2*ps*(k^2)*diff(v2,x,2) – k^4*(v2 – d_c/2) == 0;
%———
syms xL xR xI
xL = -a0 – Lcz;
xI = -Lcz;
xR = L – a0 – Lcz;
c1 = v0(xL) == d/2;
c2 = M0(xL) == 0;
c3 = v0(xI) == v2(xI);
c4 = phi0(xI) == phi2(xI);
c5 = M0(xI) == M2(xI);
c6 = T0(xI) == T2(xI);
c7 = v1(0) == v2(0);
c8 = phi1(0) == phi2(0);
c9 = M1(0) == M2(0);
c10 = T1(0) == T2(0);
c11 = v1(xR) == 0;
c12 = phi1(xR) == 0;
%———
odesys = [ode_0; ode_1; ode_2];
bc = [c1; c2; c3; c4; c5; c6; c7; c8; c9; c10; c11; c12];
v = dsolve(odesys, bc);
%———
v1_sol(x,d,Lcz) = simplify(v.v1);
v0_sol(x,d,Lcz) = simplify(v.v0);
v2_sol(x,d,Lcz) = simplify(v.v2);
phi0_sol(x,d,Lcz) = diff(v0_sol,x);
phi1_sol(x,d,Lcz) = diff(v1_sol,x);
phi2_sol(x,d,Lcz) = diff(v2_sol,x);
M0_sol(x,d,Lcz) = E*I*diff(v0_sol,x,2);
M1_sol(x,d,Lcz) = E*I*diff(v1_sol,x,2);
M2_sol(x,d,Lcz) = E*I*diff(v2_sol,x,2);
T0_sol(x,d,Lcz) = E*I*diff(v0_sol,x,3);
T1_sol(x,d,Lcz) = E*I*diff(v1_sol,x,3);
T2_sol(x,d,Lcz) = E*I*diff(v2_sol,x,3);
%———
d_lim = solve(v0_sol(0,d,0) == d_0/2,d);
% d_max = solve(v0_sol(0,d,0) == d_0/2,d);
% Lcz_max = solve(v2_sol(-Lcz,d_max,Lcz) – d_c/2 == 0, x,[0 50]);
[d_max, Lcz_max] = solve([v1_sol(0,d,Lcz) – d_0/2 == 0, v2_sol(-Lcz,d_max,Lcz) – d_c/2 == 0],[d,Lcz]);I have to solve the sistem of differential equation odesys with the condition imposed in bc vector. I obtain the "Invalid Initial Condition" at the line where v is defined, even if the domain for the boundary condition is correct. I must keep it a symbolic solution and a0 is a costant.
%% ANALYTICAL MODEL FOR A DCB SPECIMEN UNDER THE CONDITION OF PRESCRIBED DISPLACEMENTS
%% Linear Elastic Phase
%———
syms x d v0(x) v1(x) v2(x) Lcz
%———
phi0 = -diff(v0,x);
M0 = E*I*diff(v0,x,2);
T0 = E*I*diff(v0,x,3);
phi1 = -diff(v1,x);
M1 = E*I*diff(v1,x,2);
T1 = E*I*diff(v1,x,3);
phi2 = -diff(v2,x);
M2 = E*I*diff(v2,x,2);
T2 = E*I*diff(v2,x,3);
%———
ode_0 = diff(v0,x,4) == 0;
ode_1 = diff(v1,x,4) – 2*w*(lambda^2)*diff(v1,x,2) + (lambda^4)*v1 == 0;
ode_2 = diff(v2,x,4) + 2*ps*(k^2)*diff(v2,x,2) – k^4*(v2 – d_c/2) == 0;
%———
syms xL xR xI
xL = -a0 – Lcz;
xI = -Lcz;
xR = L – a0 – Lcz;
c1 = v0(xL) == d/2;
c2 = M0(xL) == 0;
c3 = v0(xI) == v2(xI);
c4 = phi0(xI) == phi2(xI);
c5 = M0(xI) == M2(xI);
c6 = T0(xI) == T2(xI);
c7 = v1(0) == v2(0);
c8 = phi1(0) == phi2(0);
c9 = M1(0) == M2(0);
c10 = T1(0) == T2(0);
c11 = v1(xR) == 0;
c12 = phi1(xR) == 0;
%———
odesys = [ode_0; ode_1; ode_2];
bc = [c1; c2; c3; c4; c5; c6; c7; c8; c9; c10; c11; c12];
v = dsolve(odesys, bc);
%———
v1_sol(x,d,Lcz) = simplify(v.v1);
v0_sol(x,d,Lcz) = simplify(v.v0);
v2_sol(x,d,Lcz) = simplify(v.v2);
phi0_sol(x,d,Lcz) = diff(v0_sol,x);
phi1_sol(x,d,Lcz) = diff(v1_sol,x);
phi2_sol(x,d,Lcz) = diff(v2_sol,x);
M0_sol(x,d,Lcz) = E*I*diff(v0_sol,x,2);
M1_sol(x,d,Lcz) = E*I*diff(v1_sol,x,2);
M2_sol(x,d,Lcz) = E*I*diff(v2_sol,x,2);
T0_sol(x,d,Lcz) = E*I*diff(v0_sol,x,3);
T1_sol(x,d,Lcz) = E*I*diff(v1_sol,x,3);
T2_sol(x,d,Lcz) = E*I*diff(v2_sol,x,3);
%———
d_lim = solve(v0_sol(0,d,0) == d_0/2,d);
% d_max = solve(v0_sol(0,d,0) == d_0/2,d);
% Lcz_max = solve(v2_sol(-Lcz,d_max,Lcz) – d_c/2 == 0, x,[0 50]);
[d_max, Lcz_max] = solve([v1_sol(0,d,Lcz) – d_0/2 == 0, v2_sol(-Lcz,d_max,Lcz) – d_c/2 == 0],[d,Lcz]); I have to solve the sistem of differential equation odesys with the condition imposed in bc vector. I obtain the "Invalid Initial Condition" at the line where v is defined, even if the domain for the boundary condition is correct. I must keep it a symbolic solution and a0 is a costant.
%% ANALYTICAL MODEL FOR A DCB SPECIMEN UNDER THE CONDITION OF PRESCRIBED DISPLACEMENTS
%% Linear Elastic Phase
%———
syms x d v0(x) v1(x) v2(x) Lcz
%———
phi0 = -diff(v0,x);
M0 = E*I*diff(v0,x,2);
T0 = E*I*diff(v0,x,3);
phi1 = -diff(v1,x);
M1 = E*I*diff(v1,x,2);
T1 = E*I*diff(v1,x,3);
phi2 = -diff(v2,x);
M2 = E*I*diff(v2,x,2);
T2 = E*I*diff(v2,x,3);
%———
ode_0 = diff(v0,x,4) == 0;
ode_1 = diff(v1,x,4) – 2*w*(lambda^2)*diff(v1,x,2) + (lambda^4)*v1 == 0;
ode_2 = diff(v2,x,4) + 2*ps*(k^2)*diff(v2,x,2) – k^4*(v2 – d_c/2) == 0;
%———
syms xL xR xI
xL = -a0 – Lcz;
xI = -Lcz;
xR = L – a0 – Lcz;
c1 = v0(xL) == d/2;
c2 = M0(xL) == 0;
c3 = v0(xI) == v2(xI);
c4 = phi0(xI) == phi2(xI);
c5 = M0(xI) == M2(xI);
c6 = T0(xI) == T2(xI);
c7 = v1(0) == v2(0);
c8 = phi1(0) == phi2(0);
c9 = M1(0) == M2(0);
c10 = T1(0) == T2(0);
c11 = v1(xR) == 0;
c12 = phi1(xR) == 0;
%———
odesys = [ode_0; ode_1; ode_2];
bc = [c1; c2; c3; c4; c5; c6; c7; c8; c9; c10; c11; c12];
v = dsolve(odesys, bc);
%———
v1_sol(x,d,Lcz) = simplify(v.v1);
v0_sol(x,d,Lcz) = simplify(v.v0);
v2_sol(x,d,Lcz) = simplify(v.v2);
phi0_sol(x,d,Lcz) = diff(v0_sol,x);
phi1_sol(x,d,Lcz) = diff(v1_sol,x);
phi2_sol(x,d,Lcz) = diff(v2_sol,x);
M0_sol(x,d,Lcz) = E*I*diff(v0_sol,x,2);
M1_sol(x,d,Lcz) = E*I*diff(v1_sol,x,2);
M2_sol(x,d,Lcz) = E*I*diff(v2_sol,x,2);
T0_sol(x,d,Lcz) = E*I*diff(v0_sol,x,3);
T1_sol(x,d,Lcz) = E*I*diff(v1_sol,x,3);
T2_sol(x,d,Lcz) = E*I*diff(v2_sol,x,3);
%———
d_lim = solve(v0_sol(0,d,0) == d_0/2,d);
% d_max = solve(v0_sol(0,d,0) == d_0/2,d);
% Lcz_max = solve(v2_sol(-Lcz,d_max,Lcz) – d_c/2 == 0, x,[0 50]);
[d_max, Lcz_max] = solve([v1_sol(0,d,Lcz) – d_0/2 == 0, v2_sol(-Lcz,d_max,Lcz) – d_c/2 == 0],[d,Lcz]); dsolve, ode, symbolic MATLAB Answers — New Questions