Tag Archives: matlab
How can I modify the lengh of the lines in a LEGEND?
I would like to reduce the length of the lines shown in the legend of a plot in MATLAB.I would like to reduce the length of the lines shown in the legend of a plot in MATLAB. I would like to reduce the length of the lines shown in the legend of a plot in MATLAB. change, specify, dwhhgwait, shrink MATLAB Answers — New Questions
Vertical 3D to Horizontal
I have scatter in 3D, as shown it is vertically, how to make it horizontally
sorry for my broken english
ThanksI have scatter in 3D, as shown it is vertically, how to make it horizontally
sorry for my broken english
Thanks I have scatter in 3D, as shown it is vertically, how to make it horizontally
sorry for my broken english
Thanks image processing, 3d plots MATLAB Answers — New Questions
download 2019b update 3
I can’t find a link on your site to download Matlab 2019b update 3. My organization has utilities that are tested with update 3 and therefor has code that checks for and rejects other updates such as update 4 which your current download link points to. Please tell me the URL to use to download 2019b update 3.I can’t find a link on your site to download Matlab 2019b update 3. My organization has utilities that are tested with update 3 and therefor has code that checks for and rejects other updates such as update 4 which your current download link points to. Please tell me the URL to use to download 2019b update 3. I can’t find a link on your site to download Matlab 2019b update 3. My organization has utilities that are tested with update 3 and therefor has code that checks for and rejects other updates such as update 4 which your current download link points to. Please tell me the URL to use to download 2019b update 3. download 2019b update 3 MATLAB Answers — New Questions
Find the indices of numbers that occur first
X is an array. Find(X, n, 1) gives the index of the first "n" that occurs. Now what of instead of "n" I have a vector like V = [n l m o …]? The elements of V are unique.X is an array. Find(X, n, 1) gives the index of the first "n" that occurs. Now what of instead of "n" I have a vector like V = [n l m o …]? The elements of V are unique. X is an array. Find(X, n, 1) gives the index of the first "n" that occurs. Now what of instead of "n" I have a vector like V = [n l m o …]? The elements of V are unique. find MATLAB Answers — New Questions
plot bar graph based on element type in matrix
I have a 20×100 (t,N) matrix with each element being either 1, 2, or 3. I want to create a bar graph showing the amount of each type of element. so at t=20, of the 100 columns, how many have 1, how many have 2, how many have 3.
Is that possible?I have a 20×100 (t,N) matrix with each element being either 1, 2, or 3. I want to create a bar graph showing the amount of each type of element. so at t=20, of the 100 columns, how many have 1, how many have 2, how many have 3.
Is that possible? I have a 20×100 (t,N) matrix with each element being either 1, 2, or 3. I want to create a bar graph showing the amount of each type of element. so at t=20, of the 100 columns, how many have 1, how many have 2, how many have 3.
Is that possible? bar graph, matrix array, graph MATLAB Answers — New Questions
“File is not a mex file” error despite the settings seeming correct
I am trying to follow the Matlab examples on using mex. I first run
copyfile(fullfile(matlabroot,"extern","examples","mex","yprime.c"),".","f")
and this works, copying the file. I then run
mex yprime.c
which gives me the output
Building with ‘MinGW64 Compiler (C)’.
Error using mex
‘yprime.mexw64’ is not a MEX file. For more information, see File is not a MEX file.
I have ensured that I am using the correct version of the compiler (6.3.0). I am using a 64-bit operating system with 64-bit MATLAB, and running
mexext
returns mexw64 as expected. So I am not sure what the issue could be. I have looked in the "see File is not a MEX file" section of the help and it did not help me resolve the issue.I am trying to follow the Matlab examples on using mex. I first run
copyfile(fullfile(matlabroot,"extern","examples","mex","yprime.c"),".","f")
and this works, copying the file. I then run
mex yprime.c
which gives me the output
Building with ‘MinGW64 Compiler (C)’.
Error using mex
‘yprime.mexw64’ is not a MEX file. For more information, see File is not a MEX file.
I have ensured that I am using the correct version of the compiler (6.3.0). I am using a 64-bit operating system with 64-bit MATLAB, and running
mexext
returns mexw64 as expected. So I am not sure what the issue could be. I have looked in the "see File is not a MEX file" section of the help and it did not help me resolve the issue. I am trying to follow the Matlab examples on using mex. I first run
copyfile(fullfile(matlabroot,"extern","examples","mex","yprime.c"),".","f")
and this works, copying the file. I then run
mex yprime.c
which gives me the output
Building with ‘MinGW64 Compiler (C)’.
Error using mex
‘yprime.mexw64’ is not a MEX file. For more information, see File is not a MEX file.
I have ensured that I am using the correct version of the compiler (6.3.0). I am using a 64-bit operating system with 64-bit MATLAB, and running
mexext
returns mexw64 as expected. So I am not sure what the issue could be. I have looked in the "see File is not a MEX file" section of the help and it did not help me resolve the issue. mex, compiler MATLAB Answers — New Questions
How to create a sequence of intervals
If my data is y= 2,-3,4,-1,6 and my x=-4. is it possible to obtain a sequence of intervals as follows:
intervalle(1)= [-abs(x-y(1)),abs(x-y(1))], intervalle(2)= [-abs(x-y(2)),abs(x-y(2))],… I tried the code:
y=[2 -3 4 -1 6];
x=-4;
n=length(y);
intervalles=[-abs(x-y),abs(x-y)];
for k=1:n
intervalles(k)=[-abs(x-y(k)),abs(x-y(k))];
endIf my data is y= 2,-3,4,-1,6 and my x=-4. is it possible to obtain a sequence of intervals as follows:
intervalle(1)= [-abs(x-y(1)),abs(x-y(1))], intervalle(2)= [-abs(x-y(2)),abs(x-y(2))],… I tried the code:
y=[2 -3 4 -1 6];
x=-4;
n=length(y);
intervalles=[-abs(x-y),abs(x-y)];
for k=1:n
intervalles(k)=[-abs(x-y(k)),abs(x-y(k))];
end If my data is y= 2,-3,4,-1,6 and my x=-4. is it possible to obtain a sequence of intervals as follows:
intervalle(1)= [-abs(x-y(1)),abs(x-y(1))], intervalle(2)= [-abs(x-y(2)),abs(x-y(2))],… I tried the code:
y=[2 -3 4 -1 6];
x=-4;
n=length(y);
intervalles=[-abs(x-y),abs(x-y)];
for k=1:n
intervalles(k)=[-abs(x-y(k)),abs(x-y(k))];
end indexing on intervals, matlab MATLAB Answers — New Questions
Nondimentionalize the 2 DOF equations
Hello all,
I hope you are doing well. I asked a question regarding dimensionalizing the motion equations in 2DOFs. Due to my mistakes, the description is not very clear. As suggested, I post a single question for the same question.
I would like to present the system I want to establish in MATLAB firstly. The absorber consists of a mass, three-spring system in the left fig, and the dashpot.
For the angular velocity , damping ratio, mass ratio , and the stiffness ratio , they are easy to determine. The length of the oblique spring in my code is set to be 2.5m. But it can be various physically.
I am not sure the approach to achieve the nondimensionlized equation is corret or not. Also, I would like to know whether I could use the ratio value only. Specifically, I do not need to set the value.
My codes are also attached. Thank you for your help.
Best wishes,
Yu
clc;
clear all;
tspan = 0:0.25:200;
% Units:
% stiffness: N/m, mass:kg, damping(c_1):Ns/m
% displacement(X):m
% alpha (stiffness ratio):k_o/k_v
% gamma (dimension ratio):a/L (structure length)
% f_opt (frequency ratio): f_1/f_2
% k_v the stiffness of the vertical spring
% k_o the stiffness of the oblique spring
X0 = [0 0 0 0];
%parameters——-
global alpha gamma mu Omega_1 Omega_2 L_0
alpha = 1 % stiffness ratio k_o/k_v
gamma = 2*alpha/(2*alpha+1)
L_0 = 2.5
a = L_0*gamma;
h = sqrt(L_0^2-a^2);
mu = 0.02; % mass ratio
f_opt = 1/(1+mu); % frequency ratio
xi_2 = sqrt(3*mu/8*(1+mu));
Omega_1 = 0.188; % 0.03 Hz angular velocity of the primary structure
Omega_2 = Omega_1*f_opt; % angular velocity of the damper
xi_1 = 0.01; % damping ratio of primary structure
%matrix——–
M = [(1+mu)/(Omega_1^2*L_0) mu/(Omega_1^2*L_0);
1/(Omega_2^2*L_0) 1/(Omega_2^2*L_0)];
C = [2*xi_1/(Omega_1*L_0) 0;
0 2*xi_2/(Omega_2*L_0)];
K = [1/L_0 0;
0 1/L_0];
% state space model——————-
% M: mass matrix, K:stiffness matrix, C:damping matrix
O = zeros(2,2);
I = eye(2);
A = [O I; -inv(M)*K -inv(M)*C];
B = [O; inv(M)];
E = [I O];
D = zeros(2,2);
% solve the equations——————-
options = odeset(‘RelTol’,1e-10,’AbsTol’,1e-10);
[t,X] = ode45(@(t,X) QZSdamper(t,A,B,X),tspan,X0,options);
x = X(:,1:4);
%% plot
figure,
plot(t,x(:,1)); xlabel(‘Time/s’),ylabel(‘Dimensionless displacement of primary structure’)
figure,
plot(t,(x(:,2)); xlabel(‘Time/s’),ylabel(‘Dimensionless displacement of TMD ‘)
sys = ss(A,B,E,D);
figure,
bodeplot(sys(1,1))
bp.FrequencyScale = "linear";
[mag,phase,wout] = bode(sys(1,1));
mag = squeeze(mag);
phase = squeeze(phase);
fout = wout/(2*pi);
BodeTable = table(fout,mag,phase);
function dXdt = QZSdamper(t,A,B,X)
global alpha gamma mu Omega_1 Omega_2
w = 0.180;
F1 = 0.001/(Omega_1^2*L_0)*sin(w*t); %harmonic excitation
F_o = 2*alpha*(sqrt(1-gamma^2)+X(2)/L_0)*(sqrt(1/((X(2)/L_0)^2+2*sqrt(1-gamma^2)*X(2)/L_0+1))-1);
F = [F;F_o];
dXdt = A*X+B*(F);
endHello all,
I hope you are doing well. I asked a question regarding dimensionalizing the motion equations in 2DOFs. Due to my mistakes, the description is not very clear. As suggested, I post a single question for the same question.
I would like to present the system I want to establish in MATLAB firstly. The absorber consists of a mass, three-spring system in the left fig, and the dashpot.
For the angular velocity , damping ratio, mass ratio , and the stiffness ratio , they are easy to determine. The length of the oblique spring in my code is set to be 2.5m. But it can be various physically.
I am not sure the approach to achieve the nondimensionlized equation is corret or not. Also, I would like to know whether I could use the ratio value only. Specifically, I do not need to set the value.
My codes are also attached. Thank you for your help.
Best wishes,
Yu
clc;
clear all;
tspan = 0:0.25:200;
% Units:
% stiffness: N/m, mass:kg, damping(c_1):Ns/m
% displacement(X):m
% alpha (stiffness ratio):k_o/k_v
% gamma (dimension ratio):a/L (structure length)
% f_opt (frequency ratio): f_1/f_2
% k_v the stiffness of the vertical spring
% k_o the stiffness of the oblique spring
X0 = [0 0 0 0];
%parameters——-
global alpha gamma mu Omega_1 Omega_2 L_0
alpha = 1 % stiffness ratio k_o/k_v
gamma = 2*alpha/(2*alpha+1)
L_0 = 2.5
a = L_0*gamma;
h = sqrt(L_0^2-a^2);
mu = 0.02; % mass ratio
f_opt = 1/(1+mu); % frequency ratio
xi_2 = sqrt(3*mu/8*(1+mu));
Omega_1 = 0.188; % 0.03 Hz angular velocity of the primary structure
Omega_2 = Omega_1*f_opt; % angular velocity of the damper
xi_1 = 0.01; % damping ratio of primary structure
%matrix——–
M = [(1+mu)/(Omega_1^2*L_0) mu/(Omega_1^2*L_0);
1/(Omega_2^2*L_0) 1/(Omega_2^2*L_0)];
C = [2*xi_1/(Omega_1*L_0) 0;
0 2*xi_2/(Omega_2*L_0)];
K = [1/L_0 0;
0 1/L_0];
% state space model——————-
% M: mass matrix, K:stiffness matrix, C:damping matrix
O = zeros(2,2);
I = eye(2);
A = [O I; -inv(M)*K -inv(M)*C];
B = [O; inv(M)];
E = [I O];
D = zeros(2,2);
% solve the equations——————-
options = odeset(‘RelTol’,1e-10,’AbsTol’,1e-10);
[t,X] = ode45(@(t,X) QZSdamper(t,A,B,X),tspan,X0,options);
x = X(:,1:4);
%% plot
figure,
plot(t,x(:,1)); xlabel(‘Time/s’),ylabel(‘Dimensionless displacement of primary structure’)
figure,
plot(t,(x(:,2)); xlabel(‘Time/s’),ylabel(‘Dimensionless displacement of TMD ‘)
sys = ss(A,B,E,D);
figure,
bodeplot(sys(1,1))
bp.FrequencyScale = "linear";
[mag,phase,wout] = bode(sys(1,1));
mag = squeeze(mag);
phase = squeeze(phase);
fout = wout/(2*pi);
BodeTable = table(fout,mag,phase);
function dXdt = QZSdamper(t,A,B,X)
global alpha gamma mu Omega_1 Omega_2
w = 0.180;
F1 = 0.001/(Omega_1^2*L_0)*sin(w*t); %harmonic excitation
F_o = 2*alpha*(sqrt(1-gamma^2)+X(2)/L_0)*(sqrt(1/((X(2)/L_0)^2+2*sqrt(1-gamma^2)*X(2)/L_0+1))-1);
F = [F;F_o];
dXdt = A*X+B*(F);
end Hello all,
I hope you are doing well. I asked a question regarding dimensionalizing the motion equations in 2DOFs. Due to my mistakes, the description is not very clear. As suggested, I post a single question for the same question.
I would like to present the system I want to establish in MATLAB firstly. The absorber consists of a mass, three-spring system in the left fig, and the dashpot.
For the angular velocity , damping ratio, mass ratio , and the stiffness ratio , they are easy to determine. The length of the oblique spring in my code is set to be 2.5m. But it can be various physically.
I am not sure the approach to achieve the nondimensionlized equation is corret or not. Also, I would like to know whether I could use the ratio value only. Specifically, I do not need to set the value.
My codes are also attached. Thank you for your help.
Best wishes,
Yu
clc;
clear all;
tspan = 0:0.25:200;
% Units:
% stiffness: N/m, mass:kg, damping(c_1):Ns/m
% displacement(X):m
% alpha (stiffness ratio):k_o/k_v
% gamma (dimension ratio):a/L (structure length)
% f_opt (frequency ratio): f_1/f_2
% k_v the stiffness of the vertical spring
% k_o the stiffness of the oblique spring
X0 = [0 0 0 0];
%parameters——-
global alpha gamma mu Omega_1 Omega_2 L_0
alpha = 1 % stiffness ratio k_o/k_v
gamma = 2*alpha/(2*alpha+1)
L_0 = 2.5
a = L_0*gamma;
h = sqrt(L_0^2-a^2);
mu = 0.02; % mass ratio
f_opt = 1/(1+mu); % frequency ratio
xi_2 = sqrt(3*mu/8*(1+mu));
Omega_1 = 0.188; % 0.03 Hz angular velocity of the primary structure
Omega_2 = Omega_1*f_opt; % angular velocity of the damper
xi_1 = 0.01; % damping ratio of primary structure
%matrix——–
M = [(1+mu)/(Omega_1^2*L_0) mu/(Omega_1^2*L_0);
1/(Omega_2^2*L_0) 1/(Omega_2^2*L_0)];
C = [2*xi_1/(Omega_1*L_0) 0;
0 2*xi_2/(Omega_2*L_0)];
K = [1/L_0 0;
0 1/L_0];
% state space model——————-
% M: mass matrix, K:stiffness matrix, C:damping matrix
O = zeros(2,2);
I = eye(2);
A = [O I; -inv(M)*K -inv(M)*C];
B = [O; inv(M)];
E = [I O];
D = zeros(2,2);
% solve the equations——————-
options = odeset(‘RelTol’,1e-10,’AbsTol’,1e-10);
[t,X] = ode45(@(t,X) QZSdamper(t,A,B,X),tspan,X0,options);
x = X(:,1:4);
%% plot
figure,
plot(t,x(:,1)); xlabel(‘Time/s’),ylabel(‘Dimensionless displacement of primary structure’)
figure,
plot(t,(x(:,2)); xlabel(‘Time/s’),ylabel(‘Dimensionless displacement of TMD ‘)
sys = ss(A,B,E,D);
figure,
bodeplot(sys(1,1))
bp.FrequencyScale = "linear";
[mag,phase,wout] = bode(sys(1,1));
mag = squeeze(mag);
phase = squeeze(phase);
fout = wout/(2*pi);
BodeTable = table(fout,mag,phase);
function dXdt = QZSdamper(t,A,B,X)
global alpha gamma mu Omega_1 Omega_2
w = 0.180;
F1 = 0.001/(Omega_1^2*L_0)*sin(w*t); %harmonic excitation
F_o = 2*alpha*(sqrt(1-gamma^2)+X(2)/L_0)*(sqrt(1/((X(2)/L_0)^2+2*sqrt(1-gamma^2)*X(2)/L_0+1))-1);
F = [F;F_o];
dXdt = A*X+B*(F);
end ode45, differential equations, nondimentionalization MATLAB Answers — New Questions
How can I insert a variable into a plot legend, with a special character following the variable?
I am attempting to create a specific legend on a plot. I am intentionally ignoring the first 3 sets of data, because I don’t want them to be labeled in the legend. I only want the legend to display the fourth data set and read: ‘Gradient: [insert variable value] °/mm’. In my case, the varibale value I am trying to display is ‘M’. I have tried a bunch of things, but have not yet been successful in displaying both the variable value and the degree symbol for the units following the variable. The following is the code I am currently trying, but is unsuccessful:
m=(y2-y1)/(x2-x1);
M=abs(m);
str=num2str(M);
legend(”,”,”,’Gradient:’,eval(str),’circ/mm’)
Any help would much appreciated. Thank you.I am attempting to create a specific legend on a plot. I am intentionally ignoring the first 3 sets of data, because I don’t want them to be labeled in the legend. I only want the legend to display the fourth data set and read: ‘Gradient: [insert variable value] °/mm’. In my case, the varibale value I am trying to display is ‘M’. I have tried a bunch of things, but have not yet been successful in displaying both the variable value and the degree symbol for the units following the variable. The following is the code I am currently trying, but is unsuccessful:
m=(y2-y1)/(x2-x1);
M=abs(m);
str=num2str(M);
legend(”,”,”,’Gradient:’,eval(str),’circ/mm’)
Any help would much appreciated. Thank you. I am attempting to create a specific legend on a plot. I am intentionally ignoring the first 3 sets of data, because I don’t want them to be labeled in the legend. I only want the legend to display the fourth data set and read: ‘Gradient: [insert variable value] °/mm’. In my case, the varibale value I am trying to display is ‘M’. I have tried a bunch of things, but have not yet been successful in displaying both the variable value and the degree symbol for the units following the variable. The following is the code I am currently trying, but is unsuccessful:
m=(y2-y1)/(x2-x1);
M=abs(m);
str=num2str(M);
legend(”,”,”,’Gradient:’,eval(str),’circ/mm’)
Any help would much appreciated. Thank you. legend, string MATLAB Answers — New Questions
How to create simulink model for simulate tasks running with different frequency, priority
Hi all,
I have 3 tasks with: task 1 frequency 10s, task 2 frequency 15s, task 3 frequency 30s.
About priority: task 3 > task 1 > task 2
Please help me for create simulink model with real running time.
Thank you so muchHi all,
I have 3 tasks with: task 1 frequency 10s, task 2 frequency 15s, task 3 frequency 30s.
About priority: task 3 > task 1 > task 2
Please help me for create simulink model with real running time.
Thank you so much Hi all,
I have 3 tasks with: task 1 frequency 10s, task 2 frequency 15s, task 3 frequency 30s.
About priority: task 3 > task 1 > task 2
Please help me for create simulink model with real running time.
Thank you so much simulink model, frequency, priority MATLAB Answers — New Questions
Why doesn’t the frame rate drop with extra processing time per frame?
I’m processing images inside a for loop with the trigger set to immediate. In the following code:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate approximately ~450 FPS.
After adding a few functions into the for loop:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
% Two functions used to process the frame
function1(frame);
function2(frame);
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate is still around 450 FPS, but I expected it to drop because function1 and function2 are now inside the loop. I measured their execution time using tictoc, and they take about 0.5 ms together, so the frame rate should drop to around 370 FPS (1/(1/450 + 0.5e-3) = 370 FPS).
I also tested by replacing function1 and function2 with pause(0.0005), but the frame rate still didn’t drop. I’m wondering why the frame rate isn’t decreasing as expected.
I have another question about timing. Is getdata providing the correct timestamps after adding functions inside the loop? Should I use tic and toc to measure the time for each frame? The timestamps from getdata don’t seem to change, even when I add a pause in the loop.
Thanks!I’m processing images inside a for loop with the trigger set to immediate. In the following code:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate approximately ~450 FPS.
After adding a few functions into the for loop:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
% Two functions used to process the frame
function1(frame);
function2(frame);
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate is still around 450 FPS, but I expected it to drop because function1 and function2 are now inside the loop. I measured their execution time using tictoc, and they take about 0.5 ms together, so the frame rate should drop to around 370 FPS (1/(1/450 + 0.5e-3) = 370 FPS).
I also tested by replacing function1 and function2 with pause(0.0005), but the frame rate still didn’t drop. I’m wondering why the frame rate isn’t decreasing as expected.
I have another question about timing. Is getdata providing the correct timestamps after adding functions inside the loop? Should I use tic and toc to measure the time for each frame? The timestamps from getdata don’t seem to change, even when I add a pause in the loop.
Thanks! I’m processing images inside a for loop with the trigger set to immediate. In the following code:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate approximately ~450 FPS.
After adding a few functions into the for loop:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
% Two functions used to process the frame
function1(frame);
function2(frame);
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate is still around 450 FPS, but I expected it to drop because function1 and function2 are now inside the loop. I measured their execution time using tictoc, and they take about 0.5 ms together, so the frame rate should drop to around 370 FPS (1/(1/450 + 0.5e-3) = 370 FPS).
I also tested by replacing function1 and function2 with pause(0.0005), but the frame rate still didn’t drop. I’m wondering why the frame rate isn’t decreasing as expected.
I have another question about timing. Is getdata providing the correct timestamps after adding functions inside the loop? Should I use tic and toc to measure the time for each frame? The timestamps from getdata don’t seem to change, even when I add a pause in the loop.
Thanks! image-processing, image acquisition MATLAB Answers — New Questions
NR Intercell Interference Modeling example it’s not running anymore
Hello to all.
I’m new on Matlab and started my studies by running examples.
"NR Intercell Interference Modeling" example was running a few days ago but not anymore.
Now, when a run it, matlab shows this message:
Dot indexing into the result of a function call requires parentheses after the function name. The supported syntax is ‘wirelessnetwork.internal.wirelessNode().reset’.
Error in wirelessNetworkSimulator/reset (line 493)
wirelessnetwork.internal.wirelessNode.reset();
Error in wirelessNetworkSimulator (line 472)
reset(obj);
Error in wirelessNetworkSimulator/getState (line 460)
simulatorInstance = wirelessNetworkSimulator();
Error in wirelessNetworkSimulator.init (line 110)
obj = wirelessNetworkSimulator.getState(0);
Debbugind the "wirelessNetworkSimulator" file (attached) I could see that the "wirelessnetwork" object doesn’t exist (wasn’t instantiated).
Important: I did not change anything in the example or in matlab classes.
Has anyone experienced this?
Any help will be appreciated.Hello to all.
I’m new on Matlab and started my studies by running examples.
"NR Intercell Interference Modeling" example was running a few days ago but not anymore.
Now, when a run it, matlab shows this message:
Dot indexing into the result of a function call requires parentheses after the function name. The supported syntax is ‘wirelessnetwork.internal.wirelessNode().reset’.
Error in wirelessNetworkSimulator/reset (line 493)
wirelessnetwork.internal.wirelessNode.reset();
Error in wirelessNetworkSimulator (line 472)
reset(obj);
Error in wirelessNetworkSimulator/getState (line 460)
simulatorInstance = wirelessNetworkSimulator();
Error in wirelessNetworkSimulator.init (line 110)
obj = wirelessNetworkSimulator.getState(0);
Debbugind the "wirelessNetworkSimulator" file (attached) I could see that the "wirelessnetwork" object doesn’t exist (wasn’t instantiated).
Important: I did not change anything in the example or in matlab classes.
Has anyone experienced this?
Any help will be appreciated. Hello to all.
I’m new on Matlab and started my studies by running examples.
"NR Intercell Interference Modeling" example was running a few days ago but not anymore.
Now, when a run it, matlab shows this message:
Dot indexing into the result of a function call requires parentheses after the function name. The supported syntax is ‘wirelessnetwork.internal.wirelessNode().reset’.
Error in wirelessNetworkSimulator/reset (line 493)
wirelessnetwork.internal.wirelessNode.reset();
Error in wirelessNetworkSimulator (line 472)
reset(obj);
Error in wirelessNetworkSimulator/getState (line 460)
simulatorInstance = wirelessNetworkSimulator();
Error in wirelessNetworkSimulator.init (line 110)
obj = wirelessNetworkSimulator.getState(0);
Debbugind the "wirelessNetworkSimulator" file (attached) I could see that the "wirelessnetwork" object doesn’t exist (wasn’t instantiated).
Important: I did not change anything in the example or in matlab classes.
Has anyone experienced this?
Any help will be appreciated. nr intercell interference modeling, error, wirelessnetworksimulator MATLAB Answers — New Questions
i am getting error in stateflow -chart
I am getting error in this stateflow chart which i have tried my level best to fix the problem .
the error is related to data discription i think so….
so, i have attached the file .i am kindy asking can anyone solve the problem .I am getting error in this stateflow chart which i have tried my level best to fix the problem .
the error is related to data discription i think so….
so, i have attached the file .i am kindy asking can anyone solve the problem . I am getting error in this stateflow chart which i have tried my level best to fix the problem .
the error is related to data discription i think so….
so, i have attached the file .i am kindy asking can anyone solve the problem . simulink, staeflow MATLAB Answers — New Questions
When a tag is defined for an app designer slider, the value-changing-function for that slider is not triggered.
I’m using Version R2024a. When I create a slider component in App Designer and define a ValueChangingFcn for it, it works fine … as long as "Tag" (in the "Identifiers" section of the slider) has not been defined. That is, the ValueChangingFcn callback is called as I drag the slider. However, if I define Tag (e.g. ‘abc’ without the quotes), then the ValueChangingFcn is no longer called when I drag the slider.
I should mention that this appears to occur only with the slider. With a Numeric Edit Field, the presence of a tag has no adverse effect on the call to its callback.
Does anyone know a workaround?I’m using Version R2024a. When I create a slider component in App Designer and define a ValueChangingFcn for it, it works fine … as long as "Tag" (in the "Identifiers" section of the slider) has not been defined. That is, the ValueChangingFcn callback is called as I drag the slider. However, if I define Tag (e.g. ‘abc’ without the quotes), then the ValueChangingFcn is no longer called when I drag the slider.
I should mention that this appears to occur only with the slider. With a Numeric Edit Field, the presence of a tag has no adverse effect on the call to its callback.
Does anyone know a workaround? I’m using Version R2024a. When I create a slider component in App Designer and define a ValueChangingFcn for it, it works fine … as long as "Tag" (in the "Identifiers" section of the slider) has not been defined. That is, the ValueChangingFcn callback is called as I drag the slider. However, if I define Tag (e.g. ‘abc’ without the quotes), then the ValueChangingFcn is no longer called when I drag the slider.
I should mention that this appears to occur only with the slider. With a Numeric Edit Field, the presence of a tag has no adverse effect on the call to its callback.
Does anyone know a workaround? app designer, tag identifier, slider MATLAB Answers — New Questions
Solving Second-Order BVP with unknown Constants using fsolve
I am trying to solve the following problem numerically using Matlab’s fsolve function. The problem is specified by:
with the boundary conditions that
, ,
The unknowns in the problem are the height profile , the angle , and the unknown constant . The problem is in fact well posed because we have the two "extra" boundary conditions are required for us to solve for the two unknown constants . I devised the following numerical scheme:
[Eq. **]
where and the length of the domain is . The number of points used to discretize space is . The above scheme is to be applied at . At , we have to be mindful of the boundary conditions. I used the contact angle BCs to come up with equations for the "ghost points", or points just outside the domain. These are given by:
, and
Utilizing these ghost point equations and the fact that , the equations for are given by:
,
My idea is to now solve Eq. [**] for with the four equations immediately above. This gives a total of equations for the unknowns which are: . To implement this in Matlab, I wanted to use an iterative method which calls fsolve at each iteration. I, however, got a bit confused as to the best way of defining these equations as function handles to then use in the fsolve command. Below is my definition of the function that should define the equations:
function F = finDiffScheme(hold,N) % here h is the value of h at the previous iteration level
xf = 6.17415;
L = 2*xf; dx=L/N; x=-xf:dx:xf;
theta = 39*(pi/180);
S = 5; ki=.37; alpha1 = 2.69;
F{1} = @(y) 2*y(1) – 2*dx*tan(theta-y(N+1))-dx^2*S+dx^2*y(N);
F{2} = @(y) y(2)-(2+dx^2)*y(1)-dx^2*S*exp(-2*ki*((x(2)+xf)+alpha1*hold(1)))+dx^2*y(N);
for i = 2:N-2
F{i+1} = @(y) y(i+1)-(2+dx^2)*y(i)+y(i-1)-dx^2*S*exp(-2*ki*((x(i+1)+xf)+alpha1*hold(i)))+dx^2*y(N);
end
F{N} = @(y) -(2+dx^2)*y(N-1)+y(N-2)-dx^2*S*exp(-2*ki*((x(N)+xf)+alpha1*hold(N-1)))+dx^2*y(N);
F{N+1} = @(y) 2*y(N-1) – 2*dx*tan(theta+y(N+1))-dx^2*S*exp(-4*ki*xf)+dx^2*y(N);
end
If I run this code, then the output is a cell array called F which is size 1 x N+1. My concern here is that if I look at F, it seems that the numerical values of the known parameters S, ki, alpha1, dx, xf are all ignored. This is very confusing to me since F should only be a function of y not also those parameters. Is there a reason for this? For reference, I call this function in the script below:
clear; clc;
% Set parameters first: xf, theta
xf = 6.17415;
theta = 39*(pi/180);
h0 = 0;
hN = 0;
iters = 3;
N=256; L=2*xf; dx = L/N; x=-xf:dx:xf;
uold = zeros(1,N+3); % First n-1 elements are h_1, …, h_{n-1}; Last 2 elements are p and theta_d
hold1 = (1 + (sinh(x-xf)-sinh(x+xf))/sinh(2*xf))*.809827;
uold(1,1:N+1) = hold1;
uold(1,N+2:N+3) = [.809827,0];
plot(x,hold1)
hold on
F = finDiffScheme(hold1,N);
F2 = @(z) cellfun(@(y) y(z), F)
for j=1:iters
u = fsolve(F2, uold)
plot(x,u(1,1:N+1))
disp(u(1,N+2:N+3))
uold = u;
end
I am a bit concerned that the fsolve command is somehow also solving for these parameters. What exactly am I doing wrong here?
For reference, I was trying to define my solution vector as so that for , , and .I am trying to solve the following problem numerically using Matlab’s fsolve function. The problem is specified by:
with the boundary conditions that
, ,
The unknowns in the problem are the height profile , the angle , and the unknown constant . The problem is in fact well posed because we have the two "extra" boundary conditions are required for us to solve for the two unknown constants . I devised the following numerical scheme:
[Eq. **]
where and the length of the domain is . The number of points used to discretize space is . The above scheme is to be applied at . At , we have to be mindful of the boundary conditions. I used the contact angle BCs to come up with equations for the "ghost points", or points just outside the domain. These are given by:
, and
Utilizing these ghost point equations and the fact that , the equations for are given by:
,
My idea is to now solve Eq. [**] for with the four equations immediately above. This gives a total of equations for the unknowns which are: . To implement this in Matlab, I wanted to use an iterative method which calls fsolve at each iteration. I, however, got a bit confused as to the best way of defining these equations as function handles to then use in the fsolve command. Below is my definition of the function that should define the equations:
function F = finDiffScheme(hold,N) % here h is the value of h at the previous iteration level
xf = 6.17415;
L = 2*xf; dx=L/N; x=-xf:dx:xf;
theta = 39*(pi/180);
S = 5; ki=.37; alpha1 = 2.69;
F{1} = @(y) 2*y(1) – 2*dx*tan(theta-y(N+1))-dx^2*S+dx^2*y(N);
F{2} = @(y) y(2)-(2+dx^2)*y(1)-dx^2*S*exp(-2*ki*((x(2)+xf)+alpha1*hold(1)))+dx^2*y(N);
for i = 2:N-2
F{i+1} = @(y) y(i+1)-(2+dx^2)*y(i)+y(i-1)-dx^2*S*exp(-2*ki*((x(i+1)+xf)+alpha1*hold(i)))+dx^2*y(N);
end
F{N} = @(y) -(2+dx^2)*y(N-1)+y(N-2)-dx^2*S*exp(-2*ki*((x(N)+xf)+alpha1*hold(N-1)))+dx^2*y(N);
F{N+1} = @(y) 2*y(N-1) – 2*dx*tan(theta+y(N+1))-dx^2*S*exp(-4*ki*xf)+dx^2*y(N);
end
If I run this code, then the output is a cell array called F which is size 1 x N+1. My concern here is that if I look at F, it seems that the numerical values of the known parameters S, ki, alpha1, dx, xf are all ignored. This is very confusing to me since F should only be a function of y not also those parameters. Is there a reason for this? For reference, I call this function in the script below:
clear; clc;
% Set parameters first: xf, theta
xf = 6.17415;
theta = 39*(pi/180);
h0 = 0;
hN = 0;
iters = 3;
N=256; L=2*xf; dx = L/N; x=-xf:dx:xf;
uold = zeros(1,N+3); % First n-1 elements are h_1, …, h_{n-1}; Last 2 elements are p and theta_d
hold1 = (1 + (sinh(x-xf)-sinh(x+xf))/sinh(2*xf))*.809827;
uold(1,1:N+1) = hold1;
uold(1,N+2:N+3) = [.809827,0];
plot(x,hold1)
hold on
F = finDiffScheme(hold1,N);
F2 = @(z) cellfun(@(y) y(z), F)
for j=1:iters
u = fsolve(F2, uold)
plot(x,u(1,1:N+1))
disp(u(1,N+2:N+3))
uold = u;
end
I am a bit concerned that the fsolve command is somehow also solving for these parameters. What exactly am I doing wrong here?
For reference, I was trying to define my solution vector as so that for , , and . I am trying to solve the following problem numerically using Matlab’s fsolve function. The problem is specified by:
with the boundary conditions that
, ,
The unknowns in the problem are the height profile , the angle , and the unknown constant . The problem is in fact well posed because we have the two "extra" boundary conditions are required for us to solve for the two unknown constants . I devised the following numerical scheme:
[Eq. **]
where and the length of the domain is . The number of points used to discretize space is . The above scheme is to be applied at . At , we have to be mindful of the boundary conditions. I used the contact angle BCs to come up with equations for the "ghost points", or points just outside the domain. These are given by:
, and
Utilizing these ghost point equations and the fact that , the equations for are given by:
,
My idea is to now solve Eq. [**] for with the four equations immediately above. This gives a total of equations for the unknowns which are: . To implement this in Matlab, I wanted to use an iterative method which calls fsolve at each iteration. I, however, got a bit confused as to the best way of defining these equations as function handles to then use in the fsolve command. Below is my definition of the function that should define the equations:
function F = finDiffScheme(hold,N) % here h is the value of h at the previous iteration level
xf = 6.17415;
L = 2*xf; dx=L/N; x=-xf:dx:xf;
theta = 39*(pi/180);
S = 5; ki=.37; alpha1 = 2.69;
F{1} = @(y) 2*y(1) – 2*dx*tan(theta-y(N+1))-dx^2*S+dx^2*y(N);
F{2} = @(y) y(2)-(2+dx^2)*y(1)-dx^2*S*exp(-2*ki*((x(2)+xf)+alpha1*hold(1)))+dx^2*y(N);
for i = 2:N-2
F{i+1} = @(y) y(i+1)-(2+dx^2)*y(i)+y(i-1)-dx^2*S*exp(-2*ki*((x(i+1)+xf)+alpha1*hold(i)))+dx^2*y(N);
end
F{N} = @(y) -(2+dx^2)*y(N-1)+y(N-2)-dx^2*S*exp(-2*ki*((x(N)+xf)+alpha1*hold(N-1)))+dx^2*y(N);
F{N+1} = @(y) 2*y(N-1) – 2*dx*tan(theta+y(N+1))-dx^2*S*exp(-4*ki*xf)+dx^2*y(N);
end
If I run this code, then the output is a cell array called F which is size 1 x N+1. My concern here is that if I look at F, it seems that the numerical values of the known parameters S, ki, alpha1, dx, xf are all ignored. This is very confusing to me since F should only be a function of y not also those parameters. Is there a reason for this? For reference, I call this function in the script below:
clear; clc;
% Set parameters first: xf, theta
xf = 6.17415;
theta = 39*(pi/180);
h0 = 0;
hN = 0;
iters = 3;
N=256; L=2*xf; dx = L/N; x=-xf:dx:xf;
uold = zeros(1,N+3); % First n-1 elements are h_1, …, h_{n-1}; Last 2 elements are p and theta_d
hold1 = (1 + (sinh(x-xf)-sinh(x+xf))/sinh(2*xf))*.809827;
uold(1,1:N+1) = hold1;
uold(1,N+2:N+3) = [.809827,0];
plot(x,hold1)
hold on
F = finDiffScheme(hold1,N);
F2 = @(z) cellfun(@(y) y(z), F)
for j=1:iters
u = fsolve(F2, uold)
plot(x,u(1,1:N+1))
disp(u(1,N+2:N+3))
uold = u;
end
I am a bit concerned that the fsolve command is somehow also solving for these parameters. What exactly am I doing wrong here?
For reference, I was trying to define my solution vector as so that for , , and . ode, fsolve, functions, cellfun MATLAB Answers — New Questions
problem playing a scene using actor blocks and 3D configuration block in simulink
this is the error that im getting, i tried to use the Rate transition block before my actors so i get the same transition rate but it still didnt work and i got the same error ,then i tried to change the transition rate to what the error needs it to be (0.05) and i got the new error . if you need any clarification please let me know, thank youthis is the error that im getting, i tried to use the Rate transition block before my actors so i get the same transition rate but it still didnt work and i got the same error ,then i tried to change the transition rate to what the error needs it to be (0.05) and i got the new error . if you need any clarification please let me know, thank you this is the error that im getting, i tried to use the Rate transition block before my actors so i get the same transition rate but it still didnt work and i got the same error ,then i tried to change the transition rate to what the error needs it to be (0.05) and i got the new error . if you need any clarification please let me know, thank you transition rate, 3d configuration block, actor block, stepimp1 MATLAB Answers — New Questions
how to calculate amount of energy consumption energy cryptography and steganography in matlab?
how to get energy amount of energy consumption in encrption and decryption as well as hiding and extracting?how to get energy amount of energy consumption in encrption and decryption as well as hiding and extracting? how to get energy amount of energy consumption in encrption and decryption as well as hiding and extracting? energy cryptography MATLAB Answers — New Questions
Cell and double in datatable
I work with Excel xlsx files where matrix represent scores (integers between 0 and 3). Each column corresponds to a visit and each row to a patient (with size around 100×200).
The data may contains MD and NA code, or empty cells (sometimes a few, sometime a lot), in function of the visits and the progress of the study.
With readtable (without option), I obtain double and cell.
I don’t understand how MATLAB makes its choice. Sometimes the column is in cell while there are only integers (?), sometime the column is in cell (or in double) for only few MD/NA codes, sometimes the colum is in double with a majority of nan (for empty cells or MD/NA codes).
In PowerQuery everything is in integer and only column with full empty cells are coded in text, so I don’t think it’s a problem with EXCEL.
Which rules MATLAB uses when importing ?
Do you have any suggestion ?
Thank you in advance.
SAINTHILLIER Jean MarieI work with Excel xlsx files where matrix represent scores (integers between 0 and 3). Each column corresponds to a visit and each row to a patient (with size around 100×200).
The data may contains MD and NA code, or empty cells (sometimes a few, sometime a lot), in function of the visits and the progress of the study.
With readtable (without option), I obtain double and cell.
I don’t understand how MATLAB makes its choice. Sometimes the column is in cell while there are only integers (?), sometime the column is in cell (or in double) for only few MD/NA codes, sometimes the colum is in double with a majority of nan (for empty cells or MD/NA codes).
In PowerQuery everything is in integer and only column with full empty cells are coded in text, so I don’t think it’s a problem with EXCEL.
Which rules MATLAB uses when importing ?
Do you have any suggestion ?
Thank you in advance.
SAINTHILLIER Jean Marie I work with Excel xlsx files where matrix represent scores (integers between 0 and 3). Each column corresponds to a visit and each row to a patient (with size around 100×200).
The data may contains MD and NA code, or empty cells (sometimes a few, sometime a lot), in function of the visits and the progress of the study.
With readtable (without option), I obtain double and cell.
I don’t understand how MATLAB makes its choice. Sometimes the column is in cell while there are only integers (?), sometime the column is in cell (or in double) for only few MD/NA codes, sometimes the colum is in double with a majority of nan (for empty cells or MD/NA codes).
In PowerQuery everything is in integer and only column with full empty cells are coded in text, so I don’t think it’s a problem with EXCEL.
Which rules MATLAB uses when importing ?
Do you have any suggestion ?
Thank you in advance.
SAINTHILLIER Jean Marie table, readtable, importing excel data MATLAB Answers — New Questions
1D heat conduction with heat generation in a plain plate
Heat is generated uniformly in a stainless steel plate having k 20 W/mK. The thickness of the plate is 1 cm and heat generation rate is 500 MW/m²; If the two side of plate are maintained at 100°C and 200°C, respectively, Calculate the temperature at the centre of the plate.Heat is generated uniformly in a stainless steel plate having k 20 W/mK. The thickness of the plate is 1 cm and heat generation rate is 500 MW/m²; If the two side of plate are maintained at 100°C and 200°C, respectively, Calculate the temperature at the centre of the plate. Heat is generated uniformly in a stainless steel plate having k 20 W/mK. The thickness of the plate is 1 cm and heat generation rate is 500 MW/m²; If the two side of plate are maintained at 100°C and 200°C, respectively, Calculate the temperature at the centre of the plate. heat generation MATLAB Answers — New Questions
Programmatically get bus data type of In Bus Element block
I’m looking to get the bus data type used in ‘In bus element’ blocks in Matlab environment, e.g. using the ‘get_param()’ function or similar. The In Bus Element selects 1 element from the bus, but I’m not interested in the type of the element, but I need the bus type (name) of the associated parent bus.
What I’m trying to do is to list the root level ports and associated bus data types of a given model that uses only In Bus Element and Out Bus Element blocks with specified bus data types.
The bus element ports are mapped to an Autosar interface, I’m not sure if that changes anything.I’m looking to get the bus data type used in ‘In bus element’ blocks in Matlab environment, e.g. using the ‘get_param()’ function or similar. The In Bus Element selects 1 element from the bus, but I’m not interested in the type of the element, but I need the bus type (name) of the associated parent bus.
What I’m trying to do is to list the root level ports and associated bus data types of a given model that uses only In Bus Element and Out Bus Element blocks with specified bus data types.
The bus element ports are mapped to an Autosar interface, I’m not sure if that changes anything. I’m looking to get the bus data type used in ‘In bus element’ blocks in Matlab environment, e.g. using the ‘get_param()’ function or similar. The In Bus Element selects 1 element from the bus, but I’m not interested in the type of the element, but I need the bus type (name) of the associated parent bus.
What I’m trying to do is to list the root level ports and associated bus data types of a given model that uses only In Bus Element and Out Bus Element blocks with specified bus data types.
The bus element ports are mapped to an Autosar interface, I’m not sure if that changes anything. simulink, matlab MATLAB Answers — New Questions