https://kr.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — 새 질문2019-12-09T05:06:03Ztag:kr.mathworks.com,2005:Question/4956172019-12-09T04:31:14Z2019-12-09T05:06:03ZHelp with function reading a fileI want to query the user for what file they want to submit. Then I want the code to read the lines from AN18:AN11228 and K18:K11228 from the file that they enter then find the average of whatever numbers are within that criteria.
Here is what I have so far:
function [AGS,ALA]=BlosserD_Data20(File)
inputAGS=xlsread(File,'AN18:AN11228');
inputALA=xlsread(File,'K18:K11228');
AGS=mean(inputAGS);
ALA=mean(inputALA);
end
File=input('Enter file name: ')
[AGS,ALA] = BlosserD_Data20(File)Dylan Blosserhttps://kr.mathworks.com/matlabcentral/profile/authors/16767051-dylan-blossertag:kr.mathworks.com,2005:Question/4956212019-12-09T05:04:00Z2019-12-09T05:04:00ZLooping each pixel of matrix imageI have image 250x100 and i want using pdf every each pixel... How to looping it? If its manual just be:
X = imread('img.jpg');
Val1 = pdf(X(1,1),mu,sigma);
Val2 = pdf(X(1,2),mu,sigma);
......
Steven Pranatahttps://kr.mathworks.com/matlabcentral/profile/authors/16339813-steven-pranatatag:kr.mathworks.com,2005:Question/4952622019-12-06T16:34:23Z2019-12-09T05:01:53ZProblem: "You must verify your university login information before you can proceed. Click here. "Hi. matlab requires a verification of my university license but when I try to do that it isappears:You must verify your university login information before you can proceed. Click here. I click but it doesn't work. Anyone the some problem?
Thank youFausto Sommahttps://kr.mathworks.com/matlabcentral/profile/authors/15563223-fausto-sommatag:kr.mathworks.com,2005:Question/4956202019-12-09T04:55:01Z2019-12-09T04:55:01ZFor loops to find minimum valuesI am designing a beam and trying to create a for loop that helps me find the smallest possible dimensions the ratio of b/d is (b_d) is from 0.6 to 0.75
b_d = 0.6;
d = (bd2/b_d).^(1/3);
d = d*1.15; % increase by 15% to account for self weight
b = b_d*d;Jesus Terrazashttps://kr.mathworks.com/matlabcentral/profile/authors/6912347-jesus-terrazastag:kr.mathworks.com,2005:Question/4956192019-12-09T04:51:03Z2019-12-09T04:51:03ZAnalytical solution of reaction-diffusion model of cancer invasionCan anybody provie with the analytical soution of the reaction -disffusion model of cancer tumor growth where the tumor cell in increasing with time, healthy cell is decreasing with time and the concentration of H+ ions is increasing in time?Parth Shahhttps://kr.mathworks.com/matlabcentral/profile/authors/16256438-parth-shahtag:kr.mathworks.com,2005:Question/4956142019-12-09T04:26:45Z2019-12-09T04:50:34Zhelp deleting rows with column value in a table of data
I need help deleting all the rows with value of '2' in the array column in the data on my tableMaritza Torreshttps://kr.mathworks.com/matlabcentral/profile/authors/16076675-maritza-torrestag:kr.mathworks.com,2005:Question/4952972019-12-06T20:28:39Z2019-12-09T04:50:04ZCan't install simscape multibodyHello, I can't install Simscape Multibody. This error message pops everytime I try to install this package: Something Unexpected Occurred
Please Help me
Daulet Baimagambethttps://kr.mathworks.com/matlabcentral/profile/authors/7381336-daulet-baimagambettag:kr.mathworks.com,2005:Question/4956102019-12-09T03:02:20Z2019-12-09T04:44:34ZError plotting bode diagram of a transfer function inside a matrixI am trying to plot bode diagram of an element inside a matrix. The transfer function is alright if i plot G11 which is first row first column matrix. But the bode plot gives error. Is there a different way to plot such bode diagram ? My code is below.
syms s
G11=s-1;G12=s;
G21=-6;G22=s-2;
den=1.25*(s+1).*(s+2);
G=[G11, G12;G21, G22]/den;
G1=G(1,1);
G2=G(1,2);
G3=G(2,1);
G4=G(2,2);
bode(G1)
I even tried G11 by removing all G1...G4. But still doesnt work. Please guide.Shah Fahadhttps://kr.mathworks.com/matlabcentral/profile/authors/13603359-shah-fahadtag:kr.mathworks.com,2005:Question/4955952019-12-09T00:17:47Z2019-12-09T04:44:19ZIs there a mistake with my code to calculate ballistic trajectory? function [x,y]= DeLaPena_Trajectory(velocity,angle)
%Fucntion that calculates x and y position of ball
%Inputs: Velocity(m/s) and Angle(degrees)
%Outputs: [x,y]
narginchk(2,2)
%Check for valid inputs
if velocity<0
error('Velocity must be a positive number')
end
if angle<0
error('Angle must be positive')
end
%Defines the velocities
v_x= velocity*cosd(angle); %x-component of v
v_y= velocity*sind(angle); %y-component of v
%Define the displacement equations and time equations
t= (2*v_y)/9.81; %time of ballistic
x= v_x*t; %x-location
y= v_y*t-(1/2)*9.81*t^2; %y-location
This is my user-defined function for ballistic trajectory is there anything wrong with my code, I dont get the same answers as I would when I do it by hand. Jose De La Penahttps://kr.mathworks.com/matlabcentral/profile/authors/16083992-jose-de-la-penatag:kr.mathworks.com,2005:Question/4849552019-10-12T19:52:12Z2019-12-09T04:43:09ZMatlab 2019b not working mac OS Catalina - Start desktop error Hi everyone,
Has anyone managed to use 2019b version with the new Catalina OS Mac update ?
Despite, the compatibility stated at https://www.mathworks.com/support/requirements/matlab-system-requirements.html.
I get an error message "error starting desktop" pointing towards what seems to be a java issue.
Matlab was working perfectly before the update to Catalina.
Thank you very much.
Justine Guillochonhttps://kr.mathworks.com/matlabcentral/profile/authors/15999988-justine-guillochontag:kr.mathworks.com,2005:Question/4956162019-12-09T04:27:08Z2019-12-09T04:42:24ZChange the number of bins in Radon transformDear experts,
Is there any way to change the defaut munber of bin in matlab built in Radon transform? I want to perform a Radon transform on an image with a specific number of bin (stand for the munber of detector), and a specific bin width.
thank you.Hieu Phanhttps://kr.mathworks.com/matlabcentral/profile/authors/15371084-hieu-phantag:kr.mathworks.com,2005:Question/4950152019-12-05T12:25:07Z2019-12-09T04:42:13Zfor loop inside a if else loopI am trying to write a code for multivariable fuction. I want all values of p2 and want to extract unique values.
The code is as follow
clear all
clc
format longEng
syms z y1
phi=(pi/180)*39;
delta=(pi/180)*26;
gma=18.4;
beta=2
h=2;
h1=2;
L=h+h1;
kh=0.0;
kv=0;
R2=3*(beta*(1-y1))^0.5
psi=atan(kh/(1-kv));
delm23=0.5*(3-1)*delta;
k23=1+0.5*(3-1)*((cos(phi-psi)^2/(cos(psi)*(cos(delm23+psi)*...
(-sqrt((sin(phi+delm23)*sin(phi-psi))/(cos(delm23+psi)))+1)^2)))-1)
delm213=0.5*(R2-1)*delta
k213=1+0.5*(R2-1)*((cos(phi-psi)^2/(cos(psi)*(cos(delm213+psi)*...
(-sqrt((sin(phi+delm213)*sin(phi-psi))/(cos(delm213+psi)))+1)^2)))-1)
delm201=0.5*(1-R2)*delta;
k201=(2*cos(phi-psi)^2)/(cos(phi-psi)^2*(1+R2)+cos(psi)*cos(delm201+psi)...
*(1-R2)*(1+sqrt((sin(phi+delm201)*sin(phi-psi))/cos(delm201+psi)))^2)
i=0;
for z=0:0.1:L
i=i+1;
if(z<=h)
p1(i)=0.2*z;
p2(i)=0;
else
p1(i)=0.5*z;
j=0;
for y1=0:0.1:1
j=j+1
if (y1>=0 && y1<=(1-(1/beta)))
p2(i,j)=-gma*(z-h)*k23*cos(delm23)
elseif (y1>(1-(1/beta)) && y1<=(1-(1/(9*beta))))
p2(i,j)=-gma*(z-h)*eval(subs(k213*cos(delm213)))
else
p2(i,j)=-gma*(z-h)*eval(subs(k201*cos(delm201)))
end
end
end
end
z=0:0.1:L;
% subplot(2,1,1);
plot(p1,z,p2,z)
grid on
set(gca, 'YDir','reverse')
Akshay Pratap Singhhttps://kr.mathworks.com/matlabcentral/profile/authors/13946450-akshay-pratap-singhtag:kr.mathworks.com,2005:Question/4956112019-12-09T03:08:36Z2019-12-09T04:36:10ZComputing the explicit expression of the integral of a function of two variables inetgrated with respective to only one variableHello Madam or Sir,
I am computing the Lagrange equation that models the dynamic behavior of flexible link manipulator, in my code below I am having a issue for getting the explicit expression of the Kinetic energy. The inetgral of the function of two variables but inetgrated with respective to only one variable does not give me the explicit answer.
Here is my code:
%% 1. Parameters
syms L1 m1 J1 rho E I k_stif1 L0 theta1 theta2 real
syms L2 m2 J2 rho E k_stif2 real
syms mp JhP real
syms Jh1 mh1 Jh2 mh2 real
syms eta_m eta_g km kg Rm b1 b2 Vm1 Vm2 real
syms q1 q2 q3 q4 q5 q6 q1d q2d q3d q4d q5d q6d q1dd q2dd q3dd q4dd q5dd q6dd x t real
syms x1(t) x1d x1dd x2(t) x2d x2dd x3d x3dd x4d x4dd;
syms Q11(t) Q12(t) Q21(t) Q22(t);
x1d = diff(x1(t),t); x2d = diff(x2(t),t);
x1dd = diff(x1(t),t,t); x2dd = diff(x2(t),t,t);
x3d = diff(Q11(t),t); x4d = diff(Q12(t),t);
x3dd = diff(Q11(t),t,t); x4dd = diff(Q12(t),t,t);
x5d = diff(Q21(t),t); x6d = diff(Q22(t),t);
x5dd = diff(Q21(t),t,t); x6dd = diff(Q22(t),t,t);
%% 2. Numerical values
m1 = 0.065; m2 = 0.070; mh1 = 0.08; mh2 = 0.05; L0 = 0.0; L1 = 0.3; L2 = 0.2; J1 = 0.00195;
J2 = 0.000933; Jh1 = 0.099; Jh2 = 0.092; fc = 3.2; k_stif1 = 2*pi*fc; k_stif2 = 2*pi*fc;
eta_m = 0.69; eta_g = 0.9; km = 0.00767; kg = 70; Rm = 2.6; b1 = 1.99; b2 = 1.99;
mP = 0.69; JhP = 2.08e-3; E = 1; I = 1; rho = 0.2; be1 = [6.24 15.6]; be2 = [15.2 42.0];
%% 2. Vectorize symbolic variables
L = [L0;L1;L2]; % vector length of links
J = [J1;J2];
k = [k_stif1;k_stif2];
m = [m1;m2;mP];
Jh = [Jh1;Jh2;JhP];
mh = [mh1;mh2];
q = [q1;q2;q3;q4;q5;q6];
qdot = [q1d;q2d;q3d;q4d;q5d;q6d];
qddot = [q1dd;q2dd;q3dd;q4dd;q5dd;q6dd];
X = [x1(t);x2(t);Q11(t);Q12(t);Q21(t);Q22(t)];
Xdot = diff(X,t);
Xddot = diff(Xdot,t);
u = [Vm1;Vm2];
b = [b1;b2];
omega1 = zeros(length(be1),1);
omega2 = zeros(length(be2),1);
g1 = zeros(length(be1),1);
g2 = zeros(length(be2),1);
Ybar1=sym(zeros(length(be1),1)); C1=zeros(length(be1),1);
Ybar2=sym(zeros(length(be2),1)); C2=zeros(length(be2),1);
3.Input parameters
Tau1 = ((eta_m*eta_g*km*kg/Rm)*(u(1)-km*kg*diff(X(1),t)))-b(1).*diff(X(1),t);
Tau1 = subs(Tau1,Xdot,qdot);
Tau2 = ((eta_m*eta_g*km*kg/Rm)*(u(2)-km*kg*diff(X(2),t)))-b(2).*diff(X(2),t);
Tau2 = subs(Tau2,Xdot,qdot);
Tau3 = 0;
Tau4 = 0;
Tau5 = 0;
Tau6 = 0;
f = vpa([Tau1;Tau2;Tau3;Tau4;Tau5;Tau6],3)
%% 4. Deflection y(x,t)
for j=1:length(be1)
omega1(j) = (be1(j)/L(2)).^2.*sqrt(E*I/rho);
g1(j) = vpa(((sin(be1(j)) - sinh(be1(j))) + (m(1)*be1(1)/(rho*L(2)))*(cos(be1(j)) - cosh(be1(j))))/((cos(be1(j)) + cosh(be1(j))) - (m(1)*be1(j)/(rho*L(2))).*(sin(be1(j)) - sinh(be1(j)))),3);
Ybar1(j) = vpa(cos(be1(j)*x/L(2)) - cosh(be1(j)*x/L(2)) + g1(j)*(sin(be1(j)*x/L(2)) - sinh(be1(j)*x/L(2))));
C1(j) = vpa(1/sqrt(int(rho*Ybar1(j)^2,x,[0 L(2)]) + m(1)*compose(Ybar1(j)^2,L(2))));
end
y1 = vpa(C1(1).*Ybar1(1).*X(3) + C1(2).*Ybar1(2).*X(4))
for j=1:length(be2)
omega2(j) = (be2(j)/L(3)).^2.*sqrt(E*I/rho);
g2(j) = vpa(((sin(be2(j)) - sinh(be2(j))) + (m(2)*be2(1)/(rho*L(3)))*(cos(be2(j)) - cosh(be2(j))))/((cos(be2(j)) + cosh(be2(j))) - (m(2)*be2(j)/(rho*L(3))).*(sin(be2(j)) - sinh(be2(j)))),3);
Ybar2(j) = vpa(cos(be2(j)*x/L(3)) - cosh(be2(j)*x/L(3)) + g2(j)*(sin(be2(j)*x/L(3)) - sinh(be2(j)*x/L(3))));
C2(j) = vpa(1/sqrt(int(rho*Ybar2(j)^2,x,[0 L(3)]) + m(2)*compose(Ybar2(j)^2,L(3))));
end
y2 = vpa(C2(1).*Ybar2(1).*X(5) + C2(2).*Ybar2(2).*X(6));
%% 5. Transformation matrices
A1 = [cos(x1(t)) -sin(x1(t)); sin(x1(t)) cos(x1(t))]; %Rigide Rotation Matrix Transformation from (X0,Y0) to (X1,Y1)
A2 = [cos(x2(t)) -sin(x2(t)); sin(x2(t)) cos(x2(t))]; %Rigide Rotation Matrix Transformation from (X0,Y0) to (X1,Y1)
E0 = [1, 0; 0, 1]; %rotation matrix of the flexible link 1 at the end point
E1 = [1, -subs(diff(y1,x),x,L(2)); subs(diff(y1,x),x,L(2)), 1]; %rotation matrix of the flexible link 2 at the end point
T0 = eye(2);
T1 = T0*E0*A1;
T2 = T1*E1*A2;
%% 6. Links and Tipload positions
p01 = subs([x ; y1],x,L(1));
r11 = [x ; y1];
r01 = p01 + T1*r11;
p12 = subs([x ; y1],x,L(2));
p02 = p01 + T1*p12;
r22 = [x ; y2];
r02 = p02 + T2*r22;
p23 = subs([x ; y2],x,L(3));
p03 = p02 + T2*p23;
r03 = p03;
alpha1 = X(1) + subs(diff(y1,x),x,L(1));
alpha2 = X(1) + X(2) + subs(diff(y1,x),x,L(2));
alpha3 = X(1) + X(2) + subs(diff(y1,x),x,L(2)) + subs(diff(y2,x),x,L(3))
%% 7. Angular velocity of links and tipload
W1 = diff(alpha1,t);
W2 = diff(alpha2,t)
W3 = diff(alpha3,t)
V1 = diff(r01,t)
V2 = diff(r02,t)
VM = diff(r03,t)
%% 8. Kinetic Energy of Hub, Links and Tipload
TH1 = (1/2)*Jh(1)*W1^2 + (1/2) * ((diff(p01,t))') * mh(1) * (diff(p01,t));
TH2 = (1/2)*Jh(2)*W2^2 + (1/2) * ((diff(p02,t))') * mh(2) * (diff(p02,t))
TL1 = (1/2)*int(rho * (V1') * V1,x,0,L(2))
TL2 = (1/2)*int(rho * (V2') * V2,x,0,L(3))
TP = (1/2)*Jh(3)*W3^2 + (1/2) * ((diff(p03,t))') * m(3) * (diff(p03,t))
K = TH1 + TH2 + TL1 + TL2 + TP;
When computing the code, from the result of TL1 is shown as :
I am wonderng why Matlab can not compute the explicit answer.
Any help please ?Cianyi Kazadihttps://kr.mathworks.com/matlabcentral/profile/authors/16272053-cianyi-kazaditag:kr.mathworks.com,2005:Question/4956152019-12-09T04:27:07Z2019-12-09T04:35:13Zhelp regarding conditional if statement How do i write the code for the if statement such that if the condition fails it maintains the previous model (m)
theta = [0:90]';
M = [1800;400;1850;0.2;0.5]';
Dm = ref_coeff(M,theta);
Ds = Dm + (0.02*randn(size(Dm)) + 0);
T = [logspace(3,0,200)]';
Mint = M;
for i = 1 : length(T)
Er = ((abs(Ds - Dm)).^2)./(2*(0.02^2));
E = sum(Er); % Initial Energy State%
n1 = 25 .* randn(1,1) + 1800;
m1 = 1500 + n1*(2000 - 1500); % Perturbation in Model Parameters%
n2 = 50 .* randn(1,1) + 400;
m2 = 0 + n2*(1000 - 0);
n3 = 50 .* randn(1,1) + 1850;
m3 = 1200 + n3*(2200 - 1200);
n4 = 0.05 .* randn(1,1) + 0.2;
m4 = 0 + n4*(1 - 0);
n5 = 0.05 .* randn(1,1) + 0.5;
m5 = 0 + n5*(1 - 0);
m = [m1;m2;m3;m4;m5]';
dm = ref_coeff(m,theta);
ds = dm + (0.02*randn(size(dm)) + 0);
En1 = ((abs(ds - dm)).^2)./(2*(0.02)^2);
En = sum(En1); % New Energy State%
Ec = En - E;
if Ec >= 0
Mint = m;
z(i,:) = Mint
elseif (exp(Ec/T(i))) >= randn(0,1)
Mint = m;
else
???????
end
endPrince Igwezehttps://kr.mathworks.com/matlabcentral/profile/authors/16234735-prince-igwezetag:kr.mathworks.com,2005:Question/4955342019-12-08T13:48:16Z2019-12-09T04:27:33ZHow to plot the velocity of a crate on a ramp for different angles?I have a task with a 12kg crate on a conveyor belt moving at u = 2.5m/s onto a ramp with kinetic friction uk = 0.3. The ramp is 3m long and I need to plot velocity against a range of angles then find the smallest angle for the ramp where the crate will still fall off at the end (s = 3).
I've been using angles from 0 to 30: A = linspace(0,30,301)
Then using this to get the normal force which seems to give correct values: N = m*g*cosd(A)
From this calculate the acceleration which also seems to give correct values: 12a = mgsinA - uk N -> a = (m*g*sind(A)-uk*N)/12
Then find the velocity using: v^2 = u^2 + 2as -> v = sqrt(u^2 + 2*a*s)
This gives imaginary values (e.g. 0.000 + 2.8267i) which I'm guessing due to this value being negative and then square root as the crate would realistically stop before reaching 3m. The values from 12.8 deg seem correct and don't have any imaginary parts.
When plotting A against v the velocity is 0 (as imaginary parts are ignored) until 10.8 when it starts to increase. At 10.8 deg the v value is 0.0000 + 0.2568i and at 10.9 deg it's 0.2018 + 0.0000i. When I've calculated it manually I get 22.6 degrees so unsure where I'm going wrong.
Any help is much appreciated!
Kiera Hardinghttps://kr.mathworks.com/matlabcentral/profile/authors/15529758-kiera-hardingtag:kr.mathworks.com,2005:Question/4956092019-12-09T02:56:09Z2019-12-09T04:26:41ZFOR loop through multiple datasetsHello,
I want to create a for loop that will sum specific columns of a single row of a matrix in a dataset. I then want to repeat that action for other datasets. The matrix is 37 rows x 100 columns. All datasets are in mat. files.
% For Nubian Aquifer - 1900-1999
sum_ET = sum(aq_gwdctr_ET(1,:))/100;
sum_P = sum(aq_gwdctr_P(1,:))/100;
sum_R = sum(aq_gwd_qover(1,:))/100;
sum_dSdt = sum(aq_gwdctr_dSdt(1,:))/100;
sum_C = sum(aq_gwdctr_C(1,:))/100;
sum_GWpumping = sum(aq_irri4d(1,:))/100;
% For Nubian Aquifer - 1950-1999
sum_ET1 = sum(aq_gwdctr_ET(1,51:end))/50;
sum_P1 = sum(aq_gwdctr_P(1,51:end))/50;
sum_R1 = sum(aq_gwd_qover(1,51:end))/50;
sum_dSdt1 = sum(aq_gwdctr_dSdt(1,51:end))/50;
sum_C1 = sum(aq_gwdctr_C(1,51:end))/50;
sum_GWpumping1 = sum(aq_irri4d(1,51:end))/50;
% For Nubian Aquifer - 1900-1949
sum_ET2 = sum(aq_gwdctr_ET(1,1:50))/50;
sum_P2 = sum(aq_gwdctr_P(1,1:50))/50;
sum_R2 = sum(aq_gwd_qover(1,1:50))/50;
sum_dSdt2 = sum(aq_gwdctr_dSdt(1,1:50))/50;
sum_C2 = sum(aq_gwdctr_C(1,1:50))/50;
sum_GWpumping2 = sum(aq_irri4d(1,1:50))/50;
Currently, the code that I have performs all these individually. What I'm hoping to achieve is to simplify the above code. The new code should be able to;
A) For 1900-1999, sum all the columns for every row for each matrix, dataset. For 1950-1999, sum columns 51 until end for every row for each matrix, dataset. For 1900-1949, sum columns 1 until 50 for every row for each matrix, dataset.
B) This action should be repeated for each dataset (aq_gwdctr_ET, aq_gwdctr_P, etc.).
C) It would be a bonus if I could tabulate all these values.
% For year 1900-1999
Aquifer = [1; 2; 3]; % This is the rows in the matrix
ET = [sum_ET]; % Sum ET for each row in the matrix, repeat for each dataset
T = table(Aquifer, ET);
Thank you for your help. Elizabeth Yeaphttps://kr.mathworks.com/matlabcentral/profile/authors/8460975-elizabeth-yeaptag:kr.mathworks.com,2005:Question/4954902019-12-08T01:58:32Z2019-12-09T04:20:26ZHow to run cell array from 1 to max_iter? max_iter = 100
V_cell = cell(max_iter, 1);
V_cell{1} = V;
for i = 1:max_iter
nrow = size(data,1);
nbar = size(V_cell{i}, 1);
out = zeros(nbar, nrow);
for k = 1:nbar
out(k,:) = sqrt(sum(((data-ones(size(data, 1), 1)*V_cell{i}(k,:)).^2), 2));
end
dist = out; % fill the distance matrix
I've done this, but the result dist contains all NaN, can you give me some solution? Thanks. Day7https://kr.mathworks.com/matlabcentral/profile/authors/17047246-day7tag:kr.mathworks.com,2005:Question/4956122019-12-09T03:59:20Z2019-12-09T04:17:21ZFor loops: initialize the sum variableFor this code if put the initial value of sum=1 then I get different answer.But I thought the inital values of sum doesn't matter? Can anyone explain?
m = input('Please enter the number of terms in the sum: ');
n = 0;
SUM = 0;
disp(' ')
for n = 1:m
an = (-1/3)^n/(2*n + 1);
SUM = SUM + an = (-1/3)^n/(2*n + 1);
Val_Exp = sqrt(12)*SUM;
Prec_pi = abs(pi-Val_Exp);
fprintf('For n = %2i, Value = %.15f to a precision of %.10e.\n', n, Val_Exp, Prec_pi)
end disp(' ')Abida Islamhttps://kr.mathworks.com/matlabcentral/profile/authors/16100958-abida-islamtag:kr.mathworks.com,2005:Question/4956132019-12-09T04:13:18Z2019-12-09T04:13:18Z To calculate fall time and settling time from response graph I want to calculate fall time, setting time and overshoot from response graph. I tried stepinfo command but I coundnt get the right answer. how can I calculate it exactly.
Ashwini Morehttps://kr.mathworks.com/matlabcentral/profile/authors/16116636-ashwini-moretag:kr.mathworks.com,2005:Question/4956072019-12-09T02:42:45Z2019-12-09T04:12:42Zhow to remove period noise from an rgb image?How do I remove period noise from an rgb photo?
I know that I must split my image to 3 channels and I have done that
rgbImage = imread(image name)
redChannel = rgbImage(:,:,1)
greenChannel = rgbImage(:,:,2)
blueChannel = rgbImage(:,:,3)
allBlack = zeros(size(rgbImage, 1), size(rgbImage, 2), 'uint8');
just_red = cat(3, redChannel, allBlack, allBlack);
just_green = cat(3, allBlack, greenChannel, allBlack);
just_blue = cat(3, allBlack, allBlack, blueChannel);
Now I don't know how to apply the notch to every single channel.
Thank you in advance.taha khaledhttps://kr.mathworks.com/matlabcentral/profile/authors/17052479-taha-khaledtag:kr.mathworks.com,2005:Question/4954292019-12-07T17:21:55Z2019-12-09T04:09:19ZIndex exceeds the number of array elements (1).for i=1:3
q=s{i,1};
x=sum(q{1});
c=s{i,1};
w=sum(c{2})
if x>=m
x=35;
else
x=(x/m)*100;
x=x*(p/100);
end
z=x+w+max;
t1=z;
disp(t1)
if t1(i) >= b(1)
g=1
elseif t1(i) >= b(2)
g=2
elseif t1(i)>= b(3)
g=3
else
g=4
end % if
f=g;
end
In this code the for loop runs correctly for the first iteration but in the second iteration it shows the error of --Index exceeds the number of array elements (1)shubham shubhamhttps://kr.mathworks.com/matlabcentral/profile/authors/16748437-shubham-shubhamtag:kr.mathworks.com,2005:Question/3466802017-06-28T23:45:29Z2019-12-09T04:03:40ZMy data is x,y,z,w. How can I create a 3D contour plot of it?I have a tab delimited text file (see attached) that has x,y,z data from a design of experiments sweep and the output variable is w.
I tried using this:
fidi=fopen('DOE sweep1A.txt', 'rt'); % version of text file without headers
D=textscan(fidi, %f%f%f%f');
X=D{1}; % rpm
Y=D{2}; % m_dot
Z=D(3); % P
W=D{4); % Power
N=100;
Xi=linspace(min(X),max(X),N);
Yi=linspace(min(Y),max(Y),N);
Zi=linspace(min(Z),max(Z),N);
[Gx,Gy,Gz]=meshgrid(Xi,Yi,Zi);
Wi=griddata(X, Y, Z, W, Gx, Gy, Gz, 'natural');
contour(Gx, Gy, Gz, Wi, 'Linestyle', '-', 'Linecolor', [0 0 0], 'ShowText', 'on', 'LevelStep', 1)
grid on
colormap(jet)
colorbar;
And I know that it doesn't work because it can only have 2 dimensions and also that there are repeating numbers for X, Y, and Z because it is a design of experiments sweep.
But I would still want to plot this preferably in a 3D contour plot.
Is there a way to do so?
Thanks.Ewen Chanhttps://kr.mathworks.com/matlabcentral/profile/authors/193071-ewen-chantag:kr.mathworks.com,2005:Question/4929262019-11-24T20:48:11Z2019-12-09T04:02:53ZEvaluating all NeuralNetworks in a cell array simultanouslyHi,
i have cell array of neural networks, which are all trained.
I now want to feed one inpuct vector into all of those NN (it's the same input values for all NNs), but it needs to be done as quickly as possible as I am working on a realtime application. Does anyone have an idea about how to do that without looping through the single networks? Or possibly a different approach than saving the networks in a cell array?
Thanks in advance!
fritzhttps://kr.mathworks.com/matlabcentral/profile/authors/12777291-fritztag:kr.mathworks.com,2005:Question/4955022019-12-08T06:51:53Z2019-12-09T04:02:04ZRandomly select a set number of samples (of size n) without overlap, nor replacement, in a signalI have a sound signal and I would like to randomly select 5 units of 10 seconds in that signal, but with no overlap, and with no replacement. It looks like I cannot use the function datasample because it only sample 1 sample in the vector (whereas I need: n = 10 seconds * sampling frequency).
If it is possible, I also would like a buffer length of b samples in between each unit sampled.
Any help much appreciated! Thank you!Butterflyfishhttps://kr.mathworks.com/matlabcentral/profile/authors/2964718-butterflyfishtag:kr.mathworks.com,2005:Question/4941942019-12-01T19:59:17Z2019-12-09T04:00:44ZMapping two binary bits to oneI have generate a set of bits 0 and 1,
N=10000;
m=(sign(randn(1,N))+1)/2;
The problem is how do I group the bits? For example
00=-j
01=-1
10=1
11=j
salad9996https://kr.mathworks.com/matlabcentral/profile/authors/16440078-salad9996tag:kr.mathworks.com,2005:Question/4916072019-11-18T00:09:28Z2019-12-09T03:57:00ZExisting table, populate a column with string (receiving errors)I have a table, and I want to populate every row in a specific column with the same string. I keep getting errors. Using Matlab R2018a, no fancy packages.
mytable = nan(5,2);
% I'm creating my table like this; it's actually much bigger, and most of the columns are numerical
% is there a better way to do this? the order of the column matters, and I don't want to have to add extra code to re-order
mytable = array2table(mytable);
mytable.Properties.VariableNames = {'colA', 'colB'};
mytable.colA(:) = 459; % just a random number, proof-of-concept that it works
mytable.colB(:) = {'words'}; % this throws errorsa1https://kr.mathworks.com/matlabcentral/profile/authors/5150515-a1tag:kr.mathworks.com,2005:Question/3831902018-02-17T03:32:42Z2019-12-09T03:56:58ZI am working on micromechanics of composites.How can i create a model in MATLAB for particulate reinforced composites and perform micromechanicsI wish to model particulate reinforced composites and perform micro mechanics.How to create a model for modelling the perfect RVE with micostructure embedded within.Siddharth Sriramhttps://kr.mathworks.com/matlabcentral/profile/authors/12177151-siddharth-sriramtag:kr.mathworks.com,2005:Question/3239262017-02-08T08:33:05Z2019-12-09T03:54:49ZMenu bar missing in SimulinkI installed an academic licanse of MATLAB R2016b and Simulink on my new computer a couple of days ago and started working on a simulink project and everything was going fine. However when I opened the simulink model today the toolbar was missing. See figure.
<</matlabcentral/answers/uploaded_files/69289/misssingToolbar.png>>
I have tried rebooting matlab and my system (windows 10 64-bit) which did not help, as well as googling the issue, but have not found any conclusive answers. If anyone knows how to fix this problem it would be much appriciated.
Best Regards
Viktor
Viktor Gustavssonhttps://kr.mathworks.com/matlabcentral/profile/authors/4963007-viktor-gustavssontag:kr.mathworks.com,2005:Question/4956022019-12-09T02:18:51Z2019-12-09T03:48:48Zhow to calculate the distance between different pixelsmeizaki fatihinhttps://kr.mathworks.com/matlabcentral/profile/authors/14122843-meizaki-fatihintag:kr.mathworks.com,2005:Question/4956042019-12-09T02:31:47Z2019-12-09T03:46:56ZSegment Dumbbell Structure into Two Circles and One RectangleI'm trying to analyze three shapes from this image--two circles and one rectangle. I would like each to be a separate object detected by bwconncomp so that I can analyze with various region props. All three are touching. Using bwconncomp unfortunately gives a single object. I tried various bwmorph operations but they are altering the objects too much. For example, I used the thin operation with n=20, followed by the open operation and then finally the thicken operation with n=20. My strategy was to isolate the circles first, then subtract from the original image to get the rectangle isolated. Unfortunately the bwmorph operations make the circles into more of a square shape afterwards. I have also tried using the watershed function to the image after it was transformed via bwdist--this also did not work, i.e. there were way too many watershed lines when I would only want two.
There is no contrast between the circles and the rectangle.
Any suggestions would be most welcome!Paul Safierhttps://kr.mathworks.com/matlabcentral/profile/authors/12547459-paul-safiertag:kr.mathworks.com,2005:Question/4956082019-12-09T02:49:07Z2019-12-09T03:44:18ZWhy is my code not working? %Hello!
Hi I am using matlab 2016 and I am trying to find the cup to disk ratio of the retina using matlabs image processing toolox. I have attached an image of an example image the program takes in. I get the error:
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Error in final (line 77)
centers = stats.Centroid;
[filename,filepath]=uigetfile({'*.png', '*.jpg'},'Select and image');
%Gets file from user
if isequal(filename,0)
disp('User selected Cancel')
else
disp(['User selected ', fullfile(filepath, filename)])
end
originalI = imread(strcat(filepath, filename));
figure
imshow(originalI);
title('Please crop the image');
%Displays the original image the user inputs.
[xpos, ypos] = ginput(1);
%Gets the x and y position from where the user clicks to crop the image.
title('Original Image');
width = 756;
height = 756;
%The dimensions of the new cropped image.
xLeft = xpos - width/2;
yBottom = ypos - height/2;
%Calculates the position of the top left corner of the crop and the bottom
%right corner of the crop
croppedI = imcrop(originalI, [xLeft, yBottom, width, height]);
%Crops the original image base of the top left corner, bottom right corner, and its
%width and height
figure
imshow(croppedI);
title('Cropped Image');
%Displays cropped image to the user
saturatedI = rgb2hsv(croppedI);
saturatedI(:,:,1)=saturatedI(:,:,3)*1.2;
saturatedI(saturatedI > 1)=1;
saturatedI=hsv2rgb(saturatedI);
%Saturates the cropped image by 20%
redChannel = saturatedI(:,:,1);
%Converts the saturated image to the redChannel
greenChannel = saturatedI(:,:,2);
%Converts the saturated image to the greenChannel
BWred = imclearborder(redChannel);
fill = imfill(BWred,'holes');
SE=strel('disk',6)
diskimage=imdilate(fill,SE)
BWgreen = imclearborder(greenChannel);
fill = imfill(BWgreen,'holes');
SE=strel('disk',6)
cupimage=imdilate(fill,SE)
figure
imshow(diskimage);
title('disk image');
figure
imshow(cupimage);
title('cup image');
BW=BWred;
CC = bwconncomp(BW);
numPixels = cellfun(@numel,CC.PixelIdxList);
[biggest,idx] = max(numPixels);
BW(CC.PixelIdxList{idx}) = 0;
filteredForeground=BW;
a = diskimage;
stats = regionprops(double(a),'Centroid','MajorAxisLength','MinorAxisLength');
centers = stats.Centroid;
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;
disp(radii);
figure,imshow(croppedI);
hold on
viscircles(centers, radii);
hold off
Hardit Singhhttps://kr.mathworks.com/matlabcentral/profile/authors/17022555-hardit-singhtag:kr.mathworks.com,2005:Question/469082012-08-28T17:46:15Z2019-12-09T03:37:57ZHow to draw a rotated ellipse without any toolbox?I need to draw rotated ellipse on a Gaussian distribution plot by surf. I am using a student version MATLAB. Can i still draw a ellipse center at estimated value without any toolbox that required money to buy. I search on internet somebody write ellipse function and allow to download. Are they work well on surf plot. ManKit Tsehttps://kr.mathworks.com/matlabcentral/profile/authors/2392099-mankit-tsetag:kr.mathworks.com,2005:Question/4423242019-01-30T05:00:00Z2019-12-09T03:21:12ZCan I use MATLAB with an NVIDIA GPU on macOS 10.14 Mojave?Can I use MATLAB with an NVIDIA GPU on macOS 10.14 Mojave?
MathWorks Support Teamhttps://kr.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:kr.mathworks.com,2005:Question/4956062019-12-09T02:37:37Z2019-12-09T02:41:57ZCreating Standalone Application from App Designer Which Includes Python file. Hi everyone,
I've been troubleshooting this issue for a while now and am not sure where to go from here.
I've written an application in App Designer using MATLAB (2019a). The application itself uses Python to return data to MATLAB, in this particular case only being integer lists. Within App Designer, I can run my application perfectly. There are no issues with the Python files, and using:
py.importlib.import_module('mymod')
on my module produces no errors. A standard 64-bit CPython 3.7.5 is installed on my machine, and calling
pyversion
confirms that Python is both found, and loaded.
Inside of my App Designer applictation, and within the StartupFcn, I have updated the Python search path
pwd_path = pwd;
mod_name = 'py_dpd_add.py'; % yes, this is what I have called my module
full_path = [pwd_path, filesep, mod_name];
python_path = py.sys.path;
if count(python_path, full_path) == 0
insert(python_path, int32(0), full_path);
end
When I package my standalone application using the ApplicationCompiler, I add the Python file under 'Files installed for your end user'.
I have the standalone MATLAB Runtime 9.6 installed on my machine, and that is also the Runtime version within MATLAB.
Nonetheless, when I try to run my standalone application on the very same machine, the error I receive is
Undefined variable "py" or class "py.py_dpd_add.gen_dist"
Keep in mind this application is working perfectly when run within App Designer itself.
My only thought is that Python is not getting loaded within the application, but I tried adding the lines
pyversion('3.7'); % this works fine inside MATLAB itself
py.int(1); % checking to see if there are errors thrown, but there are not
to the script which adds the Python path, and there doesn't appear to be any issues resulting from these lines, which should theoretically imply Python is loaded.
If there is anyone who has experienced similar conufsion, or understands how to resolve this problem, I would greatly appreciate it.
Thanks for your time.
Edit: For what it's worth, the full traceback is as follows:
Undefined variable "py" or class "py.py_dpd_add.gen_dist".
Error in dpd_roll (line 42)
Error in Present_DPD/AddToPlotButtonPushed (line 412)
Error in appdesigner.internal.service.AppManagementService/tryCallback (line 333)
Error in matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating Button PrivateButtonPushedFcn.
Ictinaetushttps://kr.mathworks.com/matlabcentral/profile/authors/16750152-ictinaetustag:kr.mathworks.com,2005:Question/4956052019-12-09T02:33:35Z2019-12-09T02:33:35ZNeed help to implement pso for optimizing relay operating timesCan anyone help regarding matlab code for optimizing time dial setting and plug setting multiplier for optimizing relay operating time using particle swarm optimization.
I have matlab code for PSO but it works only for one variable and for one relay i.e. primary relay...........
i want to optimize primary and back up relay operating times by optimizing both TDS and PS;Mian Rizwanhttps://kr.mathworks.com/matlabcentral/profile/authors/15287378-mian-rizwantag:kr.mathworks.com,2005:Question/4956032019-12-09T02:31:27Z2019-12-09T02:31:27ZSolving symbolic trigonometric equationHello Everyone ,
I am trying to solve the trigonometric equation below in order to get all the roots of the equation.
The equation looks like:
I've tried the below code to get the plot of of the function so thtat I can mark the points in which the function is equal to zero and consider these point as the roots of the equation:
m1 = 0.065; m2 = 0.070; mh1 = 0.08; mh2 = 0.05; L0 = 0.0; L1 = 0.3; L2 = 0.2; J1 = 0.00195;
J2 = 0.000933; Jh1 = 0.099; Jh2 = 0.092; fc = 3.2; k_stif1 = 2*pi*fc; k_stif2 = 2*pi*fc;
eta_m = 0.69; eta_g = 0.9; km = 0.00767; kg = 70; Rm = 2.6; b1 = 1.99; b2 = 1.99;
mP = 0.69; JhP = 2.08e-3; E = 1; I = 1; rho = 0.2; be1 = [6.24 15.6]; be2 = [15.2 42.0];
x = linspace(0,20*pi,1E6); % Define Domain
fun = @(x) 1+cos(x).*cosh(x)-(J1.*x.^3/(rho.*L1.^3)).*(cos(x).*sin(x) + cosh(x).*sinh(x)) - (m1.*x/(rho.*L1)).*(sin(x).*cosh(x)-sinh(x).*cos(x)) + (m1.*J1.*x.^4/(rho.^2.*L1.^4)).* (1-cos(x).*cosh(x));
y = fun(x); % Evaluate Range
ycs = y.*circshift(y, [0 -1]); % Shift by 1 & Multiply
yzx = find(ycs <= 0); % Approx Zero Crossing Indices
yzx = yzx(1:1:end); % Choose Alternates
ixr = 5; % Interpolation Range
for k1 = 1:length(yzx)
b = [ones(1+ixr*2,1) x(yzx(k1)-ixr:yzx(k1)+ixr)']\y(yzx(k1)-ixr:yzx(k1)+ixr)';
rt(k1) = -b(1)/b(2);
end
figure(1)
plot(x, y, '-b')
hold on
plot(x(yzx), zeros(size(yzx)), 'xm')
plot(rt, zeros(size(rt)), 'pg')
hold off
grid on
axis([0 10 [-1 1]*100 ])
xlabel('$$\beta_{1j}$$','Interpreter','Latex')
ylabel('$$f(\beta_{1j})$$','Interpreter','Latex')
legend('$$f(\beta_{1j})$$','roots $$\beta_{1j}$$','Interpreter','Latex','Location','northeast')
I am getting the below error:
Index exceeds the number of array elements (1000000).
Error in Untitled2 (line 21)
b = [ones(1+ixr*2,1) x(yzx(k1)-ixr:yzx(k1)+ixr)']\y(yzx(k1)-ixr:yzx(k1)+ixr)';
Any help please?Cianyi Kazadihttps://kr.mathworks.com/matlabcentral/profile/authors/16272053-cianyi-kazaditag:kr.mathworks.com,2005:Question/4955802019-12-08T20:37:28Z2019-12-09T02:31:10ZHow to check if a table exists?The table, it exists, will be created by using the command "table". It has columns of both numerican values and strings.
How do I check if the table exists? I tried to use the command exist:
if ~exist(app.T1, 'class')
but it keeps complaining with the below error message:
Error using exist
The first input to exist must be a string scalar or character vector.
Leonhttps://kr.mathworks.com/matlabcentral/profile/authors/3133287-leontag:kr.mathworks.com,2005:Question/10582011-02-08T22:05:18Z2019-12-09T02:19:43ZContributors metainfo: reputation and moreAs asked by <http://www.mathworks.com/matlabcentral/answers/contributors/2710900-vieniava Vieniava> in <http://www.mathworks.com/matlabcentral/answers/1041-how-to-make-a-list-of-user-s-reputation "How to make a list of user's reputation?">, some of us came up with interesting ideas on how to fill an _updated list_ with the reputation scores of the contributors to *Answers*.
I took the initiative to compile a public list of users with meta info:
* position (desc ordering by reputation)
* id
* nickname (truncated to fit the page)
* reputation
* # of comments
* # of questions asked
* % accept rate
* # of posts answered
* # of accepted answers
The code used to compile the list is available at the bottom.
*EDIT*
TMW team implemented a page with the metascores: <http://www.mathworks.com/matlabcentral/answers/contributors>
Please refer to it and congrats to the team!
Use this function to retrieve info from the link above:
function [metainfo, elapsedTime] = metainfo(type,order)
% METAINFO - Retrieve metainfo on contributors to www.matworks.com/.../answers
%
% METAINFO Retrieve data sorted by reputation in descending order
%
% METAINFO(TYPE,ORDER) Specify TYPE and sorting ORDER as
% type : 'reputation'
% 'questions'
% 'answered'
% 'accepted'
%
% order: 'asc'
% 'desc'
%
% Examples:
%
% % Standard call (rep, disc)
% info = metainfo;
%
% % Sort by question answered in descending order
% info = metainfo('an','d');
%
% See also: URLREAD, REGEXP
% Author: Oleg Komarov (oleg.komarov@hotmail.it)
% Tested on R14SP3 (7.1) and on R2009b. In-between compatibility is assumed.
% 28 feb 2011 - Created
tic
% Check # inputs
error(nargchk(0,2,nargin))
% Retrieve inputs
if nargin == 0
type = 'reputation';
order = 'desc';
end
if ~exist(type,'var')
sortTypes = {'reputation','questions','answered','accepted'};
type = sortTypes{strncmp(type,sortTypes,numel(type))};
order = 'desc';
end
if ~exist(order,'var')
orderTypes = {'asc','desc'};
type = orderTypes{strncmp(order,orderTypes,numel(order))};
end
% Build url string
url = ['http://www.mathworks.com/matlabcentral/answers/contributors?'...
'dir=' order '&sort=' type '&page='];
% First read
[page, ok] = urlread([url '1']);
% Catch number of pages to read
if ok
totcon = regexp(page,'>1 - 50 of (\d+)','tokens');
totcon = dataread('string',totcon{1}{1},'%d');
nPages = ceil(totcon/50);
else
error('Cannot read ".../contributors?page=1"')
end
% Loop over contributors pages
metainfo = cell(totcon,7);
metainfo(1:end,1) = num2cell(1:size(metainfo,1));
for p = 1:nPages
if ok
endpos = 50*p;
% Id, Rep
expr = '><a href="\/matlabcentral\/answers\/contributors\/(\d+)';
data = regexp(page, expr,'tokens');
if 50*p > totcon; endpos = 50*(p-1)+numel(data); end
metainfo(1+(p-1)*50:endpos,2) = [data{:}];
% Nickname
expr = ['"Reputation: (\d+)">([\w\ ' reshape([repmat(92,1,137);33:59,61:64,91:97,123:126,161:255],1,[]) ']+)</a></h2>'];
data = regexp(page, expr,'tokens');
metainfo(1+(p-1)*50:endpos,[4,3]) = cat(1,data{:});
% Qcount, Ans, Acc
data = regexp(page, '<span >(\d+)</span>[A-z<>"-\s\/]+','tokens');
metainfo(1+(p-1)*50:endpos,5:7) = reshape(cat(1,data{:}),3,[]).';
else
error('Metainfo import stopped. \nCannot read ".../contributors?page=%d"',p)
end
[page, ok] = urlread([url sprintf('%d',p+1)]);
end
% Convert to doubles
metainfo(:,[2,4:7]) = cellfun(@str2double,metainfo(:,[2,4:7]),'un',false);
elapsedTime = toc;
Oleg Komarovhttps://kr.mathworks.com/matlabcentral/profile/authors/1886545-oleg-komarovtag:kr.mathworks.com,2005:Question/4956012019-12-09T02:08:18Z2019-12-09T02:08:18ZError using plot, vectors must be same lengthDear MATLAB experts,
sorry for the dumb question but im in serious need of help.
Im doing alot of different calculations and some of the results that i will be using is placed in two vectors, c and H.
the size for them is: c: 64x4double and H:69x1double.
Im trying to do a plot of H and c where H is the x-axis and c being y-axis.
I have tried changing the code but it messes up my calculations.
If anyone knows a solution to avoid this it would be much appreciated.
I attached the code in the file: optim_o2_co_vs_height.m
p.s im still learning how to use MATLAB
Best Regards
Saad Khan
Saad Khanhttps://kr.mathworks.com/matlabcentral/profile/authors/6858360-saad-khantag:kr.mathworks.com,2005:Question/4862082019-10-18T19:49:11Z2019-12-09T02:06:00ZProperty inspector can not be used any more on macI cannot use the property inspector in figure any more after the macos update.
dongfei chenhttps://kr.mathworks.com/matlabcentral/profile/authors/15895741-dongfei-chentag:kr.mathworks.com,2005:Question/3973212018-04-25T14:41:33Z2019-12-09T02:03:17ZThe field showing the cursor line and column is being cut offHello
This obviously isn't a huge issue, but it's still bugging me a bit. As you can see in the two cropped screenshots below, the field that shows the position of the cursor within the editor doesn't always show the full info. Single digit column numbers still display fine, but 10 and up are being replaced by "...". I tried changing the font size, but the field isn't affected at all.
I suspect this has something to do with me working on a high DPI screen (a Surface Pro 4), but of course I don't really know.
<</matlabcentral/answers/uploaded_files/114725/2018-04-25_16-25-41.png>>
Niki Herlhttps://kr.mathworks.com/matlabcentral/profile/authors/12326671-niki-herltag:kr.mathworks.com,2005:Question/4955922019-12-08T23:20:37Z2019-12-09T02:03:04ZUsing dir to extract the names of plexon files for upload Hey I am trying to write a script that will scroll through all my folders and save the names of the plexon files I want. However matlab doesn't recognize the plexon file and thus keeps saving as an empty structure array and I don't know how to fix it.
D = dir;
D = D(~ismember({D.name}, {'.', '..'}));
for k = 1:numel(D)
currD=D(k).name
cd(currD)
dinfo=dir('day1')
end
dinfo =
0×1 empty struct array with fields:
name
folder
date
bytes
isdir
datenum
Caitli Newmanhttps://kr.mathworks.com/matlabcentral/profile/authors/16562998-caitli-newmantag:kr.mathworks.com,2005:Question/4955972019-12-09T00:25:59Z2019-12-09T02:00:50Zdisplay row and columns of filesI want to write a script code that will access multiple files at the same time and display the file of the name, the number of rows and columns of each file. My '.dat' files are in a folder.
I want to display the following per example:
data01.dat: 1885 rows by 3 columns
how can i do this using a loop
Maria Gloria Raquel Obono Ondohttps://kr.mathworks.com/matlabcentral/profile/authors/15982660-maria-gloria-raquel-obono-ondotag:kr.mathworks.com,2005:Question/4946442019-12-03T19:07:49Z2019-12-09T01:49:29ZKeeping a figure open even when a key is pressedI have a script that changes the position of a rectangle in a graph whenever an arrow key is pressed. When I run the script, the figure moves when I press the arrow key, but it also minimizes the figure. How would I keep the figure from minimizing?
Matthew Eatonhttps://kr.mathworks.com/matlabcentral/profile/authors/16398769-matthew-eatontag:kr.mathworks.com,2005:Question/4955622019-12-08T18:20:52Z2019-12-09T01:49:20ZSummation of Infinity TermsS = 0;
tol = eps;
term = inf;
n = 0;
while abs(term) > tol
term = exp(x*log10(n));
S = S + term;
n = n + 1;
end
It try by this way but I don't know what is wrong
لاRewida Hassanhttps://kr.mathworks.com/matlabcentral/profile/authors/17051383-rewida-hassantag:kr.mathworks.com,2005:Question/4954972019-12-08T03:46:30Z2019-12-09T01:43:11ZFitting Data to a Non-Linear CurveI have matrix data for x and y and am looking to find an equation that best represents this data. We don't believe it is a polynomial line of best fit so polyfit wouldn't be appropriate. Is there a method for finding the equation for logarithmic or exponential through data?
Here's the data for reference:
x=[0 1 2 3 4 5 6 7 8 9 10]
y=[.0242 0.1940 0.2792 0.2358 0.1386 0.0598 0.0238 0.0090 0.0034 0.0013 0.002]
Andrew Rowehttps://kr.mathworks.com/matlabcentral/profile/authors/14762866-andrew-rowetag:kr.mathworks.com,2005:Question/4954722019-12-07T22:44:56Z2019-12-09T01:35:41Zmono font not show up in matlab’s fontsI was looking for a good mono font and found one called bitstream Vera mono. I installed it into windows fonts but it doesn’t show up in matlab’s font options. How can I make this font show up there?Katherine Vollanohttps://kr.mathworks.com/matlabcentral/profile/authors/16857278-katherine-vollanotag:kr.mathworks.com,2005:Question/4949202019-12-05T00:51:12Z2019-12-09T01:34:53Zplot with input argumentsi want to subplot 4 string containg cell array from ( sin, cos, tan,sinh) and vector (+,o,*,x,s) and the mathmatical function should be ploted in interval (-2pi,2pi)with step 0.3Roger Nadalhttps://kr.mathworks.com/matlabcentral/profile/authors/16935264-roger-nadaltag:kr.mathworks.com,2005:Question/4955882019-12-08T22:00:21Z2019-12-09T01:16:14ZGet every first value above a treshold out of an arrayHi guys, Lets say I have an array with elements with
A = [1 2 3 4 5 6 2 3 4 5 6 3 4 5 6 7 8 1 2 1 2 1 2 3 4 5 6]
Now I want to have only the first values that are above the treshold 4.5 when reading from left to right. So reading from left to right when an element is lower than 4.5 it is a 0, when it is higher than 4.5, only the first element is a 1. When the next element is also higher than 4.5 it should be a zero. Only when the value of an element drops below 4.5 the next element above 4.5 should again be a one.
The result should be:
B = [0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0]
Please help me with the magic between A and B.Mike Mierlo vanhttps://kr.mathworks.com/matlabcentral/profile/authors/15783639-mike-mierlo-vantag:kr.mathworks.com,2005:Question/4955962019-12-09T00:23:38Z2019-12-09T00:58:39ZI want to lebel the 6 solution on the curves of my plot but idont know how to: here is my matlab script below:clear all
close all
func =@(i,j) y(j)^2 - log(y(j))^2 - 4*log(x(i)) - 4*(1/x(i)) - 3;
x = 0.7:0.05:1.5;
y = 0.7:0.05:1.5;
for i = 1:length(x)
for j = 1:length(y)
c(i,j) = y(j)^2 - 2*log(y(j)) - 4*log(x(i)) - 4*(1/x(i));
end
end
contour(x,y,c);xlabel('r/r_c');ylabel('(v/c_s)^2');
xlabel('r/r_c');ylabel('(v/c_s)^2');
colorbar;colormap('parula');
xticks(1:round(length(x)/10):length(x));
xticklabels(x(1:floor(length(x)/10):end));
yticks(1:round(length(y)/10):length(y));
yticklabels(y(1:floor(length(y)/10):end));Alvinhttps://kr.mathworks.com/matlabcentral/profile/authors/14027651-alvin