Tag Archives: matlab
why my 3D image is not extruded in 3D software?
Hello, i have 3D image but when I view the image in the 3D software to be printed, the image does not extrude. here i attached my code and images. can anyone check on my code. Many thanks.
a = imread (‘stomachgray.tif’);
mask = zeros(size(a));
mask(100:end-100,100:end-100) = 1;
bw = activecontour(a,mask,1000);
c = im2double(bw);
shading flat
d = imgaussfilt3 (c,4);
colormap(bone)
h = hgtransform;
mesh(d*100, ‘Parent’, h, ‘FaceColor’, ‘r’ )
view(3)
lighting gouraud
camlight right
% Make it taller
set (gca, ‘units’, ‘cent’)
set(h, ‘Matrix’, makehgtform(‘scale’, [10 10 500]))
[X,Y] = meshgrid(1:length(h));
surf2stl(‘stomachSurf7.stl’,X,Y,d);
end
<</matlabcentral/answers/uploaded_files/64209/3d%20mtlb.JPG>>
<</matlabcentral/answers/uploaded_files/64210/3d%20view.JPG>>Hello, i have 3D image but when I view the image in the 3D software to be printed, the image does not extrude. here i attached my code and images. can anyone check on my code. Many thanks.
a = imread (‘stomachgray.tif’);
mask = zeros(size(a));
mask(100:end-100,100:end-100) = 1;
bw = activecontour(a,mask,1000);
c = im2double(bw);
shading flat
d = imgaussfilt3 (c,4);
colormap(bone)
h = hgtransform;
mesh(d*100, ‘Parent’, h, ‘FaceColor’, ‘r’ )
view(3)
lighting gouraud
camlight right
% Make it taller
set (gca, ‘units’, ‘cent’)
set(h, ‘Matrix’, makehgtform(‘scale’, [10 10 500]))
[X,Y] = meshgrid(1:length(h));
surf2stl(‘stomachSurf7.stl’,X,Y,d);
end
<</matlabcentral/answers/uploaded_files/64209/3d%20mtlb.JPG>>
<</matlabcentral/answers/uploaded_files/64210/3d%20view.JPG>> Hello, i have 3D image but when I view the image in the 3D software to be printed, the image does not extrude. here i attached my code and images. can anyone check on my code. Many thanks.
a = imread (‘stomachgray.tif’);
mask = zeros(size(a));
mask(100:end-100,100:end-100) = 1;
bw = activecontour(a,mask,1000);
c = im2double(bw);
shading flat
d = imgaussfilt3 (c,4);
colormap(bone)
h = hgtransform;
mesh(d*100, ‘Parent’, h, ‘FaceColor’, ‘r’ )
view(3)
lighting gouraud
camlight right
% Make it taller
set (gca, ‘units’, ‘cent’)
set(h, ‘Matrix’, makehgtform(‘scale’, [10 10 500]))
[X,Y] = meshgrid(1:length(h));
surf2stl(‘stomachSurf7.stl’,X,Y,d);
end
<</matlabcentral/answers/uploaded_files/64209/3d%20mtlb.JPG>>
<</matlabcentral/answers/uploaded_files/64210/3d%20view.JPG>> mesh, extrude, matlab, 3d image MATLAB Answers — New Questions
How can ı solve this triangle problem at MATLAB?
In the triangle which has edges names:a,b,c; a=9 b=18 c=25 how can ı calculate the alfa(the angles sees a) with the law of cosines? with MATLABIn the triangle which has edges names:a,b,c; a=9 b=18 c=25 how can ı calculate the alfa(the angles sees a) with the law of cosines? with MATLAB In the triangle which has edges names:a,b,c; a=9 b=18 c=25 how can ı calculate the alfa(the angles sees a) with the law of cosines? with MATLAB matlab, mathematics, homework MATLAB Answers — New Questions
I need to rotate my 3D figure
I have particle size data for differrent De(parameter) values.
I have plotted 2Dbar graphs, I want stack all figures into one 3D figure window.
I stacked everything, that looks like the image below
But I want to rotate axis in such a way that: Particle_density(Y-axis) in vertical, Particle size(X-axis) in horizontal and De (z-axis) per pendicular to the screen. It should look like this image below
I have attached my matlab code to this thread.
Please guide me, how to do this. Thanks in advanceI have particle size data for differrent De(parameter) values.
I have plotted 2Dbar graphs, I want stack all figures into one 3D figure window.
I stacked everything, that looks like the image below
But I want to rotate axis in such a way that: Particle_density(Y-axis) in vertical, Particle size(X-axis) in horizontal and De (z-axis) per pendicular to the screen. It should look like this image below
I have attached my matlab code to this thread.
Please guide me, how to do this. Thanks in advance I have particle size data for differrent De(parameter) values.
I have plotted 2Dbar graphs, I want stack all figures into one 3D figure window.
I stacked everything, that looks like the image below
But I want to rotate axis in such a way that: Particle_density(Y-axis) in vertical, Particle size(X-axis) in horizontal and De (z-axis) per pendicular to the screen. It should look like this image below
I have attached my matlab code to this thread.
Please guide me, how to do this. Thanks in advance rotation, bar, plot3 MATLAB Answers — New Questions
How to fill a volume with spheres?
Hi,
I’d like to import *.stl files of different shapes and fill the volume with overlapping spheres.
How can I do it. I already did this task for 2D shapes using bwdist. But for 3D shapes, I don’t know how to do it.
ThanksHi,
I’d like to import *.stl files of different shapes and fill the volume with overlapping spheres.
How can I do it. I already did this task for 2D shapes using bwdist. But for 3D shapes, I don’t know how to do it.
Thanks Hi,
I’d like to import *.stl files of different shapes and fill the volume with overlapping spheres.
How can I do it. I already did this task for 2D shapes using bwdist. But for 3D shapes, I don’t know how to do it.
Thanks 3d, shapes, spheres, volume filling MATLAB Answers — New Questions
how to use stlwrite function options
Hi guys, i have to make a triangulation 3D of a solid of which i have the coordinates (x,y,z) of 20ooo points and i need to export the result (so the tetrahedra) to an stl file.
How can I use properly the stlwrite function, in particular the option indicated with TRIANGULATION?
thanks a lot.Hi guys, i have to make a triangulation 3D of a solid of which i have the coordinates (x,y,z) of 20ooo points and i need to export the result (so the tetrahedra) to an stl file.
How can I use properly the stlwrite function, in particular the option indicated with TRIANGULATION?
thanks a lot. Hi guys, i have to make a triangulation 3D of a solid of which i have the coordinates (x,y,z) of 20ooo points and i need to export the result (so the tetrahedra) to an stl file.
How can I use properly the stlwrite function, in particular the option indicated with TRIANGULATION?
thanks a lot. triangulation delaunay stl .stl stlwrite MATLAB Answers — New Questions
Spider Plot with Standard Deviation as shaded region
I want to plot a spider plot where each spoke represents the average value with solid line. In addition, I want to show standard deviation as shaded region around the average plot (Average+SD and Average-SD). I have attached a figure to show the desired outcome.
Figure available at: https://www.mdpi.com/2078-2489/15/6/364
Thank you in advance.I want to plot a spider plot where each spoke represents the average value with solid line. In addition, I want to show standard deviation as shaded region around the average plot (Average+SD and Average-SD). I have attached a figure to show the desired outcome.
Figure available at: https://www.mdpi.com/2078-2489/15/6/364
Thank you in advance. I want to plot a spider plot where each spoke represents the average value with solid line. In addition, I want to show standard deviation as shaded region around the average plot (Average+SD and Average-SD). I have attached a figure to show the desired outcome.
Figure available at: https://www.mdpi.com/2078-2489/15/6/364
Thank you in advance. spider plots, standard deviation, shaded region MATLAB Answers — New Questions
Setting axes with center in origin (0,0) in plotted variables.
Hey community, I have two variables with <10 x 1> double data. I am to plot these two in a plot, but would like to have the axes to be intersecting each other in origin (0,0). Instead in the axes are shown with intersecting at for example (-2000,-6), my lowest x-value is -1200, lowest y-value is -6. Here it would be great to have the x-axis through y=0, so that differences from y=0 easily can be seen graphically.
How would I do that, is there a command you could use in the script written, to make it move the axes? I have a large script to evaluate a lot of graphs in, so a MATLAB-command would be preferable to a tool in the figure builder.
The (simple) code used is as following:
%% person5 – Puls
hold on
plot(person5_ethanol_ekgpuls_tid,person5_ethanol_ekgpuls,’g.-‘)
xlabel(‘Tid/Sek’)
ylabel(‘Blodtryk/MmHg’)
title(‘Forsøgsperson #5 Ethanol Ekg Puls’)
Hope that my question is understandable and that it can be done.Hey community, I have two variables with <10 x 1> double data. I am to plot these two in a plot, but would like to have the axes to be intersecting each other in origin (0,0). Instead in the axes are shown with intersecting at for example (-2000,-6), my lowest x-value is -1200, lowest y-value is -6. Here it would be great to have the x-axis through y=0, so that differences from y=0 easily can be seen graphically.
How would I do that, is there a command you could use in the script written, to make it move the axes? I have a large script to evaluate a lot of graphs in, so a MATLAB-command would be preferable to a tool in the figure builder.
The (simple) code used is as following:
%% person5 – Puls
hold on
plot(person5_ethanol_ekgpuls_tid,person5_ethanol_ekgpuls,’g.-‘)
xlabel(‘Tid/Sek’)
ylabel(‘Blodtryk/MmHg’)
title(‘Forsøgsperson #5 Ethanol Ekg Puls’)
Hope that my question is understandable and that it can be done. Hey community, I have two variables with <10 x 1> double data. I am to plot these two in a plot, but would like to have the axes to be intersecting each other in origin (0,0). Instead in the axes are shown with intersecting at for example (-2000,-6), my lowest x-value is -1200, lowest y-value is -6. Here it would be great to have the x-axis through y=0, so that differences from y=0 easily can be seen graphically.
How would I do that, is there a command you could use in the script written, to make it move the axes? I have a large script to evaluate a lot of graphs in, so a MATLAB-command would be preferable to a tool in the figure builder.
The (simple) code used is as following:
%% person5 – Puls
hold on
plot(person5_ethanol_ekgpuls_tid,person5_ethanol_ekgpuls,’g.-‘)
xlabel(‘Tid/Sek’)
ylabel(‘Blodtryk/MmHg’)
title(‘Forsøgsperson #5 Ethanol Ekg Puls’)
Hope that my question is understandable and that it can be done. axes in plots, plot, figures, moving axes, origin MATLAB Answers — New Questions
How to programmatically get a list of all app properties in AppDesigner
Hi,
I’m writing a large app in appDesigner, and I want to create a list / text area that would display all of the app property fields. I can’t find a way to programatically pull their names, does anyone know a way of doing this?
P.S. I’m on 2022b.
Thanks!
VSHi,
I’m writing a large app in appDesigner, and I want to create a list / text area that would display all of the app property fields. I can’t find a way to programatically pull their names, does anyone know a way of doing this?
P.S. I’m on 2022b.
Thanks!
VS Hi,
I’m writing a large app in appDesigner, and I want to create a list / text area that would display all of the app property fields. I can’t find a way to programatically pull their names, does anyone know a way of doing this?
P.S. I’m on 2022b.
Thanks!
VS appdesigner MATLAB Answers — New Questions
How to make only x-axis invisible (y-axis stays visible)?
I have two axes (top, bottom) in a GUI. I do not want the x-axis of the top ghraph to be present (because it is the same as the bottom x-axis). I could not find how to handle separately the x and y axis visibility.
CsabaI have two axes (top, bottom) in a GUI. I do not want the x-axis of the top ghraph to be present (because it is the same as the bottom x-axis). I could not find how to handle separately the x and y axis visibility.
Csaba I have two axes (top, bottom) in a GUI. I do not want the x-axis of the top ghraph to be present (because it is the same as the bottom x-axis). I could not find how to handle separately the x and y axis visibility.
Csaba axis, visibility MATLAB Answers — New Questions
How do I link to Simulink variable from app designer
Ive created a model in app designer and want to change an image in the app based on the state of a value in the model. For example image is a pump and if the Simulink model state is 0 I want to use the closed pump image, if the state is 1 use the pump running image etc. The image widget doesn’t support bindings. that’s OK I can set up my own function and schedule it to run every second to check the pump state. In the model I have a variable setup that’s being logged. In the app I’m then trying to access that variable using: app.Simulation.LoggedSignals(‘PumpCtrlMdl/PumpState:1’).Values But this returns empty. How would I update my code so I get the value of the output value correctly?Ive created a model in app designer and want to change an image in the app based on the state of a value in the model. For example image is a pump and if the Simulink model state is 0 I want to use the closed pump image, if the state is 1 use the pump running image etc. The image widget doesn’t support bindings. that’s OK I can set up my own function and schedule it to run every second to check the pump state. In the model I have a variable setup that’s being logged. In the app I’m then trying to access that variable using: app.Simulation.LoggedSignals(‘PumpCtrlMdl/PumpState:1’).Values But this returns empty. How would I update my code so I get the value of the output value correctly? Ive created a model in app designer and want to change an image in the app based on the state of a value in the model. For example image is a pump and if the Simulink model state is 0 I want to use the closed pump image, if the state is 1 use the pump running image etc. The image widget doesn’t support bindings. that’s OK I can set up my own function and schedule it to run every second to check the pump state. In the model I have a variable setup that’s being logged. In the app I’m then trying to access that variable using: app.Simulation.LoggedSignals(‘PumpCtrlMdl/PumpState:1’).Values But this returns empty. How would I update my code so I get the value of the output value correctly? simulink, appdesigner MATLAB Answers — New Questions
Bug in readtable()? – if the first values in a CSV’s column are missing, the whole column is misinterpreted
I am reading a big CSV file (500K lines) with readtable. In the CSV, some columns have the first 250+ lines empty (e.g. ",,,," in the CSV), while the non-missing values below (pretty rare) are either text strings or dates (in the DD-MM-YYYY format). Readtable() somehow interprets these columns as numeric, and so converts all the strings and dates into NaNs – thus, I end up with 100% NaN-filled columns instead of rarely-populated data (among empty strings and NaTs).
Furthermore, if I move the "with-data" lines up – even a few dozens positions up – readtable() starts to read everything normally!
So, it looks like readtable() checks only ~250 first values to determine the type of the column, which, in my opinion, is a bug! (Although I understand that it was likely made to improve speed.)
Is there a way to fix it systematically? I have lots of such CSVs with thousands of columns in them – so, a manual check and manual fix is not an option…
UPD: a test-file (truncated to 510 lines) is attached – the behaviour is still the same. The problem columns are the 2nd and the 3rd (p190, p191). The first non-empty value is on data-line 270.I am reading a big CSV file (500K lines) with readtable. In the CSV, some columns have the first 250+ lines empty (e.g. ",,,," in the CSV), while the non-missing values below (pretty rare) are either text strings or dates (in the DD-MM-YYYY format). Readtable() somehow interprets these columns as numeric, and so converts all the strings and dates into NaNs – thus, I end up with 100% NaN-filled columns instead of rarely-populated data (among empty strings and NaTs).
Furthermore, if I move the "with-data" lines up – even a few dozens positions up – readtable() starts to read everything normally!
So, it looks like readtable() checks only ~250 first values to determine the type of the column, which, in my opinion, is a bug! (Although I understand that it was likely made to improve speed.)
Is there a way to fix it systematically? I have lots of such CSVs with thousands of columns in them – so, a manual check and manual fix is not an option…
UPD: a test-file (truncated to 510 lines) is attached – the behaviour is still the same. The problem columns are the 2nd and the 3rd (p190, p191). The first non-empty value is on data-line 270. I am reading a big CSV file (500K lines) with readtable. In the CSV, some columns have the first 250+ lines empty (e.g. ",,,," in the CSV), while the non-missing values below (pretty rare) are either text strings or dates (in the DD-MM-YYYY format). Readtable() somehow interprets these columns as numeric, and so converts all the strings and dates into NaNs – thus, I end up with 100% NaN-filled columns instead of rarely-populated data (among empty strings and NaTs).
Furthermore, if I move the "with-data" lines up – even a few dozens positions up – readtable() starts to read everything normally!
So, it looks like readtable() checks only ~250 first values to determine the type of the column, which, in my opinion, is a bug! (Although I understand that it was likely made to improve speed.)
Is there a way to fix it systematically? I have lots of such CSVs with thousands of columns in them – so, a manual check and manual fix is not an option…
UPD: a test-file (truncated to 510 lines) is attached – the behaviour is still the same. The problem columns are the 2nd and the 3rd (p190, p191). The first non-empty value is on data-line 270. readtable, missing values, csv MATLAB Answers — New Questions
How to add labels to lines on a plot in MATLAB?
When there are a lot of lines on a plot, it can be difficult to use a legend to distinguish individual lines. How can I label individual lines on a plot in MATLAB?When there are a lot of lines on a plot, it can be difficult to use a legend to distinguish individual lines. How can I label individual lines on a plot in MATLAB? When there are a lot of lines on a plot, it can be difficult to use a legend to distinguish individual lines. How can I label individual lines on a plot in MATLAB? legend, line, label, text, annotation MATLAB Answers — New Questions
Change configurations of the WLAN HDL examples of transmitter and receiver
Dear all,
I am recently trying to use the WLAN examples of the wireless HDL toolbox:
https://jp.mathworks.com/help/wireless-hdl/ug/wlanhdltransmitter.html
https://jp.mathworks.com/help/wireless-hdl/ug/wlanhdlreceiver.html
In these two examples of transmitter and receiver, it seems to support 802.11a/n/ac.
For instance, I would like to use 802.11n, then these should be selected:
HT: switched by "frameFormat"?
ODFM only: How to select?
MCS: which one should be select?
For 20 MHz channel bandwidth, which clock rare should be used in FPGA to drive the HDL codes?
ADC bit width: It seems to be 32 bit by default. How can I change to other bit width?
If I would like to use other than a/n/ac, how can I do?
For such kinds of the configurations or so, I would appreciate if anyone can instruct me how to change them before generating HDL.
Thank you in advance.Dear all,
I am recently trying to use the WLAN examples of the wireless HDL toolbox:
https://jp.mathworks.com/help/wireless-hdl/ug/wlanhdltransmitter.html
https://jp.mathworks.com/help/wireless-hdl/ug/wlanhdlreceiver.html
In these two examples of transmitter and receiver, it seems to support 802.11a/n/ac.
For instance, I would like to use 802.11n, then these should be selected:
HT: switched by "frameFormat"?
ODFM only: How to select?
MCS: which one should be select?
For 20 MHz channel bandwidth, which clock rare should be used in FPGA to drive the HDL codes?
ADC bit width: It seems to be 32 bit by default. How can I change to other bit width?
If I would like to use other than a/n/ac, how can I do?
For such kinds of the configurations or so, I would appreciate if anyone can instruct me how to change them before generating HDL.
Thank you in advance. Dear all,
I am recently trying to use the WLAN examples of the wireless HDL toolbox:
https://jp.mathworks.com/help/wireless-hdl/ug/wlanhdltransmitter.html
https://jp.mathworks.com/help/wireless-hdl/ug/wlanhdlreceiver.html
In these two examples of transmitter and receiver, it seems to support 802.11a/n/ac.
For instance, I would like to use 802.11n, then these should be selected:
HT: switched by "frameFormat"?
ODFM only: How to select?
MCS: which one should be select?
For 20 MHz channel bandwidth, which clock rare should be used in FPGA to drive the HDL codes?
ADC bit width: It seems to be 32 bit by default. How can I change to other bit width?
If I would like to use other than a/n/ac, how can I do?
For such kinds of the configurations or so, I would appreciate if anyone can instruct me how to change them before generating HDL.
Thank you in advance. wlan, wireless, hdl, simulink, matlab MATLAB Answers — New Questions
How to align multiline label and legend?
Hello
Using sprintf it is possible to create multiline labels in a legend. However, as shown in the example below, it would be better if the legend symbol (the colored line) would always be aligned with the first line of the multiline label, so aligned on top instead of being centered. The current output looks a bit confusing. Is it possible to control the position of the legend symbol w.r.t. the label?
Thanks in advance.
x=1:5;
y1=x;
y2=x.^2;
y3=x.^3;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
legend({‘first graph $y=x$’, sprintf(‘%sn%s’, ‘second graph’, ‘$y=x^2$’), sprintf(‘%sn%s’, ‘third graph’, ‘$y=x^3$’)}, ‘Interpreter’, ‘latex’)Hello
Using sprintf it is possible to create multiline labels in a legend. However, as shown in the example below, it would be better if the legend symbol (the colored line) would always be aligned with the first line of the multiline label, so aligned on top instead of being centered. The current output looks a bit confusing. Is it possible to control the position of the legend symbol w.r.t. the label?
Thanks in advance.
x=1:5;
y1=x;
y2=x.^2;
y3=x.^3;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
legend({‘first graph $y=x$’, sprintf(‘%sn%s’, ‘second graph’, ‘$y=x^2$’), sprintf(‘%sn%s’, ‘third graph’, ‘$y=x^3$’)}, ‘Interpreter’, ‘latex’) Hello
Using sprintf it is possible to create multiline labels in a legend. However, as shown in the example below, it would be better if the legend symbol (the colored line) would always be aligned with the first line of the multiline label, so aligned on top instead of being centered. The current output looks a bit confusing. Is it possible to control the position of the legend symbol w.r.t. the label?
Thanks in advance.
x=1:5;
y1=x;
y2=x.^2;
y3=x.^3;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
legend({‘first graph $y=x$’, sprintf(‘%sn%s’, ‘second graph’, ‘$y=x^2$’), sprintf(‘%sn%s’, ‘third graph’, ‘$y=x^3$’)}, ‘Interpreter’, ‘latex’) legend, multiline, align MATLAB Answers — New Questions
Why don’t gain and phase margins appear on my Bode plot?
I have discrete-time frequency response data in the form of a "frd" object. When I try to show the gain and phase margins associated with this data using the "bodeplot" function, these gain and phase margins do not appear on the plot. What am I missing?I have discrete-time frequency response data in the form of a "frd" object. When I try to show the gain and phase margins associated with this data using the "bodeplot" function, these gain and phase margins do not appear on the plot. What am I missing? I have discrete-time frequency response data in the form of a "frd" object. When I try to show the gain and phase margins associated with this data using the "bodeplot" function, these gain and phase margins do not appear on the plot. What am I missing? bodeplot, margin MATLAB Answers — New Questions
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