Tag Archives: matlab
Clean and automate indents in scripts an live scripts
Hi everyone,
Please, do you have any tips to automate indentation in scripts?
Example by the picture below:Hi everyone,
Please, do you have any tips to automate indentation in scripts?
Example by the picture below: Hi everyone,
Please, do you have any tips to automate indentation in scripts?
Example by the picture below: automatic, indentation, alignment, text MATLAB Answers — New Questions
Varying device latency for ASIO Device
Hi,
my goal is to measure impulse responses using Matlab and an ASIO device. I encountered the problem, that for different runs of my code, the peak of my impulse response is at a different location on the time axis. I was able to reproduce this behavior outside of my code in the "Impulse Respones Measurer". Looping back the output channel to an input channel and capturing a fiew imulse reponses while leaving everything else untouched gives me shifted impulse responses.
I also followed this example: Measure Audio Latency, which gave me the same results.
When measuring the same impulse response (i.e. same device, same configuration of channels etc.) with another software (REW), the delay remained constant between different runs.
I was also able to reproduce this behavior vor R2020a and R2024b
Any suggestions how to keep a constant latency between several runs of audioPlayerRecorder are appreciated.
Kind Regards,
SebastianHi,
my goal is to measure impulse responses using Matlab and an ASIO device. I encountered the problem, that for different runs of my code, the peak of my impulse response is at a different location on the time axis. I was able to reproduce this behavior outside of my code in the "Impulse Respones Measurer". Looping back the output channel to an input channel and capturing a fiew imulse reponses while leaving everything else untouched gives me shifted impulse responses.
I also followed this example: Measure Audio Latency, which gave me the same results.
When measuring the same impulse response (i.e. same device, same configuration of channels etc.) with another software (REW), the delay remained constant between different runs.
I was also able to reproduce this behavior vor R2020a and R2024b
Any suggestions how to keep a constant latency between several runs of audioPlayerRecorder are appreciated.
Kind Regards,
Sebastian Hi,
my goal is to measure impulse responses using Matlab and an ASIO device. I encountered the problem, that for different runs of my code, the peak of my impulse response is at a different location on the time axis. I was able to reproduce this behavior outside of my code in the "Impulse Respones Measurer". Looping back the output channel to an input channel and capturing a fiew imulse reponses while leaving everything else untouched gives me shifted impulse responses.
I also followed this example: Measure Audio Latency, which gave me the same results.
When measuring the same impulse response (i.e. same device, same configuration of channels etc.) with another software (REW), the delay remained constant between different runs.
I was also able to reproduce this behavior vor R2020a and R2024b
Any suggestions how to keep a constant latency between several runs of audioPlayerRecorder are appreciated.
Kind Regards,
Sebastian asio, matlab, audio, latency, delay, impulse response, loopback, signal processing MATLAB Answers — New Questions
COnnecting points on opposite end of mask
Given an mask image i have certain points as seen in the image, I want to connect the point to the point at the opposite side of it given the list of points/array of point.Well the output would look something like.Given an mask image i have certain points as seen in the image, I want to connect the point to the point at the opposite side of it given the list of points/array of point.Well the output would look something like. Given an mask image i have certain points as seen in the image, I want to connect the point to the point at the opposite side of it given the list of points/array of point.Well the output would look something like. image analysis, image processing, digital image processing, computer vision, contour MATLAB Answers — New Questions
Mass importing .txt files with sequential names to plot multiple graphs on same figure for easy comparison
I have 30 .txt files numbered like so:
FreeField1.txt
FreeField2.txt
…
FreeField30.txt
I need to find a way to import the data from all the files at once so I can then plot a graph with all of them overlaid to allow for quick comparison.
The current method I have found which inputs all the data is like so
numfiles = 30;
S = dir(‘*.txt’)
N = length(S)
for i = 1:numel(S)
S(i).data = readtable(S(i).name)
end
But this gives a structure which I do not how to progress from. I am looking for any possible methods which could be used for this mass importation to then build off for the plotting of graphs.
Any help would be appreciated as I am very new to MATLab and am wishing to understand it more. I have attached a sample text file for convenience.I have 30 .txt files numbered like so:
FreeField1.txt
FreeField2.txt
…
FreeField30.txt
I need to find a way to import the data from all the files at once so I can then plot a graph with all of them overlaid to allow for quick comparison.
The current method I have found which inputs all the data is like so
numfiles = 30;
S = dir(‘*.txt’)
N = length(S)
for i = 1:numel(S)
S(i).data = readtable(S(i).name)
end
But this gives a structure which I do not how to progress from. I am looking for any possible methods which could be used for this mass importation to then build off for the plotting of graphs.
Any help would be appreciated as I am very new to MATLab and am wishing to understand it more. I have attached a sample text file for convenience. I have 30 .txt files numbered like so:
FreeField1.txt
FreeField2.txt
…
FreeField30.txt
I need to find a way to import the data from all the files at once so I can then plot a graph with all of them overlaid to allow for quick comparison.
The current method I have found which inputs all the data is like so
numfiles = 30;
S = dir(‘*.txt’)
N = length(S)
for i = 1:numel(S)
S(i).data = readtable(S(i).name)
end
But this gives a structure which I do not how to progress from. I am looking for any possible methods which could be used for this mass importation to then build off for the plotting of graphs.
Any help would be appreciated as I am very new to MATLab and am wishing to understand it more. I have attached a sample text file for convenience. data import, graph, text file MATLAB Answers — New Questions
3D surf plot for more than two quantities
I want to plot the value in the same 3D graph .
syms x t r b %alpha
% Parameter values
a=(pi)/3;
g=9.8;
U=2.5;
O=7.29*10^(-5);
f=2*O*sin(a);
H=-(f/g)*U;
alpha=0.75; % fractional order
%%%%%%%%%initalization of variable
u_l=sym(zeros(1));
v_l=zeros(1,’sym’);
h_l=zeros(1,’sym’);
A_l=zeros(1,2,’sym’);
B_l=zeros(1,2,’sym’);
C_l=zeros(1,2,’sym’);
D_l=zeros(1,2,’sym’);
series1_l(x,t)=sym(zeros(1,1));
series2_l(x,t)=sym(zeros(1,1));
series3_l(x,t)=sym(zeros(1,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_up=sym(zeros(1));
v_up=zeros(1,’sym’);
h_up=zeros(1,’sym’);
A_up=zeros(1,2,’sym’);
B_up=zeros(1,2,’sym’);
C_up=zeros(1,2,’sym’);
D_up=zeros(1,2,’sym’);
series1_up(x,t)=sym(zeros(1,1));
series2_up(x,t)=sym(zeros(1,1));
series3_up(x,t)=sym(zeros(1,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_cr=sym(zeros(1));
v_cr=zeros(1,’sym’);
h_cr=zeros(1,’sym’);
A_cr=zeros(1,2,’sym’);
B_cr=zeros(1,2,’sym’);
C_cr=zeros(1,2,’sym’);
D_cr=zeros(1,2,’sym’);
series1_cr(x,t)=sym(zeros(1,1));
series2_cr(x,t)=sym(zeros(1,1));
series3_cr(x,t)=sym(zeros(1,1));
%%%%%%%% Initial condition fuzzy condition
R=0.5;
b_l=0 % lower bound
b_cr=0.5 % middle value
b_u=1 % upper value
%%%%%%%%%%%%%%%%%% lOWER VALUE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_l(1)=(2*b_l*(1-R)+R)*exp(x)*(sech(x))^2;
v_l(1)=(2*b_l*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_l(1)=(2*b_l*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%UPPER VALUE
u_up(1)=(2*b_u*(1-R)+R)*exp(x)*(sech(x))^2;
v_up(1)=(2*b_u*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_up(1)=(2*b_u*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Middle valur %%%%%%%%%%%%%%%%%%%%
u_cr(1)=(2*b_cr*(1-R)+R)*exp(x)*(sech(x))^2;
v_cr(1)=(2*b_cr*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_cr(1)=(2*b_cr*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%lOWER VALUR %%%%%%%%%%%%%%%%%%%%%%%%%
for k=1:2
A_l=0;
B_l=0;
C_l=0;
D_l=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_l=A_l+u_l(r)*diff(u_l(k-r+1),x,1);
B_l=B_l+u_l(r)*diff(v_l(k-r+1),x,1);
C_l=C_l+u_l(r)*diff(h_l(k-r+1),x,1);
D_l=D_l+h_l(r)*diff(u_l(k-r+1),x,1);
end
u_l(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_l+f*v_l(k)-g*diff(h_l(k),x,1)));
v_l(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_l-f*u_l(k)-g*H*E);
h_l(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_l-H*v_l(k)-D_l);
end
% t1=simplify(u(2))
% var2 = vpa(t1)
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_l(x,t)=simplify(series1_l(x,t)+u_l(k)*(power(t,k-1)));
series2_l(x,t)=simplify(series2_l(x,t)+v_l(k)*(power(t,k-1)));
series3_l(x,t)=simplify(series3_l(x,t)+h_l(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UPPER VALUE %%%%%%%%%%%%%%%%
for k=1:2
A_up=0;
B_up=0;
C_up=0;
D_up=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_up=A_up+u_up(r)*diff(u_up(k-r+1),x,1);
B_up=B_up+u_up(r)*diff(v_up(k-r+1),x,1);
C_up=C_up+u_up(r)*diff(h_up(k-r+1),x,1);
D_up=D_up+h_up(r)*diff(u_up(k-r+1),x,1);
end
u_up(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_up+f*v_up(k)-g*diff(h_up(k),x,1)));
v_up(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_up-f*u_up(k)-g*H*E);
h_up(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_up-H*v_up(k)-D_up);
end
% t1=simplify(u(2))
% var2 = vpa(t1)_u
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_up(x,t)=simplify(series1_up(x,t)+u_up(k)*(power(t,k-1)));
series2_up(x,t)=simplify(series2_up(x,t)+v_up(k)*(power(t,k-1)));
series3_up(x,t)=simplify(series3_up(x,t)+h_up(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%middle value %%%%%%%%%%%%%%
for k=1:2
A_cr=0;
B_cr=0;
C_cr=0;
D_cr=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_cr=A_cr+u_cr(r)*diff(u_up(k-r+1),x,1);
B_cr=B_cr+u_cr(r)*diff(v_up(k-r+1),x,1);
C_cr=C_cr+u_cr(r)*diff(h_up(k-r+1),x,1);
D_cr=D_up+h_cr(r)*diff(u_up(k-r+1),x,1);
end
u_cr(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_cr+f*v_up(k)-g*diff(h_cr(k),x,1)));
v_cr(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_cr-f*u_cr(k)-g*H*E);
h_cr(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_cr-H*v_cr(k)-D_cr);
end
% t1=simplify(u(2))
% var2 = vpa(t1)_u
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_cr(x,t)=simplify(series1_cr(x,t)+u_cr(k)*(power(t,k-1)));
series2_cr(x,t)=simplify(series2_cr(x,t)+v_cr(k)*(power(t,k-1)));
series3_cr(x,t)=simplify(series3_cr(x,t)+h_cr(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
C1_l=zeros(1)
C2_l=zeros(1)
C3_l=zeros(1)
C1_up=zeros(1)
C2_up=zeros(1)
C3_up=zeros(1)
C1_cr=zeros(1)
C2_cr=zeros(1)
C3_cr=zeros(1)
row=0;
x=0:0.04:2
t=0:0.002:0.1
for i=1:length(x)
row=row+1;
col=0;
for j=1:length(t)
col=col+1;
C1_l(row,col)=series1_l(x(i),t(j));
C2_l(row,col)=series2_l(x(i),t(j));
C3_l(row,col)=series3_l(x(i),t(j));
%———————————-
C1_up(row,col)=series1_up(x(i),t(j));
C2_up(row,col)=series2_up(x(i),t(j));
C3_up(row,col)=series3_up(x(i),t(j));
%————————————
C1_cr(row,col)=series1_cr(x(i),t(j));
C2_cr(row,col)=series2_cr(x(i),t(j));
C3_cr(row,col)=series3_cr(x(i),t(j));
end
end
%——————————————————–
surf(x,t,C1_l,C1_up,C1_cr)
surf(x,t,C2_l,C2_up,C2_cr)
surf(x,t,C3_l,C3_up,C3_cr)
I want to plot all the graph in the same 3D plot. I dont want different graph using subplot. and I am using MATLAB version 2023aI want to plot the value in the same 3D graph .
syms x t r b %alpha
% Parameter values
a=(pi)/3;
g=9.8;
U=2.5;
O=7.29*10^(-5);
f=2*O*sin(a);
H=-(f/g)*U;
alpha=0.75; % fractional order
%%%%%%%%%initalization of variable
u_l=sym(zeros(1));
v_l=zeros(1,’sym’);
h_l=zeros(1,’sym’);
A_l=zeros(1,2,’sym’);
B_l=zeros(1,2,’sym’);
C_l=zeros(1,2,’sym’);
D_l=zeros(1,2,’sym’);
series1_l(x,t)=sym(zeros(1,1));
series2_l(x,t)=sym(zeros(1,1));
series3_l(x,t)=sym(zeros(1,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_up=sym(zeros(1));
v_up=zeros(1,’sym’);
h_up=zeros(1,’sym’);
A_up=zeros(1,2,’sym’);
B_up=zeros(1,2,’sym’);
C_up=zeros(1,2,’sym’);
D_up=zeros(1,2,’sym’);
series1_up(x,t)=sym(zeros(1,1));
series2_up(x,t)=sym(zeros(1,1));
series3_up(x,t)=sym(zeros(1,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_cr=sym(zeros(1));
v_cr=zeros(1,’sym’);
h_cr=zeros(1,’sym’);
A_cr=zeros(1,2,’sym’);
B_cr=zeros(1,2,’sym’);
C_cr=zeros(1,2,’sym’);
D_cr=zeros(1,2,’sym’);
series1_cr(x,t)=sym(zeros(1,1));
series2_cr(x,t)=sym(zeros(1,1));
series3_cr(x,t)=sym(zeros(1,1));
%%%%%%%% Initial condition fuzzy condition
R=0.5;
b_l=0 % lower bound
b_cr=0.5 % middle value
b_u=1 % upper value
%%%%%%%%%%%%%%%%%% lOWER VALUE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_l(1)=(2*b_l*(1-R)+R)*exp(x)*(sech(x))^2;
v_l(1)=(2*b_l*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_l(1)=(2*b_l*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%UPPER VALUE
u_up(1)=(2*b_u*(1-R)+R)*exp(x)*(sech(x))^2;
v_up(1)=(2*b_u*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_up(1)=(2*b_u*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Middle valur %%%%%%%%%%%%%%%%%%%%
u_cr(1)=(2*b_cr*(1-R)+R)*exp(x)*(sech(x))^2;
v_cr(1)=(2*b_cr*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_cr(1)=(2*b_cr*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%lOWER VALUR %%%%%%%%%%%%%%%%%%%%%%%%%
for k=1:2
A_l=0;
B_l=0;
C_l=0;
D_l=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_l=A_l+u_l(r)*diff(u_l(k-r+1),x,1);
B_l=B_l+u_l(r)*diff(v_l(k-r+1),x,1);
C_l=C_l+u_l(r)*diff(h_l(k-r+1),x,1);
D_l=D_l+h_l(r)*diff(u_l(k-r+1),x,1);
end
u_l(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_l+f*v_l(k)-g*diff(h_l(k),x,1)));
v_l(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_l-f*u_l(k)-g*H*E);
h_l(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_l-H*v_l(k)-D_l);
end
% t1=simplify(u(2))
% var2 = vpa(t1)
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_l(x,t)=simplify(series1_l(x,t)+u_l(k)*(power(t,k-1)));
series2_l(x,t)=simplify(series2_l(x,t)+v_l(k)*(power(t,k-1)));
series3_l(x,t)=simplify(series3_l(x,t)+h_l(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UPPER VALUE %%%%%%%%%%%%%%%%
for k=1:2
A_up=0;
B_up=0;
C_up=0;
D_up=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_up=A_up+u_up(r)*diff(u_up(k-r+1),x,1);
B_up=B_up+u_up(r)*diff(v_up(k-r+1),x,1);
C_up=C_up+u_up(r)*diff(h_up(k-r+1),x,1);
D_up=D_up+h_up(r)*diff(u_up(k-r+1),x,1);
end
u_up(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_up+f*v_up(k)-g*diff(h_up(k),x,1)));
v_up(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_up-f*u_up(k)-g*H*E);
h_up(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_up-H*v_up(k)-D_up);
end
% t1=simplify(u(2))
% var2 = vpa(t1)_u
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_up(x,t)=simplify(series1_up(x,t)+u_up(k)*(power(t,k-1)));
series2_up(x,t)=simplify(series2_up(x,t)+v_up(k)*(power(t,k-1)));
series3_up(x,t)=simplify(series3_up(x,t)+h_up(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%middle value %%%%%%%%%%%%%%
for k=1:2
A_cr=0;
B_cr=0;
C_cr=0;
D_cr=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_cr=A_cr+u_cr(r)*diff(u_up(k-r+1),x,1);
B_cr=B_cr+u_cr(r)*diff(v_up(k-r+1),x,1);
C_cr=C_cr+u_cr(r)*diff(h_up(k-r+1),x,1);
D_cr=D_up+h_cr(r)*diff(u_up(k-r+1),x,1);
end
u_cr(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_cr+f*v_up(k)-g*diff(h_cr(k),x,1)));
v_cr(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_cr-f*u_cr(k)-g*H*E);
h_cr(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_cr-H*v_cr(k)-D_cr);
end
% t1=simplify(u(2))
% var2 = vpa(t1)_u
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_cr(x,t)=simplify(series1_cr(x,t)+u_cr(k)*(power(t,k-1)));
series2_cr(x,t)=simplify(series2_cr(x,t)+v_cr(k)*(power(t,k-1)));
series3_cr(x,t)=simplify(series3_cr(x,t)+h_cr(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
C1_l=zeros(1)
C2_l=zeros(1)
C3_l=zeros(1)
C1_up=zeros(1)
C2_up=zeros(1)
C3_up=zeros(1)
C1_cr=zeros(1)
C2_cr=zeros(1)
C3_cr=zeros(1)
row=0;
x=0:0.04:2
t=0:0.002:0.1
for i=1:length(x)
row=row+1;
col=0;
for j=1:length(t)
col=col+1;
C1_l(row,col)=series1_l(x(i),t(j));
C2_l(row,col)=series2_l(x(i),t(j));
C3_l(row,col)=series3_l(x(i),t(j));
%———————————-
C1_up(row,col)=series1_up(x(i),t(j));
C2_up(row,col)=series2_up(x(i),t(j));
C3_up(row,col)=series3_up(x(i),t(j));
%————————————
C1_cr(row,col)=series1_cr(x(i),t(j));
C2_cr(row,col)=series2_cr(x(i),t(j));
C3_cr(row,col)=series3_cr(x(i),t(j));
end
end
%——————————————————–
surf(x,t,C1_l,C1_up,C1_cr)
surf(x,t,C2_l,C2_up,C2_cr)
surf(x,t,C3_l,C3_up,C3_cr)
I want to plot all the graph in the same 3D plot. I dont want different graph using subplot. and I am using MATLAB version 2023a I want to plot the value in the same 3D graph .
syms x t r b %alpha
% Parameter values
a=(pi)/3;
g=9.8;
U=2.5;
O=7.29*10^(-5);
f=2*O*sin(a);
H=-(f/g)*U;
alpha=0.75; % fractional order
%%%%%%%%%initalization of variable
u_l=sym(zeros(1));
v_l=zeros(1,’sym’);
h_l=zeros(1,’sym’);
A_l=zeros(1,2,’sym’);
B_l=zeros(1,2,’sym’);
C_l=zeros(1,2,’sym’);
D_l=zeros(1,2,’sym’);
series1_l(x,t)=sym(zeros(1,1));
series2_l(x,t)=sym(zeros(1,1));
series3_l(x,t)=sym(zeros(1,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_up=sym(zeros(1));
v_up=zeros(1,’sym’);
h_up=zeros(1,’sym’);
A_up=zeros(1,2,’sym’);
B_up=zeros(1,2,’sym’);
C_up=zeros(1,2,’sym’);
D_up=zeros(1,2,’sym’);
series1_up(x,t)=sym(zeros(1,1));
series2_up(x,t)=sym(zeros(1,1));
series3_up(x,t)=sym(zeros(1,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_cr=sym(zeros(1));
v_cr=zeros(1,’sym’);
h_cr=zeros(1,’sym’);
A_cr=zeros(1,2,’sym’);
B_cr=zeros(1,2,’sym’);
C_cr=zeros(1,2,’sym’);
D_cr=zeros(1,2,’sym’);
series1_cr(x,t)=sym(zeros(1,1));
series2_cr(x,t)=sym(zeros(1,1));
series3_cr(x,t)=sym(zeros(1,1));
%%%%%%%% Initial condition fuzzy condition
R=0.5;
b_l=0 % lower bound
b_cr=0.5 % middle value
b_u=1 % upper value
%%%%%%%%%%%%%%%%%% lOWER VALUE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u_l(1)=(2*b_l*(1-R)+R)*exp(x)*(sech(x))^2;
v_l(1)=(2*b_l*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_l(1)=(2*b_l*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%UPPER VALUE
u_up(1)=(2*b_u*(1-R)+R)*exp(x)*(sech(x))^2;
v_up(1)=(2*b_u*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_up(1)=(2*b_u*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Middle valur %%%%%%%%%%%%%%%%%%%%
u_cr(1)=(2*b_cr*(1-R)+R)*exp(x)*(sech(x))^2;
v_cr(1)=(2*b_cr*(1-R)+R+1)*2*x*(sech(2*x))^2;
h_cr(1)=(2*b_cr*(1-R)+R)*x^2*(sech(2*x))^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%lOWER VALUR %%%%%%%%%%%%%%%%%%%%%%%%%
for k=1:2
A_l=0;
B_l=0;
C_l=0;
D_l=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_l=A_l+u_l(r)*diff(u_l(k-r+1),x,1);
B_l=B_l+u_l(r)*diff(v_l(k-r+1),x,1);
C_l=C_l+u_l(r)*diff(h_l(k-r+1),x,1);
D_l=D_l+h_l(r)*diff(u_l(k-r+1),x,1);
end
u_l(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_l+f*v_l(k)-g*diff(h_l(k),x,1)));
v_l(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_l-f*u_l(k)-g*H*E);
h_l(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_l-H*v_l(k)-D_l);
end
% t1=simplify(u(2))
% var2 = vpa(t1)
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_l(x,t)=simplify(series1_l(x,t)+u_l(k)*(power(t,k-1)));
series2_l(x,t)=simplify(series2_l(x,t)+v_l(k)*(power(t,k-1)));
series3_l(x,t)=simplify(series3_l(x,t)+h_l(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UPPER VALUE %%%%%%%%%%%%%%%%
for k=1:2
A_up=0;
B_up=0;
C_up=0;
D_up=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_up=A_up+u_up(r)*diff(u_up(k-r+1),x,1);
B_up=B_up+u_up(r)*diff(v_up(k-r+1),x,1);
C_up=C_up+u_up(r)*diff(h_up(k-r+1),x,1);
D_up=D_up+h_up(r)*diff(u_up(k-r+1),x,1);
end
u_up(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_up+f*v_up(k)-g*diff(h_up(k),x,1)));
v_up(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_up-f*u_up(k)-g*H*E);
h_up(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_up-H*v_up(k)-D_up);
end
% t1=simplify(u(2))
% var2 = vpa(t1)_u
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_up(x,t)=simplify(series1_up(x,t)+u_up(k)*(power(t,k-1)));
series2_up(x,t)=simplify(series2_up(x,t)+v_up(k)*(power(t,k-1)));
series3_up(x,t)=simplify(series3_up(x,t)+h_up(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%middle value %%%%%%%%%%%%%%
for k=1:2
A_cr=0;
B_cr=0;
C_cr=0;
D_cr=0;
if k==1
E=1;
else
E=0;
end
for r=1:k
A_cr=A_cr+u_cr(r)*diff(u_up(k-r+1),x,1);
B_cr=B_cr+u_cr(r)*diff(v_up(k-r+1),x,1);
C_cr=C_cr+u_cr(r)*diff(h_up(k-r+1),x,1);
D_cr=D_up+h_cr(r)*diff(u_up(k-r+1),x,1);
end
u_cr(k+1)=simplify(gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-A_cr+f*v_up(k)-g*diff(h_cr(k),x,1)));
v_cr(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-B_cr-f*u_cr(k)-g*H*E);
h_cr(k+1)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*(-C_cr-H*v_cr(k)-D_cr);
end
% t1=simplify(u(2))
% var2 = vpa(t1)_u
% t2=simplify(v(2))
% var = vpa(t2)
% t3=simplify(h(2))
for k=1:3
series1_cr(x,t)=simplify(series1_cr(x,t)+u_cr(k)*(power(t,k-1)));
series2_cr(x,t)=simplify(series2_cr(x,t)+v_cr(k)*(power(t,k-1)));
series3_cr(x,t)=simplify(series3_cr(x,t)+h_cr(k)*(power(t,k-1)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
C1_l=zeros(1)
C2_l=zeros(1)
C3_l=zeros(1)
C1_up=zeros(1)
C2_up=zeros(1)
C3_up=zeros(1)
C1_cr=zeros(1)
C2_cr=zeros(1)
C3_cr=zeros(1)
row=0;
x=0:0.04:2
t=0:0.002:0.1
for i=1:length(x)
row=row+1;
col=0;
for j=1:length(t)
col=col+1;
C1_l(row,col)=series1_l(x(i),t(j));
C2_l(row,col)=series2_l(x(i),t(j));
C3_l(row,col)=series3_l(x(i),t(j));
%———————————-
C1_up(row,col)=series1_up(x(i),t(j));
C2_up(row,col)=series2_up(x(i),t(j));
C3_up(row,col)=series3_up(x(i),t(j));
%————————————
C1_cr(row,col)=series1_cr(x(i),t(j));
C2_cr(row,col)=series2_cr(x(i),t(j));
C3_cr(row,col)=series3_cr(x(i),t(j));
end
end
%——————————————————–
surf(x,t,C1_l,C1_up,C1_cr)
surf(x,t,C2_l,C2_up,C2_cr)
surf(x,t,C3_l,C3_up,C3_cr)
I want to plot all the graph in the same 3D plot. I dont want different graph using subplot. and I am using MATLAB version 2023a 3 d plot MATLAB Answers — New Questions
using spice models in simlink
Hello,
I have simple spice model defined as described in the attached image.
I want to use this script in the simulink modelling environment.
Is this possible?
Can anyone help with this?
ThanksHello,
I have simple spice model defined as described in the attached image.
I want to use this script in the simulink modelling environment.
Is this possible?
Can anyone help with this?
Thanks Hello,
I have simple spice model defined as described in the attached image.
I want to use this script in the simulink modelling environment.
Is this possible?
Can anyone help with this?
Thanks simulink MATLAB Answers — New Questions
Heatmap inside custom 2d geometry shape
Hi,
I have a specific 2d geometry of an object with multiple fields. I also know the data values for each field. How can I plot a heatmap with my values inside the fileds using the shape of my 2d object. I could get the CAD of the object for example, create a smiple drawing myself, or imitate my 2d shape with blocks or somehow else ….
Thanks.Hi,
I have a specific 2d geometry of an object with multiple fields. I also know the data values for each field. How can I plot a heatmap with my values inside the fileds using the shape of my 2d object. I could get the CAD of the object for example, create a smiple drawing myself, or imitate my 2d shape with blocks or somehow else ….
Thanks. Hi,
I have a specific 2d geometry of an object with multiple fields. I also know the data values for each field. How can I plot a heatmap with my values inside the fileds using the shape of my 2d object. I could get the CAD of the object for example, create a smiple drawing myself, or imitate my 2d shape with blocks or somehow else ….
Thanks. heatmap, plot, 2d, shape, individual, geometry, fields, labels MATLAB Answers — New Questions
I’m sending 170 buffered samples from an ESP32 with MPU6050 to ThingSpeak, but the total entries increase inconsistently with a few samples missing in each interval.
I’m using an ESP32 to collect data from an MPU6050 sensor. The ESP32 buffers 170 samples at a time and uploads them to ThingSpeak using the bulk update API.
However, the data entries received on ThingSpeak are inconsistent. Here’s the pattern of total entries I see on the channel after each upload:
After 1st upload: 170 entries (correct)
After 2nd upload: 338 entries (should be 340)
After 3rd upload: 499 entries (should be 510)
After 4th upload: 657 entries (should be 680)
After 5th upload: 818 entries (should be 850)
As you can see, the expected total should increase by 170 each time, but it’s losing a few samples in each batch, and the number of missing entries increases over time. The losses are not consistent — it seems like 1 or 2 samples get dropped randomly in each interval.
Some things I’ve considered:
The ESP32 is collecting and sending the full buffer (verified via serial debug).
Could it be a payload size limit, HTTP timeout, or formatting issue?
Maybe ThingSpeak is silently dropping malformed lines from the bulk update?
Has anyone else run into this with buffered uploads to ThingSpeak? Any tips for debugging the exact cause of dropped samples?
Thanks for any help!I’m using an ESP32 to collect data from an MPU6050 sensor. The ESP32 buffers 170 samples at a time and uploads them to ThingSpeak using the bulk update API.
However, the data entries received on ThingSpeak are inconsistent. Here’s the pattern of total entries I see on the channel after each upload:
After 1st upload: 170 entries (correct)
After 2nd upload: 338 entries (should be 340)
After 3rd upload: 499 entries (should be 510)
After 4th upload: 657 entries (should be 680)
After 5th upload: 818 entries (should be 850)
As you can see, the expected total should increase by 170 each time, but it’s losing a few samples in each batch, and the number of missing entries increases over time. The losses are not consistent — it seems like 1 or 2 samples get dropped randomly in each interval.
Some things I’ve considered:
The ESP32 is collecting and sending the full buffer (verified via serial debug).
Could it be a payload size limit, HTTP timeout, or formatting issue?
Maybe ThingSpeak is silently dropping malformed lines from the bulk update?
Has anyone else run into this with buffered uploads to ThingSpeak? Any tips for debugging the exact cause of dropped samples?
Thanks for any help! I’m using an ESP32 to collect data from an MPU6050 sensor. The ESP32 buffers 170 samples at a time and uploads them to ThingSpeak using the bulk update API.
However, the data entries received on ThingSpeak are inconsistent. Here’s the pattern of total entries I see on the channel after each upload:
After 1st upload: 170 entries (correct)
After 2nd upload: 338 entries (should be 340)
After 3rd upload: 499 entries (should be 510)
After 4th upload: 657 entries (should be 680)
After 5th upload: 818 entries (should be 850)
As you can see, the expected total should increase by 170 each time, but it’s losing a few samples in each batch, and the number of missing entries increases over time. The losses are not consistent — it seems like 1 or 2 samples get dropped randomly in each interval.
Some things I’ve considered:
The ESP32 is collecting and sending the full buffer (verified via serial debug).
Could it be a payload size limit, HTTP timeout, or formatting issue?
Maybe ThingSpeak is silently dropping malformed lines from the bulk update?
Has anyone else run into this with buffered uploads to ThingSpeak? Any tips for debugging the exact cause of dropped samples?
Thanks for any help! thingspeak, buffer, burst MATLAB Answers — New Questions
sprintf vs. compose performance for large arrays
My understanding is that compose is based on sprintf, yet I’m noticing a huge discrepancy in performance. Consider the following example.
M = 32;
N = 32;
A = randn(M,N);
[m,n] = ndgrid(1:M,1:N);
Nrep = 100;
%% compose and no for loops
t1 = zeros(Nrep,1);
for kr=1:Nrep
tic;
s1 = compose("%d,%d,%.3g",m(:),n(:),A(:));
s1 = reshape(s1,M,N);
t1(kr) = toc;
end
%% sprintf and two nested for loops
t2 = zeros(Nrep,1);
for kr=1:Nrep
s2 = repelem("",M,N);
tic;
for j=1:N
for i=1:M
s2(i,j) = sprintf("%d,%d,%.3g",i,j,A(i,j));
end
end
t2(kr) = toc;
end
%% compose and two nested for loops
t3 = zeros(Nrep,1);
for kr=1:Nrep
tic;
s3 = repelem("",M,N);
for j=1:N
for i=1:M
s3(i,j) = compose("%d,%d,%.3g",i,j,A(i,j));
end
end
t3(kr) = toc;
end
fprintf(" min | mean | maxn");
fprintf("compose, no loops: %.6f | %.6f | %.6fn",min(t1),mean(t1),max(t1));
fprintf("sprintf, 2 loops: %.6f | %.6f | %.6fn",min(t2),mean(t2),max(t2));
fprintf("compose, 2 loops: %.6f | %.6f | %.6fn",min(t3),mean(t3),max(t3));
This code produces the following output on my machine.
min | mean | max
compose, no loops: 1.008151 | 1.035783 | 1.076671
sprintf, 2 loops: 0.004265 | 0.004384 | 0.008990
compose, 2 loops: 1.018900 | 1.050923 | 1.464713
It seems that sprintf is 60x – 70x faster in this example. Any idea why that is?
Here is the output of ver on my machine:
—————————————————————————————–
MATLAB Version: 25.1.0.2943329 (R2025a)
MATLAB License Number:
Operating System: macOS Version: 15.5 Build: 24F74
Java Version: Java 11.0.27+6-LTS with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
—————————————————————————————–My understanding is that compose is based on sprintf, yet I’m noticing a huge discrepancy in performance. Consider the following example.
M = 32;
N = 32;
A = randn(M,N);
[m,n] = ndgrid(1:M,1:N);
Nrep = 100;
%% compose and no for loops
t1 = zeros(Nrep,1);
for kr=1:Nrep
tic;
s1 = compose("%d,%d,%.3g",m(:),n(:),A(:));
s1 = reshape(s1,M,N);
t1(kr) = toc;
end
%% sprintf and two nested for loops
t2 = zeros(Nrep,1);
for kr=1:Nrep
s2 = repelem("",M,N);
tic;
for j=1:N
for i=1:M
s2(i,j) = sprintf("%d,%d,%.3g",i,j,A(i,j));
end
end
t2(kr) = toc;
end
%% compose and two nested for loops
t3 = zeros(Nrep,1);
for kr=1:Nrep
tic;
s3 = repelem("",M,N);
for j=1:N
for i=1:M
s3(i,j) = compose("%d,%d,%.3g",i,j,A(i,j));
end
end
t3(kr) = toc;
end
fprintf(" min | mean | maxn");
fprintf("compose, no loops: %.6f | %.6f | %.6fn",min(t1),mean(t1),max(t1));
fprintf("sprintf, 2 loops: %.6f | %.6f | %.6fn",min(t2),mean(t2),max(t2));
fprintf("compose, 2 loops: %.6f | %.6f | %.6fn",min(t3),mean(t3),max(t3));
This code produces the following output on my machine.
min | mean | max
compose, no loops: 1.008151 | 1.035783 | 1.076671
sprintf, 2 loops: 0.004265 | 0.004384 | 0.008990
compose, 2 loops: 1.018900 | 1.050923 | 1.464713
It seems that sprintf is 60x – 70x faster in this example. Any idea why that is?
Here is the output of ver on my machine:
—————————————————————————————–
MATLAB Version: 25.1.0.2943329 (R2025a)
MATLAB License Number:
Operating System: macOS Version: 15.5 Build: 24F74
Java Version: Java 11.0.27+6-LTS with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
—————————————————————————————– My understanding is that compose is based on sprintf, yet I’m noticing a huge discrepancy in performance. Consider the following example.
M = 32;
N = 32;
A = randn(M,N);
[m,n] = ndgrid(1:M,1:N);
Nrep = 100;
%% compose and no for loops
t1 = zeros(Nrep,1);
for kr=1:Nrep
tic;
s1 = compose("%d,%d,%.3g",m(:),n(:),A(:));
s1 = reshape(s1,M,N);
t1(kr) = toc;
end
%% sprintf and two nested for loops
t2 = zeros(Nrep,1);
for kr=1:Nrep
s2 = repelem("",M,N);
tic;
for j=1:N
for i=1:M
s2(i,j) = sprintf("%d,%d,%.3g",i,j,A(i,j));
end
end
t2(kr) = toc;
end
%% compose and two nested for loops
t3 = zeros(Nrep,1);
for kr=1:Nrep
tic;
s3 = repelem("",M,N);
for j=1:N
for i=1:M
s3(i,j) = compose("%d,%d,%.3g",i,j,A(i,j));
end
end
t3(kr) = toc;
end
fprintf(" min | mean | maxn");
fprintf("compose, no loops: %.6f | %.6f | %.6fn",min(t1),mean(t1),max(t1));
fprintf("sprintf, 2 loops: %.6f | %.6f | %.6fn",min(t2),mean(t2),max(t2));
fprintf("compose, 2 loops: %.6f | %.6f | %.6fn",min(t3),mean(t3),max(t3));
This code produces the following output on my machine.
min | mean | max
compose, no loops: 1.008151 | 1.035783 | 1.076671
sprintf, 2 loops: 0.004265 | 0.004384 | 0.008990
compose, 2 loops: 1.018900 | 1.050923 | 1.464713
It seems that sprintf is 60x – 70x faster in this example. Any idea why that is?
Here is the output of ver on my machine:
—————————————————————————————–
MATLAB Version: 25.1.0.2943329 (R2025a)
MATLAB License Number:
Operating System: macOS Version: 15.5 Build: 24F74
Java Version: Java 11.0.27+6-LTS with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
—————————————————————————————– string, strings, sprintf, compose, text MATLAB Answers — New Questions
defining function which generates 3d array within a class. Different behavior in class versus command window
This code:
lam = @(t) 3*(1 + 0.8*cos(2*pi*t));
A1 = @(t) reshape([lam(t(:).’); lam(t(:).’); zeros(1, numel(t)); lam(t(:).’)], [2, 2, numel(t)]);
tt=0:1/400:1-1/400;
A1stack=A1(tt);
generates a 2x2x400 array. This is what I want to happen. When I embed the code within a class function however, it returns a 2×800 array. How do I fix this?This code:
lam = @(t) 3*(1 + 0.8*cos(2*pi*t));
A1 = @(t) reshape([lam(t(:).’); lam(t(:).’); zeros(1, numel(t)); lam(t(:).’)], [2, 2, numel(t)]);
tt=0:1/400:1-1/400;
A1stack=A1(tt);
generates a 2x2x400 array. This is what I want to happen. When I embed the code within a class function however, it returns a 2×800 array. How do I fix this? This code:
lam = @(t) 3*(1 + 0.8*cos(2*pi*t));
A1 = @(t) reshape([lam(t(:).’); lam(t(:).’); zeros(1, numel(t)); lam(t(:).’)], [2, 2, numel(t)]);
tt=0:1/400:1-1/400;
A1stack=A1(tt);
generates a 2x2x400 array. This is what I want to happen. When I embed the code within a class function however, it returns a 2×800 array. How do I fix this? array function, 3d array, oop MATLAB Answers — New Questions
Word document “Saveas2()” method no longer working
As of the past few days, I seem to be no longer able to save word documents created through matlab. Several months ago I ran the following script which opens an existing word document and saves it as another document.
reportPath = ‘Table_out.docx’;
templateName = append(pwd, ‘Table_Inject_Test.docx’);
actx_word = actxserver(‘Word.Application’);
actx_word.Visible = true;
trace(actx_word.Visible);
wordTemplate = actx_word.Documents.Open(templateName); % Open template
wordTemplate.SaveAs2(reportPath); % Save copy as report
Once I started getting this error in another project, I reverted back to this script to check it wasn’t something I had done within the word template to cause the error.
However when I try to run the same script now, I get the following error:
% Unrecognized method, property, or field ‘SaveAs2’ for class
% ‘Interface.0002096B_0000_0000_C000_000000000046’.
% Error in tableinjecttest2 (line 7)
% wordTemplate.SaveAs2(reportPath); % Save copy as report
Has something changed within the WordInterface object? I see there is a ‘saveobj’ method but that doesn’t seem to save the document either. That just gives me a different error:
% Unable to resolve the name ‘wordParent.saveobj’.
%
% Error in tableInjectTest (line 22)
% wordTemplate.saveobj(reportPath)As of the past few days, I seem to be no longer able to save word documents created through matlab. Several months ago I ran the following script which opens an existing word document and saves it as another document.
reportPath = ‘Table_out.docx’;
templateName = append(pwd, ‘Table_Inject_Test.docx’);
actx_word = actxserver(‘Word.Application’);
actx_word.Visible = true;
trace(actx_word.Visible);
wordTemplate = actx_word.Documents.Open(templateName); % Open template
wordTemplate.SaveAs2(reportPath); % Save copy as report
Once I started getting this error in another project, I reverted back to this script to check it wasn’t something I had done within the word template to cause the error.
However when I try to run the same script now, I get the following error:
% Unrecognized method, property, or field ‘SaveAs2’ for class
% ‘Interface.0002096B_0000_0000_C000_000000000046’.
% Error in tableinjecttest2 (line 7)
% wordTemplate.SaveAs2(reportPath); % Save copy as report
Has something changed within the WordInterface object? I see there is a ‘saveobj’ method but that doesn’t seem to save the document either. That just gives me a different error:
% Unable to resolve the name ‘wordParent.saveobj’.
%
% Error in tableInjectTest (line 22)
% wordTemplate.saveobj(reportPath) As of the past few days, I seem to be no longer able to save word documents created through matlab. Several months ago I ran the following script which opens an existing word document and saves it as another document.
reportPath = ‘Table_out.docx’;
templateName = append(pwd, ‘Table_Inject_Test.docx’);
actx_word = actxserver(‘Word.Application’);
actx_word.Visible = true;
trace(actx_word.Visible);
wordTemplate = actx_word.Documents.Open(templateName); % Open template
wordTemplate.SaveAs2(reportPath); % Save copy as report
Once I started getting this error in another project, I reverted back to this script to check it wasn’t something I had done within the word template to cause the error.
However when I try to run the same script now, I get the following error:
% Unrecognized method, property, or field ‘SaveAs2’ for class
% ‘Interface.0002096B_0000_0000_C000_000000000046’.
% Error in tableinjecttest2 (line 7)
% wordTemplate.SaveAs2(reportPath); % Save copy as report
Has something changed within the WordInterface object? I see there is a ‘saveobj’ method but that doesn’t seem to save the document either. That just gives me a different error:
% Unable to resolve the name ‘wordParent.saveobj’.
%
% Error in tableInjectTest (line 22)
% wordTemplate.saveobj(reportPath) word application, actxserver MATLAB Answers — New Questions
Finding roots of a complex function
Hi,
I’m trying to find the roots of a complex function z=x+iyz in MATLAB. However, it seems that the root-finding routine is missing some roots, which leads to inaccurate results. Could you advise on how I can improve the code to ensure more reliable root detection? I have the two matlab files.
Thanks,
clearvars
close all
% set parameter values
pars.gamma1=0.1093;
pars.alpha3=-0.1104e-2;
pars.K1=6e-12;
pars.d=0.2e-3;
pars.eta1=0.240e-1;
pars.chia=1.219e-6;
pars.alpha=1-pars.alpha3^2/(pars.gamma1*pars.eta1);
pars.Ha=pi*sqrt(pars.K1/pars.chia)/pars.d;
% set lists of u (field) and xi (activity) values
uvals=0:0.05:3;
xivals=-0.3:0.01:0.3;
nu=length(uvals);
nxi=length(xivals);
% initiate arrays for output
taumin=ones(nu,nxi);
wavenummin=ones(nu,nxi);
% start timer
tic
disp(‘Starting u and xi loops’);
% start loop around u values
for i=1:nu
pars.H=uvals(i)*pars.Ha;
% start loop around xi value
for j=1:nxi
xi=xivals(j);
% set initial tau values for root finding, tau is a complex
% variable
tauRvals=-50:0.1:50;
tauIvals=0.1*ones(size(tauRvals));
ntau=length(tauRvals);
% plot equation (projected onto real line) to solve for these values of u and xi
fig1 = figure(1);
y=zeros(size(tauRvals));
for ii=1:ntau
tau=tauRvals(ii);
y(ii) = (pars.H ^ 2 * sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.chia * pars.d * tau ^ (0.3e1 / 0.2e1) * sqrt(pars.eta1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) + sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.d * pars.gamma1 * sqrt(pars.eta1) * sqrt(tau) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) – 0.2e1 * sqrt(pars.K1) * cos(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.alpha3 * tau ^ 2 * xi + 0.2e1 * sqrt(pars.K1) * cos(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.alpha3 ^ 2 * tau + 0.2e1 * sqrt(pars.K1) * pars.alpha3 * tau ^ 2 * xi – 0.2e1 * sqrt(pars.K1) * pars.alpha3 ^ 2 * tau) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.3e1 / 0.2e1) * (pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) ^ (-0.1e1 / 0.2e1) / pars.alpha3 / sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d);
end
plot(tauRvals,y);
hold on
plot(tauRvals,zeros(size(tauRvals)),’-k’);
xline(0);
yline(0);
xlabel(‘tau’);
ylabel(‘tau equation’);
axis([min(tauRvals) max(tauRvals) -1e-2 1e-2]);
drawnow
hold off
% loop around initial tau values for root finding
tausol=zeros(1,ntau);
flag=zeros(1,ntau);
wavenum=zeros(1,ntau);
for k=1:ntau
% set function, options and inital tau value
fun = @(x)rootsolver_complex(x,xi,pars);
options = optimset(‘TolFun’,1e-15,’MaxFunEvals’,1e5,’Maxiter’,1e5,’Display’,’none’);
tauinit=[tauRvals(k),tauIvals(k)];
% find root of tau equation
[x,fval,exitflag,output] = fsolve(fun,tauinit,options);
% save complex tau solution
tausol(k)=complex(x(1),x(2));
% set solve flag (if exitflag>0 the root finder has solved)
flag(k)=(exitflag>0);
% calulate wavenumber (real part of) using equation from Maple
% file
wavenum(k)=real(sqrt((pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) / pars.K1 / pars.eta1 / tau) * pars.d / pi / 0.2e1);
end
tauflag=[tausol’,flag’];
tausol_found=tauflag(flag==1);
tausolR=real(tausol_found);
tauRvals=tauRvals(flag==1);
wavenum=wavenum(flag==1);
% plot real part of tau solution versus initial tau
fig2 = figure(2);
plot(tauRvals,tausolR,’g-‘)
hold on
plot(tauRvals,tauRvals,’k-‘)
xlabel(‘initial $tau$’, ‘Interpreter’,’latex’);
ylabel(‘$tau$ solution’, ‘Interpreter’,’latex’);
hold off
% calculate min value of real part of tau and the wavenumber at
% that min value of tau
taumin(i,j)=min(tausolR);
wavenummins=wavenum(tausolR==min(tausolR));
wavenummin(i,j)=wavenummins(1);
% filled contour plot of minimum tau value (negative tau means instability)
fig3 = figure(3);
[Xi,U] = meshgrid(xivals,uvals);
N=[0:0.1:1];
map = [0.95*(1-N’) 0.95*(1-N’) N’];
contourf(U,Xi,taumin,[-100:10:100])
colormap(map)
colorbar
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
%title(‘minimum tau’);
drawnow
% filled contour plot of minimum tau value (negative tau means instability)
fig4 =figure(4);
contourf(U,Xi,wavenummin,10)
colormap(map)
colorbar
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
%title(‘wavenumber at minimum tau’);
drawnow
% stability domain in (u,xi) plane
fig5 = figure(5);
S = 25; % size of symbols in pixels
% normalize colouring vector to go from zero to 1
normtau = (taumin>0);
normtau=reshape(normtau,nu*nxi,1);
C = [0.95*(1-normtau) 0.95*(1-normtau) normtau];
scatter(reshape(U,nu*nxi,1),reshape(Xi,nu*nxi,1),S,C,’filled’,’Marker’,’o’)
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
title(‘Blue = stable, Yellow = unstable’, ‘Interpreter’,’latex’);
drawnow
end
% display time taken and percentage complete
toc
disp([‘Progress: ‘ num2str(round(100*(i*(j-1)+j)/(nu*nxi))) ‘ % completed’]);
end
function F = rootsolver_complex(x,xi,pars)
% function to provide right-hand-side of the equation for tau
gamma1=pars.gamma1;
alpha3=pars.alpha3;
K1=pars.K1;
d=pars.d;
eta1=pars.eta1;
chia=pars.chia;
alpha=pars.alpha;
H=pars.H;
tau=complex(x(1),x(2));
% equation taken directly from Maple file eq.mw
y = (H ^ 2 * sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * chia * d * tau ^ (0.3e1 / 0.2e1) * sqrt(eta1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) + sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * d * gamma1 * sqrt(eta1) * sqrt(tau) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) – 0.2e1 * sqrt(K1) * cos(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * alpha3 * tau ^ 2 * xi + 0.2e1 * sqrt(K1) * cos(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * alpha3 ^ 2 * tau + 0.2e1 * sqrt(K1) * alpha3 * tau ^ 2 * xi – 0.2e1 * sqrt(K1) * alpha3 ^ 2 * tau) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.3e1 / 0.2e1) * (H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) ^ (-0.1e1 / 0.2e1) / alpha3 / sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d);
F=[real(y),imag(y)];
endHi,
I’m trying to find the roots of a complex function z=x+iyz in MATLAB. However, it seems that the root-finding routine is missing some roots, which leads to inaccurate results. Could you advise on how I can improve the code to ensure more reliable root detection? I have the two matlab files.
Thanks,
clearvars
close all
% set parameter values
pars.gamma1=0.1093;
pars.alpha3=-0.1104e-2;
pars.K1=6e-12;
pars.d=0.2e-3;
pars.eta1=0.240e-1;
pars.chia=1.219e-6;
pars.alpha=1-pars.alpha3^2/(pars.gamma1*pars.eta1);
pars.Ha=pi*sqrt(pars.K1/pars.chia)/pars.d;
% set lists of u (field) and xi (activity) values
uvals=0:0.05:3;
xivals=-0.3:0.01:0.3;
nu=length(uvals);
nxi=length(xivals);
% initiate arrays for output
taumin=ones(nu,nxi);
wavenummin=ones(nu,nxi);
% start timer
tic
disp(‘Starting u and xi loops’);
% start loop around u values
for i=1:nu
pars.H=uvals(i)*pars.Ha;
% start loop around xi value
for j=1:nxi
xi=xivals(j);
% set initial tau values for root finding, tau is a complex
% variable
tauRvals=-50:0.1:50;
tauIvals=0.1*ones(size(tauRvals));
ntau=length(tauRvals);
% plot equation (projected onto real line) to solve for these values of u and xi
fig1 = figure(1);
y=zeros(size(tauRvals));
for ii=1:ntau
tau=tauRvals(ii);
y(ii) = (pars.H ^ 2 * sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.chia * pars.d * tau ^ (0.3e1 / 0.2e1) * sqrt(pars.eta1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) + sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.d * pars.gamma1 * sqrt(pars.eta1) * sqrt(tau) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) – 0.2e1 * sqrt(pars.K1) * cos(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.alpha3 * tau ^ 2 * xi + 0.2e1 * sqrt(pars.K1) * cos(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.alpha3 ^ 2 * tau + 0.2e1 * sqrt(pars.K1) * pars.alpha3 * tau ^ 2 * xi – 0.2e1 * sqrt(pars.K1) * pars.alpha3 ^ 2 * tau) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.3e1 / 0.2e1) * (pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) ^ (-0.1e1 / 0.2e1) / pars.alpha3 / sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d);
end
plot(tauRvals,y);
hold on
plot(tauRvals,zeros(size(tauRvals)),’-k’);
xline(0);
yline(0);
xlabel(‘tau’);
ylabel(‘tau equation’);
axis([min(tauRvals) max(tauRvals) -1e-2 1e-2]);
drawnow
hold off
% loop around initial tau values for root finding
tausol=zeros(1,ntau);
flag=zeros(1,ntau);
wavenum=zeros(1,ntau);
for k=1:ntau
% set function, options and inital tau value
fun = @(x)rootsolver_complex(x,xi,pars);
options = optimset(‘TolFun’,1e-15,’MaxFunEvals’,1e5,’Maxiter’,1e5,’Display’,’none’);
tauinit=[tauRvals(k),tauIvals(k)];
% find root of tau equation
[x,fval,exitflag,output] = fsolve(fun,tauinit,options);
% save complex tau solution
tausol(k)=complex(x(1),x(2));
% set solve flag (if exitflag>0 the root finder has solved)
flag(k)=(exitflag>0);
% calulate wavenumber (real part of) using equation from Maple
% file
wavenum(k)=real(sqrt((pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) / pars.K1 / pars.eta1 / tau) * pars.d / pi / 0.2e1);
end
tauflag=[tausol’,flag’];
tausol_found=tauflag(flag==1);
tausolR=real(tausol_found);
tauRvals=tauRvals(flag==1);
wavenum=wavenum(flag==1);
% plot real part of tau solution versus initial tau
fig2 = figure(2);
plot(tauRvals,tausolR,’g-‘)
hold on
plot(tauRvals,tauRvals,’k-‘)
xlabel(‘initial $tau$’, ‘Interpreter’,’latex’);
ylabel(‘$tau$ solution’, ‘Interpreter’,’latex’);
hold off
% calculate min value of real part of tau and the wavenumber at
% that min value of tau
taumin(i,j)=min(tausolR);
wavenummins=wavenum(tausolR==min(tausolR));
wavenummin(i,j)=wavenummins(1);
% filled contour plot of minimum tau value (negative tau means instability)
fig3 = figure(3);
[Xi,U] = meshgrid(xivals,uvals);
N=[0:0.1:1];
map = [0.95*(1-N’) 0.95*(1-N’) N’];
contourf(U,Xi,taumin,[-100:10:100])
colormap(map)
colorbar
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
%title(‘minimum tau’);
drawnow
% filled contour plot of minimum tau value (negative tau means instability)
fig4 =figure(4);
contourf(U,Xi,wavenummin,10)
colormap(map)
colorbar
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
%title(‘wavenumber at minimum tau’);
drawnow
% stability domain in (u,xi) plane
fig5 = figure(5);
S = 25; % size of symbols in pixels
% normalize colouring vector to go from zero to 1
normtau = (taumin>0);
normtau=reshape(normtau,nu*nxi,1);
C = [0.95*(1-normtau) 0.95*(1-normtau) normtau];
scatter(reshape(U,nu*nxi,1),reshape(Xi,nu*nxi,1),S,C,’filled’,’Marker’,’o’)
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
title(‘Blue = stable, Yellow = unstable’, ‘Interpreter’,’latex’);
drawnow
end
% display time taken and percentage complete
toc
disp([‘Progress: ‘ num2str(round(100*(i*(j-1)+j)/(nu*nxi))) ‘ % completed’]);
end
function F = rootsolver_complex(x,xi,pars)
% function to provide right-hand-side of the equation for tau
gamma1=pars.gamma1;
alpha3=pars.alpha3;
K1=pars.K1;
d=pars.d;
eta1=pars.eta1;
chia=pars.chia;
alpha=pars.alpha;
H=pars.H;
tau=complex(x(1),x(2));
% equation taken directly from Maple file eq.mw
y = (H ^ 2 * sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * chia * d * tau ^ (0.3e1 / 0.2e1) * sqrt(eta1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) + sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * d * gamma1 * sqrt(eta1) * sqrt(tau) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) – 0.2e1 * sqrt(K1) * cos(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * alpha3 * tau ^ 2 * xi + 0.2e1 * sqrt(K1) * cos(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * alpha3 ^ 2 * tau + 0.2e1 * sqrt(K1) * alpha3 * tau ^ 2 * xi – 0.2e1 * sqrt(K1) * alpha3 ^ 2 * tau) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.3e1 / 0.2e1) * (H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) ^ (-0.1e1 / 0.2e1) / alpha3 / sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d);
F=[real(y),imag(y)];
end Hi,
I’m trying to find the roots of a complex function z=x+iyz in MATLAB. However, it seems that the root-finding routine is missing some roots, which leads to inaccurate results. Could you advise on how I can improve the code to ensure more reliable root detection? I have the two matlab files.
Thanks,
clearvars
close all
% set parameter values
pars.gamma1=0.1093;
pars.alpha3=-0.1104e-2;
pars.K1=6e-12;
pars.d=0.2e-3;
pars.eta1=0.240e-1;
pars.chia=1.219e-6;
pars.alpha=1-pars.alpha3^2/(pars.gamma1*pars.eta1);
pars.Ha=pi*sqrt(pars.K1/pars.chia)/pars.d;
% set lists of u (field) and xi (activity) values
uvals=0:0.05:3;
xivals=-0.3:0.01:0.3;
nu=length(uvals);
nxi=length(xivals);
% initiate arrays for output
taumin=ones(nu,nxi);
wavenummin=ones(nu,nxi);
% start timer
tic
disp(‘Starting u and xi loops’);
% start loop around u values
for i=1:nu
pars.H=uvals(i)*pars.Ha;
% start loop around xi value
for j=1:nxi
xi=xivals(j);
% set initial tau values for root finding, tau is a complex
% variable
tauRvals=-50:0.1:50;
tauIvals=0.1*ones(size(tauRvals));
ntau=length(tauRvals);
% plot equation (projected onto real line) to solve for these values of u and xi
fig1 = figure(1);
y=zeros(size(tauRvals));
for ii=1:ntau
tau=tauRvals(ii);
y(ii) = (pars.H ^ 2 * sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.chia * pars.d * tau ^ (0.3e1 / 0.2e1) * sqrt(pars.eta1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) + sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.d * pars.gamma1 * sqrt(pars.eta1) * sqrt(tau) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) – 0.2e1 * sqrt(pars.K1) * cos(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.alpha3 * tau ^ 2 * xi + 0.2e1 * sqrt(pars.K1) * cos(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d) * pars.alpha3 ^ 2 * tau + 0.2e1 * sqrt(pars.K1) * pars.alpha3 * tau ^ 2 * xi – 0.2e1 * sqrt(pars.K1) * pars.alpha3 ^ 2 * tau) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.3e1 / 0.2e1) * (pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) ^ (-0.1e1 / 0.2e1) / pars.alpha3 / sin(pars.K1 ^ (-0.1e1 / 0.2e1) * pars.eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) * pars.d);
end
plot(tauRvals,y);
hold on
plot(tauRvals,zeros(size(tauRvals)),’-k’);
xline(0);
yline(0);
xlabel(‘tau’);
ylabel(‘tau equation’);
axis([min(tauRvals) max(tauRvals) -1e-2 1e-2]);
drawnow
hold off
% loop around initial tau values for root finding
tausol=zeros(1,ntau);
flag=zeros(1,ntau);
wavenum=zeros(1,ntau);
for k=1:ntau
% set function, options and inital tau value
fun = @(x)rootsolver_complex(x,xi,pars);
options = optimset(‘TolFun’,1e-15,’MaxFunEvals’,1e5,’Maxiter’,1e5,’Display’,’none’);
tauinit=[tauRvals(k),tauIvals(k)];
% find root of tau equation
[x,fval,exitflag,output] = fsolve(fun,tauinit,options);
% save complex tau solution
tausol(k)=complex(x(1),x(2));
% set solve flag (if exitflag>0 the root finder has solved)
flag(k)=(exitflag>0);
% calulate wavenumber (real part of) using equation from Maple
% file
wavenum(k)=real(sqrt((pars.H ^ 2 * pars.chia * pars.eta1 * tau + pars.alpha3 * tau * xi – pars.alpha3 ^ 2 + pars.eta1 * pars.gamma1) / pars.K1 / pars.eta1 / tau) * pars.d / pi / 0.2e1);
end
tauflag=[tausol’,flag’];
tausol_found=tauflag(flag==1);
tausolR=real(tausol_found);
tauRvals=tauRvals(flag==1);
wavenum=wavenum(flag==1);
% plot real part of tau solution versus initial tau
fig2 = figure(2);
plot(tauRvals,tausolR,’g-‘)
hold on
plot(tauRvals,tauRvals,’k-‘)
xlabel(‘initial $tau$’, ‘Interpreter’,’latex’);
ylabel(‘$tau$ solution’, ‘Interpreter’,’latex’);
hold off
% calculate min value of real part of tau and the wavenumber at
% that min value of tau
taumin(i,j)=min(tausolR);
wavenummins=wavenum(tausolR==min(tausolR));
wavenummin(i,j)=wavenummins(1);
% filled contour plot of minimum tau value (negative tau means instability)
fig3 = figure(3);
[Xi,U] = meshgrid(xivals,uvals);
N=[0:0.1:1];
map = [0.95*(1-N’) 0.95*(1-N’) N’];
contourf(U,Xi,taumin,[-100:10:100])
colormap(map)
colorbar
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
%title(‘minimum tau’);
drawnow
% filled contour plot of minimum tau value (negative tau means instability)
fig4 =figure(4);
contourf(U,Xi,wavenummin,10)
colormap(map)
colorbar
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
%title(‘wavenumber at minimum tau’);
drawnow
% stability domain in (u,xi) plane
fig5 = figure(5);
S = 25; % size of symbols in pixels
% normalize colouring vector to go from zero to 1
normtau = (taumin>0);
normtau=reshape(normtau,nu*nxi,1);
C = [0.95*(1-normtau) 0.95*(1-normtau) normtau];
scatter(reshape(U,nu*nxi,1),reshape(Xi,nu*nxi,1),S,C,’filled’,’Marker’,’o’)
xlabel(‘Orienting field, $u$’, ‘Interpreter’,’latex’);
ylabel(‘Activity, $xi$ [Pa]’, ‘Interpreter’,’latex’);
title(‘Blue = stable, Yellow = unstable’, ‘Interpreter’,’latex’);
drawnow
end
% display time taken and percentage complete
toc
disp([‘Progress: ‘ num2str(round(100*(i*(j-1)+j)/(nu*nxi))) ‘ % completed’]);
end
function F = rootsolver_complex(x,xi,pars)
% function to provide right-hand-side of the equation for tau
gamma1=pars.gamma1;
alpha3=pars.alpha3;
K1=pars.K1;
d=pars.d;
eta1=pars.eta1;
chia=pars.chia;
alpha=pars.alpha;
H=pars.H;
tau=complex(x(1),x(2));
% equation taken directly from Maple file eq.mw
y = (H ^ 2 * sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * chia * d * tau ^ (0.3e1 / 0.2e1) * sqrt(eta1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) + sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * d * gamma1 * sqrt(eta1) * sqrt(tau) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) – 0.2e1 * sqrt(K1) * cos(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * alpha3 * tau ^ 2 * xi + 0.2e1 * sqrt(K1) * cos(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d) * alpha3 ^ 2 * tau + 0.2e1 * sqrt(K1) * alpha3 * tau ^ 2 * xi – 0.2e1 * sqrt(K1) * alpha3 ^ 2 * tau) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.3e1 / 0.2e1) * (H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) ^ (-0.1e1 / 0.2e1) / alpha3 / sin(K1 ^ (-0.1e1 / 0.2e1) * eta1 ^ (-0.1e1 / 0.2e1) * tau ^ (-0.1e1 / 0.2e1) * sqrt(H ^ 2 * chia * eta1 * tau + alpha3 * tau * xi – alpha3 ^ 2 + eta1 * gamma1) * d);
F=[real(y),imag(y)];
end roots finding, complex finding MATLAB Answers — New Questions
Nonlinear regression of multiple datasets with different functions but wit some shared parameters between datasets
Apologies since I am new to Matlab.
I have a model describing a drug-receptor system with multiple parameters. There are two different observables (binding , activity) for each drug. (I have separate but related equations for predicting the observables). The model has four parameters per drug and four system parameters that are shared for all drugs. I have datasets with a variable number of replicates for each observable (3 binding curves and one response curve per drug). I have data for 12 different drugs. I would appreciate some help setting up global nonlinear regression for all datasets to obtain best estimates of the drug specific and system specific (shared) parameters and their associated 95% confidence intervals. A general example that can handle this type of situation would be helpful to get me started.Apologies since I am new to Matlab.
I have a model describing a drug-receptor system with multiple parameters. There are two different observables (binding , activity) for each drug. (I have separate but related equations for predicting the observables). The model has four parameters per drug and four system parameters that are shared for all drugs. I have datasets with a variable number of replicates for each observable (3 binding curves and one response curve per drug). I have data for 12 different drugs. I would appreciate some help setting up global nonlinear regression for all datasets to obtain best estimates of the drug specific and system specific (shared) parameters and their associated 95% confidence intervals. A general example that can handle this type of situation would be helpful to get me started. Apologies since I am new to Matlab.
I have a model describing a drug-receptor system with multiple parameters. There are two different observables (binding , activity) for each drug. (I have separate but related equations for predicting the observables). The model has four parameters per drug and four system parameters that are shared for all drugs. I have datasets with a variable number of replicates for each observable (3 binding curves and one response curve per drug). I have data for 12 different drugs. I would appreciate some help setting up global nonlinear regression for all datasets to obtain best estimates of the drug specific and system specific (shared) parameters and their associated 95% confidence intervals. A general example that can handle this type of situation would be helpful to get me started. nonlinear regression, shared and not shared parameters, confidence intervals MATLAB Answers — New Questions
Plotting my own validation and loss graph while training a CNN
Within the Deep learning Toolbox it’s possible to enable the training plots within the options. It uses the following code:
Options = trainingOptions(‘Plots’, ‘training-progress’);
This opens an overview of the accuracy and loss while training, like this:
I think these two plots/graphs are amazing for the analysis of the CNN. Now, I’ve ran into an issue regarding enabling the option mentioned above.
This plot reporter causes conflicts when trying to use it in a standalone application using MATLAB Compiler. This conflict can be resolved by simply removing the ‘Plots’, ‘training-progress’ from the options. When removing this, you lose the two plots/graphs aswell.
I’ve tried to see where the measurements are stored during the plotting so I could extract the data and make my own plots/graphs. This was without sucess.
Now my question is: Is it possible to make my own accuracy and loss graphs by somehow extracting the data the program would have used to create the plots with the ‘Plots’ option enabled?
Any insight would help.
Greetings,
ThomasWithin the Deep learning Toolbox it’s possible to enable the training plots within the options. It uses the following code:
Options = trainingOptions(‘Plots’, ‘training-progress’);
This opens an overview of the accuracy and loss while training, like this:
I think these two plots/graphs are amazing for the analysis of the CNN. Now, I’ve ran into an issue regarding enabling the option mentioned above.
This plot reporter causes conflicts when trying to use it in a standalone application using MATLAB Compiler. This conflict can be resolved by simply removing the ‘Plots’, ‘training-progress’ from the options. When removing this, you lose the two plots/graphs aswell.
I’ve tried to see where the measurements are stored during the plotting so I could extract the data and make my own plots/graphs. This was without sucess.
Now my question is: Is it possible to make my own accuracy and loss graphs by somehow extracting the data the program would have used to create the plots with the ‘Plots’ option enabled?
Any insight would help.
Greetings,
Thomas Within the Deep learning Toolbox it’s possible to enable the training plots within the options. It uses the following code:
Options = trainingOptions(‘Plots’, ‘training-progress’);
This opens an overview of the accuracy and loss while training, like this:
I think these two plots/graphs are amazing for the analysis of the CNN. Now, I’ve ran into an issue regarding enabling the option mentioned above.
This plot reporter causes conflicts when trying to use it in a standalone application using MATLAB Compiler. This conflict can be resolved by simply removing the ‘Plots’, ‘training-progress’ from the options. When removing this, you lose the two plots/graphs aswell.
I’ve tried to see where the measurements are stored during the plotting so I could extract the data and make my own plots/graphs. This was without sucess.
Now my question is: Is it possible to make my own accuracy and loss graphs by somehow extracting the data the program would have used to create the plots with the ‘Plots’ option enabled?
Any insight would help.
Greetings,
Thomas convolutional neural network, deep learning toolbox, accuracy, loss, plots, extract data, training-progress MATLAB Answers — New Questions
Unrecognized function or variable ‘yalmip’.
matlab should known sdpvar in the code becuse if i used help it give me the meaning of it but it said instead
Unrecognized function or variable ‘yalmip’.
Error in sdpvar (line 518)
[mt,variabletype,hashed_monoms,current_hash] = yalmip(‘monomtable’);
% Define the partially specified Euclidean distance matrix
D = [0 1 0 3; 1 0 2 0; 0 2 0 0; 3 0 0 0];
% Define the size of the matrix
n = size(D, 1);
% Define the optimization variables
X = sdpvar(n, n);
% Set up the optimization problem
Constraints = [X == semidefinite(n), diag(X) == zeros(n, 1), X >= 0];
Objective = sum(sum((X – D).^2));
Options = sdpsettings(‘solver’, ‘mosek’);
% Solve the optimization problem
optimize(Constraints, Objective, Options);
% Extract the completed Euclidean distance matrix
D_complete = value(X);matlab should known sdpvar in the code becuse if i used help it give me the meaning of it but it said instead
Unrecognized function or variable ‘yalmip’.
Error in sdpvar (line 518)
[mt,variabletype,hashed_monoms,current_hash] = yalmip(‘monomtable’);
% Define the partially specified Euclidean distance matrix
D = [0 1 0 3; 1 0 2 0; 0 2 0 0; 3 0 0 0];
% Define the size of the matrix
n = size(D, 1);
% Define the optimization variables
X = sdpvar(n, n);
% Set up the optimization problem
Constraints = [X == semidefinite(n), diag(X) == zeros(n, 1), X >= 0];
Objective = sum(sum((X – D).^2));
Options = sdpsettings(‘solver’, ‘mosek’);
% Solve the optimization problem
optimize(Constraints, Objective, Options);
% Extract the completed Euclidean distance matrix
D_complete = value(X); matlab should known sdpvar in the code becuse if i used help it give me the meaning of it but it said instead
Unrecognized function or variable ‘yalmip’.
Error in sdpvar (line 518)
[mt,variabletype,hashed_monoms,current_hash] = yalmip(‘monomtable’);
% Define the partially specified Euclidean distance matrix
D = [0 1 0 3; 1 0 2 0; 0 2 0 0; 3 0 0 0];
% Define the size of the matrix
n = size(D, 1);
% Define the optimization variables
X = sdpvar(n, n);
% Set up the optimization problem
Constraints = [X == semidefinite(n), diag(X) == zeros(n, 1), X >= 0];
Objective = sum(sum((X – D).^2));
Options = sdpsettings(‘solver’, ‘mosek’);
% Solve the optimization problem
optimize(Constraints, Objective, Options);
% Extract the completed Euclidean distance matrix
D_complete = value(X); unrecognized function, sdpvar, yalmip MATLAB Answers — New Questions
Monitor Gamma Calibration (manual and grayscale)
Hello everyone,
Would like your help with monitor gamma calibration:
Does anybody have a script that helps doing gamma calibration manually with a photometer (grayscale, not colors), and creates a gamma table which can be used in experiments?
I created a script with GPT, did a calibration with a photometer and got gamma value of 1.98. when I use the gamma table in my experiment, the the monitor seems much brighter and the stimuli are harder to distinct (it seems like the contrast decreased). Does it make sense?
Thanks in advance :)Hello everyone,
Would like your help with monitor gamma calibration:
Does anybody have a script that helps doing gamma calibration manually with a photometer (grayscale, not colors), and creates a gamma table which can be used in experiments?
I created a script with GPT, did a calibration with a photometer and got gamma value of 1.98. when I use the gamma table in my experiment, the the monitor seems much brighter and the stimuli are harder to distinct (it seems like the contrast decreased). Does it make sense?
Thanks in advance 🙂 Hello everyone,
Would like your help with monitor gamma calibration:
Does anybody have a script that helps doing gamma calibration manually with a photometer (grayscale, not colors), and creates a gamma table which can be used in experiments?
I created a script with GPT, did a calibration with a photometer and got gamma value of 1.98. when I use the gamma table in my experiment, the the monitor seems much brighter and the stimuli are harder to distinct (it seems like the contrast decreased). Does it make sense?
Thanks in advance 🙂 gamma correction, photometer, cognitive experiments, perception, contrast, rgb MATLAB Answers — New Questions
Can’t Share Heat with Pipe (G)
Hi,
I am in intership and I would like in Simscape to simulate an air duct heated by a heat source. For this, a started with a block Pipe (G) with a lenght of 5m, an area of 0.5 m^2 and I used the formula for the hydraulic diametre D_h=4A/P. Then I put a block Reservoir (G) on both side of the pipe with an ambiant temperature (25°C) and 1 atm and I put also a flow source with a volumetric flow of 5 m^3/s.
On the port H, I started with a temperature source (40°C) and a convective block with an area of 1.7 m^2 and a heat transfert coefficient of 20 W/(m^2.K).
When I launch my simulation, the temperature of the air remain at 25°C and the temperature of the thermal part drop to 26.7°C. I have a heat flow of 452.6 W from thermal part to gas part so the air have to be heated but it’s not the case.
Can you please help me ? Thank you !Hi,
I am in intership and I would like in Simscape to simulate an air duct heated by a heat source. For this, a started with a block Pipe (G) with a lenght of 5m, an area of 0.5 m^2 and I used the formula for the hydraulic diametre D_h=4A/P. Then I put a block Reservoir (G) on both side of the pipe with an ambiant temperature (25°C) and 1 atm and I put also a flow source with a volumetric flow of 5 m^3/s.
On the port H, I started with a temperature source (40°C) and a convective block with an area of 1.7 m^2 and a heat transfert coefficient of 20 W/(m^2.K).
When I launch my simulation, the temperature of the air remain at 25°C and the temperature of the thermal part drop to 26.7°C. I have a heat flow of 452.6 W from thermal part to gas part so the air have to be heated but it’s not the case.
Can you please help me ? Thank you ! Hi,
I am in intership and I would like in Simscape to simulate an air duct heated by a heat source. For this, a started with a block Pipe (G) with a lenght of 5m, an area of 0.5 m^2 and I used the formula for the hydraulic diametre D_h=4A/P. Then I put a block Reservoir (G) on both side of the pipe with an ambiant temperature (25°C) and 1 atm and I put also a flow source with a volumetric flow of 5 m^3/s.
On the port H, I started with a temperature source (40°C) and a convective block with an area of 1.7 m^2 and a heat transfert coefficient of 20 W/(m^2.K).
When I launch my simulation, the temperature of the air remain at 25°C and the temperature of the thermal part drop to 26.7°C. I have a heat flow of 452.6 W from thermal part to gas part so the air have to be heated but it’s not the case.
Can you please help me ? Thank you ! simscape, urgent MATLAB Answers — New Questions
How to use Simulink for model-based development of TC3XX series development boards
I want to use Simulink for model-based development of the TC3XX series development board, but I am not sure about the development process and toolchain? Is there a free toolchain available for me to use? Do you have a detailed development tutorial? Excuse me, big shotsI want to use Simulink for model-based development of the TC3XX series development board, but I am not sure about the development process and toolchain? Is there a free toolchain available for me to use? Do you have a detailed development tutorial? Excuse me, big shots I want to use Simulink for model-based development of the TC3XX series development board, but I am not sure about the development process and toolchain? Is there a free toolchain available for me to use? Do you have a detailed development tutorial? Excuse me, big shots infineon tc3xx simulink;mbd MATLAB Answers — New Questions
Dynamic filepath for sftp not allowed
Home="/folder1/folder2";
Scanname="Exp04_Sample1";
Sftp_path=strcat(Home,"/",Scanname);
fileInfo=dir(s,Sftp_path);
Why does the above not work?
But
fileInfo=dir(s,"/folder1/folder2/Exp04_Sample1");
will work?Home="/folder1/folder2";
Scanname="Exp04_Sample1";
Sftp_path=strcat(Home,"/",Scanname);
fileInfo=dir(s,Sftp_path);
Why does the above not work?
But
fileInfo=dir(s,"/folder1/folder2/Exp04_Sample1");
will work? Home="/folder1/folder2";
Scanname="Exp04_Sample1";
Sftp_path=strcat(Home,"/",Scanname);
fileInfo=dir(s,Sftp_path);
Why does the above not work?
But
fileInfo=dir(s,"/folder1/folder2/Exp04_Sample1");
will work? sftp MATLAB Answers — New Questions
Shading an area between two curves symbolically
I want to shade the area under the line y=2 and above the curve y=1+cos(x) from 0 to pi. I’m having trouble doing this. This is my code:
dy1 = 1+cos(x);
dy2 = 2;
fplot(dy1, [0 pi]); hold on;
fplot(dy2, [0 pi]);
patch([x fliplr(x)], [dy2 fliplr(dy1)], ‘g’);
hold off;I want to shade the area under the line y=2 and above the curve y=1+cos(x) from 0 to pi. I’m having trouble doing this. This is my code:
dy1 = 1+cos(x);
dy2 = 2;
fplot(dy1, [0 pi]); hold on;
fplot(dy2, [0 pi]);
patch([x fliplr(x)], [dy2 fliplr(dy1)], ‘g’);
hold off; I want to shade the area under the line y=2 and above the curve y=1+cos(x) from 0 to pi. I’m having trouble doing this. This is my code:
dy1 = 1+cos(x);
dy2 = 2;
fplot(dy1, [0 pi]); hold on;
fplot(dy2, [0 pi]);
patch([x fliplr(x)], [dy2 fliplr(dy1)], ‘g’);
hold off; fliplr, symbolic, fplot MATLAB Answers — New Questions