https://au.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-12-14T01:53:44Ztag:au.mathworks.com,2005:Question/4356652018-12-14T01:53:44Z2018-12-14T01:53:44ZDifferentiate a 5*5 symbolic matrix by a 5*1 symbolic vectorHi there,
Here I have a symbolic matrix A with a size of 5*5. The elements inside is composed of 5 symbolic variables , i.e., a,b,c,d,e. These 5 varibales together make a 5*1 vector q =[a;b;c;d;e].
During the computation in the project, I need to compute the differentation of A by q, i.e., .
Is there any command can be used to realize that?
Thanks very much!
Tony Chenghttps://au.mathworks.com/matlabcentral/profile/authors/9474183-tony-chengtag:au.mathworks.com,2005:Question/4356642018-12-14T01:49:46Z2018-12-14T01:49:46ZMATLAB saves file with ^M end of lineI worked with MATLAB in Linux. Recently, I edited a text file in MATLAB, and found the file was saved by MATLAB with the dos/Windows end of line ^M. Anyone can help with the MATLAB setting to enable again the UNIX newline? Qi Daihttps://au.mathworks.com/matlabcentral/profile/authors/14364615-qi-daitag:au.mathworks.com,2005:Question/4355472018-12-13T11:44:30Z2018-12-14T01:42:25ZNew line in legend does not work anymore in MATLAB 2017bHi,
I want to make a multi line legend with MATLAB 2017b:
plot([1:100;1:5:500]');
legend({['test 1' char(10) 'done'],['test 2' char(10) 'done']});
This results in:
In previous versions of MATLAB this reulted in:
which is what I want.
Christian Schwallhttps://au.mathworks.com/matlabcentral/profile/authors/5464956-christian-schwalltag:au.mathworks.com,2005:Question/4354932018-12-13T04:47:37Z2018-12-14T01:25:52ZIs it possible to run an App Designer app on an installation of Matlab which does not have App Designer?Does Matlab need App Designer or any toolbox to run an app created using App Designer?Sidhanth Guptahttps://au.mathworks.com/matlabcentral/profile/authors/12665021-sidhanth-guptatag:au.mathworks.com,2005:Question/4356572018-12-14T00:25:32Z2018-12-14T01:22:16ZSample Code of Projectile Motion. Unknown constant that's used.Disclamer: I am using the following code to help guide me through a projectile motion problem.
function projectile(theta,v0,dt,tf)
t = 0:dt:tf;
vx = v0*cos(theta);
vy = v0*sin(theta);
vx(1) = vx;
vy(1) = vy;
v = sqrt((vx^2)+(vy^2));
v(1) = v;
x(1) = 0;
y(1) = 0;
B2divm = 0.00004;
g = 9.81;
for i = 1:length(t)-1
v = sqrt((vx(i)^2)+(vy(i)^2));
x(i+1) = x(i) + vx(i)*dt;
vx(i+1) = vx(i) - (B2divm*v*vx(i))*dt;
y(i+1) = y(i) + vy(i)*dt;
vy(i+1) = vy(i) - g*dt - (B2divm*v*vy(i))*dt;
end
plot(x,y,'r')
end
I follow and reasonably understand the code, except for the use of the constant 'B2divm=0.0004'.
I strongly suspect that 'B2divm' above has something to do with Drag and air density, but I just don't know.
Anybody know what it means? How it's derived?
Thanks!!threex5x7https://au.mathworks.com/matlabcentral/profile/authors/9471108-threex5x7tag:au.mathworks.com,2005:Question/4352942018-12-12T07:33:40Z2018-12-14T01:18:35ZHow can get the value for each time step for a variable inside of a function?I need to get the value of some variables (Defined as golobal variables in the attached file) for each time steps. These variables are calculated inside of the fucntion for each time steps. Based on my code I am geeting the value only for the last time step. How can i get the value for each time steps
I have attached the files (main file. function file)
Md Shamim Ahamedhttps://au.mathworks.com/matlabcentral/profile/authors/6077641-md-shamim-ahamedtag:au.mathworks.com,2005:Question/4356632018-12-14T01:15:52Z2018-12-14T01:15:52ZY axis in two 3d plot are not samei use same data of Y axis(1*196), and i need the range of Y axis is 0 to 100ms, how can i change it?
X = zeros(196,1);
Y = 0:0.51:195*0.51;%time_ms
Z = given;
figure
subplot(1,2,2);
plot3(X,Y,Z);
surf(Z);
hold on
%plot3(X_140,Y,Z,'-w');
xlim([0 150]);
subplot(1,2,1);
plot3(X_20,Y,Z,'-r',X_70,Y,Z,'-b',X_120,Y,Z,'-m',X_140,Y,Z,'-g');
xlim([0 150]);
Jia Yuhttps://au.mathworks.com/matlabcentral/profile/authors/13764745-jia-yutag:au.mathworks.com,2005:Question/4356622018-12-14T01:12:18Z2018-12-14T01:12:18ZI see no lines on my graph after I plot themax1 = subplot(3,2,1); ax2 = subplot(3,2,2); ax3 = subplot(3,2,3);
ax4 = subplot(3,2,4); ax5 = subplot(3,2,5);
hold(ax1,'on'); hold(ax2,'on'); hold(ax3,'on'); hold(ax4,'on'); hold(ax5,'on');
for j=0:k
temp = zeros(2,1);
%dual variables plot
for m=1:I
plot(ax1,v(1,m))
ylabel(ax1,'Dual variable 1')
xlabel(ax1,'iteration')
plot(ax2,v(2,m))
ylabel(ax2,'Dual variable 2')
xlabel(ax2,'iteration')
temp = temp + A{m}*x(:,m);
end
%plot sum of all c*x and cost violation
plot(ax3,sum(dot(c',x)))
ylabel(ax3,'Cost function')
xlabel(ax3,'iteration')
plot(ax4,temp(1,1))
ylabel(ax4,'Upper Cost violation')
xlabel(ax4,'iteration')
plot(ax5,temp(2,1))
ylabel(ax5,'Lower Cost violation')
xlabel(ax5,'iteration')
show1 = sprintf('iteration %d completed\n',j);
show2 = sprintf('cost violation is %d and %d against %d and %d\n',temp(1,1), temp(2,1), Pmax, Pmin);
show3 = sprintf('cost function value is %d\n',sum(dot(c',x)));
disp(show1)
disp(show2)
disp(show3)
end
end
when this code runs, I see no lines on my graph plot. What am I doing wrong here?Muhammad Sarim Mehdihttps://au.mathworks.com/matlabcentral/profile/authors/12107305-muhammad-sarim-mehditag:au.mathworks.com,2005:Question/4353052018-12-12T08:34:10Z2018-12-14T01:11:58Zi want to ask how to adjust image contrast,i want to adjust the image contrast, the problem is the when i used imread to read the image it appears as a black image although when i browse it using image viewer the image was good. i used imadjust command to adjust image contrast , but it become brighter in the middle , but at the edges the brigntness is lower, so i want a command to change the image brighness equally through out the image
in the first column of the attached image i am tracing powder inside pocket , so the problem is that the pixel values at the pocket boundries is lower than in the middle , so it is traced as black (no powder), i think that comes from imadjust commandkhalid Elserfyhttps://au.mathworks.com/matlabcentral/profile/authors/11846776-khalid-elserfytag:au.mathworks.com,2005:Question/4356592018-12-14T00:32:43Z2018-12-14T01:00:35ZHaving trouble with "Index exceeds the number of array elements (1)" errorIf someone could help me to get this code working without error it would be greatly appreciated!
%Question 5: Robot Arm
ang01=input('Starting angle 1: ');
ang02=input('Starting angle 2: ');
angt1=input('Final angle 1: ');
angt2=input('Final angle 2: ');
tf=input('Final time (tf): ');
L1=input('Length 1 (L1): ');
L2=input('Length 2 (L2): ');
ang1=angt1-ang01;
ang2=angt2-ang02;
tmat=[tf^3,tf^4,tf^5];
a=pinv(tmat).*ang1;
b=pinv(tmat).*ang2;
disp(['a1: ',num2str(a(1))]);
disp(['a2: ',num2str(a(2))]);
disp(['a3: ',num2str(a(3))]);
disp(['b1: ',num2str(b(1))]);
disp(['b2: ',num2str(b(2))]);
disp(['b3: ',num2str(b(3))]);
angt1r=(pi/180)*angt1;
angt2r=(pi/180)*angt2;
x=L1*cosd(angt1r)+L2*cosd(angt1r+angt2r);
y=L1*sind(angt1r)+L2*sind(angt1r+angt2r);
t=0:0.01:2;
ax=gca;
for k=1:numel(t)
M=line([0,L1*cosd(angt1r(k)),x(k)],[0,L1*sind(angt1r(k)),y(k)]);
T=line(x(1:k),y(1:k));
pause(0.05)
if k~=numel(t)
delete(M)
delete(T)
end
endJordan Hamilton Morrishttps://au.mathworks.com/matlabcentral/profile/authors/13665885-jordan-hamilton-morristag:au.mathworks.com,2005:Question/4356612018-12-14T00:59:11Z2018-12-14T00:59:11ZPlotting very large data freeze MATLABI have large array 3D data and when I am plotting it using plot and plot3 function MATLAB freezes. Is there any option to create it in leass memory storageAbhishek Sainihttps://au.mathworks.com/matlabcentral/profile/authors/9533839-abhishek-sainitag:au.mathworks.com,2005:Question/4355372018-12-13T10:16:23Z2018-12-14T00:53:22ZHow to use a variant sink depending on its inputI have a s-function and it has 6 outputs, the next step is to check is there a negtive in 6 outputs. If there is one negtive, the simulation should be stop. If there is not, the 6 outputs should be passed to next s-function to continue simulating. In this case, I choose a variant sink, one of the output connects to stop block and another connects to next s-function to continue simulating. The thing is how can I use variant sink depending on its input rather than a pre-defined varable.
The pic shows how I use the variant sink, but it has an error saying that both the h and y (two of the outputs of s-funtion) are not defined.
Thank you very much！Bicheng Guohttps://au.mathworks.com/matlabcentral/profile/authors/8061640-bicheng-guotag:au.mathworks.com,2005:Question/4356362018-12-13T20:32:39Z2018-12-14T00:47:53Zhow to have a line marking in 3d image?have done a 3d plot, and want to get a line marking to mark a specific plot?
which code can i use?
Jia Yuhttps://au.mathworks.com/matlabcentral/profile/authors/13764745-jia-yutag:au.mathworks.com,2005:Question/4354572018-12-12T23:08:46Z2018-12-14T00:47:47ZHow to save & export .mlapp edit box resultsHey dear MATLABer
I've been practice using MATLAB .mlapp (under R2017b) to build a GUI with multilple edit box, and some action buttons (like 'ok', 'continue' and 'cancel')
Since this GUI will be called by other .m functions, and I need to save and export the user typed numbers inside the edit box. But I am not sure how shall these data's been export, I know the edit box values are can be found in app.Editlabel1.Value, but how shall I save and handle this data outside .mlapp? And I also want to extend .mlapp
I have read one related question (https://www.mathworks.com/matlabcentral/answers/284140-call-an-mlapp-with-input-argument-s), but seems not helping with my caseKat Leehttps://au.mathworks.com/matlabcentral/profile/authors/11259978-kat-leetag:au.mathworks.com,2005:Question/126362011-07-28T20:45:14Z2018-12-14T00:45:37ZHow can I count the number of times a number appear in a vector?How can I count the number of times a number appear in a vector?
A=[ 1 2 3 1 1 6 3 4 2 2 1 1 1 ]
1 appears 7 times
2 appears 3 times
3 appears 3 times
and on
...
Best RegardsRafael Freirehttps://au.mathworks.com/matlabcentral/profile/authors/2343440-rafael-freiretag:au.mathworks.com,2005:Question/4299492018-11-14T23:36:46Z2018-12-14T00:32:04ZSimulink Real Time: Logging non-virtual busRunning on a Speedgoat here. We have a very large Simulink Real Time model (compile time is ~10 minutes), and we're not so experienced with Simulink Real Time. We are trying to log many different non-virtual bus signals, but we have not been able to do without breaking the signals apart into their respective signals and pushing that into a File Scope. And that is still not preferable because we only have 8 (including Target scopes....).
I was looking into the Simulation Data Inspector. I was able to get some data back into the target computer, but not a lot (I think like 1 second in total), and nothing in the non-virtual buses was recorded. I'm going to guess that File Scopes are simply the best option we have here, but it's annoying that we can't feed a bus signal into one directly.
What am I doing wrong here?
Note:
We are integrating lots of other people's Simulink work here. We are mostly locked into the overall structure of this model. Kelly Schultzhttps://au.mathworks.com/matlabcentral/profile/authors/12458929-kelly-schultztag:au.mathworks.com,2005:Question/4354132018-12-12T16:54:02Z2018-12-14T00:30:45ZExample for marine vessel energy systemHello,
Can someone help me obtain the marine vessel model offered in MathWorks example section "Marine Full electric Propulsion system"
(link: Marine Full Electric Propulsion System).
It does not seem to appear in the sample examples provided in the Matlab R2018b_win64 that I have installed.
Thanks!
Jalomi
Jalomi Maayan-Tardifhttps://au.mathworks.com/matlabcentral/profile/authors/14072070-jalomi-maayan-tardiftag:au.mathworks.com,2005:Question/4356582018-12-14T00:30:44Z2018-12-14T00:30:44ZIssues with running genetic algorithm (GA) in parallel modeFirstly, I want to describe the outline/idea of my code.
I am using GA to optimize a quite complex problem.
(1) I have a main funtion. Within this main function I am using GA function.
The code is like this:
[x,fval,exitflag] = ga(@(Vars)windows_objective(Vars,Case0Input_path,Engine_path,Input_path,security_count,FluidDensity,...
FluidViscosity,PropDensity_0,PropDiameter_0,NoofClusters,Opt_PerfNo,Opt_PerfDia,...
Opt_ClusterSpacing,Opt_ProppSize,Opt_ProppDen,Opt_MaxInjRate,Opt_MaxPropConc,Opt_RampUpSpeed,...
PerfNo_Option,PerfDia_Option,ProppSize_Option,ProppDen_Option,NoofStages,...
ProppPerCluster,SlurryPerCluster),6+2*NoofClusters,A,b,[],[],...
lb,ub,@(Vars)windows_nlcon(Vars,NoofClusters,ProppPerCluster,SlurryPerCluster),IntCon,opts);
(2) In the GA objective function:
function [windows_objective] = windows_objective(Vars, Case0Input_path, Engine_path, Input_path, security_count, FluidDensity, FluidViscosity,PropDensity_0,PropDiameter_0,NoofClusters, Opt_PerfNo,Opt_PerfDia,Opt_ClusterSpacing,Opt_ProppSize,Opt_ProppDen,Opt_MaxInjRate,Opt_MaxPropConc,Opt_RampUpSpeed,PerfNo_Option,PerfDia_Option,ProppSize_Option,ProppDen_Option,NoofStages,ProppPerCluster,SlurryPerCluster)
an external .exe program will be called and multiple output files will be created by this external program. Therefore, within this objective function, I create a folder called "MatlabOpt" which will store all the output files created by the external program. After finish running this external program, by reading these output files, the objective function will calculate the objective function value and return it to the main function.
Whenever the objective function is called, it will check "MatlabOpt" folder like this (within the objective function):
X = sprintf('I am worker %d',labindex);
disp(X)
MatlabOpt_path = char(strcat(Input_path,'\MatlabOpt',num2str(labindex)));
MyFolder = MatlabOpt_path; % this is a folder
if ~isdir(MyFolder) % The first time to call objective function
mkdir(MatlabOpt_path) % this is a folder
copyfile(Case0Input_path, MatlabOpt_path)
else
rmdir(MatlabOpt_path, 's')
mkdir(MatlabOpt_path) % this is a folder
copyfile(Case0Input_path, MatlabOpt_path)
end
Secondly, I want to describe my issues.
(1) One run of the external program will take around 40 seconds. I give the GA function population size "100" and for my problem usually GA needs to run at least 20 generations to get the optimal solution. Which means that it will take around "20*100*40=80,000s". Therefore, I want to speed up my code.
Q1: Is my undestanding/calculation of the total run time correct or not?
(2) Therefore, I want to use GA in parallel mode through the following settings:
opts = optimoptions('ga','MaxStallGenerations',10,'FunctionTolerance',1e-5,...
'MaxGenerations',200,'PlotFcn',@gaplotbestf,'PopulationSize',100,...
'InitialPopulationRange',[initiallb;initialub],...
'UseParallel',true);
(3) I am thinking about the mechanism/algorithm/idea of GA in parallel mode.
Q2: I am thinking that, for example, in my case, my poupulation size is 100, which means GA needs to calculate 100 objective function values for one generation, yes?
Q3: If I have 4 workers in parallel mode, which means one worker will calculate 100/4=25 objective function values, yes?
If I am correct, to make sure multiple workers could calculate the objective function simultaneously, within the objective function, I create the MatlabOpt folder with the worker id.
X = sprintf('I am worker %d',labindex);
disp(X)
MatlabOpt_path = char(strcat(Input_path,'\MatlabOpt',num2str(labindex)));
(4) When I run GA in serial, I can see that the folder is called "MatlabOpt1" and my codes could be run without problems.
(5) However, when I run GA in parallel mode, I will have the following error:
I am worker 1
I am worker 1
I am worker 1
I am worker 1
Error using windows_objective (line 16)
No directories were removed.
Error in
windows_frac_optimization>@(Vars)windows_objective(Vars,Case0Input_path,Engine_path,Input_path,security_count,FluidDensity,FluidViscosity,PropDensity_0,PropDiameter_0,NoofClusters,Opt_PerfNo,Opt_PerfDia,Opt_ClusterSpacing,Opt_ProppSize,Opt_ProppDen,Opt_MaxInjRate,Opt_MaxPropConc,Opt_RampUpSpeed,PerfNo_Option,PerfDia_Option,ProppSize_Option,ProppDen_Option,NoofStages,ProppPerCluster,SlurryPerCluster)
(line 192)
[x,fval,exitflag] =
ga(@(Vars)windows_objective(Vars,Case0Input_path,Engine_path,Input_path,security_count,FluidDensity,...
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in fcnvectorizer (line 16)
parfor (i = 1:popSize)
Error in gaminlppenaltyfcn
Error in gapenalty
Error in makeState (line 64)
Score = FitnessFcn(state.Population(initScoreProvided+1:end,:));
Error in galincon (line 17)
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in gapenalty
Error in gaminlp
Error in ga (line 393)
[x,fval,exitFlag,output,population,scores] = gaminlp(FitnessFcn,nvars, ...
Error in windows_frac_optimization (line 192)
[x,fval,exitflag] =
ga(@(Vars)windows_objective(Vars,Case0Input_path,Engine_path,Input_path,security_count,FluidDensity,...
Caused by:
Failure in user-supplied fitness function evaluation. GA cannot continue.
Failure in initial user-supplied fitness function evaluation. GA cannot continue.
Finally, your help/comments/suggestions would be greatly appreciated!!
Thanks and best regards,
MinMin Zhanghttps://au.mathworks.com/matlabcentral/profile/authors/9152492-min-zhangtag:au.mathworks.com,2005:Question/4356332018-12-13T20:08:01Z2018-12-14T00:28:39ZPlz help number 2,3 codingwrite number3 coding. plz check my coding
x=linspace(0,8,50);
y=x.*exp(-x.^0.8)*0.2;
trapz(x,y,z)
plot(x,y)
Krisendhttps://au.mathworks.com/matlabcentral/profile/authors/13531736-krisendtag:au.mathworks.com,2005:Question/4356562018-12-14T00:24:27Z2018-12-14T00:24:27ZDelivery of variables in function and fsolve afterwards doesn't workHello,
I want to do something like this but without global variables. I want to run myfuncall.m and then I want to have the variables A and B available in myfun.m. and the result in command window .
In other programs I already deliviered variables successfully in the function in this style: [result1, result2]=myFunctionname(variable1, variable2) but here I tried but it didn't work.
%myfuncall.m
x0=[0 0];
A=3;
B=4;
x=fsolve(@myfun,x0)
%myfun.m
function F = myfun(x)
F = [2*x(1) - x(2) - exp(-x(1))-A;
-x(1) + 2*x(2) - exp(-x(2))-B];
end
Many thanks in advance
Maximilian Bachhttps://au.mathworks.com/matlabcentral/profile/authors/14363650-maximilian-bachtag:au.mathworks.com,2005:Question/4356052018-12-13T17:56:23Z2018-12-14T00:20:16ZMatrix dimensions must agree error Im trying to make a simple function in which you input the radius, centre of a circle and the intercept coordinates to output a plot with the circle, radius and tangent showing but I seem to be stuck here any help is appreciated
function circle2
x0=input('centre x-axis');
y0=input('centre y-axis');
r=input('radius');
xp=input('P x-coord');
yp=input('P y-coord');
%Parameters
th=0:0.01:2.*pi;
%Value for x
x=r.*cos(th)+x0;
%Value for y
y=r.*sin(th)+y0;
%Differentiation
dxdth = -r.*sin(th);
dydth = r.*cos(th);
%Gradient
dydx = dydth./dxdth;
%Calculate intercept
intcpt = yp - dydx.*xp;
%x vector for tangent
xt= linspace(xp-1,xp+1,2);
%Calculate tangent
yt = dydx.*xt+intcpt;
if yp~=yt
xt=xp-2<=xt<=xp+2
yt=dydx(xt-xp)+yp
elseif yp==y0
xt=xp
yt=yp-5<=yt<=yp+5
end
%Plot intercept
plot(x,y);
hold on
plot(xp, yp);
%Plot tangent
plot(xt, yt);
%Plot radius
plot ([x0 xp],[y0 yp])
%Axis limit values
axis ([-1.25*r 1.25*r -1.25*r 1.25*r]);
Alexandros Panagihttps://au.mathworks.com/matlabcentral/profile/authors/14354122-alexandros-panagitag:au.mathworks.com,2005:Question/1555712014-09-20T12:58:18Z2018-12-14T00:19:28ZMAKING SUBJECT OF FOMULARHOW DO I MAKE X SUBJECT OF FOMULAR IN THIS EQUATION x = exp(x+y).
I have tried the following code
syms x y
solve('x = exp(x+y)',x)
and this give me
*
[sym empty].*
How best can I do it.lloyd mukunzahttps://au.mathworks.com/matlabcentral/profile/authors/4027519-lloyd-mukunzatag:au.mathworks.com,2005:Question/4356112018-12-13T18:11:38Z2018-12-14T00:18:02ZHow to create a distance matrix in matlabHello,
I want to determine what the shortest route is to pick multiple items in a warehouse. However, I do not want to use a standard distance matrix, but I want to compute the distances between two items myself. Does anyone know how to create an distance matrix with the shortest distances between items in the same picking order? Lisa de Boerhttps://au.mathworks.com/matlabcentral/profile/authors/10401444-lisa-de-boertag:au.mathworks.com,2005:Question/4356502018-12-13T22:53:18Z2018-12-14T00:00:18ZComparing two input voltages?I'm attempting to build a ride by wire system, I've built a proof of concept in Simulink utilising an Arduino as the controller.
Now I've moved on to real hardware with a RBW throttle, it uses two hall effect sensors to give two voltages. On one it gives a range of 0.9 - 4.4v and the other is 0.4 - 2.2v. I've looked through various blocks but I'm struggling to see a way forward and would appreciate any guidance on this problem.Philip Harrishttps://au.mathworks.com/matlabcentral/profile/authors/14178138-philip-harristag:au.mathworks.com,2005:Question/4356542018-12-13T23:54:56Z2018-12-13T23:54:56ZHow to use linprog solver for some values of variables needs to have equal value How i could use linprog to solve this problem. My objective and constraint have this form.
Objective Pa - -> max
A x + B y = a
C x + Pa*D <= b
and Pa >=0
I don't want to use nonlinear constraint or need to know any other function (without using nonlinear constraint) to get the optimized value for Pa
A = [-1 1 0 0 0
1 -2 1 0 0
0 1 -2 1 0
0 0 1 -2 1
0 0 0 1 -1 ]
B = [-1 0; 0 0; 0 0; 0 0; 0 -1]'
a = [0 0 0 0 0]'
C = [ 1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
-1 0 0 0 0
0 -1 0 0 0
0 0 -1 0 0
0 0 0 -1 0
0 0 0 0 -1]
D = [4.50, 0.90, 2.70, 0.90, 4.50, 4.50, 0.90, 2.70, 0.90, 4.50]'
b = [3.00, 3.00, 3.00, 3.00, 3.00 6.00, 6.00, 6.00, 6.00, 6.00]'Abdulazizkhttps://au.mathworks.com/matlabcentral/profile/authors/11856499-abdulazizktag:au.mathworks.com,2005:Question/4356102018-12-13T18:09:02Z2018-12-13T23:54:02ZProblems in access on the MathWorks AccountHello dears, when I try to access my account of the my laptop a recieve the follow mensage: "Something unexpected occurred", but I can access using other computer. What could be happening?Ewerton Santoshttps://au.mathworks.com/matlabcentral/profile/authors/14362850-ewerton-santostag:au.mathworks.com,2005:Question/4355622018-12-13T13:28:06Z2018-12-13T23:47:29ZAny GPU implementation of k-nearest neighbor search? Hi, I am developing a SPH (smoothed particle hydrodynamic) code of solving fluid equations in Matlab. I have successfully vectorized and implemented the code on GPU. The speed up is astonishing, ~10 times faster than CPU code. In the process I got invaluable suggestions from Matt J and Joss Knight for speeding up the code. Thank them for their wonderful suggestions.
In SPH, one has to find the neighbor particles in a given radius for every particles in the domain. I use the matlab function knnsearch for this purpose. Now the other part of the code (except neighbor search but solving the fluid equations) is so fast that the limiting part now is the knnsearch, which uses kdtree algorithm runing on CPU. It takes 85% percent of the runtime (see the following code profiler results)
The function 'knnCPU_kdtree_func' uses the matlab built-in function knnsearch with kdtree algorithm runing on CPU. The other functions are solving the real fluid equations runing on GPU only consumes 10% of the total time.
I wonder is there any GPU implementation of k-nearest neighbor search that I can free download and using as a function call in my matlab code? Many thanks.Hao Zhanghttps://au.mathworks.com/matlabcentral/profile/authors/2574469-hao-zhangtag:au.mathworks.com,2005:Question/4356532018-12-13T23:46:07Z2018-12-13T23:46:07Zdisplay matrix with textHi,
I would like to display matrices in a command window as following:
A = [2 4;3 5];
B = [8 7;9 0];
C = A + B;
%part of code with solution to my question, which will result in displaying (in command window):
2 4 8 7 10 11
+ =
3 5 9 0 12 5
So notation feels very natural, like we would write it down on paper. Im curious to know if there is any possible solution without stringifying it to different lines like this?
'2 4 8 7 10 11'
' + = '
'3 5 9 0 12 5 'Anton Lipendinhttps://au.mathworks.com/matlabcentral/profile/authors/14364146-anton-lipendintag:au.mathworks.com,2005:Question/3087732016-10-24T03:00:53Z2018-12-13T23:43:26ZOpen .spf2Hello
I am trying to open a .spf2 file with matlab,but am having trouble. How can I do this?
Thank you
SamSamuel Yanghttps://au.mathworks.com/matlabcentral/profile/authors/5960298-samuel-yangtag:au.mathworks.com,2005:Question/4355762018-12-13T15:29:58Z2018-12-13T23:36:25ZHow to get the original Image matrix from the Integral Image of a N*N matrix?IF the original image matrix is represented by r=[ 1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]. Then it's integral image using the inbuilt 'integralImage' function is given by
0 0 0 0 0
0 1 3 6 10
0 6 14 24 36
0 15 33 54 78
0 28 60 96 136
Excluding first row and first column we get
1 3 6 10
6 14 24 36
15 33 54 78
28 60 96 136
My requirement is to obtain the original image from the given integral image provided.
Karthik Nagarajhttps://au.mathworks.com/matlabcentral/profile/authors/11245659-karthik-nagarajtag:au.mathworks.com,2005:Question/4356492018-12-13T22:35:13Z2018-12-13T23:33:43ZHow play wav files selected from a playlist/listboxI have created a GUI audio player that plays wav files. The player has an add button that selects a file from a folder and plays it.
I am able to populate the listbox/playlist with the appropiate wav files, but cant figure out how to actually play the selcted file. At the moment it just plays 1 audio file named 'handel.wav'. I would appreciate some input on how to make the player play more than just one song from the playlist. I have inlcuded the code for my player from the opening fcn and the code for the add button which puts the wav file in the listbox. There is no code in my listbox yet and just play, pause and stop buttons elsewhere.
Andrew Howehttps://au.mathworks.com/matlabcentral/profile/authors/14056908-andrew-howetag:au.mathworks.com,2005:Question/207382011-11-09T10:30:42Z2018-12-13T23:33:35Zbackward,forward, and central DifferenceCan any body help me understand how to do numerical differentiation? example:
t = 0:5:100; Z = cos(10*pi*t)+sin(35*pi*5);
how can I find the backward,forward and central difference at t = 99?Abra doghttps://au.mathworks.com/matlabcentral/profile/authors/3080357-abra-dogtag:au.mathworks.com,2005:Question/4356482018-12-13T22:29:19Z2018-12-13T23:26:53ZRound elements in a table while simultaneously having titles?I want to simultaneously have tables were the elements inside are rounded, while also having a title and labels for the rows.
'title' | var1 | var2 | var3
'row1' | .123 .421 .021
'row2' | .321 .231 .231
Without rounding I can create a table with the following syntax:
TableName = ['row1','row2'];
T = table(var1, var2, var3, 'RowNames',TableName)
But to round, it seems like I need to use the function varfun:
TableName = ['row1','row2'];
T = table(var1, var2, var3, 'RowNames',TableName)
LOGtable = varfun(@(var) round(var, 4), T)
But in doing so I lose the 'RowNames' and title options in the previous table.
How should I solve this? Steven Sagonahttps://au.mathworks.com/matlabcentral/profile/authors/7111331-steven-sagonatag:au.mathworks.com,2005:Question/4356522018-12-13T23:23:54Z2018-12-13T23:23:54Zhow to install the SPM 12 into Matlab?I have downloaded spm 12,(files from UCL) but I cant use it in matlab.
I dont know what to do and I have tried several times and no use. Could you please give me instructions on how to use SPM to carry out my analysis
Catarina Gaglianonehttps://au.mathworks.com/matlabcentral/profile/authors/14189320-catarina-gaglianonetag:au.mathworks.com,2005:Question/1630792014-11-17T14:59:51Z2018-12-13T23:20:00ZUnable to open file "binaryeye.jpg" for writing. You may not have write permission.Hi, i am trying to run this program but i keep getting this error "Unable to open file "binaryeye.jpg" for writing. You may not have write permission. "
The code which i am trying is:
im=imread('2.jpg');
imgray=rgb2gray(im);
imgray=double(imgray);
[imgx,imgy]=gradient(imgray);
imggra=sqrt(imgx.^2+imgy.^2);
imedge=uint8(imggra);
imedge=imadjust(imedge);
imedge=im2bw(imedge);
imwrite(imedge,'binaryeye.jpg');
[imr,imc]=size(imgray);
maxvalue=eps;
maxr=0;
maxx=1;
maxy=1;
for radius=9:13
for i=radius+1:imr-radius
for j=radius+1:imc-radius
maxcount=0;
for theta=0:pi/60:2*pi
y=floor(radius*sin(theta))+i;
x=floor(radius*cos(theta))+j;
if imedge(y,x)==true
maxcount=maxcount+1;
end
% y=floor((radius-1)*sin(theta))+i;
% x=floor((radius-1)*cos(theta))+j;
% if imedge(y,x)==true
% maxcount=maxcount+1;
% end
if maxcount>maxvalue
maxvalue=maxcount;
maxr=radius;
maxx=j;
maxy=i;
end
end
end
end
end
maxr,maxx,maxy
imgray=uint8(imgray);
figure,imshow(imgray)
hold on;
for theta=0:pi/50:2*pi
x=floor(maxr*cos(theta))+maxx;
y=floor(maxr*sin(theta))+maxy;
plot(x,y,'b*-');
end
However i keep getting this error
Error using imwrite (line 455)
Unable to open file "binaryeye.jpg" for writing. You may not have write
permission.
what can i do to solve it? i already change the setting of the folder containing binaryeye.jpg to be written.
Thanks.Jia Zhenhttps://au.mathworks.com/matlabcentral/profile/authors/5702831-jia-zhentag:au.mathworks.com,2005:Question/4356512018-12-13T23:06:53Z2018-12-13T23:18:15ZHow to Index Substructure I am trying to index a field in a substructure of a structure. The main structure is supermarket
the next structure is produceList
the field i wish to call from produceList is minNumber
I tried supermarket.produceList{i}.minNumber
I need the {i} to allow the for loop to work
for i = 1:length(supermarket.produceList)
It gives me the error Dot indexing is not supported for this type of variable.
I know i can index with specific elements in the structure such as supermarket.Apples.minNumber. However, this prevents me from testing it for each element of substructure produceListJoshua Konzelmanhttps://au.mathworks.com/matlabcentral/profile/authors/13451865-joshua-konzelmantag:au.mathworks.com,2005:Question/4354322018-12-12T19:18:57Z2018-12-13T22:50:23ZCreating the Snake Game using a classI'm having trouble making the Snake game using a class def, my code just continously loops & keeps recreating the graph. I'm stuck & don't know what I need to do to be able to stop the the graph from constantly remaking itself & make the snake move.
classdef snake < handle
properties
gameinput = 'k';
player1 = [];
board = [];
lose = [];
character = 1;
ex = 0;
end
methods
%constructor
function self = snake(varargin)
if ~isempty(varargin)
self.gameinput = varargin{1}
if nargin > 1
self.player1 = varargin{2};
end
end
end
%controls game flow
function play(self)
if isempty(self.lose)
draw_board(self)
end
end
%creates game board
function draw_board(self)
axis_limit = 16;
d = 0;
ate = 0;
x = round(axis_limit/2); %starting point
y = round(axis_limit/2); %starting point
a =randi([1 axis_limit-1],1);%generates random x coordinate for food
b =randi([1 axis_limit-1],1);%generates random y coordinate for food
d =randi([1,4]);% generates random direction to start in for snake
snake(1,1:2)=[x y];%defines the snake for x and y coordinates
size_snake=size(snake);
size_snake=size_snake(1);
food = [a b]; %defines coords for the food
test
while (self.ex~=1)%runs the snake as long as q is not pressed
size_snake=size(snake);
size_snake=size_snake(1);
for l=size_snake+ate:-1:2
snake(l,:)=snake(l-1,:);
end
switch d %calling callback function
case 1
snake(1,2)=snake(1,2)+1;%add value of 1 to y position
case 2
snake(1,2)=snake(1,2)-1;%subtract value of 1 to y position
case 3
snake(1,1)=snake(1,1)+1;%add value of 1 to x position
case 4
snake(1,1)=snake(1,1)-1;%subtracts value of 1 to x position
end
draw_snake(self)
if snake(1,1)==food(1) && snake(1,2)==food(2)%if the snake and food are in the same position
ate=1;
food(1) = randi([1 axis_limit-1]);%creates a new x position for the food
food(2) = randi([1 axis_limit-1]);%creates a new y position for the food
else
ate=0;
end
snake=snake-((snake>axis_limit).*(axis_limit+1));
snake=snake+((snake<0).*(axis_limit+1));
end
end
function draw_snake(self)
axis_limit = 8;
d = 0;
ate = 0;
x = round(axis_limit/2); %starting point
y = round(axis_limit/2); %starting point
a =randi([1 axis_limit-1],1);%generates random x coordinate for food
b =randi([1 axis_limit-1],1);%generates random y coordinate for food
d =randi([1,4]);% generates random direction to start in for snake
snake(1,1:2)=[x y];%defines the snake for x and y coordinates
food = [a b]; %defines coords for the food
size_snake=size(snake);
size_snake=size_snake(1);
for p = 1:size_snake
plot(snake(p,1),snake(p,2), 'wo')
hold on
end
plot(food(1,1),food(1,2), 'rs')%creates the vectors for the food and snake and plots them
drawnow
whitebg([0 0 0])%creates black background
axis([0, axis_limit, 0, axis_limit])%creates the axis for gameplay
hold off
end
%controls the movement of the snake
function move_snake(self)
switch self.character
case 'q'
self.ex=1;
case 30 % arrow direction
if(d~=2)
d = 1; %up d=1
end
case 31
if(d~=1)
d = 2; %down d=2
end
case 29
if(d~=4)
d = 3; %right d=3
end
case 28
if(d~=3)
d = 4; %left d=4
end
end
end
end
endLandon Dukehttps://au.mathworks.com/matlabcentral/profile/authors/10269981-landon-duketag:au.mathworks.com,2005:Question/4356352018-12-13T20:14:09Z2018-12-13T22:49:42ZHow to run encoder.m file .following message appears: Undefined function or variable 'raw_message'? appears as i press run buttonHow to run encoder.m file downloaded from the matlab website .
Undefined function or variable 'raw_message'? appears as i press run buttonsami ullahhttps://au.mathworks.com/matlabcentral/profile/authors/14103506-sami-ullahtag:au.mathworks.com,2005:Question/4356452018-12-13T21:53:56Z2018-12-13T22:47:16ZObjective function for projectile I have a function to calculate projectile's distance and velocity in both x and y direction. I need to write a function, which defines the objective function to be minimised. objective should take as arguments: the two variables being optimised (i.e. the initial velocity and angle), and the target coordinates tx and ty. It should call my function mentioned earlier with the initial conditions and return the shortest distance between the computed trajectory and (tx, ty). I've not dealt with optimization before so I don't know where to start.
Many thanksZivile Dailidonytehttps://au.mathworks.com/matlabcentral/profile/authors/13638220-zivile-dailidonytetag:au.mathworks.com,2005:Question/4355412018-12-13T11:16:33Z2018-12-13T22:46:26ZHow to convert text to time and merge two seperate date and time columns in readtable Hi,
Before I ask my question I have to state that I have searched forums a lot and can not compile all the information I need.
I have attached a sample of my file which has date and hour as the first and second columns. I will be needing these timestamps combined for my analysis.
I need to first convert that time data which reads as Hour with date information. but I think matlab does not see it in a date format as I attached how data shows when I use timetable, as u can see it reads hour with extra '' . I was not successful converting that column to a time information..
Si first I need to make sure readtable reads that second column in time format.
Then I need to merge these two date and time information in seperate colums so I can have something in the following format:
dd/mm/yyyy hh:mm
After that I need to add 7 hours to each of the timestamp data (Maybe this is another question)
I need to have a table2timetable in the end so I can aggregate data.
Below is my code.
I have multiple files like this and each file has around 300K rows and 10 columns so import data is out of question for me as well
I am using matlab 2017b.
filename='AUDUSD.csv';
aud = readtable(filename);
newaud=datetime (aud{:,2},'InputFormat','yyyy/MM/dd/HH:mm');
audtry = table2timetable(newaud);
Error using datetime (line 616)
Unable to parse date/time text using the format 'yyyy/MM/dd/HH:mm'.
Error in Untitled8 (line 4)
newaud=datetime (aud{:,2},'InputFormat','yyyy/MM/dd/HH:mm');
Stephhttps://au.mathworks.com/matlabcentral/profile/authors/12971362-stephtag:au.mathworks.com,2005:Question/4356472018-12-13T22:18:14Z2018-12-13T22:40:58ZA function to compare pricesI have completed most of this question but am struggling to complete.
%This is the script/function for Q.2a of Assignment 4
function a = MPR_Asgn4_Q2a_26024405(modnam,man,prc) %modnam is the model name, man is the manufacturer, prc is the price
a = cell(3, 1);
a{1, 1} = modnam;
a{2, 1} = man;
a{3, 1} = prc;
end
%This is the script/function for Q.2b of Assignment 4
p1 = MPR_Asgn4_Q2a_26024405('Iphone X 64 GB','Apple',899);
p2 = MPR_Asgn4_Q2a_26024405('Xperia XZ2 64GB','Sony',399);
p3 = MPR_Asgn4_Q2a_26024405('Galaxy J6 Plus 32GB', 'Samsung',209);
p4 = MPR_Asgn4_Q2a_26024405('Mate 10 Pro 64GB', 'Huawei', 429);
p5 = MPR_Asgn4_Q2a_26024405('Pixel 3 64GB', 'Google', 739);
P=[p1,p2,p3,p4,p5];
for
It's sorting by price and using double nested loops which I can't do.Jack Bushhttps://au.mathworks.com/matlabcentral/profile/authors/13883834-jack-bushtag:au.mathworks.com,2005:Question/2772062016-04-05T07:00:30Z2018-12-13T22:35:08ZSimulink tutorials/ examples for ZynqHello,
I have searched the internet and don't find sufficient examples of simulink for zynq (VHDL code generation). Kindly give me some tutorials/ examples from where I can learn this. I need a supporting document which explains interfacing matlab with vivado as well as I encountering some errors while doing this.sunayana chakradharhttps://au.mathworks.com/matlabcentral/profile/authors/7970922-sunayana-chakradhartag:au.mathworks.com,2005:Question/4354652018-12-13T00:22:47Z2018-12-13T22:33:53ZHow do I identify subsets of data and divide the data into the subsetsRight now I have code that takes data from two IMU's attached to each side of a knee joint and finds the angle in the knee while someone performs a squat. The Output is the angle on each plane between the two IMUs (the main one I am concerned with is the blue line which is the angle assuming the knee can only rotate on one axis). Plot attached.
I am wondering how I can identify and divide the data so I can analyze each "Repitition" of the exercise on its own. In the plot attached there would be three seperate repetitions I would want to look at.
Bill Phttps://au.mathworks.com/matlabcentral/profile/authors/6992148-bill-ptag:au.mathworks.com,2005:Question/4354522018-12-12T22:27:51Z2018-12-13T22:32:07ZChoosing bin size to include equal number of data pointsI have 'time' of certain event to happen in first column and the 'probability of event to happen' in the second column. If i want to plot the data with each bin containing equal number of visits based on the time of visit, how should i decide the bin size?Hari krishnanhttps://au.mathworks.com/matlabcentral/profile/authors/13142902-hari-krishnantag:au.mathworks.com,2005:Question/4356312018-12-13T19:43:21Z2018-12-13T22:29:35ZHow to add multiple suggestions to the automatic pop-up help boxes when typing a function?I have some functions that can accept variable amounts of inputs and I want to better document them by adding appropriate suggestions to the box that pops up when you begin typing the function name, like this:
Most built-in Matlab functions display help boxes like this but when I write a function from scratch, it either displays the inputs I specifically have listed, or it shows (...) if the function accepts "varargin", like so:
Those functions of course already handle the inputs properly, but I want to display the various acceptable ways of calling the function in the displayed suggestions here. Is there a way to customize this feature?Nathanhttps://au.mathworks.com/matlabcentral/profile/authors/5734014-nathantag:au.mathworks.com,2005:Question/3718782017-12-08T10:51:05Z2018-12-13T22:29:21ZCan Polyspace prove recursion to be impossible?We have a statemachine implementation in C for an embedded automotive product, using a table-approach. The table contains pointers to functions handling the transition and during actions for states. As these functions can call the table again, there is a chance on recursion (reported by another 3rd party static code analysis tool).
From the code design we 'know' it is not possible to have recursion, but we need proof for that as we're following ISO26262-6 (ASIL-C) and MISRA-2012 rules. From these norms, recursion in the implementation is not allowed.
Can polyspace bugfinder/codeprover report on the recursion of this tabular approached state machine implementation? If yes, how?Stein Heselmanshttps://au.mathworks.com/matlabcentral/profile/authors/8107921-stein-heselmanstag:au.mathworks.com,2005:Question/4322992018-11-27T15:10:49Z2018-12-13T22:26:51ZWhy importing ascii file and doing differentiation on it by GUI MATLAB shows this error 'Undefined operator '<=' for input arguments of type 'cell'.' ?Dears,
I come to my first Matlab code and I have no previous experience with Matlab so I need your help. I wrote the following code in order to load an ascii file of different rows and columns by push_callback in GUI Matlab. Before loading the file I entered value to define the column of interest and I loaded the desired 'tauD'. Afterwards, I need this code to do some differentiations, save the results, and finally to draw the ouput. But, I got the following message
'
' Undefined operator '<=' for input arguments of type 'cell'.
Error in PSD>pushbutton1_Callback (line 128)
I=imp(tauD(1,1)<=imp(:,1)&imp(:,1)<=tauD(end,1),col+1);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in PSD (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)PSD('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback''
So, could you please help me to fix this errors?
Your efforts and time are deeply appreciated in advance!
tauD_file='myOptions';
col=getappdata(0,'edit1');
load(tauD_file);
tauD=myOptions;
[fnames,fpath]=uigetfile({'*.dat;*.txt','ASCII Files';'*.*','All Files' },'Select data file','MultiSelect','on');
if ~iscell(fnames)
fnames={fnames};
end
for k=fnames
X1 = cell2mat(k)
imp=importdata([fpath,char(X1)]);
I=imp(tauD(1,1)<=imp(:,1)&imp(:,1)<=tauD(end,1),col+1);
[~,fname]=fileparts(char(X1));
dtau=gradient(tauD(:,1));
dtaudD=gradient(tauD(:,1),tauD(:,2));
dtaudlogD=gradient(tauD(:,1),log(tauD(:,2)));
dVdD=I.*dtaudD./dtau;
dVdlogD=I.*dtaudlogD./dtau;
result=[tauD(:,2),dVdD,dVdlogD];
save([fpath,'dVdD(C8)_cyl_0.193_6_',fname,'.dat'],'result','-ascii')
end
set(handles.pushbutton1,'String',filename);
a = get (handles.pushbutton1,'String',dVdlogD(:,1));
b= get (handles.pushbutton1,'String',dVdlogD(:,3));
axes(handles.axes1);
plot(eval(a), eval(b))
Ahmed Elsherifhttps://au.mathworks.com/matlabcentral/profile/authors/13979717-ahmed-elsheriftag:au.mathworks.com,2005:Question/4356322018-12-13T19:44:48Z2018-12-13T22:23:09ZProblems with plotting multiple objects
Hi! I have a question. There are the label of contour on the rectangle. Can I delete this for a better reading? Thank you
This is the code for the graphic part.
[c,cc]=contour(x,y,u',[13.1,13.5,14,14.5,15,15.5,15.9]);
clabel(c,cc,'LabelSpacing',72,'Color','r','FontWeight','normal');
rectangle('position',[0,0,Lx,Ly])
rectangle('position',[x(6),y(4),d,3*d],'FaceColor',[0.5 0.5 0.5],'LineWidth',1)
axis('equal');
set(cc,'ShowText','on');
colormap cool;
axis([0 Lx 0 Ly]);
hold on;
streamline(x,y,qx,qy,[x(2:4),x(9:nx)], y(ny+1)*ones(1,6));
quiver(x(2:5),y(2:ny),qx(2:ny,2:5),qy(2:ny,2:5),'b');
quiver(x(8:nx),y(2:ny),qx(2:ny,8:nx),qy(2:ny,8:nx),'b');
quiver(x(6:7),y(2:3),qx(2:3,6:7),qy(2:3,6:7),'b');
trimesh(T,P(:,1),P(:,2),hh);
title('Sheet pile wall');
xlabel('x');ylabel('y');zlabel('z');MICHELA VOLGAREhttps://au.mathworks.com/matlabcentral/profile/authors/13760896-michela-volgaretag:au.mathworks.com,2005:Question/4350492018-12-10T22:22:47Z2018-12-13T22:19:07ZPlease help me create Decimal to Two's Complement/ Two's Complement to Decimal function without using the built-in function in MatlabHello Everyone,
My goal here is to create the Decimal to Two's Complement/ Two's Complement to Decimal function without using the built-in function in Matlab , aslo to create hexadecimal number to decimal number and vise versa. without using hex2dec & dec2hex.
Your input is much appreciated.
Thank you.Irwin2000https://au.mathworks.com/matlabcentral/profile/authors/12752529-irwin2000tag:au.mathworks.com,2005:Question/4262002018-10-26T05:07:37Z2018-12-13T22:14:59ZHow to resolve the error "Expected audioIn to be a column vector."Hi,
I am using the "Speech Command Recognition Using Deep Learning " to detect words from my own database. The length of each clip in my database is 4 seconds. I am using the default parameters for creating histograms only changing the segmentDuration to the duration in my clips. What wrong I might be doing here?
segmentDuration = 3;
frameDuration = 0.025;
hopDuration = 0.010;
numBands = 40;
The problem is whenever I am trying to run the code, its throwing an error
"Computing speech spectrograms...
Error using auditorySpectrogram
Expected audioIn to be a column vector.
Error in auditorySpectrogram>validateRequiredInputs (line 196)
validateattributes(x,{'single','double'},...
Error in auditorySpectrogram (line 66)
validateRequiredInputs(x,fs)
Error in speechSpectrograms (line 24)
spec = auditorySpectrogram(x,fs, ...
Error in Speech (line 30)
XTrain = speechSpectrograms(adsTrain,segmentDuration,frameDuration,hopDuration,numBands);"
What could be the possible reason and a solution for this. ThannksMohammed Faridul Haque Siddiquihttps://au.mathworks.com/matlabcentral/profile/authors/7702407-mohammed-faridul-haque-siddiqui