Category: Matlab
Category Archives: Matlab
MATLAB online default language
Hi all,
I need help with setting the default language as English when I open MATLAB in Chrome.
Thanks in advance. ZainHi all,
I need help with setting the default language as English when I open MATLAB in Chrome.
Thanks in advance. Zain Hi all,
I need help with setting the default language as English when I open MATLAB in Chrome.
Thanks in advance. Zain matlab online MATLAB Answers — New Questions
I tried to communicate using matlab industrial communication opcuaclient to OPC factory server when it gives an error
I tried to communicate using matlab industrial communication opcuaclient to OPC factory server when it gives an error "OPCEnum service is not operating correctly. Repair OPC Core Components." Its like the matlab can’t communicate.I tried to communicate using matlab industrial communication opcuaclient to OPC factory server when it gives an error "OPCEnum service is not operating correctly. Repair OPC Core Components." Its like the matlab can’t communicate. I tried to communicate using matlab industrial communication opcuaclient to OPC factory server when it gives an error "OPCEnum service is not operating correctly. Repair OPC Core Components." Its like the matlab can’t communicate. opcua communication MATLAB Answers — New Questions
Regarding bar graphs for large data
Hey everyone,
I have an issue with the bar graphs x axis data.
I have a large amount of data say for about 1000 iterations and more. It is the load data for every hour of the day along with the number of iterations the load value is being repeated in those 1000 iterations. i.e. the probability of occurrence of the load. But when I create a 2d graph for every hour with load on x axis and occurrence on y axis, the data on y-axis comes exactly, but my load data starts from 1 and ends abruptly without reaching the end value. But the graph shape is correct, I feel the data on the x axis is being given incorrectly according to my research on them for many number of times.I know about the set function but I cannot keep setting the x axis for many iterations as in my case. Did anyone else face this. Can someone guide me through this ?
Thank youHey everyone,
I have an issue with the bar graphs x axis data.
I have a large amount of data say for about 1000 iterations and more. It is the load data for every hour of the day along with the number of iterations the load value is being repeated in those 1000 iterations. i.e. the probability of occurrence of the load. But when I create a 2d graph for every hour with load on x axis and occurrence on y axis, the data on y-axis comes exactly, but my load data starts from 1 and ends abruptly without reaching the end value. But the graph shape is correct, I feel the data on the x axis is being given incorrectly according to my research on them for many number of times.I know about the set function but I cannot keep setting the x axis for many iterations as in my case. Did anyone else face this. Can someone guide me through this ?
Thank you Hey everyone,
I have an issue with the bar graphs x axis data.
I have a large amount of data say for about 1000 iterations and more. It is the load data for every hour of the day along with the number of iterations the load value is being repeated in those 1000 iterations. i.e. the probability of occurrence of the load. But when I create a 2d graph for every hour with load on x axis and occurrence on y axis, the data on y-axis comes exactly, but my load data starts from 1 and ends abruptly without reaching the end value. But the graph shape is correct, I feel the data on the x axis is being given incorrectly according to my research on them for many number of times.I know about the set function but I cannot keep setting the x axis for many iterations as in my case. Did anyone else face this. Can someone guide me through this ?
Thank you bar graphs. MATLAB Answers — New Questions
How to copy figure from Sisotool?
Hi
I am using the latest Matlab R2016a.
There is a problem while I using sisotool
How do I copy figure form sisotool ?
There is no "EDIT" button in the GUI of sisotool like the previous version of Matlab.Hi
I am using the latest Matlab R2016a.
There is a problem while I using sisotool
How do I copy figure form sisotool ?
There is no "EDIT" button in the GUI of sisotool like the previous version of Matlab. Hi
I am using the latest Matlab R2016a.
There is a problem while I using sisotool
How do I copy figure form sisotool ?
There is no "EDIT" button in the GUI of sisotool like the previous version of Matlab. r2016a, sisotool, copy figure MATLAB Answers — New Questions
subgraph from graph matlab function
if i have a graph such as
WW = [20 10 12 14 12 10 20];
from=[1 2 2 3 4 3 5];
to = [4 1 4 2 3 5 4];
DG = sparse(from,to,WW); UG = tril(DG + DG’);
d=graphallshortestpaths(UG,’directed’,false);
is there any method to take subgraph for example(graph that contain only nodes 1 3 5)
thanks in advance
hassanif i have a graph such as
WW = [20 10 12 14 12 10 20];
from=[1 2 2 3 4 3 5];
to = [4 1 4 2 3 5 4];
DG = sparse(from,to,WW); UG = tril(DG + DG’);
d=graphallshortestpaths(UG,’directed’,false);
is there any method to take subgraph for example(graph that contain only nodes 1 3 5)
thanks in advance
hassan if i have a graph such as
WW = [20 10 12 14 12 10 20];
from=[1 2 2 3 4 3 5];
to = [4 1 4 2 3 5 4];
DG = sparse(from,to,WW); UG = tril(DG + DG’);
d=graphallshortestpaths(UG,’directed’,false);
is there any method to take subgraph for example(graph that contain only nodes 1 3 5)
thanks in advance
hassan subgraph, graph, graph theory MATLAB Answers — New Questions
Monthly to annual totals
Hello,
I am hoping to convert monthly totals to annual totals using a loop. However, instead of using the calendar year (Jan-Dec) I want to use the water year which runs from October to September. I have a number of time series organised in a structure (468 rows, 1 column) starting from Oct 1960 and ending in Sept 1999.
I have attempted to sum up each 12 consecutive rows (1:12, 13:24 and so on) to get the annual totals but my code (below) is not doing the job (I am not sure what exactly it is doing) and I was hoping I could get some help fixing it. Many thanks!
for k=1:length(varnames)
p=0;
for i=1:39
for months=1:12
p=p+1;
annual_flow.(varnames{k})(i,1)=flow_monthly.(varnames{k})(p,1);
end
end
endHello,
I am hoping to convert monthly totals to annual totals using a loop. However, instead of using the calendar year (Jan-Dec) I want to use the water year which runs from October to September. I have a number of time series organised in a structure (468 rows, 1 column) starting from Oct 1960 and ending in Sept 1999.
I have attempted to sum up each 12 consecutive rows (1:12, 13:24 and so on) to get the annual totals but my code (below) is not doing the job (I am not sure what exactly it is doing) and I was hoping I could get some help fixing it. Many thanks!
for k=1:length(varnames)
p=0;
for i=1:39
for months=1:12
p=p+1;
annual_flow.(varnames{k})(i,1)=flow_monthly.(varnames{k})(p,1);
end
end
end Hello,
I am hoping to convert monthly totals to annual totals using a loop. However, instead of using the calendar year (Jan-Dec) I want to use the water year which runs from October to September. I have a number of time series organised in a structure (468 rows, 1 column) starting from Oct 1960 and ending in Sept 1999.
I have attempted to sum up each 12 consecutive rows (1:12, 13:24 and so on) to get the annual totals but my code (below) is not doing the job (I am not sure what exactly it is doing) and I was hoping I could get some help fixing it. Many thanks!
for k=1:length(varnames)
p=0;
for i=1:39
for months=1:12
p=p+1;
annual_flow.(varnames{k})(i,1)=flow_monthly.(varnames{k})(p,1);
end
end
end loop, structure, annual total MATLAB Answers — New Questions
Non linear system by Newton-Raphson
Hey, I m trying to solve a non-linear system by Newton-Raphson method with an iteration max of 10 and 10^(-8) max error.
It ‘s my 1st time using matrices in Matlab and i think i don t get it right because my answer shoul be somewhat around x=0,88 y=0,99
I would love to know what is going wrong in my code ( I hope my derivatives are right (they should be))
thanks !
f1=@(x,y) atan(y)-y.*x.^2;
f2=@(x,y) x.^2+y.^2-2*x;
x1 = 1;
y1 = 1;
P = [x1 ; y1];
F= @(P) [atan(y1)-y1.*x1.^2 ; x1.^2+y1.^2-2*x1];
JF = @(P) [-2.*x1.*y1 (1/(1+y1.^2))-(x1.^(-2)) ; 2.*x1-2 2.*y1];
error = 1;
k = 1;
while k<10 && error > 10^(-8)
Q = P-JF(P)F(P);
error = abs( norm(Q-P)/norm(Q+eps));
P=Q;
k=k+1;
end
PHey, I m trying to solve a non-linear system by Newton-Raphson method with an iteration max of 10 and 10^(-8) max error.
It ‘s my 1st time using matrices in Matlab and i think i don t get it right because my answer shoul be somewhat around x=0,88 y=0,99
I would love to know what is going wrong in my code ( I hope my derivatives are right (they should be))
thanks !
f1=@(x,y) atan(y)-y.*x.^2;
f2=@(x,y) x.^2+y.^2-2*x;
x1 = 1;
y1 = 1;
P = [x1 ; y1];
F= @(P) [atan(y1)-y1.*x1.^2 ; x1.^2+y1.^2-2*x1];
JF = @(P) [-2.*x1.*y1 (1/(1+y1.^2))-(x1.^(-2)) ; 2.*x1-2 2.*y1];
error = 1;
k = 1;
while k<10 && error > 10^(-8)
Q = P-JF(P)F(P);
error = abs( norm(Q-P)/norm(Q+eps));
P=Q;
k=k+1;
end
P Hey, I m trying to solve a non-linear system by Newton-Raphson method with an iteration max of 10 and 10^(-8) max error.
It ‘s my 1st time using matrices in Matlab and i think i don t get it right because my answer shoul be somewhat around x=0,88 y=0,99
I would love to know what is going wrong in my code ( I hope my derivatives are right (they should be))
thanks !
f1=@(x,y) atan(y)-y.*x.^2;
f2=@(x,y) x.^2+y.^2-2*x;
x1 = 1;
y1 = 1;
P = [x1 ; y1];
F= @(P) [atan(y1)-y1.*x1.^2 ; x1.^2+y1.^2-2*x1];
JF = @(P) [-2.*x1.*y1 (1/(1+y1.^2))-(x1.^(-2)) ; 2.*x1-2 2.*y1];
error = 1;
k = 1;
while k<10 && error > 10^(-8)
Q = P-JF(P)F(P);
error = abs( norm(Q-P)/norm(Q+eps));
P=Q;
k=k+1;
end
P newton-raphson, non linear systems MATLAB Answers — New Questions
get real-time new coming sensor data from mobile phone, old sensor data is not include?
I want to get real-time sensor data using mobile phone,
% Initialize the mobile device object
m = mobiledev;
% Enable the accelerometer sensor
m.AccelerationSensorEnabled = 1;
% Start logging accelerometer data
m.Logging = 1;
% Set the figure for real-time plotting
figure;
duration = 15; % Duration of data collection in seconds
startTime = tic; % Start the timer
% Loop to collect and display data in real-time for 15 seconds
while toc(startTime) < duration
[accelData, timeStamps] = accellog(m); % Retrieve accelerometer data and timestamps
if ~isempty(accelData)
% Plot X, Y, Z axis acceleration in different colors
plot(timeStamps, accelData(:, 1), ‘r’); hold on;
plot(timeStamps, accelData(:, 2), ‘g’);
plot(timeStamps, accelData(:, 3), ‘b’);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
legend(‘X-axis’, ‘Y-axis’, ‘Z-axis’);
drawnow; % Update the plot in real-time
hold off;
end
pause(0.1); % Pause for smooth plotting
end
% Stop logging after the duration
m.Logging = 0;
% Optionally, retrieve all the logged data for further processing
[accelData, timeStamps] = accellog(m);
The function accellog(m) returns all logged accelerometer data from the start of the logging session, including both old and new data, in every call. It does not return only the new sensor data since the last call.
This means that in the code you provided, each time accellog(m) is called inside the loop, it will return the complete set of logged accelerometer data from the moment m.Logging = 1 was set, up to the current time.
How can I get the new coming sensor data? (logging=0 , logging=1 again is not a good way)I want to get real-time sensor data using mobile phone,
% Initialize the mobile device object
m = mobiledev;
% Enable the accelerometer sensor
m.AccelerationSensorEnabled = 1;
% Start logging accelerometer data
m.Logging = 1;
% Set the figure for real-time plotting
figure;
duration = 15; % Duration of data collection in seconds
startTime = tic; % Start the timer
% Loop to collect and display data in real-time for 15 seconds
while toc(startTime) < duration
[accelData, timeStamps] = accellog(m); % Retrieve accelerometer data and timestamps
if ~isempty(accelData)
% Plot X, Y, Z axis acceleration in different colors
plot(timeStamps, accelData(:, 1), ‘r’); hold on;
plot(timeStamps, accelData(:, 2), ‘g’);
plot(timeStamps, accelData(:, 3), ‘b’);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
legend(‘X-axis’, ‘Y-axis’, ‘Z-axis’);
drawnow; % Update the plot in real-time
hold off;
end
pause(0.1); % Pause for smooth plotting
end
% Stop logging after the duration
m.Logging = 0;
% Optionally, retrieve all the logged data for further processing
[accelData, timeStamps] = accellog(m);
The function accellog(m) returns all logged accelerometer data from the start of the logging session, including both old and new data, in every call. It does not return only the new sensor data since the last call.
This means that in the code you provided, each time accellog(m) is called inside the loop, it will return the complete set of logged accelerometer data from the moment m.Logging = 1 was set, up to the current time.
How can I get the new coming sensor data? (logging=0 , logging=1 again is not a good way) I want to get real-time sensor data using mobile phone,
% Initialize the mobile device object
m = mobiledev;
% Enable the accelerometer sensor
m.AccelerationSensorEnabled = 1;
% Start logging accelerometer data
m.Logging = 1;
% Set the figure for real-time plotting
figure;
duration = 15; % Duration of data collection in seconds
startTime = tic; % Start the timer
% Loop to collect and display data in real-time for 15 seconds
while toc(startTime) < duration
[accelData, timeStamps] = accellog(m); % Retrieve accelerometer data and timestamps
if ~isempty(accelData)
% Plot X, Y, Z axis acceleration in different colors
plot(timeStamps, accelData(:, 1), ‘r’); hold on;
plot(timeStamps, accelData(:, 2), ‘g’);
plot(timeStamps, accelData(:, 3), ‘b’);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
legend(‘X-axis’, ‘Y-axis’, ‘Z-axis’);
drawnow; % Update the plot in real-time
hold off;
end
pause(0.1); % Pause for smooth plotting
end
% Stop logging after the duration
m.Logging = 0;
% Optionally, retrieve all the logged data for further processing
[accelData, timeStamps] = accellog(m);
The function accellog(m) returns all logged accelerometer data from the start of the logging session, including both old and new data, in every call. It does not return only the new sensor data since the last call.
This means that in the code you provided, each time accellog(m) is called inside the loop, it will return the complete set of logged accelerometer data from the moment m.Logging = 1 was set, up to the current time.
How can I get the new coming sensor data? (logging=0 , logging=1 again is not a good way) matlab mobile MATLAB Answers — New Questions
Add x1[n] = exp(−n/4), −4 ≤ n ≤ 8 with x2[n] = cos(πn/4), 0 ≤ n ≤ 12. Plot x1[n], x2[n], and y[n].
Hello, I am having a problem with this. I couldn’t identify where to start. Thank you.Hello, I am having a problem with this. I couldn’t identify where to start. Thank you. Hello, I am having a problem with this. I couldn’t identify where to start. Thank you. matlab, plot MATLAB Answers — New Questions
select subgraph from graph
Dear All,
i have a graph such as
W = [.41 .99 .51 .32 .15 .45 .38 .32 .36 .29 .21];
DG = sparse([6 1 2 2 3 4 4 5 5 6 1],[2 6 3 5 4 1 6 3 4 3 5],W)
i need to select subgraph for only some nodes such as [6,2,4]
thanks in advance
hassanDear All,
i have a graph such as
W = [.41 .99 .51 .32 .15 .45 .38 .32 .36 .29 .21];
DG = sparse([6 1 2 2 3 4 4 5 5 6 1],[2 6 3 5 4 1 6 3 4 3 5],W)
i need to select subgraph for only some nodes such as [6,2,4]
thanks in advance
hassan Dear All,
i have a graph such as
W = [.41 .99 .51 .32 .15 .45 .38 .32 .36 .29 .21];
DG = sparse([6 1 2 2 3 4 4 5 5 6 1],[2 6 3 5 4 1 6 3 4 3 5],W)
i need to select subgraph for only some nodes such as [6,2,4]
thanks in advance
hassan subgraph, graph, select MATLAB Answers — New Questions
why the give code doesn’t meet my requirements?
I want to Wrap angles to the range [-180, 180] degrees. For this I have the following code:
function wrapped_angles = wrapTo180(angles)
% Wrap angles to the range [-180, 180] degrees
wrapped_angles = mod(angles + 180, 360) – 180;
end
Likewise, I want Wrap angles to the range [-90, 90] degrees. For this I have the following code:
function wrapped_angles = wrapTo90(angles)
% Wrap angles to the range [-90, 90] degrees
wrapped_angles = mod(angles + 90, 180) – 90;
end
The 2nd function works correctly but the 1st one doesn’t work correctly. Why it is so?I want to Wrap angles to the range [-180, 180] degrees. For this I have the following code:
function wrapped_angles = wrapTo180(angles)
% Wrap angles to the range [-180, 180] degrees
wrapped_angles = mod(angles + 180, 360) – 180;
end
Likewise, I want Wrap angles to the range [-90, 90] degrees. For this I have the following code:
function wrapped_angles = wrapTo90(angles)
% Wrap angles to the range [-90, 90] degrees
wrapped_angles = mod(angles + 90, 180) – 90;
end
The 2nd function works correctly but the 1st one doesn’t work correctly. Why it is so? I want to Wrap angles to the range [-180, 180] degrees. For this I have the following code:
function wrapped_angles = wrapTo180(angles)
% Wrap angles to the range [-180, 180] degrees
wrapped_angles = mod(angles + 180, 360) – 180;
end
Likewise, I want Wrap angles to the range [-90, 90] degrees. For this I have the following code:
function wrapped_angles = wrapTo90(angles)
% Wrap angles to the range [-90, 90] degrees
wrapped_angles = mod(angles + 90, 180) – 90;
end
The 2nd function works correctly but the 1st one doesn’t work correctly. Why it is so? wrapping angles within a range, logic is correct but, not working, though one is working MATLAB Answers — New Questions
Wind Turbine Doubly Fed Induction Generator (Phasor Type) is operated under phasor and energy storage is discrete, this is how to solve
Hello, everyone, do you know how to change the Wind Turbine Doubly Fed Induction Generator (Phasor Type) in simulink to discrete, because the system needs to add energy storage, energy storage a lot of things are discrete, two put together can not run, How to modify it? Is it a need to redo an energy storage system that can run on phasor? How should I do this? Are there any good people willing to help meHello, everyone, do you know how to change the Wind Turbine Doubly Fed Induction Generator (Phasor Type) in simulink to discrete, because the system needs to add energy storage, energy storage a lot of things are discrete, two put together can not run, How to modify it? Is it a need to redo an energy storage system that can run on phasor? How should I do this? Are there any good people willing to help me Hello, everyone, do you know how to change the Wind Turbine Doubly Fed Induction Generator (Phasor Type) in simulink to discrete, because the system needs to add energy storage, energy storage a lot of things are discrete, two put together can not run, How to modify it? Is it a need to redo an energy storage system that can run on phasor? How should I do this? Are there any good people willing to help me wind turbine doubly fed induction generator (phaso, energy storage MATLAB Answers — New Questions
Shortest Path with Single Source Node and Multiple Target Nodes
Hi,
There is node from A to H and used shortestpath fn to find the short path
a=["A" "A" "A" "B" "B" "C" "C" "D" "D" "E" "F" "F" "G"];
b=["B" "C" "D" "D" "F" "D" "E" "E" "G" "G" "G" "H" "H"];
distance=[3 2 5 2 13 2 5 4 3 6 2 3 6];
c=digraph(a,b,distance)
plot(c,’EdgeLabel’,c.Edges.Weight)
[p,d]=shortestpath(c,"A","H")
got this
c =
digraph with properties:
Edges: [13×2 table]
Nodes: [8×1 table]
p = 1×5 string
"A" "C" "D" "G" "H" *
d = 13
But i need to have results from A to B , A to C ,…. till A to H. I have used shortestpathtree but gives only edges and nodes with distance. I need result like above one ‘p’ with multiple target nodes (with single source node). is that for loop helpful? else any other way.
Thanks in advance.Hi,
There is node from A to H and used shortestpath fn to find the short path
a=["A" "A" "A" "B" "B" "C" "C" "D" "D" "E" "F" "F" "G"];
b=["B" "C" "D" "D" "F" "D" "E" "E" "G" "G" "G" "H" "H"];
distance=[3 2 5 2 13 2 5 4 3 6 2 3 6];
c=digraph(a,b,distance)
plot(c,’EdgeLabel’,c.Edges.Weight)
[p,d]=shortestpath(c,"A","H")
got this
c =
digraph with properties:
Edges: [13×2 table]
Nodes: [8×1 table]
p = 1×5 string
"A" "C" "D" "G" "H" *
d = 13
But i need to have results from A to B , A to C ,…. till A to H. I have used shortestpathtree but gives only edges and nodes with distance. I need result like above one ‘p’ with multiple target nodes (with single source node). is that for loop helpful? else any other way.
Thanks in advance. Hi,
There is node from A to H and used shortestpath fn to find the short path
a=["A" "A" "A" "B" "B" "C" "C" "D" "D" "E" "F" "F" "G"];
b=["B" "C" "D" "D" "F" "D" "E" "E" "G" "G" "G" "H" "H"];
distance=[3 2 5 2 13 2 5 4 3 6 2 3 6];
c=digraph(a,b,distance)
plot(c,’EdgeLabel’,c.Edges.Weight)
[p,d]=shortestpath(c,"A","H")
got this
c =
digraph with properties:
Edges: [13×2 table]
Nodes: [8×1 table]
p = 1×5 string
"A" "C" "D" "G" "H" *
d = 13
But i need to have results from A to B , A to C ,…. till A to H. I have used shortestpathtree but gives only edges and nodes with distance. I need result like above one ‘p’ with multiple target nodes (with single source node). is that for loop helpful? else any other way.
Thanks in advance. shortestpath, graph, nodes, plot MATLAB Answers — New Questions
Simscape Multibody – Error “Model not assembled due to a position violation” when I change the value of the actuation input of a RevoluteJoint
Hi,
i am currently trying my first major project in Simscape (delta robot).
I want to adjust the angles of the joints RevoluteJoint2, 3 and 4 via three inputs. When I do that I get the mentioned error. If all joints have the same input value, no error occurs.
Can someone tell me why the error occurs? Thank you.
Project:
Is attached.
Error message:
"An error occurred while running the simulation and the simulation was terminated
Caused by:
[‘untitled_ohneCad/Solver Configuration’]: Model not assembled due to a position violation. The failure occurred during the attempt to assemble all joints in the system and satisfy any motion inputs. If an Update Diagram operation completes successfully, the failure is likely caused by motion inputs. Consider adjusting the motion inputs to specify a different starting configuration. Also consider adjusting or adding joint targets to better guide the assembly."Hi,
i am currently trying my first major project in Simscape (delta robot).
I want to adjust the angles of the joints RevoluteJoint2, 3 and 4 via three inputs. When I do that I get the mentioned error. If all joints have the same input value, no error occurs.
Can someone tell me why the error occurs? Thank you.
Project:
Is attached.
Error message:
"An error occurred while running the simulation and the simulation was terminated
Caused by:
[‘untitled_ohneCad/Solver Configuration’]: Model not assembled due to a position violation. The failure occurred during the attempt to assemble all joints in the system and satisfy any motion inputs. If an Update Diagram operation completes successfully, the failure is likely caused by motion inputs. Consider adjusting the motion inputs to specify a different starting configuration. Also consider adjusting or adding joint targets to better guide the assembly." Hi,
i am currently trying my first major project in Simscape (delta robot).
I want to adjust the angles of the joints RevoluteJoint2, 3 and 4 via three inputs. When I do that I get the mentioned error. If all joints have the same input value, no error occurs.
Can someone tell me why the error occurs? Thank you.
Project:
Is attached.
Error message:
"An error occurred while running the simulation and the simulation was terminated
Caused by:
[‘untitled_ohneCad/Solver Configuration’]: Model not assembled due to a position violation. The failure occurred during the attempt to assemble all joints in the system and satisfy any motion inputs. If an Update Diagram operation completes successfully, the failure is likely caused by motion inputs. Consider adjusting the motion inputs to specify a different starting configuration. Also consider adjusting or adding joint targets to better guide the assembly." model position violation, delta robot MATLAB Answers — New Questions
How to find the model of a black box with a known input and output signature of signal.
Please help me identify the model of a black box with a known input x(t) and output y(t), using the provided DATA.mat.
I have attempted to map the output to the given input using MATLAB System Identification Toolbox and neural networks, as described in the application section, but have not been successful.
Kindly assist in mapping this input to the output. You are free to use any methods.
Attacked input and output data.Please help me identify the model of a black box with a known input x(t) and output y(t), using the provided DATA.mat.
I have attempted to map the output to the given input using MATLAB System Identification Toolbox and neural networks, as described in the application section, but have not been successful.
Kindly assist in mapping this input to the output. You are free to use any methods.
Attacked input and output data. Please help me identify the model of a black box with a known input x(t) and output y(t), using the provided DATA.mat.
I have attempted to map the output to the given input using MATLAB System Identification Toolbox and neural networks, as described in the application section, but have not been successful.
Kindly assist in mapping this input to the output. You are free to use any methods.
Attacked input and output data. system identification, signal processing MATLAB Answers — New Questions
USB callback “terminator” fails to trigger a read when messages are close together
My App Designer program uses USB communication to an Arduino
It usually works but every once in a while Matlab fails to read.
configureCallback(app.PicoCom,"terminator",@app.PicoInput);
…
function PicoInput(app,src,~)
% check if there is more than 1 line. For some reason I don’t get another callback!!!
while (app.PicoCom.NumBytesAvailable>0)
raw = readline(src);
I’ve already added the while loop which mostly fixed it except if the messages are 20msec apart.
The only time it fails (and not very often) is between 2 messages that are known to be 20 ms apart.
When it fails (App Designer says "Run" … no action), I can go into the debugger (with a special pause I put in to read app properties) and check with
K>> app.PicoCom
ans =
Serialport with properties:
Port: "COM6"
BaudRate: 57600
NumBytesAvailable: 11
K>> read(app.PicoCom,11,"char")
ans =
‘z73851718
‘
And there it sits, not being read.
Sure, there are probably work arounds (I’m open to suggestions to manage it now) but isn’t this a bug!
My next attempt to handle this is to add a pause(0.03); at the end of the while loop but this is very unsatisfying and how do I know it will NEVER fail?My App Designer program uses USB communication to an Arduino
It usually works but every once in a while Matlab fails to read.
configureCallback(app.PicoCom,"terminator",@app.PicoInput);
…
function PicoInput(app,src,~)
% check if there is more than 1 line. For some reason I don’t get another callback!!!
while (app.PicoCom.NumBytesAvailable>0)
raw = readline(src);
I’ve already added the while loop which mostly fixed it except if the messages are 20msec apart.
The only time it fails (and not very often) is between 2 messages that are known to be 20 ms apart.
When it fails (App Designer says "Run" … no action), I can go into the debugger (with a special pause I put in to read app properties) and check with
K>> app.PicoCom
ans =
Serialport with properties:
Port: "COM6"
BaudRate: 57600
NumBytesAvailable: 11
K>> read(app.PicoCom,11,"char")
ans =
‘z73851718
‘
And there it sits, not being read.
Sure, there are probably work arounds (I’m open to suggestions to manage it now) but isn’t this a bug!
My next attempt to handle this is to add a pause(0.03); at the end of the while loop but this is very unsatisfying and how do I know it will NEVER fail? My App Designer program uses USB communication to an Arduino
It usually works but every once in a while Matlab fails to read.
configureCallback(app.PicoCom,"terminator",@app.PicoInput);
…
function PicoInput(app,src,~)
% check if there is more than 1 line. For some reason I don’t get another callback!!!
while (app.PicoCom.NumBytesAvailable>0)
raw = readline(src);
I’ve already added the while loop which mostly fixed it except if the messages are 20msec apart.
The only time it fails (and not very often) is between 2 messages that are known to be 20 ms apart.
When it fails (App Designer says "Run" … no action), I can go into the debugger (with a special pause I put in to read app properties) and check with
K>> app.PicoCom
ans =
Serialport with properties:
Port: "COM6"
BaudRate: 57600
NumBytesAvailable: 11
K>> read(app.PicoCom,11,"char")
ans =
‘z73851718
‘
And there it sits, not being read.
Sure, there are probably work arounds (I’m open to suggestions to manage it now) but isn’t this a bug!
My next attempt to handle this is to add a pause(0.03); at the end of the while loop but this is very unsatisfying and how do I know it will NEVER fail? usb terminate based callback fails occasionally MATLAB Answers — New Questions
Script for a sum of value drive by rules
Hi!
I have a matrix of data with only 0 and 0.2 values. I need to have the sum of successive 0.2 values (delta) for each columns of my matrix. Example: col1= 0 0 0 0.2 0.2 0.2 0.2 0 0 0.2 0 0.2 0.2 and the result_col1= 0.8 0.2 0.4. I write a script that works very well to do this (see above). First little problem, how can I say to my script that you need to read all columns of my matrix and put each correspondant delta values in my final matrix d?
Then, I would like to have a rule saying to the script "when you saw less than five zeros successively don’t stop to calculate delta". In my script, the calculation of delta stop when the script saw only one zero after a 0.2 value.
Thanks a lot.
Julien
T = importdata(‘data.xls’)
T= T.Feuil1;
d(1,:) = zeros(1,size(T,2));
j=1;
for individu=1:size(T,2)
for i=1:size(T,1);
if T(i,individu)== 0.2 || any(T(1:i))==0
d(j,individu) = d(j,individu)+T(i,individu);
elseif T(i)==0 && T(i-1)== 0.2
j= j+1;
d(j,individu) = 0;
end
end
j=1;
endHi!
I have a matrix of data with only 0 and 0.2 values. I need to have the sum of successive 0.2 values (delta) for each columns of my matrix. Example: col1= 0 0 0 0.2 0.2 0.2 0.2 0 0 0.2 0 0.2 0.2 and the result_col1= 0.8 0.2 0.4. I write a script that works very well to do this (see above). First little problem, how can I say to my script that you need to read all columns of my matrix and put each correspondant delta values in my final matrix d?
Then, I would like to have a rule saying to the script "when you saw less than five zeros successively don’t stop to calculate delta". In my script, the calculation of delta stop when the script saw only one zero after a 0.2 value.
Thanks a lot.
Julien
T = importdata(‘data.xls’)
T= T.Feuil1;
d(1,:) = zeros(1,size(T,2));
j=1;
for individu=1:size(T,2)
for i=1:size(T,1);
if T(i,individu)== 0.2 || any(T(1:i))==0
d(j,individu) = d(j,individu)+T(i,individu);
elseif T(i)==0 && T(i-1)== 0.2
j= j+1;
d(j,individu) = 0;
end
end
j=1;
end Hi!
I have a matrix of data with only 0 and 0.2 values. I need to have the sum of successive 0.2 values (delta) for each columns of my matrix. Example: col1= 0 0 0 0.2 0.2 0.2 0.2 0 0 0.2 0 0.2 0.2 and the result_col1= 0.8 0.2 0.4. I write a script that works very well to do this (see above). First little problem, how can I say to my script that you need to read all columns of my matrix and put each correspondant delta values in my final matrix d?
Then, I would like to have a rule saying to the script "when you saw less than five zeros successively don’t stop to calculate delta". In my script, the calculation of delta stop when the script saw only one zero after a 0.2 value.
Thanks a lot.
Julien
T = importdata(‘data.xls’)
T= T.Feuil1;
d(1,:) = zeros(1,size(T,2));
j=1;
for individu=1:size(T,2)
for i=1:size(T,1);
if T(i,individu)== 0.2 || any(T(1:i))==0
d(j,individu) = d(j,individu)+T(i,individu);
elseif T(i)==0 && T(i-1)== 0.2
j= j+1;
d(j,individu) = 0;
end
end
j=1;
end beginner MATLAB Answers — New Questions
Write a Convolution function without using for loop and verify result using conv function.
Write a Convolution function with two inputs x[n] and h[n] without using for loop and verify result using conv function.Write a Convolution function with two inputs x[n] and h[n] without using for loop and verify result using conv function. Write a Convolution function with two inputs x[n] and h[n] without using for loop and verify result using conv function. convolution, signal processing, digital signal processing, system, dtft, electrical MATLAB Answers — New Questions
time shifting
i want the program to advance or delay the signal…
by taking input from user whether to advance or delay & by what number?….
please use switch statement?….
any signal like-ramp,step,exponential
in it i am using subplot to plot the original signal & shifted version of the signal..
i have a program something like this–
*clear all
close all
clc
disp(‘given function is’)
x=(-10:10);
for i=1:1:21
if(x(i)>0)
y(i)=exp(x(i));
else
y(i)=0;
end
end
subplot(1,2,1)
stem(x,y)
disp(‘enter whether to advance or delay’)
s=input(‘1>advancen 2>Delay’)
n=input(‘enter the no of step by which signal is to be shifted’)
switch(s)
case 1
[
for i=1+n:1:21+n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
case 2
[
for i=1-n:1:21-n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
subplot(1,2,2)
stem(x,y)
but when i run the program it gives error in the ‘for’ command in case 1.i want the program to advance or delay the signal…
by taking input from user whether to advance or delay & by what number?….
please use switch statement?….
any signal like-ramp,step,exponential
in it i am using subplot to plot the original signal & shifted version of the signal..
i have a program something like this–
*clear all
close all
clc
disp(‘given function is’)
x=(-10:10);
for i=1:1:21
if(x(i)>0)
y(i)=exp(x(i));
else
y(i)=0;
end
end
subplot(1,2,1)
stem(x,y)
disp(‘enter whether to advance or delay’)
s=input(‘1>advancen 2>Delay’)
n=input(‘enter the no of step by which signal is to be shifted’)
switch(s)
case 1
[
for i=1+n:1:21+n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
case 2
[
for i=1-n:1:21-n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
subplot(1,2,2)
stem(x,y)
but when i run the program it gives error in the ‘for’ command in case 1. i want the program to advance or delay the signal…
by taking input from user whether to advance or delay & by what number?….
please use switch statement?….
any signal like-ramp,step,exponential
in it i am using subplot to plot the original signal & shifted version of the signal..
i have a program something like this–
*clear all
close all
clc
disp(‘given function is’)
x=(-10:10);
for i=1:1:21
if(x(i)>0)
y(i)=exp(x(i));
else
y(i)=0;
end
end
subplot(1,2,1)
stem(x,y)
disp(‘enter whether to advance or delay’)
s=input(‘1>advancen 2>Delay’)
n=input(‘enter the no of step by which signal is to be shifted’)
switch(s)
case 1
[
for i=1+n:1:21+n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
case 2
[
for i=1-n:1:21-n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
subplot(1,2,2)
stem(x,y)
but when i run the program it gives error in the ‘for’ command in case 1. switch, homework MATLAB Answers — New Questions
Is there anyone working on electric powertrain 1-D simulation?
Hi guys, is there anyone working on electric powertrain 1-D simulation? I’m currently learning about 1-D scripting, modeling EV powertrains in both quasi-static and dynamic modes, traction motor & regenerative energy modeling, transmission & auto gear modeling, motor & battery cooling and HVAC system. So far, I’m using MATLAB and Simulink. I want to know if there are any other tools or processes I should learn in order to start a career in 1-D simulation for E-powertrains. Any advice or suggestions would be greatly appreciated.Hi guys, is there anyone working on electric powertrain 1-D simulation? I’m currently learning about 1-D scripting, modeling EV powertrains in both quasi-static and dynamic modes, traction motor & regenerative energy modeling, transmission & auto gear modeling, motor & battery cooling and HVAC system. So far, I’m using MATLAB and Simulink. I want to know if there are any other tools or processes I should learn in order to start a career in 1-D simulation for E-powertrains. Any advice or suggestions would be greatly appreciated. Hi guys, is there anyone working on electric powertrain 1-D simulation? I’m currently learning about 1-D scripting, modeling EV powertrains in both quasi-static and dynamic modes, traction motor & regenerative energy modeling, transmission & auto gear modeling, motor & battery cooling and HVAC system. So far, I’m using MATLAB and Simulink. I want to know if there are any other tools or processes I should learn in order to start a career in 1-D simulation for E-powertrains. Any advice or suggestions would be greatly appreciated. e-powertriain, bev, 1d simulation, matlab, simulink MATLAB Answers — New Questions