Tag Archives: matlab
“error 354 “
I have my license at home I’m leaving for holidays, bringing my work from home on a new laptop I go to deactivate the license on the 2 PCs but when installed on the new laptop it continues to give me an error…(I read the discussions on the matter but I don’t understand)
how can I use matlab on my new laptop?I have my license at home I’m leaving for holidays, bringing my work from home on a new laptop I go to deactivate the license on the 2 PCs but when installed on the new laptop it continues to give me an error…(I read the discussions on the matter but I don’t understand)
how can I use matlab on my new laptop? I have my license at home I’m leaving for holidays, bringing my work from home on a new laptop I go to deactivate the license on the 2 PCs but when installed on the new laptop it continues to give me an error…(I read the discussions on the matter but I don’t understand)
how can I use matlab on my new laptop? "error 354 " MATLAB Answers — New Questions
active damping systems design with matlab
I’m a graduate student and my research area is about structural control systems in civil engineering. Especially active damping systems in civil engineering applications. When i looked at internet, i see that these kind of applications are written with matlab. And this programming language is very helpful to civil engineers in this area. So I want to learn matlab for programming this damping device. and simulink for modeling it.
what do you prefer to me? books, tutorials, research papers, anything you can say. but i need you to make attention that the books and tutorials are need to be for civil engineers. not for mech / electrics and electronical engineers. but if you insist that your prefer will be very good for me, please inform me where i can benefit from it. please tell me where i can start?I’m a graduate student and my research area is about structural control systems in civil engineering. Especially active damping systems in civil engineering applications. When i looked at internet, i see that these kind of applications are written with matlab. And this programming language is very helpful to civil engineers in this area. So I want to learn matlab for programming this damping device. and simulink for modeling it.
what do you prefer to me? books, tutorials, research papers, anything you can say. but i need you to make attention that the books and tutorials are need to be for civil engineers. not for mech / electrics and electronical engineers. but if you insist that your prefer will be very good for me, please inform me where i can benefit from it. please tell me where i can start? I’m a graduate student and my research area is about structural control systems in civil engineering. Especially active damping systems in civil engineering applications. When i looked at internet, i see that these kind of applications are written with matlab. And this programming language is very helpful to civil engineers in this area. So I want to learn matlab for programming this damping device. and simulink for modeling it.
what do you prefer to me? books, tutorials, research papers, anything you can say. but i need you to make attention that the books and tutorials are need to be for civil engineers. not for mech / electrics and electronical engineers. but if you insist that your prefer will be very good for me, please inform me where i can benefit from it. please tell me where i can start? active damping, passive damping, structural control systems, performance analysis MATLAB Answers — New Questions
Selectin elements that satisfy a certain condition with modular arithmetic
Suppose I have the finite field F_3={0,1,2}. Suppose I have the following equations:
1=x_1+x_4+x_5
0=x_2+x_5+x_6
0=x_3+x_4+x_6
where each x_i is a member of F_3. How Can I obtain the set of all possible combinations for the solutions of the above equations?
Thanks for any help in advance.Suppose I have the finite field F_3={0,1,2}. Suppose I have the following equations:
1=x_1+x_4+x_5
0=x_2+x_5+x_6
0=x_3+x_4+x_6
where each x_i is a member of F_3. How Can I obtain the set of all possible combinations for the solutions of the above equations?
Thanks for any help in advance. Suppose I have the finite field F_3={0,1,2}. Suppose I have the following equations:
1=x_1+x_4+x_5
0=x_2+x_5+x_6
0=x_3+x_4+x_6
where each x_i is a member of F_3. How Can I obtain the set of all possible combinations for the solutions of the above equations?
Thanks for any help in advance. system of equations, modular arithmetic, finite field MATLAB Answers — New Questions
I am trying to figure out how to use writetable instead of xlswrite, but the feature is converting my numbers to text. Headers are text.
Original Code that works fine
Excel_Sheet = [Excel_head; Excel_out];
xlswrite(‘C:D_LocalMATLABAAAAPhaseII_CA_out.xlsx’,Excel_sheet);
Where Excel_head is a text array and Excel_out is a numberical matrix of values.
New Code that converts the numbers to text
Excel_sheet = table([Excel_head; Excel_out]);
writetable(Excel_sheet,’C:D_LocalMATLABAAAPhaseII_CA_out.xlsx’);
why does it convert? There must be a way of making the table with numbers?
Best regards,
FarleyOriginal Code that works fine
Excel_Sheet = [Excel_head; Excel_out];
xlswrite(‘C:D_LocalMATLABAAAAPhaseII_CA_out.xlsx’,Excel_sheet);
Where Excel_head is a text array and Excel_out is a numberical matrix of values.
New Code that converts the numbers to text
Excel_sheet = table([Excel_head; Excel_out]);
writetable(Excel_sheet,’C:D_LocalMATLABAAAPhaseII_CA_out.xlsx’);
why does it convert? There must be a way of making the table with numbers?
Best regards,
Farley Original Code that works fine
Excel_Sheet = [Excel_head; Excel_out];
xlswrite(‘C:D_LocalMATLABAAAAPhaseII_CA_out.xlsx’,Excel_sheet);
Where Excel_head is a text array and Excel_out is a numberical matrix of values.
New Code that converts the numbers to text
Excel_sheet = table([Excel_head; Excel_out]);
writetable(Excel_sheet,’C:D_LocalMATLABAAAPhaseII_CA_out.xlsx’);
why does it convert? There must be a way of making the table with numbers?
Best regards,
Farley excel, spreadsheet, xlswrite, writetable, converts to text MATLAB Answers — New Questions
solving coupled differential equations using ode45 for “n” modes
Hello everyone,
I am trying to solve some differential equation in matlab using ode45. The equations are as shown below:
I have written the equations in state space form where ydot_1(i) is , ydot_2(i) is , ydot_3(i) is and ydot_4(i) is . In the equation of motion of x, eq.2, x terms are not in terms of “ i “ but I have written them like that (so ydot_3(i) is and ydot_4(i) is ) because of the loop that I use on the function below. So the “for” loop, for each time step, solves first the ydot terms for each mode for i = 1:n and then gets out of the loop, goes to the new time step and then solve again for each mode. However, since for each time step it will start from the first mode, and ydot_1(i) and ydot_2(i) depend on ydot_3(i) and ydot_4(i) , then I am solving the equation of x, eq.2, for each mode. For the new time step, before starting with the first mode again I am defining the
ydot_1=y(1:n); %displacement beam
ydot_2=y(n+1:2*n); %velocity beam
ydot_3=y(2*n+1:3*n); %displacement mass
ydot_4=y(3*n+1:4*n); %velocity mass
v_m=0;
x_m=0;
x_c_prev = x_c_prev_modes{1};
so it can start with the data from the previous first mode (first mode of the previous time step).
My problem is that when I solve for 1 mode only, so for n=1 and get the solution du_1= y(:,n+i).*sin(i*pi.* x_c_values_new); and then solve for n=2 but still get the solution du_1= y(:,n+i).*sin(i*pi.* x_c_values_new); for the first mode only, these first modes do not match. The solution have the same shape but differ in amplitude. The same happens with I use n=20, for example, but again plot only the first mode du_1. The solution changes from the first mode obtained when n=2 and from the first mode obtained for n=1. I have checked for days and cant see my mistake so have reached desperation.
Would really appreciate your help! Thank youuu!
clear all
clc
global xi xi_b r_w r_m mu_s mu_k v alpha P l a w l_0 n x_c_prev x_c_prev_modes
dt=0.01;
tspan = (0:dt:150).’;
% parameters
xi=0.14;
xi_b=0.0025;
r_w=4.5;
r_m=4.8;
mu_s=0.5;
mu_k=0.2 ;
alpha=300;
P=0.002;
l=1/75;
l_0=0.25;
a=0;
w=9;
v=0.005;
% Initialize y_c_prev and the array to store x_c values
x_c_prev = 0;
global t_values x_c_values; % Declare t_values and x_c_values as global
t_values = tspan; % Store time values
x_c_values = zeros(size(tspan)); % Initialize array to store x_c values
n=1;
y0 = zeros(4*n,1);
y0(3*n+1) = -v;
% Initialize y_c_prev
x_c_prev = 0;
% Define your initial value for x_c_prev
x_c_prev_initial = 0;
% Initialize x_c_prev_modes, assuming you have ‘n’ modes
x_c_prev_modes = cell(1, n);
% Initialize the first mode’s x_c_prev
x_c_prev_modes{1} = x_c_prev_initial;
[t,y] = ode45(@rhs_cont4,tspan,y0);
zero_indices = find(x_c_values == 0);
% Iterate over zero indices and replace with mean of neighboring non-zero elements
for i = 1:length(zero_indices)
idx = zero_indices(i);
left_idx = idx – 1;
right_idx = idx + 1;
% Find the nearest non-zero elements
while left_idx > 0 && x_c_values(left_idx) == 0
left_idx = left_idx – 1;
end
while right_idx <= length(x_c_values) && x_c_values(right_idx) == 0
right_idx = right_idx + 1;
end
% Replace zero with mean of neighboring non-zero elements
if left_idx > 0 && right_idx <= length(x_c_values)
x_c_values(idx) = (x_c_values(left_idx) + x_c_values(right_idx)) / 2;
elseif left_idx > 0
x_c_values(idx) = x_c_values(left_idx);
elseif right_idx <= length(x_c_values)
x_c_values(idx) = x_c_values(right_idx);
else
% If there are no non-zero neighbors, we can’t replace it, so skip
continue;
end
end
x_c_values_new=x_c_values;
for i=1:1
u_1= y(:,i).*sin(i*pi.* x_c_values_new);
du_1= y(:,n+i).*sin(i*pi.* x_c_values_new);
end
figure
plot(t,du_1)
legend("beam vel mode 1")
and the function is saved separately
function ydot=rhs_cont4(t,y)
global xi xi_b r_w r_m mu_s mu_k v alpha P a w l_0 n x_c_prev x_c_prev_modes
ydot_1=y(1:n); %displacement beam
ydot_2=y(n+1:2*n); %velocity beam
ydot_3=y(2*n+1:3*n); %displacement mass
ydot_4=y(3*n+1:4*n); %velocity mass
v_m=0;
x_m=0;
x_c_prev = x_c_prev_modes{1};
for i = 1:n
x_m=y(i)*sin(i*pi*x_c_prev)+x_m;
x_c=y(2*n+i)+v*t+l_0-x_m;
x_c_prev = x_c; % Update x_c_prev for the next iteration
x_c_prev_modes{i} = x_c_prev;
%Store x_c values at the corresponding time step
global t_values x_c_values; % Access global variables
[~, idx] = min(abs(t – t_values)); % Find the index of the closest time step
x_c_values(idx) = x_c; % Store x_c at the corresponding time step
v_m=y(n+i)*sin(i*pi*x_c)+v_m;
ydot_1(i) = y(n+i);
ydot_2(i) = -2*xi_b*r_w*y(n+i)-(r_w*i)^2*y(i)+2*sign(y(3*n+i)+v-v_m)*(mu_k+(mu_s-mu_k)*exp(-alpha*abs(y(3*n+i)+v-v_m)))*P*sin(i*pi*x_c);
ydot_3(i) =y(3*n+i);
ydot_4(i) =-2*xi*y(3*n+i)-y(2*n+i)-r_m*sign(y(3*n+i)+v-v_m)*(mu_k+(mu_s-mu_k)*exp(-alpha*abs(y(3*n+i)+v-v_m)))*P+a*w^2*sin(w*t);
end
ydot = [ydot_1; ydot_2; ydot_3; ydot_4];
endHello everyone,
I am trying to solve some differential equation in matlab using ode45. The equations are as shown below:
I have written the equations in state space form where ydot_1(i) is , ydot_2(i) is , ydot_3(i) is and ydot_4(i) is . In the equation of motion of x, eq.2, x terms are not in terms of “ i “ but I have written them like that (so ydot_3(i) is and ydot_4(i) is ) because of the loop that I use on the function below. So the “for” loop, for each time step, solves first the ydot terms for each mode for i = 1:n and then gets out of the loop, goes to the new time step and then solve again for each mode. However, since for each time step it will start from the first mode, and ydot_1(i) and ydot_2(i) depend on ydot_3(i) and ydot_4(i) , then I am solving the equation of x, eq.2, for each mode. For the new time step, before starting with the first mode again I am defining the
ydot_1=y(1:n); %displacement beam
ydot_2=y(n+1:2*n); %velocity beam
ydot_3=y(2*n+1:3*n); %displacement mass
ydot_4=y(3*n+1:4*n); %velocity mass
v_m=0;
x_m=0;
x_c_prev = x_c_prev_modes{1};
so it can start with the data from the previous first mode (first mode of the previous time step).
My problem is that when I solve for 1 mode only, so for n=1 and get the solution du_1= y(:,n+i).*sin(i*pi.* x_c_values_new); and then solve for n=2 but still get the solution du_1= y(:,n+i).*sin(i*pi.* x_c_values_new); for the first mode only, these first modes do not match. The solution have the same shape but differ in amplitude. The same happens with I use n=20, for example, but again plot only the first mode du_1. The solution changes from the first mode obtained when n=2 and from the first mode obtained for n=1. I have checked for days and cant see my mistake so have reached desperation.
Would really appreciate your help! Thank youuu!
clear all
clc
global xi xi_b r_w r_m mu_s mu_k v alpha P l a w l_0 n x_c_prev x_c_prev_modes
dt=0.01;
tspan = (0:dt:150).’;
% parameters
xi=0.14;
xi_b=0.0025;
r_w=4.5;
r_m=4.8;
mu_s=0.5;
mu_k=0.2 ;
alpha=300;
P=0.002;
l=1/75;
l_0=0.25;
a=0;
w=9;
v=0.005;
% Initialize y_c_prev and the array to store x_c values
x_c_prev = 0;
global t_values x_c_values; % Declare t_values and x_c_values as global
t_values = tspan; % Store time values
x_c_values = zeros(size(tspan)); % Initialize array to store x_c values
n=1;
y0 = zeros(4*n,1);
y0(3*n+1) = -v;
% Initialize y_c_prev
x_c_prev = 0;
% Define your initial value for x_c_prev
x_c_prev_initial = 0;
% Initialize x_c_prev_modes, assuming you have ‘n’ modes
x_c_prev_modes = cell(1, n);
% Initialize the first mode’s x_c_prev
x_c_prev_modes{1} = x_c_prev_initial;
[t,y] = ode45(@rhs_cont4,tspan,y0);
zero_indices = find(x_c_values == 0);
% Iterate over zero indices and replace with mean of neighboring non-zero elements
for i = 1:length(zero_indices)
idx = zero_indices(i);
left_idx = idx – 1;
right_idx = idx + 1;
% Find the nearest non-zero elements
while left_idx > 0 && x_c_values(left_idx) == 0
left_idx = left_idx – 1;
end
while right_idx <= length(x_c_values) && x_c_values(right_idx) == 0
right_idx = right_idx + 1;
end
% Replace zero with mean of neighboring non-zero elements
if left_idx > 0 && right_idx <= length(x_c_values)
x_c_values(idx) = (x_c_values(left_idx) + x_c_values(right_idx)) / 2;
elseif left_idx > 0
x_c_values(idx) = x_c_values(left_idx);
elseif right_idx <= length(x_c_values)
x_c_values(idx) = x_c_values(right_idx);
else
% If there are no non-zero neighbors, we can’t replace it, so skip
continue;
end
end
x_c_values_new=x_c_values;
for i=1:1
u_1= y(:,i).*sin(i*pi.* x_c_values_new);
du_1= y(:,n+i).*sin(i*pi.* x_c_values_new);
end
figure
plot(t,du_1)
legend("beam vel mode 1")
and the function is saved separately
function ydot=rhs_cont4(t,y)
global xi xi_b r_w r_m mu_s mu_k v alpha P a w l_0 n x_c_prev x_c_prev_modes
ydot_1=y(1:n); %displacement beam
ydot_2=y(n+1:2*n); %velocity beam
ydot_3=y(2*n+1:3*n); %displacement mass
ydot_4=y(3*n+1:4*n); %velocity mass
v_m=0;
x_m=0;
x_c_prev = x_c_prev_modes{1};
for i = 1:n
x_m=y(i)*sin(i*pi*x_c_prev)+x_m;
x_c=y(2*n+i)+v*t+l_0-x_m;
x_c_prev = x_c; % Update x_c_prev for the next iteration
x_c_prev_modes{i} = x_c_prev;
%Store x_c values at the corresponding time step
global t_values x_c_values; % Access global variables
[~, idx] = min(abs(t – t_values)); % Find the index of the closest time step
x_c_values(idx) = x_c; % Store x_c at the corresponding time step
v_m=y(n+i)*sin(i*pi*x_c)+v_m;
ydot_1(i) = y(n+i);
ydot_2(i) = -2*xi_b*r_w*y(n+i)-(r_w*i)^2*y(i)+2*sign(y(3*n+i)+v-v_m)*(mu_k+(mu_s-mu_k)*exp(-alpha*abs(y(3*n+i)+v-v_m)))*P*sin(i*pi*x_c);
ydot_3(i) =y(3*n+i);
ydot_4(i) =-2*xi*y(3*n+i)-y(2*n+i)-r_m*sign(y(3*n+i)+v-v_m)*(mu_k+(mu_s-mu_k)*exp(-alpha*abs(y(3*n+i)+v-v_m)))*P+a*w^2*sin(w*t);
end
ydot = [ydot_1; ydot_2; ydot_3; ydot_4];
end Hello everyone,
I am trying to solve some differential equation in matlab using ode45. The equations are as shown below:
I have written the equations in state space form where ydot_1(i) is , ydot_2(i) is , ydot_3(i) is and ydot_4(i) is . In the equation of motion of x, eq.2, x terms are not in terms of “ i “ but I have written them like that (so ydot_3(i) is and ydot_4(i) is ) because of the loop that I use on the function below. So the “for” loop, for each time step, solves first the ydot terms for each mode for i = 1:n and then gets out of the loop, goes to the new time step and then solve again for each mode. However, since for each time step it will start from the first mode, and ydot_1(i) and ydot_2(i) depend on ydot_3(i) and ydot_4(i) , then I am solving the equation of x, eq.2, for each mode. For the new time step, before starting with the first mode again I am defining the
ydot_1=y(1:n); %displacement beam
ydot_2=y(n+1:2*n); %velocity beam
ydot_3=y(2*n+1:3*n); %displacement mass
ydot_4=y(3*n+1:4*n); %velocity mass
v_m=0;
x_m=0;
x_c_prev = x_c_prev_modes{1};
so it can start with the data from the previous first mode (first mode of the previous time step).
My problem is that when I solve for 1 mode only, so for n=1 and get the solution du_1= y(:,n+i).*sin(i*pi.* x_c_values_new); and then solve for n=2 but still get the solution du_1= y(:,n+i).*sin(i*pi.* x_c_values_new); for the first mode only, these first modes do not match. The solution have the same shape but differ in amplitude. The same happens with I use n=20, for example, but again plot only the first mode du_1. The solution changes from the first mode obtained when n=2 and from the first mode obtained for n=1. I have checked for days and cant see my mistake so have reached desperation.
Would really appreciate your help! Thank youuu!
clear all
clc
global xi xi_b r_w r_m mu_s mu_k v alpha P l a w l_0 n x_c_prev x_c_prev_modes
dt=0.01;
tspan = (0:dt:150).’;
% parameters
xi=0.14;
xi_b=0.0025;
r_w=4.5;
r_m=4.8;
mu_s=0.5;
mu_k=0.2 ;
alpha=300;
P=0.002;
l=1/75;
l_0=0.25;
a=0;
w=9;
v=0.005;
% Initialize y_c_prev and the array to store x_c values
x_c_prev = 0;
global t_values x_c_values; % Declare t_values and x_c_values as global
t_values = tspan; % Store time values
x_c_values = zeros(size(tspan)); % Initialize array to store x_c values
n=1;
y0 = zeros(4*n,1);
y0(3*n+1) = -v;
% Initialize y_c_prev
x_c_prev = 0;
% Define your initial value for x_c_prev
x_c_prev_initial = 0;
% Initialize x_c_prev_modes, assuming you have ‘n’ modes
x_c_prev_modes = cell(1, n);
% Initialize the first mode’s x_c_prev
x_c_prev_modes{1} = x_c_prev_initial;
[t,y] = ode45(@rhs_cont4,tspan,y0);
zero_indices = find(x_c_values == 0);
% Iterate over zero indices and replace with mean of neighboring non-zero elements
for i = 1:length(zero_indices)
idx = zero_indices(i);
left_idx = idx – 1;
right_idx = idx + 1;
% Find the nearest non-zero elements
while left_idx > 0 && x_c_values(left_idx) == 0
left_idx = left_idx – 1;
end
while right_idx <= length(x_c_values) && x_c_values(right_idx) == 0
right_idx = right_idx + 1;
end
% Replace zero with mean of neighboring non-zero elements
if left_idx > 0 && right_idx <= length(x_c_values)
x_c_values(idx) = (x_c_values(left_idx) + x_c_values(right_idx)) / 2;
elseif left_idx > 0
x_c_values(idx) = x_c_values(left_idx);
elseif right_idx <= length(x_c_values)
x_c_values(idx) = x_c_values(right_idx);
else
% If there are no non-zero neighbors, we can’t replace it, so skip
continue;
end
end
x_c_values_new=x_c_values;
for i=1:1
u_1= y(:,i).*sin(i*pi.* x_c_values_new);
du_1= y(:,n+i).*sin(i*pi.* x_c_values_new);
end
figure
plot(t,du_1)
legend("beam vel mode 1")
and the function is saved separately
function ydot=rhs_cont4(t,y)
global xi xi_b r_w r_m mu_s mu_k v alpha P a w l_0 n x_c_prev x_c_prev_modes
ydot_1=y(1:n); %displacement beam
ydot_2=y(n+1:2*n); %velocity beam
ydot_3=y(2*n+1:3*n); %displacement mass
ydot_4=y(3*n+1:4*n); %velocity mass
v_m=0;
x_m=0;
x_c_prev = x_c_prev_modes{1};
for i = 1:n
x_m=y(i)*sin(i*pi*x_c_prev)+x_m;
x_c=y(2*n+i)+v*t+l_0-x_m;
x_c_prev = x_c; % Update x_c_prev for the next iteration
x_c_prev_modes{i} = x_c_prev;
%Store x_c values at the corresponding time step
global t_values x_c_values; % Access global variables
[~, idx] = min(abs(t – t_values)); % Find the index of the closest time step
x_c_values(idx) = x_c; % Store x_c at the corresponding time step
v_m=y(n+i)*sin(i*pi*x_c)+v_m;
ydot_1(i) = y(n+i);
ydot_2(i) = -2*xi_b*r_w*y(n+i)-(r_w*i)^2*y(i)+2*sign(y(3*n+i)+v-v_m)*(mu_k+(mu_s-mu_k)*exp(-alpha*abs(y(3*n+i)+v-v_m)))*P*sin(i*pi*x_c);
ydot_3(i) =y(3*n+i);
ydot_4(i) =-2*xi*y(3*n+i)-y(2*n+i)-r_m*sign(y(3*n+i)+v-v_m)*(mu_k+(mu_s-mu_k)*exp(-alpha*abs(y(3*n+i)+v-v_m)))*P+a*w^2*sin(w*t);
end
ydot = [ydot_1; ydot_2; ydot_3; ydot_4];
end ode45, differential equations, for loop MATLAB Answers — New Questions
Matlab publish to pdf unicode characters print statements
I am trying to publish my code to pdf and use unicode characters as mathmatical variables. A simplified example would be:
% delta
fprintf(‘x03B4n’)
Output:
δ
I would like this to show up in the published pdf but the output is replaced with ‘#’ instead.I am trying to publish my code to pdf and use unicode characters as mathmatical variables. A simplified example would be:
% delta
fprintf(‘x03B4n’)
Output:
δ
I would like this to show up in the published pdf but the output is replaced with ‘#’ instead. I am trying to publish my code to pdf and use unicode characters as mathmatical variables. A simplified example would be:
% delta
fprintf(‘x03B4n’)
Output:
δ
I would like this to show up in the published pdf but the output is replaced with ‘#’ instead. matlab, fprintf MATLAB Answers — New Questions
Not recognizing any text files in folder using dir(fullfile)
I am trying to plot data from multiple text csv files in a folder. This is the first part of my code:
folder_path = ‘C:userspowerdownloadsstar capillary files’; % Replace with your folder path
% List all TXT files in the folder
txt_files = dir(fullfile(folder_path, ‘*.txt’));
for file_idx = 1:length(txt_files)
filename = fullfile(folder_path, txt_files(file_idx).name);
% Load the TXT file
data = readtable(filename, ‘Delimiter’, ‘,’);
Matlab is not recognizing that there are text files in my folder, though there are. I wrote a similar code to make calculations from a single txt file in that folder and it works. Does anyone know why it might not be recognizing txt files with this code? I added the folder to path in the matlab software by right clicking. Any help would be extremely appreciated!I am trying to plot data from multiple text csv files in a folder. This is the first part of my code:
folder_path = ‘C:userspowerdownloadsstar capillary files’; % Replace with your folder path
% List all TXT files in the folder
txt_files = dir(fullfile(folder_path, ‘*.txt’));
for file_idx = 1:length(txt_files)
filename = fullfile(folder_path, txt_files(file_idx).name);
% Load the TXT file
data = readtable(filename, ‘Delimiter’, ‘,’);
Matlab is not recognizing that there are text files in my folder, though there are. I wrote a similar code to make calculations from a single txt file in that folder and it works. Does anyone know why it might not be recognizing txt files with this code? I added the folder to path in the matlab software by right clicking. Any help would be extremely appreciated! I am trying to plot data from multiple text csv files in a folder. This is the first part of my code:
folder_path = ‘C:userspowerdownloadsstar capillary files’; % Replace with your folder path
% List all TXT files in the folder
txt_files = dir(fullfile(folder_path, ‘*.txt’));
for file_idx = 1:length(txt_files)
filename = fullfile(folder_path, txt_files(file_idx).name);
% Load the TXT file
data = readtable(filename, ‘Delimiter’, ‘,’);
Matlab is not recognizing that there are text files in my folder, though there are. I wrote a similar code to make calculations from a single txt file in that folder and it works. Does anyone know why it might not be recognizing txt files with this code? I added the folder to path in the matlab software by right clicking. Any help would be extremely appreciated! text file MATLAB Answers — New Questions
Hi, I am applying findpeaks function to find the peaks of an oscilloscope signal but in the peak plot graph it is automatically changing the x-label with a large difference.
Can there be any command so that x-label will not change and it will remain same as my signal plot as it is creating a lot of confusion . please help me on an urgent note.Can there be any command so that x-label will not change and it will remain same as my signal plot as it is creating a lot of confusion . please help me on an urgent note. Can there be any command so that x-label will not change and it will remain same as my signal plot as it is creating a lot of confusion . please help me on an urgent note. #findpeaks, #signalprocessing #rockcharacterization MATLAB Answers — New Questions
Alternatives to ‘For Each subsystem’ that are compatible with global data outside the subsystem
Hello all,
For a project, I am making use of the For Each subsystem in my Simulink model. I have a set of values for one of the input variables of the block and the goal is to have Simulink generate a set of outputs for each input value. The number of input and output will be different with configurations "N". The For Each subsystem works great for this purpose, but unfortunately the Coder cannot convert it to C code. How could I make use an N as exportgloabl with For Each subsystem?Hello all,
For a project, I am making use of the For Each subsystem in my Simulink model. I have a set of values for one of the input variables of the block and the goal is to have Simulink generate a set of outputs for each input value. The number of input and output will be different with configurations "N". The For Each subsystem works great for this purpose, but unfortunately the Coder cannot convert it to C code. How could I make use an N as exportgloabl with For Each subsystem? Hello all,
For a project, I am making use of the For Each subsystem in my Simulink model. I have a set of values for one of the input variables of the block and the goal is to have Simulink generate a set of outputs for each input value. The number of input and output will be different with configurations "N". The For Each subsystem works great for this purpose, but unfortunately the Coder cannot convert it to C code. How could I make use an N as exportgloabl with For Each subsystem? for each, config, global MATLAB Answers — New Questions
How to measure time of matrix multiplication in matab?
I am using R2023b in case that is important.
For the sake of a project, I am trying to measure the average time of matlab when it multiplies a 96 x 192 matrix with a 192 x 1 matrix.
I have used the following code:
repeats = 100;
tTot = 0;
m = 96;
n = 192;
for j = 0:repeats
A = rand([m,n]);
A(:,1) = 1;
b = rand([n,1]);
tic
c = A * b;
tTot = tTot + toc;
end
tAvg = tTot/repeats
I have run this script a few times on my computer with different values for "repeats":
If I set repeats to 1, I get the time it takes to complete a matrix multiplication is ~1.25e-04
If I set repeats to 10, I get the time it takes to complete a matrix multiplication is ~8.75e-05
If I set repeats to 100, I get the time it takes to complete a matrix multiplication is ~5e-06
It seems quite strange to me that the average changed so much if I increase the value for repeats, so my questions are: Am I doing something wrong when I am measuring the average time? If yes, what am I doing wrong?I am using R2023b in case that is important.
For the sake of a project, I am trying to measure the average time of matlab when it multiplies a 96 x 192 matrix with a 192 x 1 matrix.
I have used the following code:
repeats = 100;
tTot = 0;
m = 96;
n = 192;
for j = 0:repeats
A = rand([m,n]);
A(:,1) = 1;
b = rand([n,1]);
tic
c = A * b;
tTot = tTot + toc;
end
tAvg = tTot/repeats
I have run this script a few times on my computer with different values for "repeats":
If I set repeats to 1, I get the time it takes to complete a matrix multiplication is ~1.25e-04
If I set repeats to 10, I get the time it takes to complete a matrix multiplication is ~8.75e-05
If I set repeats to 100, I get the time it takes to complete a matrix multiplication is ~5e-06
It seems quite strange to me that the average changed so much if I increase the value for repeats, so my questions are: Am I doing something wrong when I am measuring the average time? If yes, what am I doing wrong? I am using R2023b in case that is important.
For the sake of a project, I am trying to measure the average time of matlab when it multiplies a 96 x 192 matrix with a 192 x 1 matrix.
I have used the following code:
repeats = 100;
tTot = 0;
m = 96;
n = 192;
for j = 0:repeats
A = rand([m,n]);
A(:,1) = 1;
b = rand([n,1]);
tic
c = A * b;
tTot = tTot + toc;
end
tAvg = tTot/repeats
I have run this script a few times on my computer with different values for "repeats":
If I set repeats to 1, I get the time it takes to complete a matrix multiplication is ~1.25e-04
If I set repeats to 10, I get the time it takes to complete a matrix multiplication is ~8.75e-05
If I set repeats to 100, I get the time it takes to complete a matrix multiplication is ~5e-06
It seems quite strange to me that the average changed so much if I increase the value for repeats, so my questions are: Am I doing something wrong when I am measuring the average time? If yes, what am I doing wrong? matrix multiplication, time, measuring performance, tic toc MATLAB Answers — New Questions
Video for stacked plot
Is there a function which seeks through the stacked plot as a video. I have a 15000 data points,
s=stackedplot(data)
Can we save this stacked plot as a video ?Is there a function which seeks through the stacked plot as a video. I have a 15000 data points,
s=stackedplot(data)
Can we save this stacked plot as a video ? Is there a function which seeks through the stacked plot as a video. I have a 15000 data points,
s=stackedplot(data)
Can we save this stacked plot as a video ? stackedplot, video, graph to video MATLAB Answers — New Questions
solving symbolic equations with partial derivatives
hello, I can’t find a solution to the following problem: i am trying to solve symbolically some equations which include partial derivatives and a change of reference.
Here is the code:
syms Cf(zf, zr) Cr(zf, zr) theta z L
z = zf;
theta = (zf – zr)/L;
Cf_z = diff(Cf, z);
Cf_f = diff(Cf, zf);
Cf_r = diff(Cf, zr);
Cf_theta = diff(Cf, theta);
eqn = [diff(Cf, z)*diff(z, zf) + diff(Cf, theta)*diff(theta, zf) == diff(Cf, zf), diff(Cf, z)*diff(z, zr) + diff(Cf, theta)*diff(theta, zr) == diff(Cf, zr)];
S= solve(eqn)
when i run this, the following error appears:
"Second argument must be a variable or a nonnegative integer specifying the number of differentiations." (@ line 7) because i doesn’t recognize theta as a variable of Cf. How can i make the change of reference effective so that it can calculate the partial derivatives of Cf in the new reference z, theta?
thank you very muchhello, I can’t find a solution to the following problem: i am trying to solve symbolically some equations which include partial derivatives and a change of reference.
Here is the code:
syms Cf(zf, zr) Cr(zf, zr) theta z L
z = zf;
theta = (zf – zr)/L;
Cf_z = diff(Cf, z);
Cf_f = diff(Cf, zf);
Cf_r = diff(Cf, zr);
Cf_theta = diff(Cf, theta);
eqn = [diff(Cf, z)*diff(z, zf) + diff(Cf, theta)*diff(theta, zf) == diff(Cf, zf), diff(Cf, z)*diff(z, zr) + diff(Cf, theta)*diff(theta, zr) == diff(Cf, zr)];
S= solve(eqn)
when i run this, the following error appears:
"Second argument must be a variable or a nonnegative integer specifying the number of differentiations." (@ line 7) because i doesn’t recognize theta as a variable of Cf. How can i make the change of reference effective so that it can calculate the partial derivatives of Cf in the new reference z, theta?
thank you very much hello, I can’t find a solution to the following problem: i am trying to solve symbolically some equations which include partial derivatives and a change of reference.
Here is the code:
syms Cf(zf, zr) Cr(zf, zr) theta z L
z = zf;
theta = (zf – zr)/L;
Cf_z = diff(Cf, z);
Cf_f = diff(Cf, zf);
Cf_r = diff(Cf, zr);
Cf_theta = diff(Cf, theta);
eqn = [diff(Cf, z)*diff(z, zf) + diff(Cf, theta)*diff(theta, zf) == diff(Cf, zf), diff(Cf, z)*diff(z, zr) + diff(Cf, theta)*diff(theta, zr) == diff(Cf, zr)];
S= solve(eqn)
when i run this, the following error appears:
"Second argument must be a variable or a nonnegative integer specifying the number of differentiations." (@ line 7) because i doesn’t recognize theta as a variable of Cf. How can i make the change of reference effective so that it can calculate the partial derivatives of Cf in the new reference z, theta?
thank you very much symbolic, symbolic math, symbolic math toolbox, derivatives, solve MATLAB Answers — New Questions
How to pick all elements from a set that satisfy a certain condition?
Let’s say I have a set of numbers A=-5,-4,-3,-2,-1,0,1,2,3,4,5
and I want to pick those pairs that give a sum of 1. For example, -2 and 3 is one possible pair, but how do we display all such pairs?
Any help will be much appreciated.Let’s say I have a set of numbers A=-5,-4,-3,-2,-1,0,1,2,3,4,5
and I want to pick those pairs that give a sum of 1. For example, -2 and 3 is one possible pair, but how do we display all such pairs?
Any help will be much appreciated. Let’s say I have a set of numbers A=-5,-4,-3,-2,-1,0,1,2,3,4,5
and I want to pick those pairs that give a sum of 1. For example, -2 and 3 is one possible pair, but how do we display all such pairs?
Any help will be much appreciated. matlab code, selecting elements from a set MATLAB Answers — New Questions
How to solve type mismatch error when assigning variable to class in conditional?
Example Code:
1 flag = true;
2 if flag
3 this.prop = TFlag();
4 else
5 this.prop = FFlag();
6 end
Error Code:
Type name mismatch: TFlag ~= FFlag.
In the diagnostic report, the error is shown in line 5, where this.prop cannot be assigned FFlag() because it is understood as a varible of class type TFlag().
Question:
It appears that this.prop is being intialized as a variable of class type TFlag regardless of the condition, and I am unable to run this conditional. It should also be noted that the constructor method of each of these classes returns a struct(), but they are different sizes. TFlag returns a struct of size 30, and FFlag returns a struct of size 10.Example Code:
1 flag = true;
2 if flag
3 this.prop = TFlag();
4 else
5 this.prop = FFlag();
6 end
Error Code:
Type name mismatch: TFlag ~= FFlag.
In the diagnostic report, the error is shown in line 5, where this.prop cannot be assigned FFlag() because it is understood as a varible of class type TFlag().
Question:
It appears that this.prop is being intialized as a variable of class type TFlag regardless of the condition, and I am unable to run this conditional. It should also be noted that the constructor method of each of these classes returns a struct(), but they are different sizes. TFlag returns a struct of size 30, and FFlag returns a struct of size 10. Example Code:
1 flag = true;
2 if flag
3 this.prop = TFlag();
4 else
5 this.prop = FFlag();
6 end
Error Code:
Type name mismatch: TFlag ~= FFlag.
In the diagnostic report, the error is shown in line 5, where this.prop cannot be assigned FFlag() because it is understood as a varible of class type TFlag().
Question:
It appears that this.prop is being intialized as a variable of class type TFlag regardless of the condition, and I am unable to run this conditional. It should also be noted that the constructor method of each of these classes returns a struct(), but they are different sizes. TFlag returns a struct of size 30, and FFlag returns a struct of size 10. matlab, code generation MATLAB Answers — New Questions
How can I determine the update release number of MATLAB I am using in MATLAB R2022b and later?
I can no longer determine what update release number of MATLAB I am using when running the following commands
>> version -description
ans =
0×0 empty char array
>> ver -support
MATLAB Version: 9.13.0.2049777 (R2022b)
It is important to know which version of MATLAB my team members and I are using. Please advise me on where I can find this information.I can no longer determine what update release number of MATLAB I am using when running the following commands
>> version -description
ans =
0×0 empty char array
>> ver -support
MATLAB Version: 9.13.0.2049777 (R2022b)
It is important to know which version of MATLAB my team members and I are using. Please advise me on where I can find this information. I can no longer determine what update release number of MATLAB I am using when running the following commands
>> version -description
ans =
0×0 empty char array
>> ver -support
MATLAB Version: 9.13.0.2049777 (R2022b)
It is important to know which version of MATLAB my team members and I are using. Please advise me on where I can find this information. package, release, number, version MATLAB Answers — New Questions
Fill colour in a scatter plot
I neet to fill the graph for with light grey colour and remaining graph with a darker shade. Also two different pattern as backgrounds can also work.I neet to fill the graph for with light grey colour and remaining graph with a darker shade. Also two different pattern as backgrounds can also work. I neet to fill the graph for with light grey colour and remaining graph with a darker shade. Also two different pattern as backgrounds can also work. scatter plot, graph MATLAB Answers — New Questions
How to deploy simulink dashboard to app designer
I use a lot of customizable block for the simulation demo like vertical gauge, slider, etc.
now i want to create standalone app, which i believe i need to create a new GUI using app designer.
However, there is no customizable vertical gauge on App designer’s library component.
Is there any way to "copy+paste" simulink dashboard to App designer ?I use a lot of customizable block for the simulation demo like vertical gauge, slider, etc.
now i want to create standalone app, which i believe i need to create a new GUI using app designer.
However, there is no customizable vertical gauge on App designer’s library component.
Is there any way to "copy+paste" simulink dashboard to App designer ? I use a lot of customizable block for the simulation demo like vertical gauge, slider, etc.
now i want to create standalone app, which i believe i need to create a new GUI using app designer.
However, there is no customizable vertical gauge on App designer’s library component.
Is there any way to "copy+paste" simulink dashboard to App designer ? simulink dashboard, appdesigner, standalone application MATLAB Answers — New Questions
dicominfo showing more fields in Windows than Linux OS
I was looking for a private tag (07A3,1018) as I’ve seen it in MicroDicom viewer on my Windows workstation, however I cannot find this field after I transfer the images to the Linux workstation and read it using dicominfo. After a little research (on and off for 3 weeks…), I found dicominfo gave different number of attributes in Windows and Linux OS on the same file. DICOMs are from SIEMENS Prisma and Biograph_mCT.
In Windows (MATLAB version R2020a), dicominfo gave 186 attributes after executing:
attrs = builtin(‘_dicomparse’, fileDetails.name, …
fileDetails.bytes, …
getMachineEndian, …
false, …
dictionary, …
args.UseVRHeuristic);
In Linux (MATLAB version R2023a), dicominfo only gave 123 attributes after executing:
attrs = images.internal.builtins.dicomparse(fileDetails.name, …
fileDetails.bytes, …
getMachineEndian, …
false, …
dictionary, …
args.UseVRHeuristic);
I don’t know what’s the difference in this "dicomparse" built-in function (I didn’t find them anywhere in MATLAB installation directory) but the Linux one seems missing ELSCINT1 groups (like 07A1, 07A3, 07A5).
Would really appreciate it if there’s anything can get them back under Linux.I was looking for a private tag (07A3,1018) as I’ve seen it in MicroDicom viewer on my Windows workstation, however I cannot find this field after I transfer the images to the Linux workstation and read it using dicominfo. After a little research (on and off for 3 weeks…), I found dicominfo gave different number of attributes in Windows and Linux OS on the same file. DICOMs are from SIEMENS Prisma and Biograph_mCT.
In Windows (MATLAB version R2020a), dicominfo gave 186 attributes after executing:
attrs = builtin(‘_dicomparse’, fileDetails.name, …
fileDetails.bytes, …
getMachineEndian, …
false, …
dictionary, …
args.UseVRHeuristic);
In Linux (MATLAB version R2023a), dicominfo only gave 123 attributes after executing:
attrs = images.internal.builtins.dicomparse(fileDetails.name, …
fileDetails.bytes, …
getMachineEndian, …
false, …
dictionary, …
args.UseVRHeuristic);
I don’t know what’s the difference in this "dicomparse" built-in function (I didn’t find them anywhere in MATLAB installation directory) but the Linux one seems missing ELSCINT1 groups (like 07A1, 07A3, 07A5).
Would really appreciate it if there’s anything can get them back under Linux. I was looking for a private tag (07A3,1018) as I’ve seen it in MicroDicom viewer on my Windows workstation, however I cannot find this field after I transfer the images to the Linux workstation and read it using dicominfo. After a little research (on and off for 3 weeks…), I found dicominfo gave different number of attributes in Windows and Linux OS on the same file. DICOMs are from SIEMENS Prisma and Biograph_mCT.
In Windows (MATLAB version R2020a), dicominfo gave 186 attributes after executing:
attrs = builtin(‘_dicomparse’, fileDetails.name, …
fileDetails.bytes, …
getMachineEndian, …
false, …
dictionary, …
args.UseVRHeuristic);
In Linux (MATLAB version R2023a), dicominfo only gave 123 attributes after executing:
attrs = images.internal.builtins.dicomparse(fileDetails.name, …
fileDetails.bytes, …
getMachineEndian, …
false, …
dictionary, …
args.UseVRHeuristic);
I don’t know what’s the difference in this "dicomparse" built-in function (I didn’t find them anywhere in MATLAB installation directory) but the Linux one seems missing ELSCINT1 groups (like 07A1, 07A3, 07A5).
Would really appreciate it if there’s anything can get them back under Linux. dicominfo, operating system, windows, linux, image processing, dicom, os, elscint, dicomparse MATLAB Answers — New Questions
Are Flooded Evaporators modeled already?
Is there a block ready to be used to model a shell and tube flooded evaporator using Ammonia as a refrigerant?Is there a block ready to be used to model a shell and tube flooded evaporator using Ammonia as a refrigerant? Is there a block ready to be used to model a shell and tube flooded evaporator using Ammonia as a refrigerant? heat-transfer, evaporators, simulink, fluids MATLAB Answers — New Questions
Calculations with distributions of variables only
Hi,
I would like to define the distribution of some variables for a design and then calculate the output distribution.
Let make a simple example:
Vout = Vref*(R1/R2 + 1). Now I know the distribution of R1, R2 and Vref, and I would like to know the distibution (mean and variance) of the result. Here I could make it rather quickly on myself, but most of the time I have much more complex designs, with more variables and calculation steps.
Is there a way to define distributions in variables and then work/calculate with them to get the output distribution ?
Thanks community !Hi,
I would like to define the distribution of some variables for a design and then calculate the output distribution.
Let make a simple example:
Vout = Vref*(R1/R2 + 1). Now I know the distribution of R1, R2 and Vref, and I would like to know the distibution (mean and variance) of the result. Here I could make it rather quickly on myself, but most of the time I have much more complex designs, with more variables and calculation steps.
Is there a way to define distributions in variables and then work/calculate with them to get the output distribution ?
Thanks community ! Hi,
I would like to define the distribution of some variables for a design and then calculate the output distribution.
Let make a simple example:
Vout = Vref*(R1/R2 + 1). Now I know the distribution of R1, R2 and Vref, and I would like to know the distibution (mean and variance) of the result. Here I could make it rather quickly on myself, but most of the time I have much more complex designs, with more variables and calculation steps.
Is there a way to define distributions in variables and then work/calculate with them to get the output distribution ?
Thanks community ! distribution, probability, confidence interval, tolerance MATLAB Answers — New Questions