https://fr.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-10-25T00:04:56Ztag:fr.mathworks.com,2005:Question/6251332020-10-24T22:39:34Z2020-10-25T00:04:56ZMy for loop is running only onceHello all! I'm an engineering student and I'm trying to build a for loop that gives me matrix calculations for every single index value defined in its range i.e. 0 to 360.
However, when I run my code, it's only giving me the resulatant matrix for one index value, which is at 360, rather than 361 matrices. I've set it in diefferent ranges and done anything I could think of, but, I couldn't figure it out. I'd appreciate for any help or advice on it. Thanks! Below is my code I've been working on so far:
for theta2 = 0:360 %for theta2 = 0:1:360, theta2 be the index.
%Given:
% Lengths (m)
a = 0.4;
b = 5;
c = 1.2;
%Distance from A to G3:
px = (b*sind(71.7))-1.5; %C to P = 1.5 in x.
py = 0.5;
p = sqrt((px^2)+(py^2));
%36; %theta2 varies from 0 to 360 deg. Randomly selected initial entry (36)
%delta3 (deg):
ac = b*sind(71.7);
bac = acosd(ac/b);
pac = atand(py/px);
delta3 = bac- pac;
% Velocities (m/s, rad/s)
w2 = -10; %CW, Constant velocity
%Accelerations (m/s^2, rad/s^2)
alpha2 = 0; %w2 is constant velocity, no acceleration.
% Position analysis: Ch. 4
theta3 = asind((a.*sind(theta2)-c)./b) %180 deg = pi
d = a.*cosd(theta2)-b.*cosd(theta3)
% Velocity analysis=s: Ch. 6
w3 = ((a.*cosd(theta2))./(b.*cosd(theta3))).*w2
ddot = -a.*w2.*sind(theta2)+b.*w3.*sind(theta3) %vB = ddot, slip velocity
% Acceleration Analysis: Ch. 7
% wn^2 terms are for normal accelerations, alphan terms are for tangential
%accelerations.
alpha3 = (a.*alpha2.*cosd(theta2)-a.*(w2.^2).*sind(theta2)+b.*(w3.^2).*sind(theta3))./(b.*cosd(theta3))
dddot = -a.*alpha2.*sind(theta2)-a.*(w2.^2).*cosd(theta2)+b.*alpha3.*sind(theta3)+b.*(w3.^2).*cosd(theta3)
%Mass (kg):
m2 = 0.3;
m3 = 5;
m4 = 0.2;
%Accelerations (m/s^2, rad/s^2):
a2x = -(0.5).*a.*(w2.^2).*cosd(theta2)-(0.5).*a.*alpha2.*sind(theta2);
a2y = -(0.5).*a.*(w2.^2).*sind(theta2)+(0.5).*a.*alpha2.*cosd(theta2);
a3x = -a.*(w2.^2).*cosd(theta2)-a.*alpha2.*sind(theta2)-p.*(w3.^2).*cosd(theta3-180+delta3)-p.*alpha3.*sind(theta3-180+delta3); %Q
a3y = -a.*(w2.^2).*sind(theta2)+a.*alpha2.*cosd(theta2)-p.*(w3.^2).*sind(theta3-180+delta3)+p.*alpha3.*cosd(theta3-180+delta3); %Q
a4x = dddot;
a4y = 0;
g = 9.8; %Q + or -?
%Mass moment of Inertia (kg-m^2):
I2 = 0;
I3 = 15;
%Spring Constant (N/m):
k = 500; %Fs = kd, Q + or - or 0?
dis = d-(-5.2649); % min d = -5.2649
%Position Vectors:
%Link2:
R12x = 0.5.*a.*cosd(theta2+180); %0.5 for CG2 being at the centre of link 2, the rectangular bar link.
R12y = 0.5.*a.*sind(theta2+180);
R32x = 0.5.*a.*cosd(theta2);
R32y = 0.5.*a.*sind(theta2);
%Link3:
R23x = p.*cosd(360+theta3+delta3);
R23y = p.*sind(360+theta3+delta3);
BC = b.*cosd(71.7);
PBx = 1.5;
PBy = BC-py;
thetaBC =180-atand(PBy./PBx)-90;
deltaPB = 90+((71.7-thetaBC) + (-(theta3)));
PB = sqrt((PBy.^2)+(PBx.^2));
R43x = PB.*cosd(270-deltaPB);
R43y = PB.*sind(270-deltaPB);
R3 = sqrt((py.^2)+((1.5).^2));
thetaR3 = 205.609; %x axis to R3 => 205.609 deg.
R3x = R3.*cosd(thetaR3);
R3y = R3.*sind(thetaR3);
%Forces (N):
F3x = 200.*cosd(315);
F3y = 200.*sind(315);
%Force in y direction still exists!
mu = 0; %Smooth surface => zero friction.
%Matrix Form:
A = [1 0 1 0 0 0 0 0;
0 1 0 1 0 0 0 0;
-R12y R12x -R32y R32x 0 0 0 1;
0 0 -1 0 1 0 0 0;
0 0 0 -1 0 1 0 0;
0 0 R23y -R23x -R43y R43x 0 0;
0 0 0 0 -1 0 mu 0;
0 0 0 0 0 -1 1 0];
C = [m2.*a2x + m2.*g;
m2.*a2y;
I2.*alpha2;
m3.*a3x + -F3x + m3.*g;
-F3y + m3.*a3y;
I3.*alpha3 + -R3x.*F3y + R3y.*F3x;
m4.*a4x + k.*dis + m4.*g;
m4.*a4y];
B = inv(A)*C;
F12x = B(1,1);
F12y = B(2,1);
F32x = B(3,1);
F32y = B(4,1);
F43x = B(5,1);
F43y = B(6,1);
F14y = B(7,1);
T12 = B(8,1);
F12 = sqrt((F12x.^2)+(F12y.^2))
F32 = sqrt((F32x.^2)+(F32y.^2))
F43 = sqrt((F43x.^2)+(F43y.^2))
F14 = F14y
T12 = T12
endJason Sunghttps://fr.mathworks.com/matlabcentral/profile/authors/12232883tag:fr.mathworks.com,2005:Question/6251782020-10-24T23:57:44Z2020-10-24T23:57:44ZMatlab fplot not workingI'm new to matlab, and I'm trying to write a function that will compute the value of an option using black scholes and monte carlo. However when I try and graph the output of the what the function returns vs the input (option price vs number of simulation in monte carlo) using this command:
fh = @solv;
fplot(fh,[1 10000])
I get this error:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an
output with the same size and shape as the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function/FunctionLine/updateFunction
In matlab.graphics.function.FunctionLine.set.Function_I
In matlab.graphics.function.FunctionLine.set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 245)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 200)
In fplot>vectorizeFplot (line 200)
In fplot (line 166)
My code is below:
function v = solv(x)
S = 28;
r = .04;
o = .25;
T = .5;
K = 30;
Z = randn(1,x);
val2 = [];
pickmax = [];
val3 = exp(-1.*r.*T);
for i=1:x
% return a value
val = (S.*exp((r-((o.^2)./2)).*T - (o.*sqrt(T).*Z(i)))) - K;
pickmax = [pickmax, val];
pickmax = [pickmax, 0];
% pick between the max of the value or 0
m = max(pickmax);
% empty vector
pickmax = [];
% get option price
val4 = val3.*m;
% insert into an array
val2 = [val2, val4];
end
% the above gives us our Xj as a vector called val2
% now we compute running avg
summer = 0;
for h=1:x
summer = summer + val2(h);
end
runavg = (1./x).*summer;
v = runavg;
endRaymond Pistonettihttps://fr.mathworks.com/matlabcentral/profile/authors/19482485tag:fr.mathworks.com,2005:Question/6251732020-10-24T23:51:10Z2020-10-24T23:51:10ZHow can we refer world coordinate to image coordinates??I know that matlab has imref2d function that refers image coordinates to world coordinates, but I cannot find a function that does the opposite, is there any?
Thanks in advanceSharif Khalilhttps://fr.mathworks.com/matlabcentral/profile/authors/12233857tag:fr.mathworks.com,2005:Question/6221782020-10-22T02:56:25Z2020-10-24T23:46:10ZError: Unrecognized function or variable 'FunExample2'. / Error in Newton Root (line 15)
I am not very familiar with MATLAB, but use it as a tool in my Numerical Methods class. I have taken a C class before so I do have a general idea of how to debug, but I really have no idea with this one.Brennan Mullinshttps://fr.mathworks.com/matlabcentral/profile/authors/14777041tag:fr.mathworks.com,2005:Question/6251682020-10-24T23:31:11Z2020-10-24T23:39:20ZNeed Help New to MATLABI am new to MATLAB and have been assigned to do some problems, here is the one I am stuck on. Firstly I have been given some vectors that I have to find the rectangular form of and secondly I then have to find the magnitude of the two of the vectors. Here is the code I have come up with so far
syms F1 F2
Force = 125;
Theta1 = -90;
Theta2 = 180;
Theta3 = 41.7;
Fwx = Force*cosd(Theta1);
Fwy = Force*sind(Theta1);
F1x = cosd(Theta2)*F1;
F1y = sind(Theta2)*F1;
F2x = cosd(Theta3)*F2;
F2y = sind(Theta3)*F2;
vFw = Fwx+Fwy*j
vF1 = F1x+F1y*j
vF2 = F2x+F2y*j
solve(Fwy+F1y+F2y == 0,F2)
solve(Fwx+F1x+F2x == 0,F1)
It works out in the end almost, however there are a few issues and they most relate to the F2 components. In the vF2 it gives me the correct answer, but in an arbitraily large fraction that though correct I do not believe is satisfactory. In the solve for the F2 the same issue arises, a large fraction that is technically correct. The last thing I am having an issue with is that solve for F1 requires the answer from solve for F2 in order to be solved completely, but once again it appears that it will give me a really large fraction. Any and all help would be great.Corey Kadohttps://fr.mathworks.com/matlabcentral/profile/authors/19880811tag:fr.mathworks.com,2005:Question/6246332020-10-24T09:16:06Z2020-10-24T23:37:05ZAvoid divergent curves of ODE solutionsHi all
I have solved a system of differential equations in an iterative way, as you can see from the graph I have several curves each of which is associated with a different combination of the iterative parameters. Again from the graph, it can be seen that some curves at a certain abscissa diverge; this is not acceptable so I would like to remedy it. Is it possible to create a new solution vector capable of avoiding the divergence as described below ?
I would like the solution not to diverge near the various cusp points and, on the contrary, to maintain the value immediately upstream of the latter, until the end of the domain. I'll explain: suppose we have the following solution values 1000 K,1020 K,2000 K,4000 K I would like instead: 1000 K,1020 K,1020 K,1020 K
Thank you for the help
Regards
T0=293;
delta_Thot=2500;%s
%%%%%%%%%%%%%
Nc_Thot=2;
[ya,sa,lea]=size(Aexposehot);
for y=1:yV%passo,altezza tubo,Rextbobbin,lunghezza cavo
for le=1:leV%lunghezza tubo equilibrio
for sv=1:sV%spessore parete3
% for k=1:km%Mach
for rf=1:length(Pressure_percentage_hot)
Rextbobb_cellhot(y)={Rextbobbin_fluxhot(y)};
Y0hot(y,le)={[T0,m0hot(y,le)]};
Dall_Th_hot ={[0:Nc_Thot:delta_Thot]};
Lequilibrium_cellhot(le)={Lequilibriumhot(le)};
Passo_cellhot(y)={Passo_fluxhot(y)};
hrad_cellhot(y)={Hradial_fluxhot(y)};
Spessore_parete3_cellhot(sv) ={Spessore_parete3hot(sv)};
Aexpose_cellhot(y,sv,le)={Aexposehot(y,sv,le)};
Volume_cell_Aisihot(le,y,sv)={Volume_Aisihot(le,y,sv)};
Volume_cell_gashot(y,le)={Volume_gashot(y,le)};
throat_cell_hot(y)={ThrtR_fluxhot(y)};
Pressure_end_chamber_hot_cell(rf)={Pressure_end_chamber_hot(rf)};
end
end
end
end
for iDom_Th = 1:numel(Dall_Th_hot)
for leLE=1:numel(Lequilibrium_cellhot)
for yY=1:numel(hrad_cellhot)
for rF=1:numel(Pressure_end_chamber_hot_cell)
for sS=1:numel(Spessore_parete3_cellhot)
TSol_hot(iDom_Th,yY,leLE,sS,rF)={zeros(length(Dall_Th_hot{iDom_Th}),2)};
end
end
end
end
end
opt_t_hot=odeset('NormControl','Refine','Stats','MaxStep');
for iDom_Th = 1:numel(Dall_Th_hot)
tRange_hot = Dall_Th_hot{iDom_Th};
for leLE=1:numel(Lequilibrium_cellhot)
for yY=1:numel(hrad_cellhot)
for rF=1:numel(Pressure_end_chamber_hot_cell)
for sS=1:numel(Spessore_parete3_cellhot)
Ltube_hot= Lequilibrium_cellhot{leLE};%L_cellhot{yY};
Leq_hot= Lequilibrium_cellhot{leLE} ;
Vol_Aisi_hot=Volume_cell_Aisihot{leLE,yY,sS};
Aexp_hot=Aexpose_cellhot{yY,sS,leLE};
Hradial_hot=hrad_cellhot{yY};
ThroatradiuS_hot=throat_cell_hot{yY};
Pressure_hot_end_chamber=Pressure_end_chamber_hot_cell{rF};
if Vol_Aisi_hot>0&&Leq_hot>0 &&Aexp_hot>0 &&Ltube_hot>0 && ThroatradiuS_hot>0&&Pressure_hot_end_chamber>0
[tSol{iDom_Th,yY,leLE,sS,rF},TSol_hot{iDom_Th,yY,leLE,sS,rF}]=ode23t(@(t,Y) ...
temperaturaheaterclassica(t,Y,Ltube_hot,Voltage1,Vol_Aisi_hot,Aexp_hot,ThroatradiuS_hot,Pressure_hot_end_chamber),tRange_hot,Y0hot{yY,leLE},opt_t_hot);
if(any(TSol_hot{iDom_Th,yY,leLE,sS,rF}(:,1)>1600))
% disp([ ' condizione verificata'])
%disp (iDom_Th)
disp(yY)
disp(leLE)
%disp(sS)
%disp(rF)
break
end
end
end
end
end
end
end
%end
[tT,yT,leT,sT,rFT]=size(TSol_hot);
for t = 1:tT
for y=1:yT
for le=1:leT
for s=1:sT
for rf=1:rFT
if TSol_hot{t,y,le,s,rf}(end,1)>0
figure(1);set(gcf,'Visible', 'on')
plot(tSol{t,y,le,s,rf}(:,1),TSol_hot{t,y,le,s,rf}(:,1))
xlabel('time [s]')
ylabel('Teq-transition/turbulent [K]')
hold on
end
end
end
end
end
end
EldaEbrithilhttps://fr.mathworks.com/matlabcentral/profile/authors/8447926tag:fr.mathworks.com,2005:Question/6250282020-10-24T18:17:45Z2020-10-24T23:34:10ZClosest Points between two datasets without using pdist2Hi, i have two matrices A, of size mx2, and B, of size nx2.
Each row of both matrices identifies a point in 2D space. What i want to do is to write a code, that does not involve loops and pdist2, as fast as possible, that tells me the indices of the row of both A and B such that the distance squared of the two points is the minimum one.
Example:
A=[5 6;
1 2;
3 4
1 8];
B=[3 0;
2 1;
4 1;
3 5;
1 2];
My function must be like [indA,indB]=function(A_matrix,B_matrix)
I want as output [2,5]=function(A,B)
I found a solution using for-loops but i really would like to find a solution using repmat that involves vectorization.
Thanks
Alberto Belvederehttps://fr.mathworks.com/matlabcentral/profile/authors/8834034tag:fr.mathworks.com,2005:Question/6251632020-10-24T23:26:55Z2020-10-24T23:26:55ZConstruct an array from the position of a certain value in a matrixHello everyone
Let's assume we have a matrix, which I attach, matrix.dat, which has 220x200 elements (https://we.tl/t-KwSPQEsCtf link to download the aformentioned matrix). This matrix would correspond to the definition of two physical quantities, given by
time=horzcat(linspace(0,20,200),linspace(21.1,40,20));
field=linspace(0,50,200);
What I am looking for is that, when there is, for a time element, a value in the matrix that is equal to 1.5708, the value of the first field element is stored in a new array. As you can see, for the first elements of time, there is no matrix value that matches the aforementioned value of 1.5708. So I don't know beforehand what the dimension of my vector will be, ?x1 elements. Is there an efficient way to build the above array?Richard Woodhttps://fr.mathworks.com/matlabcentral/profile/authors/15810187tag:fr.mathworks.com,2005:Question/6250432020-10-24T19:07:18Z2020-10-24T23:23:49ZCompute the measure of error of an interpolationHello guys,
This is my first question here, sorry for anything being done wrong.
I am trying to compute the measure of error between my interpolant and the actual function. I was told to use the norm(gn - f2) function.
for n=3:20
x = linspace(0,1,n); % vector of points to evaluate the function at
alpha = alphas (0,1,n,f2exact); % coefficients
F2 = @(x,alpha) monomialF(x,alpha);
xx = linspace(-1,2,1000); % points to graph
ff = evaluate_test_points(-1,2,1000,F2,alpha); % results
if n<12
nexttile
plot_fun(xx,f2exact,ff);
else
if (flag==0) % when we reach half of the N points
figure (3) % new figure to show the rest of the graphs
flag = 1;
tiledlayout(3,3);
end
nexttile
plot_fun(xx,f2exact,ff);
end
title (n); % title of our graphs
end
I want to produce a figure of norm(gn - f2) against n, but the function norm doesn't take function handles.
f2exact is my exact function:
f2exact = @(x) sin(pi*x);
The points for my interpolant are in ff, and F2 is where every point is evaluated with the coefficients found alpha. The function of F2, monomialF just takes one point and evaluates it in the polinomial with the coefficients of alpha.
The function evaluate_test_points evaluate the points on F2 and save them in ff.
Hopefully this is enough for people to help me.
Do I have to evaluate norm(ff(x)-f2exact(x)) for every test point, add them up, and then save it to another array to plot against n? Or is there a way to do use the function directly with my function handles and my points?
Thanks for any help here.Dussan Radonichhttps://fr.mathworks.com/matlabcentral/profile/authors/19669589tag:fr.mathworks.com,2005:Question/6251232020-10-24T21:50:01Z2020-10-24T23:14:32ZMatlab returns empty symbol when solving laplace transformI have a laplace equation defined in matlab that I believe to be correct. It is defined as eqnLT
% R1, R2, C1, C2 are positive symbols
% i(t) is a symbolic function
% i(0) is set to be 0
eqn(t) =
0 == R1*i(t) + R2*i(t) + diff(i(t), t)/10 + int(i(t), t)/C1 + int(i(t), t)/C2
eqnLT = laplace(eqn, t, s) =
0 == (s*laplace(i(t), t, s))/10 - i(0)/10 + laplace(int(i(t), t), t, s)/C1 + laplace(int(i(t), t), t, s)/C2 + R1*laplace(i(t), t, s) + R2*laplace(i(t), t, s)
I want to solve for `laplace(i(t), t, s)` let it be called `I(s)`. Following the instructions I can find in the matlab documentation, I do the following:
subs(eqnLT, laplace(i(t),t,s),I(s)));
solve(eqnLT, I(s))
The answer I get is empty sym. I am not sure what I am doing wrong.Richard Bairdhttps://fr.mathworks.com/matlabcentral/profile/authors/19598547tag:fr.mathworks.com,2005:Question/6251582020-10-24T23:11:22Z2020-10-24T23:11:22ZRequesting help for piecewise plotingclc
clear
syms r I % I = current, r = radius
a = 2;
b = 5;
c = 7;
B = piecewise(r<=0 & r>=a,((r/a)^2)*I, r>=a & r<=b, I, r>=b & r<=c, (c^2-r^2)/(c^2-b^2), r>c, 0);
fplot(B)
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
grid on
title('\color[rgb]{0,0.5,0.5} Magentic Flux Density Magnitude')
xlabel('\sl \color[rgb]{0,0.5,0.5} r Radial Distance (cm)')
ylabel('\sl \color[rgb]{0,0.5,0.5} H Magnetic field magnitude (A/cm)')
Above is a what I would like to plot, but I recieve errors plotting. Below are my errors, I would like some guidance on how to correct my errors.
piecewise(2 <= r & r <= 5, I, 5 <= r & r <= 7, sym(49/24) - r^2/24, 7 < r, 0)
Error using fplot>singleFplot (line 240)
Input must be a function or functions of a single variable.
Error in fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 200)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);
Error in fplot>vectorizeFplot (line 200)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);
Error in fplot (line 166)
hObj = vectorizeFplot(cax,fn,limits,extraOpts,args);
Thanks in advance!Jonathan Hawkinshttps://fr.mathworks.com/matlabcentral/profile/authors/12411869tag:fr.mathworks.com,2005:Question/6251432020-10-24T22:50:44Z2020-10-24T22:59:56ZPloting an anonymous functionI an trying to plot this graph :
M_a = mb*g*2 - Cw*rIntegral*y_bar
Cw = 0.5*rho*(v^2)*(1/yr^0.286)*(rb+rt)*(h/2)*0.2 % Wind force constant;
c1 = ((rt-rb)/h)^2;
c2 = ((rt-rb)/h)*rb;
c3 = rb^2;
y = linspace(0,h);
M1 = (y) M_a + 2*Cw((c1/4.286)*(y.^(4.286)) + (2*c2/3.286)*(y.^(3.286)) + (c3/2.286)*(y.^(2.286))) - F_ax*y;
plot(y,M1(y))
and it gives me this error:
"Array indices must be positive integers or logical values. Error in MatLab_2020 (line 36)
M1 = @ (y) + 2*Cw((c1/4.286).*(y.^(4.286)) + (2*c2/3.286).*(y.^(3.286)) + (c3/2.286).*(y.^(2.286))) - F_ax.*y;"Mulanga Forgiveness Mulangahttps://fr.mathworks.com/matlabcentral/profile/authors/19048733tag:fr.mathworks.com,2005:Question/6251532020-10-24T22:59:25Z2020-10-24T22:59:25ZWarning: Initializing MATLAB Graphics failed.Warning: Initializing MATLAB Graphics failed.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as
possible. Error detected was:
MATLAB:hg:InvalidProperty
There is no screenpixelsperinch property on the Root class.
> In hgrc (line 163)
In initprefs (line 11)
In matlabrc (line 94)
How can I modify the screenpixelsperinch proptery on the Root class in ubuntu to recover this error? Some properties are missed and the functions above can't work properly because of that missing properties.
https://www.mathworks.com/help/matlab/ref/matlab.ui.root-properties.html#buc8_0n-ScreenPixelsPerInch
As I understood from the above link, after R2015b versions, we should adjust the values. But I don't know where are the required files or which commands will be executed. Could you please help me?
Musa KUCUKALIhttps://fr.mathworks.com/matlabcentral/profile/authors/20101230tag:fr.mathworks.com,2005:Question/6251482020-10-24T22:55:22Z2020-10-24T22:55:22ZHow to restart a function if it takes too long to run?Hello! I created a time stepping function to solve differential dynamic equations. Within this function I have a while loop that aims to refine the solution for each time step.
I've noticed that for very small timesteps, the function stops progressing and gets stuck. I'd like to make it so that if this happens, then the function gets reset with a new (larger) timestep. All of this would occur automatically and I was thinking about it being based on runtime.
Thank you!Diogo Carvalhohttps://fr.mathworks.com/matlabcentral/profile/authors/14730031tag:fr.mathworks.com,2005:Question/6251382020-10-24T22:45:26Z2020-10-24T22:45:26ZAudiowrite on a cellHi, I a folder (wavOrig) that has 7 subfolders with each 10 audio wav.files, and also a txt list with the 70 wav files. My program is supposed to :
Read the txt file [DONE]
Load the 70 files in a loop [DONE]
Apply a filter on them [DONE]
Save each filtered files in a different folder : wavFilt , while keeping the same audio names [HELP]
The function audiowrite only works with one file, I do not know how to get it to work with a list of files, and how to save the files to the other folder. Basically, I have an outpout cell o (70 x 1 ) that contains the 70 samples of the audio files. I don't know where to go from there. So this is my code :
%scanning text file
file_id=fopen("listData.txt","rt");
txt_A=textscan(file_id,'%s');
fclose(file_id);
p=txt_A{1,1}; %store textfile data into cell array
for i=1:length(p)
if length(p{i,1})>2
r(i)=[string(p{i,1})+".wav"];
q{i,1}=r(i);
else
break;
end
end
for i=1:length(q)
[x{i,1}, Fs]=audioread(q{i,1}); %stores the samples into a cell x ( 70 x 1 )
nSamples = length(x{i,1});
firCoef = [-0.1, 0.3, 0.5, 0.5, 0.5, 0.3, -0.1]; %the filter is defined by this impulse response
nCoef = length(firCoef);
x{i,1} = [zeros(nCoef,1); x{i,1} ; zeros(nCoef,1)];
nSamplesnew = length(x{i,1});
o{i,1} = zeros(nSamplesnew,1);
for j = 1+nCoef:nSamples+nCoef
o{i,1}(j) = firCoef(1)*x{i,1}(j)+firCoef(2)*x{i,1}(j-1)...
+firCoef(3)*x{i,1}(j-2)+firCoef(4)*x{i,1}(j-3)+firCoef(5)*x{i,1}(j-4)...
+firCoef(6)*x{i,1}(j-5)+firCoef(7)*x{i,1}(j-6);
end
end
Melissa Ettehttps://fr.mathworks.com/matlabcentral/profile/authors/19783382tag:fr.mathworks.com,2005:Question/6248882020-10-24T15:36:46Z2020-10-24T22:37:31ZHow to Plot a Fourier Series?Hi,
I was given a half range expansion function f(x) = 0, 0<x<2 and f(x) = 1, <2<x<4.
I was asked to solve for the Fourier cosine series and Fourier sine series and then plot each.
I solved by hand:
Fourier Cosine Series:
a0 = 1/2
an = -2/(n*pi)*sin((n*pi)/2)
f(x) = 1/2 + sum(an*cos((n*pi*x)/4)) from n =1 to infinity
Fourier Sine Series:
bn = [2/(n*pi)]*[(-1)^(n+1) + cos((n*pi)/2)]
f(x) = sum(bn*sin((n*pi*x)/4))
I'm fairly new to Matlab and very unexperienced, where I'm having dificulty is plotting these functions against x, say x = [-24 24] and n=1:1:50 or until square waves appear. I gained some experience plotting their partial sums using fplot, but that approach does not appear to work here. It isn't feasible to plot the 50th partial sum. I've seen more arrayfun usage online, but I do not understand it whatsoever.
Any help and explanation would be greatly appreciated. Thanks in advance.
Alexander McGlonehttps://fr.mathworks.com/matlabcentral/profile/authors/5353628tag:fr.mathworks.com,2005:Question/285402012-02-09T11:39:11Z2020-10-24T22:30:54ZMetthew Correlation Coeffecient Hi All
I would like to calculate Metthew correlation coeffecient for four class of data for example
N1=25,36,98,78,98,53....n,
N2=45,12,25,36,17,45....n,
N3=12,13,24,25,51,62....n and
N4=13,15,61,17,81,28....n
any one could you kind enough to provide information or code to calculate Metthew correlation coeffecient by using MATLAB code.
thank you very much in advance for your help and assistance.Malde Goraniahttps://fr.mathworks.com/matlabcentral/profile/authors/3315701tag:fr.mathworks.com,2005:Question/6249382020-10-24T16:53:33Z2020-10-24T22:26:47ZMEX api and interleaved complex arraysDoes MATLAB store complex data in interleaved format since R2018a?
If you compile a MEX function with the -R2018a flag, you can process complex arrays in interleaved format. But what happens, if a MEX function is compiled with the -R2017b flag and called from a modern Matlab version? Does accessing mxGetPr / mxGetPi cause a deep data copy to create the two arrays in separate memory blocks, and another copy to re-create an interleaved array for the output?
This would mean, that MEX fumnctions processing complex data are very inefficient, when they use the -R2017b flag. Is this correct?Janhttps://fr.mathworks.com/matlabcentral/profile/authors/869888tag:fr.mathworks.com,2005:Question/6251282020-10-24T22:10:14Z2020-10-24T22:22:38Zplot a 3D function with changing variablesHi there! I'm trying real hard to plot the 3D yield function for the strain energy density failure criterion:
f = v^2 - y^2
Where y takes on the value 300
Where v takes on the values (0, 0.1, 0.3, 0.5)
Not sure which syntax to use in the plot3 tab even. Thanks for any help offered.Maddy Khttps://fr.mathworks.com/matlabcentral/profile/authors/16323246tag:fr.mathworks.com,2005:Question/6233082020-10-22T23:13:17Z2020-10-24T21:49:16ZFinding an analytical fit for a multi-dimensional functionI have numerical data in a MATLAB multi-dimensional array f(a,b,c,d) which I would like to fit into an analytical function with 4 arguments: f(a,b,c,d).
For a one-dimensional funcion I am fairly comfortable: I could for example choose a Taylor series and use polyfit (just solve a fitting problem via Least Squares).
However, for such a high dimensional problem I am lacking the intuition how to best do this. Let's for simplicity start with just two parameters and keep a=b=const. This is how f looks like:
Pick one of those curves (=also fix d). How would you pick which function to fit with? (note the log-log plot!). Would you pick just a Taylor series with logf and logc? Or do these curves look like there would be a more natural option?
Now suppose I would fit f(a,b,c,d) with a=b=d=const. How would you proceed fitting a variable d?
I hope that I could tackle variable a and b in the same way as (2)
Note that the dimension of f is different, for example:
>> size(f)
ans =
10 7 42 10
PS: I found https://www.mathworks.com/matlabcentral/fileexchange/34765-polyfitn ... however, the independent variables have to be the same and the dependent variable (f in my case) has to be 1 x n. But for my case, it is a multidemensional array.Daniel Hhttps://fr.mathworks.com/matlabcentral/profile/authors/1612115tag:fr.mathworks.com,2005:Question/6251182020-10-24T21:47:59Z2020-10-24T21:47:59Zwhat is the code for bin histogram of fraction to the binPooja Jangrahttps://fr.mathworks.com/matlabcentral/profile/authors/19623759tag:fr.mathworks.com,2005:Question/6251132020-10-24T21:42:36Z2020-10-24T21:42:36ZPermutations and Combinations of Solution sets Hello Everyone (and anyone haha)!!
I'm solving a problem for class, in which the equation is:
= 1
****J1-J5 are different variables, they're not being multiplied.
My teacher told us to essentially create an excel sheet, and keep guessing the inputs until our outputs equal 1, but I feel like there has to be a way to design a program/code block that can provide sets of working permutations and combinations of correct solution sets, rather than continuously guessing.
Any suggestions? Thanks!!Jose Vazquezhttps://fr.mathworks.com/matlabcentral/profile/authors/13285626tag:fr.mathworks.com,2005:Question/6247932020-10-24T13:38:34Z2020-10-24T21:34:22ZHow to write a machine learning algorithm or modifying a machine learning algorithm in matlab?Hello expert of matlab and precisely in machine learning algorithm. I am new in machine learning and recently i m planning to create any kind of machine learning algorithm or modifying the existing machine learning algorithm for better classification and accuracy. But i do not know how to start and where. If any volunteer may guid with a link or any kind of suggestion which will help me to start. Thank you for your answer, i will be very grateful Camille Dingamhttps://fr.mathworks.com/matlabcentral/profile/authors/16232717tag:fr.mathworks.com,2005:Question/6251082020-10-24T21:34:20Z2020-10-24T21:34:20Zsaving workspace of each pair of variable in a loopHello,
I help. I have a loop where I take each pair of variables and run. However, I want to save the workspace of each pair after each iterations. see example below:
iteration=10
for ii = 1 : length(X)
for jj = 1 : length(Y)
display(['ii is ', num2str(ii), ' and jj is ', num2str(jj)])
%%% Function Call
end
let say X= 1 2 3
y = 5 6 7
I want to save the workspace for each pair. For instance, to save ii=1 and jj=5, e.t.cSamsonhttps://fr.mathworks.com/matlabcentral/profile/authors/14635796tag:fr.mathworks.com,2005:Question/6251032020-10-24T21:29:52Z2020-10-24T21:29:52ZProblem in creating a new local Git repositoryHello,
I've just discovered that Matlab 2020b implements a built-in git integration. I tried to create a new repository without success.
As far as I know, when you use the command git init in "A" folder, git will create an hidden .git folder in "A" where all snapshots are stored. So, I opened my project folder in Matlab, right clicked in current empty folder and then clicked on source control -> manage files. When the dialog box opens, I selected:
"A\.git" as Repository path
"A" as Sandbox
But I received this errore message: "Destination path "A" already exists and is not an empty directory".
I also tried others configurations:
"A" as Repository path
"A" as Sandbox
I'm able to finish the procedure if and only if I choose two not related folders, ie. "B" and "A". In this case, however, I'll find git files both in "B" and in "A\.git" folder which is automatically created.
How could obtain the typical git behaviour?
ThanksRoberto Dimahttps://fr.mathworks.com/matlabcentral/profile/authors/14206700tag:fr.mathworks.com,2005:Question/6244032020-10-23T23:25:55Z2020-10-24T21:26:55ZHow to plot an implicit and dicontinues function?
Hello, I want to ask how to plot the level curves of this function. I have tried with fimplicit and with fcontour but I can't plot it because of its discontinuities. If anyone knows it will be very helpful because it is for my composite structures course.
function [z] = THb(x1,x2)
E1 = 100*10^3;E2 = 7*10^3;nu12=.3;F1t=1000;F2t=45;F1c=600;F2c=150;F6=65;
if x1>=0
A=1/F1t^2;
C=-(1/F1t^2);
else
A=1/F1c^2;
C=-(1/F1c^2);
end
if x2>=0
B=1/F2t^2;
else
B=1/F2c^2;
end
z=A*x1.^2 + B*x2.^2 +C*x1.*x2;
end
Francisco Patitucci Perezhttps://fr.mathworks.com/matlabcentral/profile/authors/14225700tag:fr.mathworks.com,2005:Question/6250982020-10-24T21:19:36Z2020-10-24T21:19:36Ztable2timetable adding time vector with start- and end dateFrom the recording software I"m using, I can export my data only using minutes from a reference point but I would like to convert my data to a timetable.
I know the start date and time and end date and time and tried to create a timetable based on that information:
newTimes = [datetime('2018-07-04 21:40:42'):datetime('2018-07-17 10:02:10')];
TT = table2timetable(tblB,'rowTime',newTimes)
The data was recorded in between this time range in a approx. 5 ms interval resutling in approx. 220000000 data points. Can I interpolate all the datetime/ from start and end time somehow assuming that the data was recorded regularly?Newbiehttps://fr.mathworks.com/matlabcentral/profile/authors/20037566tag:fr.mathworks.com,2005:Question/6250932020-10-24T21:10:52Z2020-10-24T21:10:52ZError using matlab.internal.webservices.HTTPConnector/copyContentToByteArray (line 396) The server returned the status 429 with message "Too Many Requests" in response to the request to URL.I am writing a script that will take my protein sequence of interest and find matches to it using NCBI blast. I identify the hits and then try and get the sequence for each (in code this is 'j=1:.....'). This works fine, but when I get to number 1226, I get the error below. I have tried a couple of things:
Pausing longer between iterations of my loop did not help
Manually doing this particular one in the command window returned the same error, though if I go to the NCBI website and find the protein, there's no problem.
Any advice would be greatly appreciated!!
THE ERROR:
Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray
(line 396)
The server returned the status 429 with message "Too Many Requests" in response
to the request to URL
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=nucest&term=NXO81641%5BAccession%5D.
Error in readContentFromWebService (line 46)
byteArray = copyContentToByteArray(connection);
Error in webread (line 125)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
Error in getncbidata>accession2gi (line 316)
searchXML = webread(searchurl);
Error in getncbidata (line 182)
[giID,db] = accession2gi(accessnum,db,'quick');
Error in getgenpept (line 64)
[varargout{1:nargout}] =
getncbidata(accessnum,'database','protein','fileformat','GenPept',varargin{:});
75 rethrow(e)
MY CODE:
%% Get a list of everything that aligns with TPC2 (and must be listed as TPC2)
POI = 'MAEPQAESEPLLGGARGGGGDWPAGLTTYRSIQVGPGAAARWDLCIDQAVVFIEDAIQYRSINHRVDASSMWLYRRYYSNVCQRTLSFTIFLILFLAFIETPSSLTSTADVRYRAAPWEPPCGLTESVEVLCLLVFAADLSVKGYLFGWAHFQKNLWLLGYLVVLVVSLVDWTVSLSLVCHEPLRIRRLLRPFFLLQNSSMMKKTLKCIRWSLPEMASVGLLLAIHLCLFTMFGMLLFAGGKQDDGQDRERLTYFQNLPESLTSLLVLLTTANNPDVMIPAYSKNRAYAIFFIVFTVIGSLFLMNLLTAIIYSQFRGYLMKSLQTSLFRRRLGTRAAFEVLSSMVGEGGAFPQAVGVKPQNLLQVLQKVQLDSSHKQAMMEKVRSYGSVLLSAEEFQKLFNELDRSVVKEHPPRPEYQSPFLQSAQFLFGHYYFDYLGNLIALANLVSICVFLVLDADVLPAERDDFILGILNCVFIVYYLLEMLLKVFALGLRGYLSYPSNVFDGLLTVVLLVLEISTLAVYRLPHPGWRPEMVGLLSLWDMTRMLNMLIVFRFLRIIPSMKLMAVVASTVLGLVQNMRAFGGILVVVYYVFAIIGINLFRGVIVALPGNSSLAPANGSAPCGSFEQLEYWANNFDDFAAALVTLWNLMVVNNWQVFLDAYRRYSGPWSKIYFVLWWLVSSVIWVNLFLALILENFLHKWDPRSHLQPLAGTPEATYQMTVELLFRDILEEPGEDELTERLSQHPHLWLCR'
%Blast the inputted sequence against NCBI protein. Return 5000 results.
[blastsend, waittime]=blastncbi(POI, 'blastp', 'MaxNumberSequences', 5000);
%Get a copy of the blast report.
tm = string(datetime('now'));
blastresultsfile=string('blastresults'+tm+'.xml');
getblast(blastsend, 'Wait', waittime, 'ToFile', blastresultsfile);
%%
%Read in the blast results.
BlastFile=blastread('blastresults.xml');
BlastFileTb=struct2table(BlastFile.Hits);
IdentityFile=strings(1);
%Get the Identity value!
for b=1:height(BlastFileTb)
IdentityFile(1,b)=((BlastFile.Hits(b).Hsps(1).Identities)/752)*100;
end
IdentityFile=IdentityFile';
%Identify the different elements of the blast report.
Definition=table(BlastFileTb.Definition);
Definition.Properties.VariableNames={'Definition'};
ID=table(BlastFileTb.ID);
ID.Properties.VariableNames={'ID'};
Accession=table(BlastFileTb.Accession);
Accession.Properties.VariableNames={'Accession'};
Identity=table(IdentityFile);
Identity.Properties.VariableNames={'Identity'};
ExtractedBlast=[ID, Definition, Accession, Identity];
%%
TPC2_list1=ExtractedBlast(contains(ExtractedBlast.Definition, 'protein 2'),:);
TPC2_list2=ExtractedBlast(contains(ExtractedBlast.Definition, 'TPC2'),:);
TPC2_totallist=[TPC2_list1;TPC2_list2];
specieslist=strings(1);
seqlist=strings(1);
%%
% Now we have a list of all the TPC2 on ncbi. I want to identify a) all the
% the speices wirth it and b) also be ab;e to check box the species I want
% to focus on.
for i=1:height(TPC2_totallist)
%Take the description of the target
thisentry=string(table2array(TPC2_totallist(i,2)));
%Find the name of the species by looking between square brackets
findingspecies=split(thisentry, '[');
findingspecies2=findingspecies(contains(findingspecies, ']'));
findingspecies3= split(findingspecies2(1), ']') ;
speciesname=findingspecies3(1);
%Make a list of all the species
specieslist(i,1)=speciesname;
%Remove any repeats from the species list.
unique_specieslist=unique(specieslist);
end
%
%%
%Add the species list to the table we've been working from
TPC2_amendedlist=[TPC2_totallist, array2table(specieslist)];
%%
%% **THIS IS WHERE I HAVE THE PROBLEM, WITH NUMBER 1226
for j=1:height(TPC2_amendedlist)
%For each entry, get the accession number
accno=string(table2array(TPC2_amendedlist(j,3)));
%Use the accession number to get the FASTA online. Put it in a list for
%now ('seqlist')
seq=getgenpept(accno, 'SequenceOnly', true) ;
seqlist(1,j)=seq;
%This step needs a pause ( 1 sec) because the server will ping too often if not
%and reject the request. An extra pause on every tenth iteration. 'j' indicates what iteration we're on.
j
pause(.5);
% if mod(j, 10)==0
% pause(10);
% end
endRebecca Joneshttps://fr.mathworks.com/matlabcentral/profile/authors/8913720tag:fr.mathworks.com,2005:Question/6250882020-10-24T21:08:42Z2020-10-24T21:08:42ZHow can i unnormalize the forecasted system load outputs in Neural Networks in Matlab I normalised and unnormalised training and test data as mentioned below and hwo can i unnormalise the forecased output to the scale of test data ?
% normalising training and test data
[pn,ps] = mapminmax(input_train);
[tn,ts] = mapminmax(target_train);
[pn1,ps1] = mapminmax(input_test);
[tn1,ts1] = mapminmax(target_test);
forecastedoutput=net(pn1);
an = sim(net,pn);
a = mapminmax('reverse',an,ts);NNhttps://fr.mathworks.com/matlabcentral/profile/authors/15064601tag:fr.mathworks.com,2005:Question/809802013-07-03T10:08:26Z2020-10-24T20:58:17Zwhat does the four vector mean in matlab legend 'Position'?I use the line:
leg = legend('Ionisation','Recombination');
pos = get(leg,'Position')
But get returned the answer:
pos =0.638988095238095,0.209126984126984, O.257142857142857,0.1
Can I ask what this means because this not the positions on the axes because when you look by eye it seems incorrect...
All I want to do is find the location (on the axes of the graph) of the bottom left corner so I can add another text box below with a string in it...
Thanks in advance
MAMartinhttps://fr.mathworks.com/matlabcentral/profile/authors/3736072tag:fr.mathworks.com,2005:Question/6169382020-10-17T13:39:42Z2020-10-24T20:51:06ZHow to deal with a single tsv-file whose size is out of the memory?Hi, guys.
I have a tsv file whose size is 20GB while my pc's memory is only 16GB.
When I read the file, it always shows errors.
I tried tall array as follows but fails due to tsv file cannot be recognized.
So I am looking for advice.
ds = tabularTextDatastore('D:\database1\scipatlinkage\paperauthoridaffiliationname.tsv');
ds.TreatAsMissing = 'NA';
ds.SelectedVariableNames = {'paperid','authorid','affiliationame'};
ds.SelectedFormats(2:3) = {'%s','%s'};
pre = preview(ds)
My matlab is R2020aziyou tenghttps://fr.mathworks.com/matlabcentral/profile/authors/20002681tag:fr.mathworks.com,2005:Question/6232382020-10-22T21:35:32Z2020-10-24T20:43:33ZPoisson Boltzmann eq. with an infinite boundary conditionHi everybody!
I've written a code that solves the following PB problem
This is a 2nd order ode and the dependant variable here is psi (tilde) and the independant variable is x (tilde). The boundary conditions are:
The code includes an optimizer based on the secant method. I'm trying to guess the solution that will ''land'' on the 2nd boundary condition via the shooting method:
function [x2,p2]=optimumup(y21,y22,bc2,l)
%optimizing the choice of y2 for the shooting method, using the Newton
%method (secant) by solving the equation p(length(p(:,1))-bc2=0
[x1,p1] = BP(y21,l);
[x2,p2] = BP(y22,l)
size(p2)
for i=1:10
dp=((p2(length(p2(:,1)),1)-bc2)-(p1(length(p1(:,1)),1)-bc2))/(y22-y21);
y23=y22-(p2(length(p2(:,1)),1)-bc2)/dp;%recurrence relation
p1=p2;
[x2,p2] = BP(y23,l);
if abs(p2(length(p2(:,1)))-bc2)<0.001;
disp(p2(length(p2(:,1)),1));
disp(p2(length(p2(:,1)),1)-bc2);
plot(x2,p2(:,1),x2,p2(:,2))
return
end
y21=p1(1,2);
y22=p2(1,2);
end
disp('No success')
end
function [x,p] = BP(y2,l)
%Shooting method for the BP eq
options = odeset('RelTol',1e-4,'AbsTol',1e-4);
[x,p] = ode45(@eqs,[0 l],[90/24 y2],options);
%n=size(p);p(n(1),1)
%plot(x,p(:,1),x,p(:,2))
end
function [dy] = eqs(x,y)
%PB equation
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = sinh(y(1));
end
y21 and y22 are the initial x guesses for the secant method. bc2 is the boundary condition at x goes to inifinity. l is the interval size.
I have two main problems:
I don't know how to incorperate the inifinite boundary condition.
For some reason my solution does not converge. I'm working dimensionless.
I would appreciate some help guys.
Thanks,
RoiRoi Bar-Onhttps://fr.mathworks.com/matlabcentral/profile/authors/16405929tag:fr.mathworks.com,2005:Question/6250682020-10-24T19:58:50Z2020-10-24T20:37:24ZNeed the function or Equation that solve this kind of questions?Dodohttps://fr.mathworks.com/matlabcentral/profile/authors/19740964tag:fr.mathworks.com,2005:Question/6250832020-10-24T20:36:49Z2020-10-24T20:36:49ZHow could I obtain the step response of a closed loop space state system with an integrator?Hi, I'm having trouble gasping how can I represent a closed loop space state MIMO system with the the ss(A,B,C,D) function. I know that if I want to represent a closed loop i should replace A for A-B*K, but the thing is, i had to use an integrator since the step rsponse had constant error at steady state. Here is what I have:
A=[...]; %4x4
B=[...]; %4x3
C=[...]; %2x4
D=[0 0 0 ;0 0 0 ];
Ahat=[A zeros(4,2);-C zeros(2,2)]; %these new matrixes are for the system with a integrator
Bhat=[B;zeros(2,3)];
Chat=[C zeros(2,2)];
(...)
I got the controller gain using lrq, K1 is for the system with the integrator, I then decomposed it in the controller gain, and the integrator gain:
Ki=K1(1:3,5:6);
K2=K1(1:3,1:4);
sys=ss(A-B*K, B, C, D);
sysc=ss(Ahat - Bhat*K2, Bhat*Ki, Chat, 0);
step(sys, sysc)
I want to know if using B*Ki really makes sense. I'll attach the images of the step response (blue without integrator, red with it):
Also, here is an explanation of the Ahat, Bhat and Chat in case it is not clear:
Thanks in advance, sorry if I made things confusing.
pietro camilohttps://fr.mathworks.com/matlabcentral/profile/authors/12796213tag:fr.mathworks.com,2005:Question/6246282020-10-24T09:09:30Z2020-10-24T20:22:51ZWhy won't all my data show up in the produced image and only some of the data? Hello,
I have a problem with my matlab-script. As you can see in the picture i have attached (marked in red), there are for some reason areas in the image where the data aint registered compared to the other places where data are present in the image. The data are from same note file. I dont know why it happens. Dont know if its me that have made a error in the script or wrong placement of data in my files (also attached in here). Hope you guys can help.
have also attached my matlab script (the green colors are just notes for the script in danish)
A bonus help, only if you guys know. How can i place a z-axis size-bar like i have done for the colorbar. Have data that shows the diameter of each tree and of course their x- and y-axis coordinate locations. I can only make them big and small compared to the data but i cant show it as i have with the colorbar. Lukas Samuelsenhttps://fr.mathworks.com/matlabcentral/profile/authors/10175263tag:fr.mathworks.com,2005:Question/6250782020-10-24T20:14:30Z2020-10-24T20:20:40Zсколько различных компьютеров можно активировать одновременно? могу ли установить одновременно на пк и ноутбук?сколько различных компьютеров можно активировать одновременно,если лицензию матлаб получил при помощи университетской почты?
How many different computers can be activated at the same time if the Matlab license was obtained through the university mail? Can I install on a pc and laptop at the same time?Pavel Kuzmitskyhttps://fr.mathworks.com/matlabcentral/profile/authors/16375303tag:fr.mathworks.com,2005:Question/3333412017-04-03T11:16:38Z2020-10-24T20:16:08ZHow to calcualte psnr of images of two different size?I am having one image 0f 500 * 500 size. I have resized it to 250 * 250. How to calculate psnr between two images?anuhttps://fr.mathworks.com/matlabcentral/profile/authors/8445883tag:fr.mathworks.com,2005:Question/6250532020-10-24T19:37:07Z2020-10-24T20:14:35ZHow to solve 3 functions in 4 variablesTan = 2 - c - a
Man = b + c - 1
Lan = a - 3*b - c + d - 1
The answer
a=d
b=d-1
c= 2-dMohamed Mahmoudhttps://fr.mathworks.com/matlabcentral/profile/authors/15248157tag:fr.mathworks.com,2005:Question/6195232020-10-20T02:32:18Z2020-10-24T20:13:07ZError Using convertToGUIDECallbackArguments(app, event)Hi everyone,
I've been working on migrating GUIs from GUIDE to App Designer with the Migration Tool. Recently, I migrated a very complex GUI that calls multiple GUIs at the same. However, this is not the problem. The real problem is that when I use the MATLAB function convertToGUIDECallbackArguments as below I get an error:
Reference to non-existent field 'Source'.
Error in CVCRCI_App/WaveformName_Callback (line 3591)
[hObject, eventdata, handles] =
convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
function WaveformName_Callback(app, event)
% Create GUIDE-style callback args - Added by Migration Tool
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
%If it is changed, then resets values, otherwise it just updates
POS=get(handles.WaveformPV,'value');
WID=get(handles.WaveformName,'value');
...
end
It seems like the variable event that's being passed into convertToGUIDECallbackArguments(app, event); %#ok<ASGLU> does not have a field called "Source".
So, my question is: how can I circumnavigate this problem? Should I define a global property for event?
Sebastian Bustillohttps://fr.mathworks.com/matlabcentral/profile/authors/18947810tag:fr.mathworks.com,2005:Question/6242632020-10-23T19:53:55Z2020-10-24T20:07:05ZSum sound signals with different sizeHello,
I want to produce a sound from a sound_signal, but I don't know how to create the sound signal.
I have a cell sequence like that as input
{'0'} {'111'} {'0'} {'111'} {'0'} {'0'} {'0'} {'1'} {'0'} {'111'} {'0'}
Now my code looks like this:
dot_duration = 0.1
sampling_freq = 1000
tone_freq = 700
t_dot=0:1/sampling_freq:dot_duration;
t_dash=0:1/sampling_freq:3*dot_duration;
t_code_space=0:1/sampling_freq:dot_duration;
y_dot=cos(2*pi*tone_freq*t_dot);
y_dash=cos(2*pi*tone_freq*t_dash);
y_code_space=0*t_code_space;
input = reshape(pulse_sequential, 1, 1, length(input));
%with the reshape I avoid the use of loops
soundsignal1 = ismember(input(:), '1')*y_dot;
soundsignal2 = ismember(input(:), '111')*y_dash;
soundsignal3 = ismember(input(:), '0')*y_code_space;
soundsignal = soundsignal1+soundsignal2+soundsignal3
My problem is in the sum of the soundsignal1, soundsignal2 and soundsignal3, but obviously I can not add those elements because the Matrix dimensions do not agree.
I don't know how to solve this error, I understand it, (y_dot, y_dash and y_code_space have different size).
If you could help me I would grateful
Raquel Lucena Perishttps://fr.mathworks.com/matlabcentral/profile/authors/19496941tag:fr.mathworks.com,2005:Question/6250632020-10-24T19:42:04Z2020-10-24T20:02:50ZHow to divide 8 bit binary into two 4 bit?For example A=11001111,
i want to break it as A1=1100 and A2=1111.
How it can be done in matlab?sami ullahhttps://fr.mathworks.com/matlabcentral/profile/authors/14103506tag:fr.mathworks.com,2005:Question/6247832020-10-24T12:59:52Z2020-10-24T19:58:31Zchar to double data typeHow do I convert the following
164x11 char=
'03-Jan-2018'
'07-Jan-2018'
'07-Jan-2018'..
to 164x11 double=
'03-Jan-2018'
'07-Jan-2018'
'07-Jan-2018'
I want the elements to remain the same and just change the data typeWaqas Siddiquehttps://fr.mathworks.com/matlabcentral/profile/authors/19812601tag:fr.mathworks.com,2005:Question/6228682020-10-22T15:20:26Z2020-10-24T19:56:04ZIf statement is not correctly operatingDear Matlab experts,
I have a simple if statement to execute, however is not responding how I am expecting in a relaxation function. In the attached matlab code, I want my code to respond in two steps:
Firstly, initialize some internal variables to ZEROS during first elements of X-data vector, i.e., lambda(1,1) and lambda(1,2): The value of these variables remains ZEROS until a subsequent if statement is fulfilled.
for r = 1
if (lambda(r,1) == lambda(1,1)) && (lambda(r,2) == lambda(1,2))
Dmat = 0.0;
Dmat_ant = 0.0;
Thetam = 0.0;
Thetam_ant = 0.0;
end
end
2. Secondly, I need to compute a function value PK2 which is dependent on an internal variable Dmat = [0, 1] and is calculated fulfilling a if statement:
if Taum_t < Taum_max
PK2(:,1) = PK2_peak1;
PK2(:,2) = PK2_peak2;
PK2(:,3) = PK2_peak3;
else
Taum_max = Taum_t;
Amat = (gdm./S0dm.^2 - 0.5).^(-1);
Dmat = 1 - (S0dm./Taum_t).* exp(Amat.*(1 - (Taum_t./S0dm)));
delDmat = Dmat - Dmat_ant;
Thetam = Thetam_ant + WbarISO.* delDmat;
Dmat_ant = Dmat;
Thetam_ant = Thetam;
PK2(:,1) = (1 - Dmat).*PK2_peak1;
PK2(:,2) = (1 - Dmat).*PK2_peak2;
PK2(:,3) = (1 - Dmat).*PK2_peak3;
end
It means, Dmat is calculated only when Taum_t >= Taum_max, for other cases, Dmat = 0. It applies the same for Dmat_ant, Thetam and Thetam_ant.
Running the existing matlab code gives a continusouly increasing PK2 value which does not fit to the Y-data. In addition, commenting the if statement
%if Taum_t < Taum_max
% PK2(:,1) = PK2_peak1;
% PK2(:,2) = PK2_peak2;
% PK2(:,3) = PK2_peak3;
%else
gives the fitted curve towards X-data vs Y-data plot which is again not correct because Dmat, Dmat_ant, Thetam and Thetam_ant are not initialized to ZEROS at the beginning of the calculation.
Can anyone please help me to fix the issue? Thank you very much in advance.aroj bhattaraihttps://fr.mathworks.com/matlabcentral/profile/authors/19737649tag:fr.mathworks.com,2005:Question/991502009-10-11T21:34:00Z2020-10-24T19:48:39ZIs there an example of using MATLAB to create PowerPoint slides?Is there a way, from MATLAB, to write images and content directly into PowerPoint slides? Do you have any examples of how to do this?
MathWorks Support Teamhttps://fr.mathworks.com/matlabcentral/profile/authors/4622813tag:fr.mathworks.com,2005:Question/3343952017-04-08T21:05:02Z2020-10-24T19:44:20ZHow to create random seed to have different results at each simevents run???I would like to generate different seed at each time to have various outcomes ... I have tried "shuffle," however it showed that "it is not supported!" Wish someone can help me!Thank you~
My setting is as below: (this setting makes that my simulation is always with the same outcome every time.)
<</matlabcentral/answers/uploaded_files/74626/Screen%20Shot%202017-04-09%20at%205.01.30%20AM.png>>
Min-Bin Linhttps://fr.mathworks.com/matlabcentral/profile/authors/9996356tag:fr.mathworks.com,2005:Question/6250582020-10-24T19:38:26Z2020-10-24T19:42:13ZHow DeepLab v3+ is connected with ResNet-18 in matlab?In matlab how DeepLab v3+ is combined with ResNet-18? I mean how both architectures are combined to form deeplabv3plusLayers function? How ResNet-18 features are connected with DeepLab v3+ layers?
In this "https://www.mathworks.com/help/vision/ref/deeplabv3pluslayers.html" they explained how to create a DeepLab v3+ network based on ResNet-18. But how are they both combined to get features? (Which layers have to be connected from ResNet-18 to DeepLab v3+ to get this "deeplabv3plusLayers(imageSize,numClasses,'resnet18');" network) kumara dommetihttps://fr.mathworks.com/matlabcentral/profile/authors/14275303tag:fr.mathworks.com,2005:Question/6244982020-10-24T02:58:08Z2020-10-24T19:34:12ZHow to multiply a cylinder function with a rectangularpulseI dont know matlab at all very well but I know my error that I get is from the matrix dimensions not matching.
I don't really understand how to fix this. Thanks
x = -10:0.1:10;
y = -10:0.1:10;
r= sqrt(x.^2+y.^2)
[x,y] = meshgrid(x,y)
[x,y,z]= (cylinder(r)).*((rectangularPulse(-.5,.5,x)).*(rectangularPulse(-.5,.5,y)))-((rectangularPulse(.5,1.5,x)).*(rectangularPulse(-.5,.5,y)))
mesh(x,y,z)
Jennifer Christine Bragghttps://fr.mathworks.com/matlabcentral/profile/authors/19747923tag:fr.mathworks.com,2005:Question/6248332020-10-24T14:23:59Z2020-10-24T19:15:45ZHow to create a 6 dimension array in Matlab and store values in it I have 8-relay , which i want to represent by x and y coordinates , then store 4 attribues of each of these relay , these attribues are generated randomly
for example relay no 1. at x=2 and y=7 ,
has power =5,
buffer total =1000, SINR=20 ,
Packets in buffer = 100
Shakeel alvihttps://fr.mathworks.com/matlabcentral/profile/authors/9688775tag:fr.mathworks.com,2005:Question/2325622015-08-06T05:44:07Z2020-10-24T19:14:24ZHow to plot this equation?How to plot this equation e parameters are knownHaider al-kananhttps://fr.mathworks.com/matlabcentral/profile/authors/5939623tag:fr.mathworks.com,2005:Question/2762992016-03-31T02:02:07Z2020-10-24T19:13:29Z3 D plot in MatlabI have 3 variables x, y, z
x ,y are independent variable
z(1,:)=f(x,1), y=1
z(2,:)=f(x,2), y=2
z(3,:)=f(x,3), y=3
How tHaider al-kananhttps://fr.mathworks.com/matlabcentral/profile/authors/5939623