メインコンテンツ

結果:

Janne Daams
Janne Daams
最後のアクティビティ: 2023 年 10 月 26 日

Hi all,
I want to solve an ode45 equation for a multibody model. The matrixes I have to implement in the ode45 are very big. Now I am using the subs function to place the values for x into the matrixes. However because the fact that this is done inside the ode45 function running the function takes a while. Is there a way to already implement the x value in the matrixes as a variable outside the ode45 function?
In the code WT and w_bar are matrixes of 12x15 and12x1
The vector hulp_vec and hulp_vec_derivative contain both 15 syms variables
% Solve the equation
[t,x]=ode45(@(t,x)analytical_simplified(t,x,M,H,S,WT,w_bar,N,constr_eq,hulp_vec,hulp_vec_derivative),tspan,x0);
function [dx, lambda, constraint_eq]=analytical_simplified(t,x,M,H,S,WT,w_bar,N,constraint_eq,hulp_vec,hulp_vec_derivative)
tic
tau=[0;sin(t);0];
%make matrices afhankelijk van x and dx
% WT=subs(WT,hulp_vec',x(1:N));
WT=subs(WT,hulp_vec_derivative',x(N+1:2*N));
w_bar=subs(w_bar,hulp_vec',x(1:N));
w_bar=subs(w_bar,hulp_vec_derivative',x(N+1:2*N));
constraint_eq=subs(constraint_eq,hulp_vec',x(1:N));
toc
tic
Minv=inv(M);
% Stabilize the matrixes
wo=100;
alpha=wo/5; beta=1;
w_bar_stab = w_bar + 2*alpha*beta*WT*x(N+1:2*N) + alpha^2*constraint_eq;
% w_bar_stab=w_bar;
L1=(WT*Minv*WT');
L2=(WT*Minv*(H-S*tau)-w_bar_stab);
L1=double(L1); L2=double(L2);
lambda=L1\L2;
ddx=Minv*(S*tau-H+WT'*lambda);
dx(1:N)=x(N+1:2*N);
dx(N+1:2*N)=ddx;
dx=dx';
dx=double(dx);
toc
end
With kind regards,
Janne
Ying Jie Tan
Ying Jie Tan
最後のアクティビティ: 2024 年 2 月 7 日

Good day community, can I know what is this symbol could be? It looks like a ramp/ continuous ramp. But I believe it is not both them. I saw someone connect it after a voltage/ current measurement. Can I know what is the function of this symbol too? Much appreciate for the answers given

New Cheat Sheet Alert!
Level up your data organization and access skills in MATLAB with our latest cheat sheet! Download the full cheat sheet on MATLAB GitHub for Students here.
Abhishek
Abhishek
最後のアクティビティ: 2024 年 2 月 7 日

Hello All,
I was wondering, from which version Tracebility Diagrams are available (in SLK Req)?
Regards
Abhishek KUMAR
Ahmed Tamer
Ahmed Tamer
最後のアクティビティ: 2023 年 10 月 25 日

Hello, I am trying to use a Velodyne VLP 16 Puck Lidar, to receive live data (visualized) as well as point cloud, the issue I have is; I do actually run the code to visualize the lidar and I can see the live map, as well as I get frames in the work space as (1x1 Pointcloud), now how can I process these pointclouds(from the live stream of lidar), I would like to denoise them, downsample, etc. I tried going through alot of toolboxes but I usually get stuck, need tips and how to start working, thanks.,
Prageeth
Prageeth
最後のアクティビティ: 2023 年 10 月 25 日

unable to download and cant install Arduino third party packages , but support packeages are download,
Samar Ayman
Samar Ayman
最後のアクティビティ: 2023 年 10 月 24 日

  1. Why do the stations transmit to each other while there is no association among them?
  2. How the stations transmit to the access point while the traffic generation is one way?
please find the attached code"ex1_AP_STA.m" and output data of simulator "Simulation data.zip"
fina
fina
最後のアクティビティ: 2023 年 10 月 24 日

when i use command openExample('px4/PX4HITLSimulationFixedWingPlantSimulinkExample'),matlab shows "PX4HITLSimulationFixedWingPlantSimulinkExample" cannot find. So does somebody know how to find this demo? Thanks.
Maddalena
Maddalena
最後のアクティビティ: 2023 年 10 月 24 日

ncorr is not working on MATLAB 2023b new version, it gives me an error. Does somebody know why? Thanks
N Y Srinivas
N Y Srinivas
最後のアクティビティ: 2023 年 10 月 24 日

Dear all,
In an excel file, we have temperature (te) and humidity (hu) data in two columns. The Gaussian kernel-density estimation and best-fit quadratic curve were plotted. However, we need to determine whether the relationship is statistically significant or not, as well as the coefficient of determination (R2). For calulation of the both of them, we used functions like:
1. cofficient of determination aa= fitlm(te, hu)
2. statistically significant p= coefTest(aa)
Is it correct? If not, please provide the any other suggestions.
Thank you.
narf
narf
最後のアクティビティ: 2023 年 10 月 20 日

For example, my main line chart have values: X=[10 20 30 40 50] Y=[0.5 1.5 5 -6 4]. I need to add second X axis, with value [1 2 3 4 5] but but I would like the distance between individual points to be variable. For example, between points 1-2 d=25, between 2-3 d=10. I would like to define this distance freely.
xt = e^-3t
ht= -5e^-2t +6e^-3t
so ofcourse these would be used to plot yt which is xt*ht in other words xt conv ht. Thanks for your assistance!!
Recently, I came across a post about the JIT compiler on this Korean blog. In the post. The writer discussed the concept of the "Compile Threshold" and how it is calculated.
"The JVM accumulates the number of calls for each method called and compiles when the number exceeds a certain number. In other words, there is a standard for checking how often it is called and then deciding, 'It is time to compile.' This standard is called the compilation threshold. But what is this and why should it be used as a standard?"
The concept of the "Compile Threshold," as used above, seems to be more commonly associated with Tracing just-in-time compilation.
The writer used the simple Java code below to calculate the threshold.
for (int i = 0; i < 500; ++i) {
long startTime = System.nanoTime();
for (int j = 0; j < 1000; ++j) {
new Object();
}
long endTime = System.nanoTime();
System.out.printf("%d\t%d\n", i, endTime - startTime);
}
Since the MATLAB execution engine uses JIT compilation, I just wanted to perform the same experiment that the writer did.
I experimented using simple codes based on the code in the blog. I iterated a function 500 time using for-loop and calculated the execution time for each iteration using tic and toc. Then I plotted the execution time for each loop as blow. First five execution times are much higher than followings (10 times!) The test is very rough so I am not sure that I can conclude "MATLAB has Compile Threshold and it is 5!" but this value is actually correct ;-)
t0 = 0;
tfinal = 10;
y0 = [20;20];
timeToRun = zeros(500,1);
for i = 1:500
tStart = tic;
[preypeaks,predatorpeaks] = solvelotka(t0, tfinal, y0);
tEnd = toc(tStart);
timeToRun(i) = tEnd;
end
Toshiaki Takeuchi
Toshiaki Takeuchi
最後のアクティビティ: 2023 年 10 月 23 日

VS Code Extension for MATLAB was introduced back in April and has been downloaded 75K times since. Do people here use VS Code for writing MATLAB code?
Toshiaki Takeuchi
Toshiaki Takeuchi
最後のアクティビティ: 2023 年 10 月 20 日

Earlier this year a bunch of MATLAB users got together to talk about their hobbies in a lightning talk format.
  • Using "UIHTML" to create app components and Lightning
  • Creating generative art with MATLAB
  • Making MATLAB run on the Steam Deck (it was a wager)
Do you use MATLAB for hobbies?
Alex Savic
Alex Savic
最後のアクティビティ: 2024 年 2 月 7 日

Hi,
I'm trying to use subs to subsitute x and y coordinates into a symbolic equation so I can solve it for the value at each coordinate. Below is how my code is currently sctructured.
%% Creating Fluid Equations
syms x y
vel_x = sin(x) + cos(y);
vel_y = cos(x)^2 + sin(y)^0.5;
pressure = 101300 * (x*exp(y));
density = 1.2 * (x^2 + y^0.5);
%% Plotting Fluid Equations
x_input = 0:0.1:10;
y_input = 0:0.1:10;
[x_coord, y_coord] = meshgrid(x_input, y_input);
% Subsitute symbolic variables with x and y arrays and turn into array of
% doubles
vel_x = double(subs(vel_x, [x, y], {x_coord, y_coord}));
vel_y = double(subs(vel_y, [x, y], {x_coord, y_coord}));
pressure = double(subs(pressure, [x, y], {x_coord, y_coord}));
density = double(subs(density, [x, y], {x_coord, y_coord}));
surf(x_input, y_input, vel_x)
This code is already taking 5 whole seconds to run and ideally I'd like to increase the density of coordinates. I was trying to stay away from using for loops wich is how I ended up using meshgrid and subs instead. How can I make this much more efficient?
Any advice would be much appreciated thank you!
Venkatesan
Venkatesan
最後のアクティビティ: 2023 年 10 月 17 日

Is there a way to generate "typedef short int" and typedef "unsigned short int"? I want this for my harware but what I get is only "typedef int" and typedef "unsigned int" irrespective of various hardware I selected including custom hardware.
Matt J
Matt J
最後のアクティビティ: 2024 年 1 月 23 日

Are there Matlab features which intend to satisfy your needs but fail in certain critical areas, forcing you to abandon them completely in favor of your own version or a 3rd party alternative? Perhaps these features are starting to improve with new Matlab releases, but not quickly enough? Share your own frustrations in the comments below.
Here are two of mine:
1. volumeViewier
volumeViewer is 6 years old now. It is fine when you only need to view one 3D image at a time, but I never do. In my work, I am putting several images side-by-side for visual comparison. For such work, you need to be able to programmatically change axis limits and grayscale and use linkprop to reflect these changes across all the images. With 2D image comparison, all that is possible, but volumeViewer supports none of those things. So, I resort to my own 3D viewer
2.Tomographic projection commands RADON and FANBEAM
These commands are provided in the Image Processing Toolbox seemingly for no other reason than to support homework exercises for people taking introductory tomographic imaging courses. They fail in a number of ways for people who need to do serious tomographic imaging work, producing artifacts or nonlinear effects which shouldn't be there. See for example Why isn't FANBEAM linear? or Radon Transform works unexpectedly. Moreover, the toolbox still provides tomographic projectors only for 2D imaging not 3D, even though 64-bit RAM has made volumetric imaging commonplace in Matlab for at least 10 years. Luckily, there are now freely available 3rd party alternatives like TIGRE.
Muhammad
Muhammad
最後のアクティビティ: 2023 年 10 月 17 日

Hi Everyone,
I have Experiemental Data (Bode Plot), using MATLAB I found the Transfer Function of my plant. I have attached my E7i_CSV file.
T2 = readtable('E7i_CSV.csv');
% Fill With Actual Sampling Frequency
FHz = T2.F;
Ts = 1/(2*(max(FHz)+10000))
for k = 1:size(T2,1)-1
if FHz(k+1) == FHz(k)
FHz(k+1) = FHz(k+1)+0.5; % 'Brute Force' Interpolation
end
end
Mag = T2.G;
PhDeg = T2.P;
Response = Mag.*exp(1j*deg2rad(PhDeg)); % Complex Vector
sysfr = idfrd(Response, FHz, Ts, 'FrequencyUnit','Hz')
%bode(sysfr)
%tfsys = tfest(sysfr,4,3) This is much better
tfsys = tfest(sysfr,4,3) %82.69%
%tfsys = tfest(sysfr,6,3)
figure
compare(sysfr, tfsys)
is_stable = isstable(tfsys);
disp(is_stable);
I want to convert this transfer function to statespace equations, which will be used for Model Predictive Control Design. Simple tf2ss command give me TF but it doesn't look very accrurate.
[A, B, C, D] = tf2ss(num,den)
So, I was reading a paper which i will follow, they have mentioned that they had FRF (Frequency Response Function) data and they find state space model/equations using Prediction Error Method (PEM). But I am unable to understand how I can used Bode Plot data and convert it state space using PEM. I will appreciate your help.
Secondy I verified the paper StateSpace Model by first converting it to Transfer Function and then using tf2ss command. which shows inaccurate results similiar to my results. I am looking for your help. Following is the verification code for paper i am following
%Rana Paper State Space Equations Coversion to
%Transfer Function for Validation Reason
% Define state-space matrices
Ax = [-49.3277, -980.7648, 618.2198;
567.3557, -120.2273, 651.7342;
-45.8885, -415.4194, -115.7522];
Bx = [-1.8122; 3.901370; 4.3011];
Cx = [14.9368, 16.9208, -23.6827];
Dx = 0;
% Create a state-space model
sys = ss(Ax, Bx, Cx, Dx);
% Display the state-space model
disp('State-Space Model:');
disp(sys);
% Convert the state-space model to a transfer function
tf_sys = tf(sys);
% Display the transfer function
disp('Transfer Function:');
disp(tf_sys);
%TF to StateSpace Rana Model
num_rana = [ -62.92 3.625*10^4 -1.065*10^8];
den_rana = [ 1 285.3 8.811*10^5 1.982*10^8];
tff_rana = tf(num_rana,den_rana);
tffss_rana = tf2ss(num_rana,den_rana);
[Arana,Brana,Crana,Drana] = tf2ss(num_rana,den_rana);
goc3
goc3
最後のアクティビティ: 2024 年 1 月 23 日

Have you ever learned that something you were doing manually in MATLAB was already possible using a built-in feature? Have you ever written a function only to later realize (or be told) that a built-in function already did what you needed?
Two such moments come to mind for me.
1. Did you realize that you can set conditional breakpoints? Neither did I, until someone showed me that feature. To do that, open or create a file in the editor, right click on a line number for any line that contains code, and select Set Conditional Breakpoint... This will bring up a dialog wherein you can type any logical condition for which execution should be paused. Before I learned about this, I would manually insert if-statements during debugging. Then, after fixing each bug, I would have to delete those statements. This built-in feature is so much better.
2. Have you ever needed to plot horizontal or vertical lines in a plot? For the longest time, I would manually code such lines. Then, I learned about xline() and yline(). Not only is less code required, these lines automatically span the entire axes while zooming, panning, or adjusting axis limits!
Share your own Aha! moments below. This will help everyone learn about MATLAB functionality that may not be obvious or front and center.
(Note: While File Exchange contains many great contributions, the intent of this thread is to focus on built-in MATLAB functionality.)