Tag Archives: matlab
error “Error in untitled (line 9)”
I’m trying to run the following code, byt I have the error "Error in untitled (line 9) [t,x]=ode45(‘prob’,tspan,x0);" .
Why is that happening? Can anyone help me, please? Thank you!
%Numerical Solutions
%Problem #57
clc
clear
close all
%Numerical Solution
x0=[0;0];
tspan=[0 15];
[t,x]=ode45(‘prob’,tspan,x0);
figure(1)
plot(t,x(:,1));
title(‘Problem #57’);
xlabel(‘Time, sec.’);
ylabel(‘Displacement, m’);
hold on
%Analytical Solution
m=100;
c=20;
k=1000;
F=30;
w=sqrt(k/m);
d=c/(2*w*m);
wd=w*sqrt(1-d^2);
to=1;
phi=atan(d/sqrt(1-d^2));
%for t<to
t=linspace(0,1,3);
x=0.*t;
plot(t,x,’*’);
%for t>=to
t=linspace(1,15);
x=F/k-F/(k*sqrt(1-d^2)).*exp(-d.*w.*(t-to)).*cos(wd.*(t-to)-phi);
plot(t,x,’*’);
legend(‘Numerical’, ‘Analytical’)
%M-file for Prob #50
function dx=prob(t,x)
[rows, cols]=size(x);dx=zeros(rows, cols);
m=100;
c=20;
k=1000;
F=30;
if t<1
dx=0;
else
dx(1)=x(2);
dx(2)=-c/m*x(2) – k/m*x(1) + F/m;
end
endI’m trying to run the following code, byt I have the error "Error in untitled (line 9) [t,x]=ode45(‘prob’,tspan,x0);" .
Why is that happening? Can anyone help me, please? Thank you!
%Numerical Solutions
%Problem #57
clc
clear
close all
%Numerical Solution
x0=[0;0];
tspan=[0 15];
[t,x]=ode45(‘prob’,tspan,x0);
figure(1)
plot(t,x(:,1));
title(‘Problem #57’);
xlabel(‘Time, sec.’);
ylabel(‘Displacement, m’);
hold on
%Analytical Solution
m=100;
c=20;
k=1000;
F=30;
w=sqrt(k/m);
d=c/(2*w*m);
wd=w*sqrt(1-d^2);
to=1;
phi=atan(d/sqrt(1-d^2));
%for t<to
t=linspace(0,1,3);
x=0.*t;
plot(t,x,’*’);
%for t>=to
t=linspace(1,15);
x=F/k-F/(k*sqrt(1-d^2)).*exp(-d.*w.*(t-to)).*cos(wd.*(t-to)-phi);
plot(t,x,’*’);
legend(‘Numerical’, ‘Analytical’)
%M-file for Prob #50
function dx=prob(t,x)
[rows, cols]=size(x);dx=zeros(rows, cols);
m=100;
c=20;
k=1000;
F=30;
if t<1
dx=0;
else
dx(1)=x(2);
dx(2)=-c/m*x(2) – k/m*x(1) + F/m;
end
end I’m trying to run the following code, byt I have the error "Error in untitled (line 9) [t,x]=ode45(‘prob’,tspan,x0);" .
Why is that happening? Can anyone help me, please? Thank you!
%Numerical Solutions
%Problem #57
clc
clear
close all
%Numerical Solution
x0=[0;0];
tspan=[0 15];
[t,x]=ode45(‘prob’,tspan,x0);
figure(1)
plot(t,x(:,1));
title(‘Problem #57’);
xlabel(‘Time, sec.’);
ylabel(‘Displacement, m’);
hold on
%Analytical Solution
m=100;
c=20;
k=1000;
F=30;
w=sqrt(k/m);
d=c/(2*w*m);
wd=w*sqrt(1-d^2);
to=1;
phi=atan(d/sqrt(1-d^2));
%for t<to
t=linspace(0,1,3);
x=0.*t;
plot(t,x,’*’);
%for t>=to
t=linspace(1,15);
x=F/k-F/(k*sqrt(1-d^2)).*exp(-d.*w.*(t-to)).*cos(wd.*(t-to)-phi);
plot(t,x,’*’);
legend(‘Numerical’, ‘Analytical’)
%M-file for Prob #50
function dx=prob(t,x)
[rows, cols]=size(x);dx=zeros(rows, cols);
m=100;
c=20;
k=1000;
F=30;
if t<1
dx=0;
else
dx(1)=x(2);
dx(2)=-c/m*x(2) – k/m*x(1) + F/m;
end
end error untitled MATLAB Answers — New Questions
Reading multiple sheets from an excel file
I have an excel spreadsheet and the data is seperated into a different sheet for each year but I want to have all of the years worth of data in one table so I was wondering what the best way to approach this is? Right now my code only gets the data from 2007 and thats it.
opt=detectImportOptions(‘BC1 2007-2020.xlsx’);
opt.VariableTypes(3)={‘double’};
BC1=readtable(‘BC1 2007-2020.xlsx’,opt);
BC1.Date=datetime(BC1{:,1},’InputFormat’,’dd/MM/yy HH:mm:ss’);
BC1=table2timetable(BC1);
plot(BC1.Date,BC1.WaterLevel_Meters);I have an excel spreadsheet and the data is seperated into a different sheet for each year but I want to have all of the years worth of data in one table so I was wondering what the best way to approach this is? Right now my code only gets the data from 2007 and thats it.
opt=detectImportOptions(‘BC1 2007-2020.xlsx’);
opt.VariableTypes(3)={‘double’};
BC1=readtable(‘BC1 2007-2020.xlsx’,opt);
BC1.Date=datetime(BC1{:,1},’InputFormat’,’dd/MM/yy HH:mm:ss’);
BC1=table2timetable(BC1);
plot(BC1.Date,BC1.WaterLevel_Meters); I have an excel spreadsheet and the data is seperated into a different sheet for each year but I want to have all of the years worth of data in one table so I was wondering what the best way to approach this is? Right now my code only gets the data from 2007 and thats it.
opt=detectImportOptions(‘BC1 2007-2020.xlsx’);
opt.VariableTypes(3)={‘double’};
BC1=readtable(‘BC1 2007-2020.xlsx’,opt);
BC1.Date=datetime(BC1{:,1},’InputFormat’,’dd/MM/yy HH:mm:ss’);
BC1=table2timetable(BC1);
plot(BC1.Date,BC1.WaterLevel_Meters); excel MATLAB Answers — New Questions
Pass bus signals to a function as an array (Stateflow)
Hello!
I’m working within stateflow and defining a transition check:
[checkInRange(User_CMDs.r,0,1)==1]
Check In range is a simple function as follows and returns true if all inputs are true (In Range):
function result = checkInRange(input,request,tolerance)
result = abs(request – input) <= tolerance;
result = all(result(:));
end
Ive been able to pass arrays as input to the function, however i am trying to define a transition and for a state within simulink. The User_CMD.r is a bus with 4 singals called X1, X2, X3 and X4. I need all of these to be in range for state transition. Is there a way of doing this without doing it as below?
[checkInRange([User_CMDs.r.X1,User_CMDs.r.X1,User_CMDs.r.X1,User_CMDs.r.X1], 0,1)==1]Hello!
I’m working within stateflow and defining a transition check:
[checkInRange(User_CMDs.r,0,1)==1]
Check In range is a simple function as follows and returns true if all inputs are true (In Range):
function result = checkInRange(input,request,tolerance)
result = abs(request – input) <= tolerance;
result = all(result(:));
end
Ive been able to pass arrays as input to the function, however i am trying to define a transition and for a state within simulink. The User_CMD.r is a bus with 4 singals called X1, X2, X3 and X4. I need all of these to be in range for state transition. Is there a way of doing this without doing it as below?
[checkInRange([User_CMDs.r.X1,User_CMDs.r.X1,User_CMDs.r.X1,User_CMDs.r.X1], 0,1)==1] Hello!
I’m working within stateflow and defining a transition check:
[checkInRange(User_CMDs.r,0,1)==1]
Check In range is a simple function as follows and returns true if all inputs are true (In Range):
function result = checkInRange(input,request,tolerance)
result = abs(request – input) <= tolerance;
result = all(result(:));
end
Ive been able to pass arrays as input to the function, however i am trying to define a transition and for a state within simulink. The User_CMD.r is a bus with 4 singals called X1, X2, X3 and X4. I need all of these to be in range for state transition. Is there a way of doing this without doing it as below?
[checkInRange([User_CMDs.r.X1,User_CMDs.r.X1,User_CMDs.r.X1,User_CMDs.r.X1], 0,1)==1] stateflow, signal bus, bus MATLAB Answers — New Questions
Interactive point selection 3D points
Hello,
I need your help.
In the image bellow (hopefully it did work this time) there is a three-dimensional tooth on the left (with its three-dimensional coordinates, of course) and on the left the same tooth but in a two-dimensional parameterised disc. The order of the points on the 2D and 3D vectors are the same, that is, the points are corresponding.
I woud like to select a point on the 3D tooth and get the same point marked on the right 2D tooth. I can do this the other way around, that is, selecting a point on the disc and then getting the correspondent on the 3D figure.
My method for doing this on the 2D was with the function getpts, which gives me the coordinates of the mouse where I click. I then take the nearest neighbour of that point (or points) and plot the corresponding points on the 3D figure with its correct indexes.
So my question is, is there a similar function to getpts() for a 3D figure?
Thank you :)Hello,
I need your help.
In the image bellow (hopefully it did work this time) there is a three-dimensional tooth on the left (with its three-dimensional coordinates, of course) and on the left the same tooth but in a two-dimensional parameterised disc. The order of the points on the 2D and 3D vectors are the same, that is, the points are corresponding.
I woud like to select a point on the 3D tooth and get the same point marked on the right 2D tooth. I can do this the other way around, that is, selecting a point on the disc and then getting the correspondent on the 3D figure.
My method for doing this on the 2D was with the function getpts, which gives me the coordinates of the mouse where I click. I then take the nearest neighbour of that point (or points) and plot the corresponding points on the 3D figure with its correct indexes.
So my question is, is there a similar function to getpts() for a 3D figure?
Thank you 🙂 Hello,
I need your help.
In the image bellow (hopefully it did work this time) there is a three-dimensional tooth on the left (with its three-dimensional coordinates, of course) and on the left the same tooth but in a two-dimensional parameterised disc. The order of the points on the 2D and 3D vectors are the same, that is, the points are corresponding.
I woud like to select a point on the 3D tooth and get the same point marked on the right 2D tooth. I can do this the other way around, that is, selecting a point on the disc and then getting the correspondent on the 3D figure.
My method for doing this on the 2D was with the function getpts, which gives me the coordinates of the mouse where I click. I then take the nearest neighbour of that point (or points) and plot the corresponding points on the 3D figure with its correct indexes.
So my question is, is there a similar function to getpts() for a 3D figure?
Thank you 🙂 3d getpts MATLAB Answers — New Questions
how to make transformation in mp4 vedio
i have two vedio of mp4.i want to apply some tranformation on it and run the tranform vedio.i have wriiten the code but contently facing the error.i even tried "NumberOfFrames" but it is unrecongnized in my matlab
code is here
% read videos
vid1 = VideoReader(‘video1.mp4’);
vid2 = VideoReader(‘vedio2.mp4’);
% read first frame from each video
frame1 = readFrame(vid1);
frame2 = readFrame(vid2);
% create a figure
fig = figure;
while hasFrame(vid1) && hasFrame(vid2)
% read frames from each video
frame1 = readFrame(vid1);
frame2 = readFrame(vid2);
% perform geometric transformations
frame1_scaled = imresize(frame1, 0.5);
frame1_sheared = imresize(frame1, [size(frame1,1) size(frame1,2)*0.8]);
frame1_rotated = imrotate(frame1, 30, ‘crop’);
frame2_scaled = imresize(frame2, 0.5);
frame2_sheared = imresize(frame2, [size(frame2,1) size(frame2,2)*0.8]);
frame2_rotated = imrotate(frame2, -30, ‘crop’);
% concatenate frames
combined_frame = cat(2, cat(1, frame1, frame1_scaled, frame1_sheared, frame1_rotated), …
cat(1, frame2, frame2_scaled, frame2_sheared, frame2_rotated));
% display frames
imshow(combined_frame, ‘Parent’, fig);
drawnow;
end
error that i facing is
Error using cat
Dimensions
of
arrays
being
concatenated
are
not
consistent.
Error in untitled (line 27)
combined_frame = cat(2, cat(1, frame1, frame1_scaled, frame1_sheared, frame1_rotated), …i have two vedio of mp4.i want to apply some tranformation on it and run the tranform vedio.i have wriiten the code but contently facing the error.i even tried "NumberOfFrames" but it is unrecongnized in my matlab
code is here
% read videos
vid1 = VideoReader(‘video1.mp4’);
vid2 = VideoReader(‘vedio2.mp4’);
% read first frame from each video
frame1 = readFrame(vid1);
frame2 = readFrame(vid2);
% create a figure
fig = figure;
while hasFrame(vid1) && hasFrame(vid2)
% read frames from each video
frame1 = readFrame(vid1);
frame2 = readFrame(vid2);
% perform geometric transformations
frame1_scaled = imresize(frame1, 0.5);
frame1_sheared = imresize(frame1, [size(frame1,1) size(frame1,2)*0.8]);
frame1_rotated = imrotate(frame1, 30, ‘crop’);
frame2_scaled = imresize(frame2, 0.5);
frame2_sheared = imresize(frame2, [size(frame2,1) size(frame2,2)*0.8]);
frame2_rotated = imrotate(frame2, -30, ‘crop’);
% concatenate frames
combined_frame = cat(2, cat(1, frame1, frame1_scaled, frame1_sheared, frame1_rotated), …
cat(1, frame2, frame2_scaled, frame2_sheared, frame2_rotated));
% display frames
imshow(combined_frame, ‘Parent’, fig);
drawnow;
end
error that i facing is
Error using cat
Dimensions
of
arrays
being
concatenated
are
not
consistent.
Error in untitled (line 27)
combined_frame = cat(2, cat(1, frame1, frame1_scaled, frame1_sheared, frame1_rotated), … i have two vedio of mp4.i want to apply some tranformation on it and run the tranform vedio.i have wriiten the code but contently facing the error.i even tried "NumberOfFrames" but it is unrecongnized in my matlab
code is here
% read videos
vid1 = VideoReader(‘video1.mp4’);
vid2 = VideoReader(‘vedio2.mp4’);
% read first frame from each video
frame1 = readFrame(vid1);
frame2 = readFrame(vid2);
% create a figure
fig = figure;
while hasFrame(vid1) && hasFrame(vid2)
% read frames from each video
frame1 = readFrame(vid1);
frame2 = readFrame(vid2);
% perform geometric transformations
frame1_scaled = imresize(frame1, 0.5);
frame1_sheared = imresize(frame1, [size(frame1,1) size(frame1,2)*0.8]);
frame1_rotated = imrotate(frame1, 30, ‘crop’);
frame2_scaled = imresize(frame2, 0.5);
frame2_sheared = imresize(frame2, [size(frame2,1) size(frame2,2)*0.8]);
frame2_rotated = imrotate(frame2, -30, ‘crop’);
% concatenate frames
combined_frame = cat(2, cat(1, frame1, frame1_scaled, frame1_sheared, frame1_rotated), …
cat(1, frame2, frame2_scaled, frame2_sheared, frame2_rotated));
% display frames
imshow(combined_frame, ‘Parent’, fig);
drawnow;
end
error that i facing is
Error using cat
Dimensions
of
arrays
being
concatenated
are
not
consistent.
Error in untitled (line 27)
combined_frame = cat(2, cat(1, frame1, frame1_scaled, frame1_sheared, frame1_rotated), … video processing, transformation MATLAB Answers — New Questions
Correct way to calculate the dominant frequency of time series signal?
My dataset consists of two parameters: time (in micro second) and amplitude (Attached):
I am particularly interested in analyzing the fluctuation of the dominant frequency across the entire dataset. Additionally, I want to examine how the frequency content changes as a function of time. For instance, in time intervals such as 0–200 ms, 100–300 ms, 300–500 ms, and so on.
I attempted multiple approaches, but the results are not very consistent. I would be interested in getting a second opinion.
Thanks in Advance!My dataset consists of two parameters: time (in micro second) and amplitude (Attached):
I am particularly interested in analyzing the fluctuation of the dominant frequency across the entire dataset. Additionally, I want to examine how the frequency content changes as a function of time. For instance, in time intervals such as 0–200 ms, 100–300 ms, 300–500 ms, and so on.
I attempted multiple approaches, but the results are not very consistent. I would be interested in getting a second opinion.
Thanks in Advance! My dataset consists of two parameters: time (in micro second) and amplitude (Attached):
I am particularly interested in analyzing the fluctuation of the dominant frequency across the entire dataset. Additionally, I want to examine how the frequency content changes as a function of time. For instance, in time intervals such as 0–200 ms, 100–300 ms, 300–500 ms, and so on.
I attempted multiple approaches, but the results are not very consistent. I would be interested in getting a second opinion.
Thanks in Advance! time series, fft MATLAB Answers — New Questions
prev value in a stateflow chart
Stateflow documentation:
…To detect changes, the chart automatically double-buffers these values in local variables, as follows:
var_name_prev Value of data at the beginning of the last time step
var_name_start Value of data at the beginning of the current time step
Question: do I have read access to the buffered variables? I want to use them for calculations inside the stateflow chart.Stateflow documentation:
…To detect changes, the chart automatically double-buffers these values in local variables, as follows:
var_name_prev Value of data at the beginning of the last time step
var_name_start Value of data at the beginning of the current time step
Question: do I have read access to the buffered variables? I want to use them for calculations inside the stateflow chart. Stateflow documentation:
…To detect changes, the chart automatically double-buffers these values in local variables, as follows:
var_name_prev Value of data at the beginning of the last time step
var_name_start Value of data at the beginning of the current time step
Question: do I have read access to the buffered variables? I want to use them for calculations inside the stateflow chart. stateflow, double-buffer MATLAB Answers — New Questions
How to arrange elements in one array to match the position of elements in a second array?
If I have two arrays A and B as displayed below, how can I rearrange B such that a new boolean array Ba which corresponds to the values of array B can be resorted according to the values of array A instead?
For example, if I have:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
B =
1 2 2 2 3 3 4 4 5 5
2 1 1 2 0 1 0 1 0 1
30 18 25 25 -1 23 -1 30 -1 22
Ba =
0 0 1 0 1 0 0 0 0 0
Note that array B is simply the sorted version of array A according to the first row in an ascended order. It is resorted twice according to the second row in an ascended order for the values in row 1 that equal one another (e.g., if there are multiples elements equal to 3 in row 1, then the array will sort by the second row instead, so if the second row has values 3 3 3 3 3; 2 6 3 9 1, it will then be sorted to 3 3 3 3 3; 1 2 3 6 9)
I only mentioned this in case reverse sorting might work easier than entirely rearranging the position of the array.
I want to rearrange array B and Ba such that it corresponds to the positioning of array A.
So the new arrays would look like this:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
Aa =
0 0 0 0 0 0 0 1 1 0
The new array would essentially match A, and the array Aa is the same array Ba but now rearranged so that it follows the arrangement of A rather than B.
I am not entirely sure how to write the MATLAB code to accomplish this. All help is appreciated!If I have two arrays A and B as displayed below, how can I rearrange B such that a new boolean array Ba which corresponds to the values of array B can be resorted according to the values of array A instead?
For example, if I have:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
B =
1 2 2 2 3 3 4 4 5 5
2 1 1 2 0 1 0 1 0 1
30 18 25 25 -1 23 -1 30 -1 22
Ba =
0 0 1 0 1 0 0 0 0 0
Note that array B is simply the sorted version of array A according to the first row in an ascended order. It is resorted twice according to the second row in an ascended order for the values in row 1 that equal one another (e.g., if there are multiples elements equal to 3 in row 1, then the array will sort by the second row instead, so if the second row has values 3 3 3 3 3; 2 6 3 9 1, it will then be sorted to 3 3 3 3 3; 1 2 3 6 9)
I only mentioned this in case reverse sorting might work easier than entirely rearranging the position of the array.
I want to rearrange array B and Ba such that it corresponds to the positioning of array A.
So the new arrays would look like this:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
Aa =
0 0 0 0 0 0 0 1 1 0
The new array would essentially match A, and the array Aa is the same array Ba but now rearranged so that it follows the arrangement of A rather than B.
I am not entirely sure how to write the MATLAB code to accomplish this. All help is appreciated! If I have two arrays A and B as displayed below, how can I rearrange B such that a new boolean array Ba which corresponds to the values of array B can be resorted according to the values of array A instead?
For example, if I have:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
B =
1 2 2 2 3 3 4 4 5 5
2 1 1 2 0 1 0 1 0 1
30 18 25 25 -1 23 -1 30 -1 22
Ba =
0 0 1 0 1 0 0 0 0 0
Note that array B is simply the sorted version of array A according to the first row in an ascended order. It is resorted twice according to the second row in an ascended order for the values in row 1 that equal one another (e.g., if there are multiples elements equal to 3 in row 1, then the array will sort by the second row instead, so if the second row has values 3 3 3 3 3; 2 6 3 9 1, it will then be sorted to 3 3 3 3 3; 1 2 3 6 9)
I only mentioned this in case reverse sorting might work easier than entirely rearranging the position of the array.
I want to rearrange array B and Ba such that it corresponds to the positioning of array A.
So the new arrays would look like this:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
Aa =
0 0 0 0 0 0 0 1 1 0
The new array would essentially match A, and the array Aa is the same array Ba but now rearranged so that it follows the arrangement of A rather than B.
I am not entirely sure how to write the MATLAB code to accomplish this. All help is appreciated! array, sort MATLAB Answers — New Questions
STL to solid 3d matrix
Is there a way to import STL and save it as 3D matrix and stlil maintain its size? Patch is a good function to import stl, I need voxelisation of the mesh so I can slice the 2D data out of it.
This is a good work by Adam , but it does not maintain the size and ratio:
https://uk.mathworks.com/matlabcentral/fileexchange/27390-mesh-voxelisation
RegardsIs there a way to import STL and save it as 3D matrix and stlil maintain its size? Patch is a good function to import stl, I need voxelisation of the mesh so I can slice the 2D data out of it.
This is a good work by Adam , but it does not maintain the size and ratio:
https://uk.mathworks.com/matlabcentral/fileexchange/27390-mesh-voxelisation
Regards Is there a way to import STL and save it as 3D matrix and stlil maintain its size? Patch is a good function to import stl, I need voxelisation of the mesh so I can slice the 2D data out of it.
This is a good work by Adam , but it does not maintain the size and ratio:
https://uk.mathworks.com/matlabcentral/fileexchange/27390-mesh-voxelisation
Regards stl, patch, voxelisation MATLAB Answers — New Questions
How to get the values of x axis only visible at the bottom subplots?
Hi,
I have a series of subplots (5×4). Every subplot has the same x axis and the same limits. At the moment, I have the values of x axis visible in every subplot. I would like to have the values only visible at the bottom subplots, so that the figure would be simpler. I already edited the code so that the x label is only visible at the bottom subplots. But how do I do the same to the x axis values?
I tried turning of the ‘XTick’
set(gca,’XTick’,[]);
This worked, however, now the grid also turned off. How can I get the values to be only at the bottom subplots, and the grid on?
The same goes for y axis. I only want the values of the y axis to be visible at the left subplots.
Thank you in advance for any answers!Hi,
I have a series of subplots (5×4). Every subplot has the same x axis and the same limits. At the moment, I have the values of x axis visible in every subplot. I would like to have the values only visible at the bottom subplots, so that the figure would be simpler. I already edited the code so that the x label is only visible at the bottom subplots. But how do I do the same to the x axis values?
I tried turning of the ‘XTick’
set(gca,’XTick’,[]);
This worked, however, now the grid also turned off. How can I get the values to be only at the bottom subplots, and the grid on?
The same goes for y axis. I only want the values of the y axis to be visible at the left subplots.
Thank you in advance for any answers! Hi,
I have a series of subplots (5×4). Every subplot has the same x axis and the same limits. At the moment, I have the values of x axis visible in every subplot. I would like to have the values only visible at the bottom subplots, so that the figure would be simpler. I already edited the code so that the x label is only visible at the bottom subplots. But how do I do the same to the x axis values?
I tried turning of the ‘XTick’
set(gca,’XTick’,[]);
This worked, however, now the grid also turned off. How can I get the values to be only at the bottom subplots, and the grid on?
The same goes for y axis. I only want the values of the y axis to be visible at the left subplots.
Thank you in advance for any answers! subplot, axes, xlabel, xvalue MATLAB Answers — New Questions
Are dlnetworks supposed to be allowed to have output layers?
Are dlnetworks allowed to have output layers? In the following code, I manage to create one, so the answer would seem to be yes.
layers= [imageInputLayer([1,1,1]) , reluLayer(Name=’relu’) ] ;
dln = replaceLayer( dlnetwork(layers) ,’relu’, regressionLayer);
class(dln)
dln.Layers
However, when I try to create this more directly, an error is raised:
dln = dlnetwork( [imageInputLayer([1,1,1]) , regressionLayer] )
Have I found an unintended backdoor?Are dlnetworks allowed to have output layers? In the following code, I manage to create one, so the answer would seem to be yes.
layers= [imageInputLayer([1,1,1]) , reluLayer(Name=’relu’) ] ;
dln = replaceLayer( dlnetwork(layers) ,’relu’, regressionLayer);
class(dln)
dln.Layers
However, when I try to create this more directly, an error is raised:
dln = dlnetwork( [imageInputLayer([1,1,1]) , regressionLayer] )
Have I found an unintended backdoor? Are dlnetworks allowed to have output layers? In the following code, I manage to create one, so the answer would seem to be yes.
layers= [imageInputLayer([1,1,1]) , reluLayer(Name=’relu’) ] ;
dln = replaceLayer( dlnetwork(layers) ,’relu’, regressionLayer);
class(dln)
dln.Layers
However, when I try to create this more directly, an error is raised:
dln = dlnetwork( [imageInputLayer([1,1,1]) , regressionLayer] )
Have I found an unintended backdoor? dlnetwork, output layer MATLAB Answers — New Questions
Inserting Table from Matlab into Powerpoint slide
Does anyone know how to insert a table from MATLAB to a powerpoint slide?
For example:
header = cell{1,3};
header = {‘Header1’ ‘Header2’ ‘Header 3’};
data= [1, 2, 3;
1, 4, 9;];
How would one output this to powerpoint? I’ve seen the Matlab figures to powerpoint copying and pasting, but not sure how to insert a table.
Thanks for your help!Does anyone know how to insert a table from MATLAB to a powerpoint slide?
For example:
header = cell{1,3};
header = {‘Header1’ ‘Header2’ ‘Header 3’};
data= [1, 2, 3;
1, 4, 9;];
How would one output this to powerpoint? I’ve seen the Matlab figures to powerpoint copying and pasting, but not sure how to insert a table.
Thanks for your help! Does anyone know how to insert a table from MATLAB to a powerpoint slide?
For example:
header = cell{1,3};
header = {‘Header1’ ‘Header2’ ‘Header 3’};
data= [1, 2, 3;
1, 4, 9;];
How would one output this to powerpoint? I’ve seen the Matlab figures to powerpoint copying and pasting, but not sure how to insert a table.
Thanks for your help! powerpoint, table, inserting MATLAB Answers — New Questions
IK solver algorithm fminconsqp performance (2025a prerelease)
Hello everyone,
I’ve been testing 2025a prerelease matlab version’s new IK solver algorithm fminconsqp with default parameters, but BFGS with random restart enabled (while keeping other parameters default) still seems more powerful.
Am I missing something? I can’t quite figure out the advantage of this new solver.
Thanks in advance!Hello everyone,
I’ve been testing 2025a prerelease matlab version’s new IK solver algorithm fminconsqp with default parameters, but BFGS with random restart enabled (while keeping other parameters default) still seems more powerful.
Am I missing something? I can’t quite figure out the advantage of this new solver.
Thanks in advance! Hello everyone,
I’ve been testing 2025a prerelease matlab version’s new IK solver algorithm fminconsqp with default parameters, but BFGS with random restart enabled (while keeping other parameters default) still seems more powerful.
Am I missing something? I can’t quite figure out the advantage of this new solver.
Thanks in advance! matlab MATLAB Answers — New Questions
How to ensure that all values are not equal when using the ecef2enu function
I’m doing coordinate system transformation using the ecef2enu function. But for some reason, all three E, N, and U values are the same. I wonder why. How can I modify it to get the exact value?
Isn’t it normal for the 1, 2, 3 matrices to have different values? Is there something wrong with my code?
currTime = gnss.SensorModel.InitialTime;
setup(scene)
wgs84 = wgs84Ellipsoid(‘meter’);
while scene.IsRunning
[~,~,p,satPos,status] = gnss.read ();
allSatPos = gnssconstellation(currTime); % ecef
currTime = currTime + seconds(1/scene.UpdateRate);
[~,trueRecPos] = plat.read; % lla
trueRecPos_ecef = lla2ecef(trueRecPos); % uav ecef
[az,el] = lookangles(trueRecPos,satPos,gnss.SensorModel.MaskAngle);
nsat = length(satPos(:,1));
enu_sat = zeros(nsat,3);
for k = 1:1:nsat
enu_sat(k,:) = ecef2enu(satPos(k,1),satPos(k,2),satPos(k,3),trueRecPos(1),trueRecPos(2),trueRecPos(3),wgs84);
end
temp=1;
unit_sat = normalize(enu_sat,’norm’,1);
target_z = 500;
scale_factors = target_z ./ unit_sat(:,3);
unit_sat_scaled = unit_sat .* scale_factors;
endI’m doing coordinate system transformation using the ecef2enu function. But for some reason, all three E, N, and U values are the same. I wonder why. How can I modify it to get the exact value?
Isn’t it normal for the 1, 2, 3 matrices to have different values? Is there something wrong with my code?
currTime = gnss.SensorModel.InitialTime;
setup(scene)
wgs84 = wgs84Ellipsoid(‘meter’);
while scene.IsRunning
[~,~,p,satPos,status] = gnss.read ();
allSatPos = gnssconstellation(currTime); % ecef
currTime = currTime + seconds(1/scene.UpdateRate);
[~,trueRecPos] = plat.read; % lla
trueRecPos_ecef = lla2ecef(trueRecPos); % uav ecef
[az,el] = lookangles(trueRecPos,satPos,gnss.SensorModel.MaskAngle);
nsat = length(satPos(:,1));
enu_sat = zeros(nsat,3);
for k = 1:1:nsat
enu_sat(k,:) = ecef2enu(satPos(k,1),satPos(k,2),satPos(k,3),trueRecPos(1),trueRecPos(2),trueRecPos(3),wgs84);
end
temp=1;
unit_sat = normalize(enu_sat,’norm’,1);
target_z = 500;
scale_factors = target_z ./ unit_sat(:,3);
unit_sat_scaled = unit_sat .* scale_factors;
end I’m doing coordinate system transformation using the ecef2enu function. But for some reason, all three E, N, and U values are the same. I wonder why. How can I modify it to get the exact value?
Isn’t it normal for the 1, 2, 3 matrices to have different values? Is there something wrong with my code?
currTime = gnss.SensorModel.InitialTime;
setup(scene)
wgs84 = wgs84Ellipsoid(‘meter’);
while scene.IsRunning
[~,~,p,satPos,status] = gnss.read ();
allSatPos = gnssconstellation(currTime); % ecef
currTime = currTime + seconds(1/scene.UpdateRate);
[~,trueRecPos] = plat.read; % lla
trueRecPos_ecef = lla2ecef(trueRecPos); % uav ecef
[az,el] = lookangles(trueRecPos,satPos,gnss.SensorModel.MaskAngle);
nsat = length(satPos(:,1));
enu_sat = zeros(nsat,3);
for k = 1:1:nsat
enu_sat(k,:) = ecef2enu(satPos(k,1),satPos(k,2),satPos(k,3),trueRecPos(1),trueRecPos(2),trueRecPos(3),wgs84);
end
temp=1;
unit_sat = normalize(enu_sat,’norm’,1);
target_z = 500;
scale_factors = target_z ./ unit_sat(:,3);
unit_sat_scaled = unit_sat .* scale_factors;
end optimization, gnss, ecef2enu, enu, ecef MATLAB Answers — New Questions
Why is my Simulink Desktop Real-Time simulation very slow or halts in Windows when Hyper-V is enabled?
I am trying to use Simulink Desktop Real-Time (SLDRT) on my Windows machine, but when I launch the example model "sldrtex_vdp.slx", it runs very slow, halts, or may even cause a blue-screen.
The following warning message may be prompted out:
Warning: The "Real-Time Synchronization" block has timed out while
trying to synchronize to real-time kernel.
The following warning messages may be shown in Diagnostic Viewer:
Model sldrtex_vdp loaded
A disconnect message was sent to the target 10 seconds ago. Waiting for response.. [6 similar]
Never received disconnect response from target. Disconnecting…
Model sldrtex_vdp unloaded
Additionally, I may see the following error message during the kernel installation (since R2019b) or when trying to run a real-time simulation (since R2020b):
The Hyper-V hypervisor has been detected. The Simulink Desktop Real-Time kernel
cannot run in the presence of the hypervisor. Please disable the Hyper-V operating
system component before attempting to use Simulink Desktop Real-Time.I am trying to use Simulink Desktop Real-Time (SLDRT) on my Windows machine, but when I launch the example model "sldrtex_vdp.slx", it runs very slow, halts, or may even cause a blue-screen.
The following warning message may be prompted out:
Warning: The "Real-Time Synchronization" block has timed out while
trying to synchronize to real-time kernel.
The following warning messages may be shown in Diagnostic Viewer:
Model sldrtex_vdp loaded
A disconnect message was sent to the target 10 seconds ago. Waiting for response.. [6 similar]
Never received disconnect response from target. Disconnecting…
Model sldrtex_vdp unloaded
Additionally, I may see the following error message during the kernel installation (since R2019b) or when trying to run a real-time simulation (since R2020b):
The Hyper-V hypervisor has been detected. The Simulink Desktop Real-Time kernel
cannot run in the presence of the hypervisor. Please disable the Hyper-V operating
system component before attempting to use Simulink Desktop Real-Time. I am trying to use Simulink Desktop Real-Time (SLDRT) on my Windows machine, but when I launch the example model "sldrtex_vdp.slx", it runs very slow, halts, or may even cause a blue-screen.
The following warning message may be prompted out:
Warning: The "Real-Time Synchronization" block has timed out while
trying to synchronize to real-time kernel.
The following warning messages may be shown in Diagnostic Viewer:
Model sldrtex_vdp loaded
A disconnect message was sent to the target 10 seconds ago. Waiting for response.. [6 similar]
Never received disconnect response from target. Disconnecting…
Model sldrtex_vdp unloaded
Additionally, I may see the following error message during the kernel installation (since R2019b) or when trying to run a real-time simulation (since R2020b):
The Hyper-V hypervisor has been detected. The Simulink Desktop Real-Time kernel
cannot run in the presence of the hypervisor. Please disable the Hyper-V operating
system component before attempting to use Simulink Desktop Real-Time. slow, timeout, sldrt, bluescreen, bsod, hyper-v, hypervisor MATLAB Answers — New Questions
Abnormally high reaction force in Simscape Multibody
Hello,
I have a simscape model of a hexapod robot which I am trying to make traverse over a small obstacle. When walking on the regular floor object, the robot is fine. However, as soon as the first leg makes contact with the obstacle, it experiences an abnormally high normal reaction force, causing the whole robot to get sent flying into the air. I am not sure why this is happening. The settings for the spatial contact forces between the floor object and the obstacle object are identical. Here is a video from the mechanics explorer (apologies for the speed, it may have to be watched on 0.25x playback).
I have tried everything I can think of – tweaking stiffness and damping parameters (K_obs and C_obs) and trying different solver settings/tolerances. Drastically reducing the stiffness and damping coefficients does help, but results in the legs of the robot sinking several millimetres through the obstacle.
I have attached a zip file containing the full project. To run the model, open and run HexMaster.m. Then, run adeept.slx. Any help would be massively appreciated.Hello,
I have a simscape model of a hexapod robot which I am trying to make traverse over a small obstacle. When walking on the regular floor object, the robot is fine. However, as soon as the first leg makes contact with the obstacle, it experiences an abnormally high normal reaction force, causing the whole robot to get sent flying into the air. I am not sure why this is happening. The settings for the spatial contact forces between the floor object and the obstacle object are identical. Here is a video from the mechanics explorer (apologies for the speed, it may have to be watched on 0.25x playback).
I have tried everything I can think of – tweaking stiffness and damping parameters (K_obs and C_obs) and trying different solver settings/tolerances. Drastically reducing the stiffness and damping coefficients does help, but results in the legs of the robot sinking several millimetres through the obstacle.
I have attached a zip file containing the full project. To run the model, open and run HexMaster.m. Then, run adeept.slx. Any help would be massively appreciated. Hello,
I have a simscape model of a hexapod robot which I am trying to make traverse over a small obstacle. When walking on the regular floor object, the robot is fine. However, as soon as the first leg makes contact with the obstacle, it experiences an abnormally high normal reaction force, causing the whole robot to get sent flying into the air. I am not sure why this is happening. The settings for the spatial contact forces between the floor object and the obstacle object are identical. Here is a video from the mechanics explorer (apologies for the speed, it may have to be watched on 0.25x playback).
I have tried everything I can think of – tweaking stiffness and damping parameters (K_obs and C_obs) and trying different solver settings/tolerances. Drastically reducing the stiffness and damping coefficients does help, but results in the legs of the robot sinking several millimetres through the obstacle.
I have attached a zip file containing the full project. To run the model, open and run HexMaster.m. Then, run adeept.slx. Any help would be massively appreciated. simscape, multibody MATLAB Answers — New Questions
regarding to your support
I hope you well receive this messege as well.
I am happy jion for your site.
I start to do project on UAV
kindy could you please send me you tube, documets regarding to quadrotror mathlab simulink?
Please help meI hope you well receive this messege as well.
I am happy jion for your site.
I start to do project on UAV
kindy could you please send me you tube, documets regarding to quadrotror mathlab simulink?
Please help me I hope you well receive this messege as well.
I am happy jion for your site.
I start to do project on UAV
kindy could you please send me you tube, documets regarding to quadrotror mathlab simulink?
Please help me uav MATLAB Answers — New Questions
Is it possible to orient the legend’s symbols vertically instead of horizontally?
Is it possible to orient the legend’s symbols vertically instead of horizontally?
In the following example, the red and blue lines in the legend are horizontally oriented, but I would like them to be vertically oriented within the legend:
x = linspace(0, 10, 100);
y1 = sin(x);
y2 = cos(x);
plot(x, y1, ‘red’, x, y2, ‘blue’);
hold on;
h1 = plot(nan, nan, ‘red’, ‘LineWidth’, 2);
h2 = plot(nan, nan, ‘blue’, ‘LineWidth’, 2);
legend([h1, h2], ‘sin(x)’, ‘cos(x)’);Is it possible to orient the legend’s symbols vertically instead of horizontally?
In the following example, the red and blue lines in the legend are horizontally oriented, but I would like them to be vertically oriented within the legend:
x = linspace(0, 10, 100);
y1 = sin(x);
y2 = cos(x);
plot(x, y1, ‘red’, x, y2, ‘blue’);
hold on;
h1 = plot(nan, nan, ‘red’, ‘LineWidth’, 2);
h2 = plot(nan, nan, ‘blue’, ‘LineWidth’, 2);
legend([h1, h2], ‘sin(x)’, ‘cos(x)’); Is it possible to orient the legend’s symbols vertically instead of horizontally?
In the following example, the red and blue lines in the legend are horizontally oriented, but I would like them to be vertically oriented within the legend:
x = linspace(0, 10, 100);
y1 = sin(x);
y2 = cos(x);
plot(x, y1, ‘red’, x, y2, ‘blue’);
hold on;
h1 = plot(nan, nan, ‘red’, ‘LineWidth’, 2);
h2 = plot(nan, nan, ‘blue’, ‘LineWidth’, 2);
legend([h1, h2], ‘sin(x)’, ‘cos(x)’); legend, symbols, lines, plot MATLAB Answers — New Questions
Why do I receive the error: Unrecognized function or variable ‘V_o’?
Please guide me to solve the following error:
Warning: The specified buffer for ‘Convertidor_Boost/Mean/Model/Transport Delay’ was too small. During simulation, the buffer size was
temporarily increased to 106496. In order to generate code, you need to update the buffer size parameter
Unrecognized function or variable ‘V_o’.
Error in Run_Convertidor_Boost (line 62)
plot(tt1,V_o)
Thank you so much,
Edwin Rodríguez JiménezPlease guide me to solve the following error:
Warning: The specified buffer for ‘Convertidor_Boost/Mean/Model/Transport Delay’ was too small. During simulation, the buffer size was
temporarily increased to 106496. In order to generate code, you need to update the buffer size parameter
Unrecognized function or variable ‘V_o’.
Error in Run_Convertidor_Boost (line 62)
plot(tt1,V_o)
Thank you so much,
Edwin Rodríguez Jiménez Please guide me to solve the following error:
Warning: The specified buffer for ‘Convertidor_Boost/Mean/Model/Transport Delay’ was too small. During simulation, the buffer size was
temporarily increased to 106496. In order to generate code, you need to update the buffer size parameter
Unrecognized function or variable ‘V_o’.
Error in Run_Convertidor_Boost (line 62)
plot(tt1,V_o)
Thank you so much,
Edwin Rodríguez Jiménez ftt, matlab, simulink MATLAB Answers — New Questions
Managing preferences does not work for add ons explorer issue
I was trying to get the Field Trip Toolbox as an add on, and https://in.mathworks.com/matlabcentral/answers/60662-how-do-i-install-fieldtrip-toolbox tells me that installing it from https://www.fieldtriptoolbox.org/ doesn’t go well.
I tried regenerating preferences, as stated in https://www.mathworks.com/matlabcentral/answers/99625-how-do-i-regenerate-my-matlab-preferences, but to no avail. I still get the message:
Error in matab.internal.addons.launchers.showExplorer (line 134)
matlab.internal.addons.Explorer.getInstance.show(navigationData);
Is there no other way than to reinstall the whole package?I was trying to get the Field Trip Toolbox as an add on, and https://in.mathworks.com/matlabcentral/answers/60662-how-do-i-install-fieldtrip-toolbox tells me that installing it from https://www.fieldtriptoolbox.org/ doesn’t go well.
I tried regenerating preferences, as stated in https://www.mathworks.com/matlabcentral/answers/99625-how-do-i-regenerate-my-matlab-preferences, but to no avail. I still get the message:
Error in matab.internal.addons.launchers.showExplorer (line 134)
matlab.internal.addons.Explorer.getInstance.show(navigationData);
Is there no other way than to reinstall the whole package? I was trying to get the Field Trip Toolbox as an add on, and https://in.mathworks.com/matlabcentral/answers/60662-how-do-i-install-fieldtrip-toolbox tells me that installing it from https://www.fieldtriptoolbox.org/ doesn’t go well.
I tried regenerating preferences, as stated in https://www.mathworks.com/matlabcentral/answers/99625-how-do-i-regenerate-my-matlab-preferences, but to no avail. I still get the message:
Error in matab.internal.addons.launchers.showExplorer (line 134)
matlab.internal.addons.Explorer.getInstance.show(navigationData);
Is there no other way than to reinstall the whole package? edf, add-ons MATLAB Answers — New Questions