https://de.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-08-03T10:12:45Ztag:de.mathworks.com,2005:Question/5743302020-08-03T08:50:41Z2020-08-03T10:12:45Zgrowing bubbles with a predetermined radius in a given volume?Is there a code that can plots as many as possible bubbles with a predetermined radius in a given volume?Xiaochun Zhaohttps://de.mathworks.com/matlabcentral/profile/authors/18030630tag:de.mathworks.com,2005:Question/5464552020-06-11T10:31:45Z2020-08-03T10:12:34Zhow can i calculate in matlabwe borrowed $1000 at a 10% anual intrests rate. if we do not makre a payment for 2 years, and assuming there is no penalty for non payment, how much do we owe now?Neha Jaiswalhttps://de.mathworks.com/matlabcentral/profile/authors/18706370tag:de.mathworks.com,2005:Question/5743572020-08-03T10:11:37Z2020-08-03T10:11:37ZMATLAB coder GUI / CLI shows cryptic errors: libmwboost / CUDA_CODEGENHi, I hit a number of snags when using MATLAB coder. I'm using R2020a on Ubuntu 18.04 on an XPS 15 9570.
Issue no.1 (GUI): When I run the GUI, I am stopped at the automatically define input types step by the message
"Invalid MEX-file '/path/on/my/machine' : libmwboost_system.so.1.65.1: cannot open shared object file: No such file or directory.
However...
>> !locate libmwboost_system
/usr/local/MATLAB/R2020a/bin/glnxa64/libmwboost_system.so.1.70.0
Why doesn't MATLAB detect and use the latest version of this .so? How to fix this problem?
Issue no.2 (CLI): Raw C code is better than nothing. so I ran the command below and hit another snag
>> codegen -c foo
CRL: "CUDA_CODEGEN" cannot be found in the registry.
Use help codegen for more information on using this command.
Error using codegen
Googling for CUDA_CODEGEN doesn't even give relevant results. Before diving into debugging GPU issues, I need to emphasize that CUDA code generation is the absolute least of my concern. If there is a way to make Coder ignore CUDA and move on, I'd go with that.
I'm totally stalled now and I greatly appreciate any answer.
Both issues manifest with the simplest toy function like
function y = foo(x)
y = x;
end
Hei Shing Helson Gohttps://de.mathworks.com/matlabcentral/profile/authors/19008898tag:de.mathworks.com,2005:Question/5743542020-08-03T10:11:35Z2020-08-03T10:11:35ZI use imsegkmeans but it takes too long. Is there another way to do so?I use the imsegkmeans to cluster lab images but it takes more than a minute to complete these lines:
ab = lab_img1(:,:,2:3);
ab = im2single(ab);
nColors = 3;
pixel_labels = imsegkmeans(ab,nColors,'NumAttempts',10);
imshow(pixel_labels,[])
title('Image Labeled by Cluster Index');
from this link : https://www.mathworks.com/help/images/color-based-segmentation-using-k-means-clustering.html
Stephani Kangahttps://de.mathworks.com/matlabcentral/profile/authors/18629889tag:de.mathworks.com,2005:Question/5740602020-08-02T12:33:23Z2020-08-03T10:10:32ZHow to do feature extraction from an image?Hi
I want to do feature extraction from an image.
I read a paper and did this steps:
I did image segmentation. Then I want to do feature extraction.
In this paper:
Segmented lungs were divided into 3*3 windows in which all nine pixels were located in the lung mask. Window size selection is a compromise between higher resolution (in the classification process) and faster algorithm. Smaller windows (i.e. 1*1 or 2*2) have the problem of more time complexity for training
and increaseing the number of FP. Larger windows (i.e. 5* 5 or larger) cause lower resolution of reconstructed image after
classification and miss some tiny nodules. Thus, for better resolution and faster algorithm, simultaneously, we used a 3*3
window. In the training process, these windows were labeled as nodule (þ1) and non-nodule (1).
My question is this:
Is there any standard criteria to lable the 3*3 window as a noudle? ( I mean if how many of these pixcles are 1, we should lable the window as a noudle?)</pre>sarahttps://de.mathworks.com/matlabcentral/profile/authors/5590407tag:de.mathworks.com,2005:Question/4256192018-10-23T13:01:10Z2020-08-03T10:04:37ZHow do i count same consecutive occurrencesConsider I have an array of occurrences
A=[1,1,1,1,1,2,2,2,2,3,3,3,3,2,2,2,1,1,1,1]
I want to find out how many 2 are on each occurrence.
The answer should be 4 starting 6th position and 3 starting 14 positions.
Is it possible to do it in a wise Matlab way without many loop complications?DuckDuckhttps://de.mathworks.com/matlabcentral/profile/authors/3460389tag:de.mathworks.com,2005:Question/5743512020-08-03T10:00:04Z2020-08-03T10:02:37ZHow to replace string values in a column of a table into numeric?I have a table X
It has a column named 'fruit' with string values such as {'apple','orange','grapes'}, There are 13 different string values in the column 'fruit'
Now I need to change it as if apple or orange then 1, grapes then 2 and so on.
How can I do that?Vaishali Ravihttps://de.mathworks.com/matlabcentral/profile/authors/17063546tag:de.mathworks.com,2005:Question/5697282020-07-23T18:34:35Z2020-08-03T09:55:48ZInvalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of sequences. All sequences must have the same feature dimension and at least one time step.Hi I am working on deep learning tool to desing a technique to classify fault type, im facing difficulty in preparing data type and I dont know why please have a look at my code and advice.
%unamed is 170*244 double type matrix
Daten = unnamed;
[m,n] = size(Daten) ;
%Split into train and test
P = 0.7;
Training = Daten(1:round(P*m),:) ;
Testing = Daten(round(P*m)+1:end,:);
%XTrain is 119*243 double type matrix
XTrain = Training(:,1:n-1);
%YTrain is 119*1 double type matrix
YTrain = Training(:,n);
%XTest is 51*243 double type matrix
XTest = Testing(:,1:n-1);
%YTest is 51*1 double type matrix
YTest = Testing(:,n);
layers = [ ...
sequenceInputLayer(119)
lstmLayer(100,"OutputMode","sequence")
dropoutLayer(0.1)
lstmLayer(100,"OutputMode","last")
fullyConnectedLayer(1)
softmaxLayer
classificationLayer];
options = trainingOptions("adam", ...
"MaxEpochs",150, ...
"MiniBatchSize",miniBatchSize, ...
"Plots","training-progress", ...
"Verbose",false, ...
"Shuffle","every-epoch", ...
"LearnRateSchedule","piecewise", ...
"LearnRateDropFactor",0.1, ...
"LearnRateDropPeriod",20,...
'ValidationData',{XTest,categorical(YTest)});
net = trainNetwork( XTrain , categorical(YTrain) , layers , options);
zain yousafhttps://de.mathworks.com/matlabcentral/profile/authors/9706832tag:de.mathworks.com,2005:Question/5743482020-08-03T09:54:34Z2020-08-03T09:54:34ZCar model/computational errorHi all,
I'm creating a model of a car with automatic gear changes when certain speeds are met, and is driven by a desired speed using the longitudinal driver block. For some reason when second gear is reached there is a spike increase in acceleration from ~2m/s2 to ~13*10^6m/s2 for a very brief amount of time. This causes a large increase in speed over a very small interval, therefore the car cycles through the gears extremely quickly. I can only imagine this is some kind of computational or solver error but can't find anything on the forums.
The model and required mat files are attached.
Thanks in advance!Joshua Rodgershttps://de.mathworks.com/matlabcentral/profile/authors/9077885tag:de.mathworks.com,2005:Question/571862012-12-21T19:36:43Z2020-08-03T09:53:49ZHow can I rescale an image while not changing the dimension of the image?How can I rescale an image while not changing the dimension of the image? When I scale it up, it just crops the image to fit within the original size. When I scale it down, it pads the edges of the image with zeros. I want to zoom in and out about the center of the image. When using "imresize", it changes the dimensions of the image to preserve all the content. I have the image processing toolbox.Sonoma Richhttps://de.mathworks.com/matlabcentral/profile/authors/436243tag:de.mathworks.com,2005:Question/168972011-09-28T01:19:49Z2020-08-03T09:52:04ZFunction File to Solve Thermodynamics ProblemI am trying to solve a thermodynamics problem based on an isentropic relationship. The problem boils down to a higher order equation in terms of T2. Ultimately, T2 needs to be found. I would like to be able to write a function file that is a function of only T2 and then I can use bisection or newtons method to solve. I have input the isentropic relationship as my function, and the rest of my parameters under that. cp_2 and gamma2 are fucntions of T2. Right now, Matlab is not referencing the parameters under the isentropic relationship. Here is the code I have so far.
function [f]=temperature_2(T2)
f= T1*((.02*v1.^(gamma1-1))./(v1.^(gamma2-1)))-T2
%Givens
%Volume at state 1(cubic meters)
v1=.75
%Temperature at state 1(kelvin)
T1=375
%Universal gas constant(kJ/kmole)
R=8.314
%Matrix for a is given in the problem statement
a=[2.0909*10^1; 6.8717*10^-2; -5.2719*10^-5; 2.1664*10^-8; -4.5346*10^-12; 3.7873*10^-16];
%cp_1 calculation, there is enough info to compute this
cp_1=a(1)+T1.*(a(2)+T1.*(a(3)+T1.*(a(4)+T1.*(a(5)+T1.*a(6)))));
%cp_2 calculation, this is a function of T2
cp_2=a(1)+T2.*(a(2)+T2.*(a(3)+T2.*(a(4)+T2.*(a(5)+T2.*a(6)))));
%Compute Gamma as per equation given
gamma1=((cp_1)./(cp_1-R));
%This is a function of T2
gamma2=((cp_2)./(cp_2-R));
end
Josephhttps://de.mathworks.com/matlabcentral/profile/authors/1494910tag:de.mathworks.com,2005:Question/5732922020-07-31T08:31:43Z2020-08-03T09:51:44ZHow to get the solution to a GIVEN input VECTOR using ode45 solverHi everyone!
I already posted my problem here, but unfortunately we did not come to a proper solution, so I've decided to reformulate my problem in an easier way, hoping it to be clear enough.
In the code below, you'll find the variable u_opt which represents the imput u of my system of equations.
u in function calc_only_f is a single scalar number, not a vector.
u_opt is a 50x1 double vector I obtained from a previous calculation as a solution of an optimal control problem (THIS INFO IS NOT RELEVANT). What I want to acheive is using u_opt as the imput of the ode45 solver and get for EACH component of this vector (50x1 i.e. for 50 different values) a 4x1 double solution as output.
After N=50 interation I would like to have a 50x4 double solution (aka trajectory) for those 50x1 double inputs of vector u_opt
As You can see below (represented by an arrow <-- in second to last line) I obtain for EACH component (i.e. value) of the input vector u_opt a 50x4 double solution. So for N=50 interations, I get 50 of these 50x4 double trajectoies, which are given as 1x50 double cell array.
Is there possibility to acheive exactly what I'm looking for, so getting a 50x4 double solution for those 50x1 double inputs? I spent a lot of hours in finding a solution, but unfortunately I'm still stuck on this problem.
........... calcf .........
% System of equations x' = f(t,x,u)
function f = calc_only_f(t,x,u,param)
% Parameter of the systems given as a struct
M = param.M;
g = param.g;
L = param.L;
m = param.m;
d = param.d;
Sx = sin(x(3)); % sin(x)
Cx = cos(x(3)); % cos(x)
N = M + m*(1-Cx^2); % denominator
K = N*L; % L*(M + m*(1-Cx^2))
f = [x(2); (1/N)*(-m*g*Cx*Sx + m*L*x(4)^2*Sx - d*x(2)+ u); x(4); (1/(N*L))*((m+M)*g*Sx -Cx*(m*L*x(4)^2*Sx - d*x(2)) - Cx*u)];
end
% +++++++++++++++++++++++++++++++++++++++++++++++++++
% -------------------- MAIN -------------------------
% +++++++++++++++++++++++++++++++++++++++++++++++++++
N=50; sizeu=1; tf= 5;
u_opt = rand(N*sizeu,1,'double'); % only for the implementation ... dimension of u_opt should be a 50x1 double
x0 = [0;0;pi;0]; % start point 4x1 double ... x0_1 position x0_2 velocity x0_3 angle x0_4 angular velocity
param.m = 1.5;
param.M = 27;
param.L = 2;
param.g = -9.80665;
param.d = 1.2;
param.N = 50;
param.timePart = linspace(t0,tf,N);
tspan = param.timePart;
for k = 1:numel(u_opt)
[t_ode{k},x_ode{k}] = ode45(@(t,x)calc_only_f(t,x,u_opt(k),param),tspan,x0); % <-- I get a 1x50 double cell array
end
I appreciate any help!
Cheers !
Ivanhttps://de.mathworks.com/matlabcentral/profile/authors/16473198tag:de.mathworks.com,2005:Question/5717112020-07-28T14:43:17Z2020-08-03T09:49:23ZUnexpected Change in Population Diversity of Genetic AlgorithmWe have been having unexpected results in our optimization processes, using the genetic algorithm. We have found that the diversity of the population seems to increase back to the original population diversity at the beginning of the optimization process.
This appears to happen in mostly periodic steps in the generation every n generations. What seems odd is that the population immediately then collapses back to the diversity it had before the diversification.
We have had more than one script, by different users, produce the same result. We understand that the GA should change the diversity overtime, but it does not seem that the diversity should ‘explode’ for a single iteration, followed by an ‘implosion’ the next iteration.
This is demonstrated in the figure below showing the generation at a specific generation.
We are trying to optimize three integer variables with only upper and lower bounds on the variables, there is no constraints. The optimization is finding the a near optimal solution, but we want to understand why this population is diversifying periodically as a function of generation.
The same behavior is seen for different max generation counts also. Yet the period seems to change given the max generation count.
We observe the same behavior regardless of our fitness function, as can be seen below.
We have tried to change the crossover, scale and other settings, we can minimize this, but it still appears to happen. Again, it’s not so much that the population is becoming diverse, it’s the change of the magnitude of diversity over time that is our concern.
Thank you!
David Hoxiehttps://de.mathworks.com/matlabcentral/profile/authors/6284473tag:de.mathworks.com,2005:Question/1427142014-07-21T04:33:01Z2020-08-03T09:47:33ZIs there a thermodynamics toolbox in MATLAB ?Dear All,
I need to know is there a thermodynamics toolbox in MATLAB? or Are there any other solutions to design thermodynamics models?
Thank You!
Nuwan Dassanayakehttps://de.mathworks.com/matlabcentral/profile/authors/4220008tag:de.mathworks.com,2005:Question/5743272020-08-03T08:42:29Z2020-08-03T09:43:28ZHow to split a 3d matrix into sub-3d matrices?How can I split e.g. a a1xb1xc matrix into non-overlapping (neighbouring) smaller matrices a2xb2xc? farhad vaseghihttps://de.mathworks.com/matlabcentral/profile/authors/15951582tag:de.mathworks.com,2005:Question/5742792020-08-03T07:00:29Z2020-08-03T09:41:34ZVector dimensions in my odeclc,clear all
k_s = 26400; %spring stiffness
m = 483; %Mass
f_n = sqrt(k_s/m)/(2*pi); %Natural frequency in Hz
%% Road profile
% spatial frequency (n0) cycles per meter
Omega0 = 0.1; %%%%conventional value of spatial frequency(n0)?
% psd ISO (used for formula 8)
Gd_0 = 32 * (10^-6);
% waveviness
w = 2;
% road length
L = 250;
%delta n
N = 1000;
Omega_L = 0.004;
Omega_U = 4;
delta_n = 1/L; % delta_n = (Omega_U - Omega_L)/(N-1);
% spatial frequency band
Omega = Omega_L:delta_n:Omega_U;
%PSD of road
Gd = Gd_0.*(Omega./Omega0).^(-w);
% calculate amplitude using formula(8) in the article
%Amp = sqrt(2*Gd*delta_n); %%%from Eq. 7?
%calculate amplitude using simplified formula(9) in the article
k = 3; %%%upper limit A and lower limit B k=3?
%Amp = sqrt(delta_n) * (2^k) * (10^-3) * (Omega0./Omega);
Amp = sqrt(delta_n) * (2^k) * (10^-3) * (Omega0./Omega);
%random phases
Psi = 2*pi*rand(size(Omega));
% x abicsa from 0 to L
x1 = 0:0.25:250;
h= zeros(size(x1));
%artificial random road profile
for iv=1:length(x1)
h(iv) = sum( Amp.*cos(2*pi*Omega*x1(iv) + Psi) );
end
%% ode45
T = 120;
x0 = [0,0];
f = @(t,x) [ x(2); -( k_s*(x(1)-h)/ m ) ];
[t, x] = ode45(f,[100,T],x0);
%% plot
plot(t,x(:,1));
set(gca,'xtick',17)
Hi, I generated a random road file (h) and tried to apply this in my ode, however it says the vector dimension is not consistent. Can anyone solve this problem please?Donghun Leehttps://de.mathworks.com/matlabcentral/profile/authors/17824938tag:de.mathworks.com,2005:Question/5737752020-08-01T12:45:24Z2020-08-03T09:37:13Zhelp solving differential equationshello, i tring to solve this equation
m*f'^2 -0.5(m+1)*f*f'' = m+f'''
m is a variable i need to set
my initial values are:
f(0) = f'(0) = 0
f ' (inf) =1
this is my code:
m=-0.1;
h = 0.01;
f1 = @(x, y1, y2, y3) y2;
f2 = @(x, y1, y2, y3) y3;
f3 = @(x, y1, y2, y3) -0.5*(m+1)*y1*y3 +m*(y2^2)-m;
eta = 0:h:10;
x = 0:h:10;
y1(1) = 0;
y2(1) = 0;
y3(1) = 1;
for i = 1:(length(eta)-1)
a = h.*[f1(eta(i), y1(i), y2(i), y3(i)), f2(eta(i), y1(i), y2(i), y3(i)), f3(eta(i), y1(i), y2(i), y3(i))];
b = h.*[f1(eta(i), y1(i)+a(1)/2, y2(i)+a(2)/2, y3(i)+a(3)/2), f2(eta(i)+h/2, y1(i)+a(1)/2, y2(i)+a(2)/2, y3(i)+a(3)/2), f3(eta(i)+h/2, y1(i)+a(1)/2, y2(i)+a(2)/2, y3(i)+a(3)/2)];
c = h.*[f1(eta(i), y1(i)+b(1)/2, y2(i)+b(2)/2, y3(i)+b(3)/2), f2(eta(i)+h/2, y1(i)+b(1)/2, y2(i)+b(2)/2, y3(i)+b(3)/2), f3(eta(i)+h/2, y1(i)+b(1)/2, y2(i)+b(2)/2, y3(i)+b(3)/2)];
d = h.*[f1(eta(i), y1(i)+c(1), y2(i)+c(2), y3(i)+c(3)), f2(eta(i)+h, y1(i)+c(1), y2(i)+c(2), y3(i)+c(3)), f3(eta(i)+h, y1(i)+c(1), y2(i)+c(2), y3(i)+c(3))];
y3(i+1) = y3(i)+ 1/6*(a(3)+2*b(3)+2*c(3)+d(3));
y2(i+1) = y2(i)+ 1/6*(a(2)+2*b(2)+2*c(2)+d(2));
y1(i+1) = y1(i)+ 1/6*(a(1)+2*b(1)+2*c(1)+d(1));
i'm trying to solve it with finding the f''(0) initial value and than solve the equation, but it's seem not to work. could any one help me with that?
thank ueden meirovichhttps://de.mathworks.com/matlabcentral/profile/authors/13238624tag:de.mathworks.com,2005:Question/5739912020-08-02T06:45:47Z2020-08-03T09:28:08ZAdvection-dominant 1D advection-diffusion equationI'm trying to solve the following 1D PDE of an advection-diffusion equation:
for , and
I used the pdepe function, here's the code:
function c = lfaF2
para.Ao = 10^-5; % Ao
para.DA = 10^-6; % D
para.L = 40;
para.T = 180;
para.dx = 0.1; % x discretization step
para.dt = 0.1; % t discretization step
c.x = 0:para.dx:para.L;
c.t = 0:para.dt:para.T;
m = 0;
fun = @(x,t,u,dudx) lfapde(x,t,u,dudx,para);
bc = @(xl,ul,xr,ur,t) lfabc(xl,ul,xr,ur,t,para);
c.A = pdepe(m,fun,@lfaic,bc,c.x,c.t);
c.surf = surf(c.x,c.t,c.A,'LineStyle','none');
title('Flow')
xlabel('Distance (mm)')
ylabel('Time (s)')
bar = colorbar;
bar.Label.String = 'Concentration (M)';
end
function [c,f,s] = lfapde(x,t,u,dudx,para)
c = 1;
f = para.DA*dudx;
v = para.L/para.T;
s = -v*dudx;
end
function u0 = lfaic(x)
u0 = 0;
end
function [pl,ql,pr,qr] = lfabc(xl,ul,xr,ur,t,para)
pl = ul-para.Ao;
ql = 0;
pr = 0;
qr = 1;
end
The code works fine for or but when and , I get spurious oscillatory behaviors:
This is usually seen when numerically solving advection-diffusion equations when the Peclet number, (advection dominant). I have two questions:
1) Why does affect the stability of the solution when it is not in the Peclet number formula?
2) How can I solve such a problem in Matlab without reducing the distance step size?THAI CAM LINH HOANGhttps://de.mathworks.com/matlabcentral/profile/authors/15781849tag:de.mathworks.com,2005:Question/5722752020-07-29T14:13:39Z2020-08-03T09:25:27ZConvert the intensity of image into a specific intensity range Hello everybody,
I have 100 3D medical images that have different intensity ranges. most of them have a maximum intensity of 255( and their type is single) but that of some of them is about 2000-3000( uint16). How can I convert the intensity of all images into [0,255]?
I tried this: 255*( (Img - min(Img(:)))./max(img(:))) but it didn't give the expected result. please help me with this problem.
Thank you. SaHaRhttps://de.mathworks.com/matlabcentral/profile/authors/11317038tag:de.mathworks.com,2005:Question/5743242020-08-03T08:35:03Z2020-08-03T09:16:38ZHow to create empty XYZ image matrixI am trying to do colour correction and I need an empty image in the XYZ colourspace to write values into. Is there a way to create a blank XYZ image to store the values?
Simon Kirkmanhttps://de.mathworks.com/matlabcentral/profile/authors/17530202tag:de.mathworks.com,2005:Question/5743392020-08-03T09:13:32Z2020-08-03T09:13:32ZMatlab 2020a X11 forwarding crashHi everyone,
I am using Matlab 2020a on the remote server with X11 forwarding that enables a GUI on my local machine.
If I run matlab, it will pop up the blue start-up window, and then the main window. After a few seconds, the window freezes and matlab crashes.
Since in the report libjvm appears repeatedly, I also tried the following: If I run either matlab -nojvm or matalb -nodesktop, the blue start-up windows shows, and I can use the command-line in the remote shell. However, I can not use GUI.
The specs of the remote server is in the crash report. If it helps, the local machine is running macOS 10.15.4 with XQuartz 2.7.11 (latest) as X11 client. Does anyone know how to resolve this issue? I have tried with both Matlab 2020a and 2019b, but the same problem occurs.
Many thanks in advance.
MATLAB crash file:/root/matlab_crash_dump.25858-1:
--------------------------------------------------------------------------------
Segmentation violation detected at Mon Aug 03 08:58:02 2020 +0000
--------------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : US-ASCII
Deployed : false
GNU C Library : 2.23 stable
Graphics Driver : Unknown software
Graphics card 1 : 0x1a03 ( 0x1a03 ) 0x2000 Version 0.0.0.0 (0-0-0)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : glnxa64
MATLAB Entitlement ID : 3436765
MATLAB Root : /usr/local/MATLAB/R2020a
MATLAB Version : 9.8.0.1417392 (R2020a) Update 4
OpenGL : software
Operating System : Ubuntu 16.04.4 LTS
Process ID : 25858
Processor ID : x86 Family 6 Model 79 Stepping 1, GenuineIntel
Session Key : 5dd6178a-97b9-49b7-8570-278f2c9d0065
Static TLS mitigation : Enabled: Full
Window System : The X.Org Foundation (11804000), display dingtj-admin:24.0
Fault Count: 1
Abnormal termination:
Segmentation violation
Register State (from fault):
RAX = 0000000000000000 RBX = 00007f48f36809f8
RCX = 00007f48f39a7bc8 RDX = 0000000000000009
RSP = 00007f48f3cf7e20 RBP = 00007f48f3cf7f40
RSI = 0000000000000000 RDI = 00007f48f366b150
R8 = 0000000000000048 R9 = 0000000000000004
R10 = 00007f48f39a6f20 R11 = 00007f48f3665000
R12 = 00007f4abc7cd0a0 R13 = 0000001000000006
R14 = 0000000000000006 R15 = 00007f48f366b2d0
RIP = 00007f4ba5eb973c EFL = 0000000000010206
CS = 0033 FS = 0000 GS = 0000
Stack Trace (from fault):
[ 0] 0x00007f4ba5eb973c /lib64/ld-linux-x86-64.so.2+00051004
[ 1] 0x00007f4ba5ec2851 /lib64/ld-linux-x86-64.so.2+00088145
[ 2] 0x00007f4ba5ebd564 /lib64/ld-linux-x86-64.so.2+00066916
[ 3] 0x00007f4ba5ec1da9 /lib64/ld-linux-x86-64.so.2+00085417
[ 4] 0x00007f4ba48e7f09 /lib/x86_64-linux-gnu/libdl.so.2+00003849
[ 5] 0x00007f4ba5ebd564 /lib64/ld-linux-x86-64.so.2+00066916
[ 6] 0x00007f4ba48e8571 /lib/x86_64-linux-gnu/libdl.so.2+00005489
[ 7] 0x00007f4ba48e7fa1 /lib/x86_64-linux-gnu/libdl.so.2+00004001 dlopen+00000049
[ 8] 0x00007f4b85cb49e1 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+09497057
[ 9] 0x00007f4b85aa2539 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+07324985 JVM_LoadLibrary+00000153
[ 10] 0x00007f4b75fcf380 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/libjava.so+00058240 Java_java_lang_ClassLoader_00024NativeLibrary_load+00000416
[ 11] 0x00007f4b5d0186c7 <unknown-module>+00000000
[ 12] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 13] 0x00007f4b5d007a90 <unknown-module>+00000000
[ 14] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 15] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 16] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 17] 0x00007f4b5d0007a7 <unknown-module>+00000000
[ 18] 0x00007f4b85a2e39b /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06849435
[ 19] 0x00007f4b859ea084 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06570116
[ 20] 0x00007f4b859ea46e /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06571118
[ 21] 0x00007f4b859ea6b1 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06571697
[ 22] 0x00007f4b85a1bc35 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06773813
[ 23] 0x00007f4b5d025df9 <unknown-module>+00000000
[ 24] 0x00007f4b5d008040 <unknown-module>+00000000
[ 25] 0x00007f4b5d008040 <unknown-module>+00000000
[ 26] 0x00007f4b5d0007a7 <unknown-module>+00000000
[ 27] 0x00007f4b85a2e39b /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06849435
[ 28] 0x00007f4b85d3fda5 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+10067365
[ 29] 0x00007f4b85d416e6 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+10073830
[ 30] 0x00007f4b85aa33e2 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+07328738 JVM_InvokeMethod+00000258
[ 31] 0x00007f4b5da04c2d <unknown-module>+00000000
[ 32] 0x00007f4b5da0eecc <unknown-module>+00000000
[ 33] 0x00007f4b5d008040 <unknown-module>+00000000
[ 34] 0x00007f4b5d008040 <unknown-module>+00000000
[ 35] 0x00007f4b5d008040 <unknown-module>+00000000
[ 36] 0x00007f4b5d008040 <unknown-module>+00000000
[ 37] 0x00007f4b5d008114 <unknown-module>+00000000
[ 38] 0x00007f4b5d008040 <unknown-module>+00000000
[ 39] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 40] 0x00007f4b5d008040 <unknown-module>+00000000
[ 41] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 42] 0x00007f4b5d008040 <unknown-module>+00000000
[ 43] 0x00007f4b5d008040 <unknown-module>+00000000
[ 44] 0x00007f4b5d007a90 <unknown-module>+00000000
[ 45] 0x00007f4b5d007ad5 <unknown-module>+00000000
[ 46] 0x00007f4b5d008040 <unknown-module>+00000000
[ 47] 0x00007f4b5d008040 <unknown-module>+00000000
[ 48] 0x00007f4b5d008040 <unknown-module>+00000000
[ 49] 0x00007f4b5d008040 <unknown-module>+00000000
[ 50] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 51] 0x00007f4b5d008040 <unknown-module>+00000000
[ 52] 0x00007f4b5d0007a7 <unknown-module>+00000000
[ 53] 0x00007f4b85a2e39b /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06849435
[ 54] 0x00007f4b859ea084 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06570116
[ 55] 0x00007f4b859ea46e /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06571118
[ 56] 0x00007f4b859ea6b1 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06571697
[ 57] 0x00007f4b85b7a170 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+08208752
[ 58] 0x00007f4b85b7ea0e /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+08227342
[ 59] 0x00007f4b85b81760 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+08238944
[ 60] 0x00007f4b85a21713 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06797075
[ 61] 0x00007f4b5d024d88 <unknown-module>+00000000
[ 62] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 63] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 64] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 65] 0x00007f4b5d0007a7 <unknown-module>+00000000
[ 66] 0x00007f4b85a2e39b /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06849435
[ 67] 0x00007f4b85d3fda5 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+10067365
[ 68] 0x00007f4b85d416e6 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+10073830
[ 69] 0x00007f4b85aa33e2 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+07328738 JVM_InvokeMethod+00000258
[ 70] 0x00007f4b5da04c2d <unknown-module>+00000000
[ 71] 0x00007f4b5da0eecc <unknown-module>+00000000
[ 72] 0x00007f4b5d0082bd <unknown-module>+00000000
[ 73] 0x00007f4b5d008040 <unknown-module>+00000000
[ 74] 0x00007f4b5d008040 <unknown-module>+00000000
[ 75] 0x00007f4b5d008302 <unknown-module>+00000000
[ 76] 0x00007f4b5d0007a7 <unknown-module>+00000000
[ 77] 0x00007f4b85a2e39b /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06849435
[ 78] 0x00007f4b85a2bc63 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06839395
[ 79] 0x00007f4b85a2c227 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+06840871
[ 80] 0x00007f4b85a9839c /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+07283612
[ 81] 0x00007f4b85e219eb /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+10992107
[ 82] 0x00007f4b85e21cf1 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+10992881
[ 83] 0x00007f4b85cb38c2 /usr/local/MATLAB/R2020a/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so+09492674
[ 84] 0x00007f4ba54546ba /lib/x86_64-linux-gnu/libpthread.so.0+00030394
[ 85] 0x00007f4ba4bf241d /lib/x86_64-linux-gnu/libc.so.6+01078301 clone+00000109Tianjiao Dinghttps://de.mathworks.com/matlabcentral/profile/authors/11452549tag:de.mathworks.com,2005:Question/5727222020-07-30T08:46:41Z2020-08-03T09:11:48ZImporting big .ASC fileGood morning, I searched on the web but I din't find anything useful for me.
I have a big .ASC file that begins like this:
Time 1 - default sample rate [s] MX840A_0_CH 1 [µm/m] MX840A_0_CH 2 [µm/m] MX840A_0_CH 3 [µm/m] MX840A_0_CH 4 [µm/m] MX840A_0_CH 5 [µm/m] MX840A_0_CH 6 [µm/m] MX840A_0_CH 7 [µm/m] MX840A_0_CH 8 [µm/m] Time 2 - default sample rate [s] Time 2 - fast sample rate [s] MX410_0_CH 1 [µm/m] MX410_1_CH 2 [g]
0 0,1980 0,3258 -0,2376 -0,5230 1,680 -0,1286 -0,3765 -0,2802 0 0 0,2373 -0,00105
0,00083 0,07124 0,3033 -0,04901 -0,4132 1,524 0,05268 -0,2449 -0,1356 0,00083 0,00021 0,2639 -0,00067
0,00167 0,05543 0,2692 0,05971 -0,3727 1,215 0,2908 -0,1258 -0,1223 0,00167 0,00042 0,3119 0,000
0,00250 0,1738 0,2790 0,2098 -0,3734 0,7158 0,1389 -0,1260 -0,1299 0,00250 0,00063 0,3839 0,00058
0,00333 0,2204 0,2843 0,3669 -0,2345 0,3564 0,09048 0,01820 -0,04594 0,00333 0,00083 0,3732 0,00080
...
It is basically n x 13 matrix with a big "n" (millions of rows).
I would like to import all these data in a suitable file for Matlab. I tried with the code:
filename = 'myfile01.txt';
delimiterIn = ' ';
headerlinesIn = 1;
A = importdata(filename,delimiterIn,headerlinesIn);
The result of this simple script (A) is only a 1x1 cell. I can't understand what I am missing. I would like to handle this data in Matlab then, in order to perform an analysis.
Thank you for your help!
Guglielmo Giambartolomeihttps://de.mathworks.com/matlabcentral/profile/authors/7868344tag:de.mathworks.com,2005:Question/5743362020-08-03T09:03:41Z2020-08-03T09:03:41ZInverse Laplace transform with Bessel functionI have the following function that requires the inverse Laplace transform:
where and are constant numbers. And, is the modified Bessel's function of the second kind of order .
Could someone guide me to solve this numerically? I have heard of Stehfest algorithm but doesn't really know its relevance for this problem.BeeTiawhttps://de.mathworks.com/matlabcentral/profile/authors/318942tag:de.mathworks.com,2005:Question/5743212020-08-03T08:23:11Z2020-08-03T09:02:59Z[SIMULINK] Sound interface, multiple inputs and outputs Hello,
I am using Simulink to emit and receive signals with a sound interface with multiple inputs and outputs (8 inputs / 20 outputs).
The "Audio Device Reader" block only has one signal, how can I get the signals from all the inputs?
Thanks!Jose M. Requena Plenshttps://de.mathworks.com/matlabcentral/profile/authors/5890853tag:de.mathworks.com,2005:Question/5741562020-08-02T18:36:16Z2020-08-03T09:01:53Zhow can i solve this errori writed this code and i want to integral the sum of Egb and Egs but i get this error
Error using integral (line 82)
First input argument must be a function handle.
and this error
Error in figure (line 28)
Eg=integral(Egs+Egb,0,TETAmax,TETA);
this is the code
clc
clear all
syms TETA
S0=613e9;
Sp=3.7e9;
Rin=27.5e-3;
Rout=31.5e-3;
h=15e-3;
for t=0.001:0.0001:0.0014;
TETAmax=-3.661*((h/t)^-1.14)+2.589;
DELTAmax=h-t-(h/(2*TETAmax));
R=Rin+(t/2);
Egb=pi*S0*(t^2)*((TETA*4*R)+h-(h*cos(TETA)))/((3^(0.5))*(TETA))
Egs=pi*S0*(h^2)*t*(TETA*sin(TETA)+cos(TETA)-1)/(2*(TETA)^2)
Eg=integral(Egs+Egb,0,TETAmax,TETA);
end
what is wrong?thank you for your help.sajjad barzigarhttps://de.mathworks.com/matlabcentral/profile/authors/19116549tag:de.mathworks.com,2005:Question/5743332020-08-03T09:01:44Z2020-08-03T09:01:44ZIs there any way to accelerate the solving of a series of large sparse positive definite linear equations "Ax=b" with same "A" and different "b"?I am trying to solve a series of the linear equations Ax=b. A is a large sparse positive definite matrix, in n*n. And b is a vector, in n*1. Among this equations, "A" matrix are the same, while the vector "b" are different. They both come from finite element method (e.g. same geometry and different loadings in structral machanics). I used to apply the PCG (preconditioned conjugate gradients) iterative method with an incomplete Cholesky preconditioner to solve every one of them. I would like to know whether I could get some accelerating idea from the same property of matrix "A"?
To note some details,
1. At first, I think I'd better get the inverse of "A" directly. Then I could calculate all the solution of these equations easily. But I found it is impossible to get the inverse of a large sparse positive definite matrix. I learned that It is very expensive and less precise.
2. The only way I could use now is to run the PCG iterative method with an incomplete Cholesky preconditioner parallelly. It takes large RAM.
3. I may make a preconditioner with smaller "droptol" for matrix "A". All the PCG would converge faster with it as below. But this step is very slow.
tol = 1e-6;
L1 = ichol(A, struct('type','ict','droptol',tol));
Any suggestion would be appreciated. Thank you.
wei zhanghttps://de.mathworks.com/matlabcentral/profile/authors/3994770tag:de.mathworks.com,2005:Question/4747252019-08-03T16:26:32Z2020-08-03T08:57:30ZInserting string into specific field in tableI'm trying to insert a string into a specific cell in a table. I've tried a handful of combinations, including curly brackets, cellstr()... but can't seem to get the right combination. Stand-along code is below; thanks for any help, I am sure it is something simple that I am missing.
files = {'file1.txt', 'file2.txt', 'file3.txt'};
mytable = NaN(length(files), 4);
mytable = array2table(mytable);
mytable.Properties.VariableNames = {'FILENAME', 'valueA', 'valueB', 'valueC'};
for i = 1:length(files)
filename = char(files(i));
% do things
mytable.FILENAME{i} = filename;
% also save other values; these are all doubles, so they write to table easily
end
Here is the error message:
Unable to perform assignment because brace indexing is not supported for variables of
this type.
Here are some other combos I have tried:
mytable.FILENAME{i} = cellstr(filename);
Unable to perform assignment because brace indexing is not supported for variables of
this type.
mytable.FILENAME{i} = filename;
Unable to perform assignment because brace indexing is not supported for variables of
this type.
mytable.FILENAME(i,:) = filename;
Unable to perform assignment because the size of the left side is 1-by-1 and the size
of the right side is 1-by-9.
mytable.FILENAME(i,:) = cellstr(filename);
Conversion to double from cell is not possible.
a1https://de.mathworks.com/matlabcentral/profile/authors/5150515tag:de.mathworks.com,2005:Question/5742672020-08-03T06:14:02Z2020-08-03T08:53:53ZIs Soft Actor Critic(SAC) coming to Reinforcement Learning Toolbox in MATLAB2020bNeed it for research. Or I'd really appreciate it if someone knows a third party implementation of SAC in MATLABYifei Shaohttps://de.mathworks.com/matlabcentral/profile/authors/15764993tag:de.mathworks.com,2005:Question/5743122020-08-03T08:18:44Z2020-08-03T08:53:39Zgenerate two correlated matrixhow to generated a set of matrices to make them have a given correlation coefficient each other?Peng LIhttps://de.mathworks.com/matlabcentral/profile/authors/11931500tag:de.mathworks.com,2005:Question/5742942020-08-03T07:47:33Z2020-08-03T08:53:09ZHow to plot roc and find pfaI have a radar data of size 55*12 with SNR 14db. How do I plot ROC for this data.
Any help is appreciated. Thanks in advance.Praanesh Sambathhttps://de.mathworks.com/matlabcentral/profile/authors/13510669tag:de.mathworks.com,2005:Question/1801312015-02-24T19:23:47Z2020-08-03T08:51:53ZHow can I find the angle between two vectors, including directional information?Hello, I am a graduate student, and I am working on a script that tracks the position of animals during a courtship. I have position data in the form of XY coordinates from two points on each animal's body taken from top down filming. I use these two points to create a vector that defines the animal's orientation. My script needs to calculate the angle between these two vectors, but also include directional information - IE, go from -180 through 0 to 180 degrees, depending on where the vectors are placed (see image).
<</matlabcentral/answers/uploaded_files/26099/matlabhelp.png>>
This is the code that I currently have. It gives me the desired angle (I believe), but is NOT directional. 60 degrees to either side spits out as 60 degrees no matter which it is.
angle_maleToFemale_radians = acos(dot(maleFemaleVector,femaleVector)/(norm(maleFemaleVector)*norm(femaleVector)));
angle_maleToFemale_degrees(index) = radtodeg(angle_maleToFemale_radians);
angle_maleToFemale_degrees(index) = 180 - angle_maleToFemale_degrees(index);
Sebastian Echeverrihttps://de.mathworks.com/matlabcentral/profile/authors/6214608tag:de.mathworks.com,2005:Question/738812013-04-28T18:01:46Z2020-08-03T08:48:22Zhow can i solve the error of reading permission during loading of number of images from a folderd=dir('d:\train2');
for i=1:4
fname=d(i).name;
z=imread(fname,'bmp');
end
this code is giving error
??? Error using ==> imread at 358
Can't open file "." for reading;
you may not have read permission.
help me out to solve this error pleasetejashttps://de.mathworks.com/matlabcentral/profile/authors/3594149tag:de.mathworks.com,2005:Question/5687642020-07-22T06:26:10Z2020-08-03T08:47:46ZWhether result of Code Prover is depend on the power of the computer which run it?Good afternoon,
When I run a same project on 2 computers, one is core i7, one is core i9. I realize that number of warnings in result of Code Prover from 2 computers is different. Why?Hiep Nguyen Hoanghttps://de.mathworks.com/matlabcentral/profile/authors/15606675tag:de.mathworks.com,2005:Question/5739282020-08-01T23:24:32Z2020-08-03T08:39:52ZParticularly strange bug using the eval functionIn the MWE below, I define a bunch of parameters using an eval command. I know that the experts recommend against using eval, as in this thread, but I don't really see an alternative in this instance. I also know that MATHWORKS would prefer me not to define variables that clash with their own builtins. However, the code still should work properly, but doesn't in this example.
The class for rho is correctly defined as double. But the fourth last line returns an error, as does the second last line. In both cases the code still thinks gamma is matlab's built-in function. Yet the third last line indicates that gamma is correctly defined as 0.6. Note that if I remove the first line of the code, and thus run the code in the base workspace, everything works as expected.
Could somebody please explain a) what's causing this bug and b) a simple alternative to my use of the eval function?
function nothing
rhoY = 0.8;
phiY = 0.8;
gammaY = 0.6;
etaY = 0.05;
muY = .5;
ecLetter = 'Y';
Params = {'phi','rho','eta','gamma','mu'};
nParam = numel(Params);
for ii=1:nParam;
thisParam = Params{ii};
eval([thisParam '=' thisParam ecLetter ';']);
end;
%This kludge fixes the problem
tmp=gamma;
gamma=tmp;
class(rho)
class(gamma)
gamma
3*gamma
keyboard;
Leo Simonhttps://de.mathworks.com/matlabcentral/profile/authors/115160tag:de.mathworks.com,2005:Question/5407072020-06-02T04:00:00Z2020-08-03T08:39:06ZWhy does MATLAB fail to install with a "'std::runtime_error' what(): Unable to launch the MATLABWindow application" error on Linux?When I try to install MATLAB it fails with the following error:
terminate called after throwing an instance of 'std::runtime_error'
what(): Unable to launch the MATLABWindow application
Aborted
MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813tag:de.mathworks.com,2005:Question/4551662019-04-08T20:51:35Z2020-08-03T08:29:56Zsin(x)^2How to expand a function like sin(x)^2 to output 1/2*(1-cos(2*x))? I tried expand(sin(x)^2) but it returns the same. Ethhttps://de.mathworks.com/matlabcentral/profile/authors/14439759tag:de.mathworks.com,2005:Question/5743152020-08-03T08:20:22Z2020-08-03T08:24:46ZGerchberg–Saxton AlgorithmHi, i am new to fourier transform and I get this codes from file exhange, but there is 1 line of code that i don't understand, it is "error = [error; sum(sum(abs(1.32*abs(C) - abs(Target))))];"; can anyone explain it to me? Thank you.
These are the codes:
%Author :Musa AYDIN
%e-mail :maydin@fsm.edu.tr
%Fatih Sultan Mehmet Vakif University,
%Department of Computer Engineering,
%Turkey / Istanbul
% Gerchberg亡axton Algorithm
% an example an of the gs algorithm is shown in this example
%--------------------------------------------------------
% pseudo code of GS algorithm
% Gerchberg亡axton Algorithm(Source, Target, Retrieved_Phase)
% A = IFT(Target)
% while error criterion is not satisfied
% B = Amplitude(Source) * exp(i*Phase(A))
% C = FT(B)
% D = Amplitude(Target) * exp(i*Phase(C))
% A = IFT(D)
% end while
% Retrieved_Phase = Phase(A)
%---------------------------------------------------------
% %-------------------------------------------------------
% calculate input beam or input intensity,
% in this example a gaussian beam was selected,
clear all; close all;
tic;
x = linspace(-10,10,256);
y = linspace(-10,10,256);
[X,Y] = meshgrid(x,y);
x0 = 0; % center
y0 = 0; % center
sigma = 2; % beam waist
A = 1; % peak of the beam
res = ((X-x0).^2 + (Y-y0).^2)./(2*sigma^2);
input_intensity = A * exp(-res);
surf(input_intensity);
shading interp
%---------------------------------------------------------
Target=rgb2gray(imread('Sample_Image'));
Target=double(Target);
A = fftshift(ifft2(fftshift(Target)));
error = [];
iteration_num = 100;
%hologram = |objectWave + referenceWave|.^2
for i=1:iteration_num
B = abs(input_intensity) .* exp(1i*angle(A));
C = fftshift(fft2(fftshift(B)));
D = abs(Target) .* exp(1i*angle(C));
A = fftshift(ifft2(fftshift(D)));
error = [error; sum(sum(abs(1.32*abs(C) - abs(Target))))];
end
figure
subplot(2,1,1);
imshow(Target);
title('Original image')
subplot(2,1,2);
imagesc(abs(C)) %last pattern
title('reconstructed image');
figure
i = 1:1:i;
plot(i,(error'));
title('Error');
figure
imagesc(abs(C)) %last pattern
title('reconstructed image');
toc;Soong Wei Kanghttps://de.mathworks.com/matlabcentral/profile/authors/18480833tag:de.mathworks.com,2005:Question/5685692020-07-21T19:21:55Z2020-08-03T08:23:13ZWhere has depfun gone? or How to make a dependency graph?I would like to use plot_graph from plot_depfun: https://www.mathworks.com/matlabcentral/fileexchange/46080-plot_depfun
These functions use the function depfun, wich does not seem to exist in newer matlab versions.
I am looking for an easy way to make a connection map (node graph) which shows the dependencys between functions.
Further more the dependency report does not seem to work when .mlapp files come in play.
Thanks!Christian Tieberhttps://de.mathworks.com/matlabcentral/profile/authors/19051773tag:de.mathworks.com,2005:Question/5743182020-08-03T08:20:26Z2020-08-03T08:20:26ZSection an array into equal rows and changing simultaneously the values of each section.I've been trying to section a matrix into equal rows while changing simultaneously the values of each section but I've been stuck for a while now please I need help. Thanks.Princewill Azoromhttps://de.mathworks.com/matlabcentral/profile/authors/19119386tag:de.mathworks.com,2005:Question/5727312020-07-30T08:52:36Z2020-08-03T08:17:32ZWrap Xilinx IP in Simulink black boxHi all,
I have done several of the Xilinx tutorials for black-box wrapping of HDL in Simulink but have not come across one yet where more than one HDL file is used. I have a fairly large HDL codebase with ~40 files.
My top file makes use of all the other files (which are contained within pre-defined libraries). I am doubtful as to whether wrapping my top file in a black-box (which I have done) in Simulink, will work. I understand that I could just include all my hdl files in the config.m script, but how would I infer the libraries each set of files belong to?
I have a working Vivado project for this build but asides from that, I am unsure how I need to tell Simulink (and by association system generator) about the hierarchy/libraries/multiple files for correct synthesis and implementation. Do I need to supply accompanying tcl scripts? Is there a way to pass the Vivado project file to System Generator in Simulink? Could I create a custom IP from the Vivado project for wrap that in a black box?
Please assist.
I am happy to share my .slx and config.m (for the black box I have created for my top vhdl file), and Vivado project should you need it.
Thank you.
Using: Vivado 2019.1 and Matlab 2019a.
Talon Myburgh.
Below you can see a screenshot of my black box I've created in Simulink:
Simulink black box of my top HDL file. Block shows in/out ports available and window beside it shows customisable generics. A system generator block is present in the design so that Simulink knows to hand off the design to System Generator in Vivado for Synthesis and Implementation. Talon Myburghhttps://de.mathworks.com/matlabcentral/profile/authors/8194740tag:de.mathworks.com,2005:Question/5742852020-08-03T07:20:56Z2020-08-03T08:15:31ZError while plotting matrix of complex numbers clc
clear all
sub=[ -1.1691 + 113.64i; -9.0587 + 137.23i; -10.221 + 166.23i; -9.6819 + 197.8i; -8.5346 + 233.76i;
-1.1691 - 113.64i; -9.0587 - 137.23i; -10.221 - 166.23i; -9.6819 - 197.8i; -8.5346 - 233.76i];
sup=[ -13.605 + 570.94i; -12.344 + 556.39i; -11.068 + 539.83i; -9.7952 + 520.39i; -8.4823 + 496.4i;
-13.605 - 570.94i; -12.344 - 556.39i; -11.068 - 539.83i; -9.7952 - 520.39i ; -8.4823 - 496.4i];
TI=[ -86.534 + 37.766i; -85.883 + 37.936i; -85.384 + 38.191i; -84.9 + 38.399i; -84.506 + 38.589i;
-86.534 - 37.766i; -85.883 - 37.936i; -85.384 - 38.191i; -84.9 - 38.399i; -84.506 - 38.589i];
shaft=[ -0.48455 + 6.1504i; -0.48842 + 6.1493i; -0.4907 + 6.1486i; -0.49212 + 6.1481i; -0.49306 + 6.1477i;
-0.48455 - 6.1504i; -0.48842 - 6.1493i; -0.4907 - 6.1486i; -0.49212 - 6.1481i ; -0.49306 - 6.1477i];
EM=[ -19.362 + 91.845i ; -9.6224 + 94.729i; -6.5132 + 94.265i; -5.1096 + 94.093i; -4.3018 + 94.032i;
-19.362 - 91.845i; -9.6224 - 94.729i; -6.5132 - 94.265i ; -5.1096 - 94.093i; -4.3018 - 94.032i];
plot(sub,'r-',sub,'b*');
hold on;
plot(sup,'r-',sub,'b^');
hold on;
plot(TI,'r-',TI,'bx');
hold on;
plot(EM,'r-',EM,'bv');
hold on;
plot(shaft,'r-',shaft,'bs');
hold off
chirag rohithttps://de.mathworks.com/matlabcentral/profile/authors/7055363tag:de.mathworks.com,2005:Question/5743092020-08-03T08:13:18Z2020-08-03T08:13:18ZRandom road profile into ode45clc,clear all
k_s = 26400;
m = 483; %Mass
f_n = sqrt(k_s/m)/(2*pi); %Natural frequency in Hz
%% Road profile
% spatial frequency (n0) cycles per meter
Omega0 = 0.1; %%%%conventional value of spatial frequency(n0)?
% psd ISO (used for formula 8)
Gd_0 = 32 * (10^-6);
% waveviness
w = 2;
% road length
L = 250;
%delta n
N = 1000;
Omega_L = 0.004;
Omega_U = 4;
delta_n = 1/L; % delta_n = (Omega_U - Omega_L)/(N-1);
% spatial frequency band
Omega = Omega_L:delta_n:Omega_U;
%PSD of road
Gd = Gd_0.*(Omega./Omega0).^(-w);
% calculate amplitude using formula(8) in the article
%Amp = sqrt(2*Gd*delta_n); %%%from Eq. 7?
%calculate amplitude using simplified formula(9) in the article
k = 3; %%%upper limit A and lower limit B k=3?
%Amp = sqrt(delta_n) * (2^k) * (10^-3) * (Omega0./Omega);
Amp = sqrt(delta_n) * (2^k) * (10^-3) * (Omega0./Omega);
%random phases
Psi = 2*pi*rand(size(Omega));
% x abicsa from 0 to L
x1 = 0:0.25:250;
% road sinal
h= zeros(size(x1));
plot(x1, h*1000);
%% ode45
T = 110;
x0 = [0,0];
for iv=1:length(x1)
h(iv) = sum( Amp.*cos(2*pi*Omega*x1(iv) + Psi) );
f = @(t,x) [ x(2); -( k_s*(x(1)-1000*h(iv))/ m ) ];
[t, x] = ode45(f,[100,T],x0);
end
plot(t,x(:,1));
Hi, I generated a random road profile (h) and it gives such a figure as below,
As you can see, there are quite lots of elevation in this road profile. However, if I apply this into my ode45, it gives a graph as below,
this seems to be a sinosoidal graph, but I think this graph should not be like this because the road has lots of elevation during the journey.
Can any one tell me what is wrong with my code please?
Donghun Leehttps://de.mathworks.com/matlabcentral/profile/authors/17824938tag:de.mathworks.com,2005:Question/2204682015-05-28T19:59:58Z2020-08-03T07:59:35ZWrite a function called halfsum that takes as input an at most two-dimensional matrix A and computes the sum of the elements of A that are in the diagonal or are to the right of it. example, the input is [1 2 3; 4 5 6; 7 8 9],the ans is 26 function s = halfsum(A)
[row col] = size(A);
if row ~= col
error('Expecting a square matrix here people...');
end
s = 0;
for ii = 1:row
for jj = ii:col
s = s + A(ii,jj);
end
endDeepanshu Pariharhttps://de.mathworks.com/matlabcentral/profile/authors/6023207tag:de.mathworks.com,2005:Question/5743032020-08-03T07:52:54Z2020-08-03T07:52:54Zsolve 4 degree partial equation with ode45vd^2t-wdt+v-w=-v^3-w^2*v-wdt*teta
wd^2t+vdt+v+w=-w^3-v^2*w+vdt*teta
phid^2t+phi=0
tetadt+tetadt*(-w^2+v^2)+(1-teta)*w*wdt+(teta-1)v*vdt=vd^2t*w-wd^2t*v-vdt*wdt
dear all.
my first two equations are non-linear and coupled.The third equation is linear and the last equation is a first-order derivative, nonlinear and coupled.my inputs is time(2second) and boundry condition is:
v(0)=1
vdt(0)=1
w(0)=1
wdt(0)=1
phi(0)=1
phidt(0)=1
my output are v,w,phi,teta and I want to plot output-time diagram.
alfred jakobihttps://de.mathworks.com/matlabcentral/profile/authors/19116615tag:de.mathworks.com,2005:Question/5743002020-08-03T07:51:41Z2020-08-03T07:51:41ZHow to solve the font of the property inspector is too small in Matlab 2019a?In the Matlab 2019a, the font of the property inspector is too small. Yalong Renhttps://de.mathworks.com/matlabcentral/profile/authors/14097321tag:de.mathworks.com,2005:Question/5741682020-08-02T19:50:28Z2020-08-03T07:50:44ZHow can one extract this vector from a matrix?First, suppose I have a matrix M of 60 rows and 3 columns. Suppose each row is a month like January, February, ... so that every 12 months make a year.
Second, I now want to create a matrix Y of 5 rows and 2 columns where each row represents year and the second column is the yearly average of entries of the second column and the third columns of each year.
How can one write a program?
(Just to make sure, the actual case is not about months and year so it is not that one wants to use retime and other time related function.)alpedhuezhttps://de.mathworks.com/matlabcentral/profile/authors/10930090tag:de.mathworks.com,2005:Question/5742342020-08-03T03:35:02Z2020-08-03T07:48:18Zanimate 2d plotHi, All!
Say i have 2 variable, x1 and x2. I wanna plot (x1, x2) and animate it over time. i've tried this code:
x = [1 2;2 1;3 1;1 2;2 1;3 2];
x1 = x(1:end,1);
x2 = x(1:end,2);
r=animatedline;
for t=1:1000
for i=1:6
x1(i,t+1)=x1(i,t)+3;
x2(i,t+1)=x2(i,t)+x1(i,t);
end
addpoints(r,x1(1,:),x2(1,:))
addpoints(r,x1(2,:),x2(2,:))
drawnow
end
But that's not what i meant. From code above, the first line move from (1,2) to (4,3) to (7,7).... the second line move from (2,1) to (5,3), to (8,8),...
till the figure show the movement of those 6 lines.Nur Amalinahttps://de.mathworks.com/matlabcentral/profile/authors/7681873tag:de.mathworks.com,2005:Question/5742972020-08-03T07:47:45Z2020-08-03T07:47:45ZError using netcdflib NC_EINVALCOORDHi,
I'm trying to get some wind direction timelines for different heights. The dataset includes wind data for 37 pressure levels. And I'm getting the following error:
h =
1
Error using netcdflib
The NetCDF library encountered an error during execution of 'getVarsShort' function - 'Index exceeds dimension bound (NC_EINVALCOORDS)'.
Error in netcdf.getVar (line 140)
data = netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/read (line 635)
data = netcdf.getVar(gid, varid, ...
Error in ncread (line 66)
vardata = ncObj.read(varName, varargin{:});
Error in DirectionTimelines_from_ERAInt6hrly_SJ (line 44)
uwnd_all_temp = ncread(Wu(f).name,'u', [(int16((VolcLong/0.75)+1)) (int16(241-((90+VolcLat)/0.75))) h 1],[1 1 1 (length(ncread(Wu(f).name,
'time')))],[1 1 1 1]); %Some years have a leap year and thus 1464 time periods, but leave at 1460 so doesn't need adapting for leap years.
Error in run (line 91)
evalin('caller', strcat(script, ';'));
The code is the following:
cd ~/Documents/MATLAB/Wind
Wu = dir('u*.nc');
Wv = dir('v*.nc');
YearRange = '2009-2018';
NumYears = 10;
Levels = length(ncread(Wu(1).name, 'level'));
for f = 1:length(Wu)
if (f==1)
date(1:16072) = ncread(Wu(f).name, 'time');
else
date((length(date)+1):((length(date)+1)+length(ncread(Wu(f).name, 'time'))-1)) = ncread(Wu(f).name, 'time');
end
end
Time = length(date);
%Change for each volcano run...
Volcano = '5S'; VolcLat = -5; VolcLong = 95;
mkdir(strcat('../../Output-Wind/',Volcano,'_WindInfo_2019-2018'));
if (VolcLong < 0) %i.e. in Western Hem
VolcLong = 360 + VolcLong;
end
uMatrix = zeros(Time, 37); %Matrix of n rows (1460 time records per year for 6 hourly daily data) by 37 (heights)
%To convert mb or hPa (unit for pressure level data) to altitude, try: www.csgnetwork.com/pressurealtcalc.html
for h = 1:37 %Number of levels
h %So can track progress when running
count = 0;
for f = 1:length(Wu)
uwnd_all_temp = ncread(Wu(f).name,'u', [(int16((VolcLong/0.75)+1)) (int16(241-((90+VolcLat)/0.75))) h 1],[1 1 1 (length(ncread(Wu(f).name, 'time')))],[1 1 1 1]); %Some years have a leap year and thus 1464 time periods, but leave at 1460 so doesn't need adapting for leap years.
uwnd_all_temp = squeeze(uwnd_all_temp);
uMatrix((count+1):(count+length(uwnd_all_temp)),h) = uwnd_all_temp;
count = count+length(uwnd_all_temp);
end
end
vMatrix = zeros(Time, 37); %Matrix of rows (no. years * no. days * no. records/day) by 37 cols (heights)
for h = 1:37 %Number of levels
h
count = 0;
for f = 1:length(Wv)
vwnd_all_temp = ncread(Wv(f).name,'v', [(int16((VolcLong/0.75)+1)) (int16(241-((90+VolcLat)/0.75))) h 1],[1 1 1 (length(ncread(Wu(f).name, 'time')))],[1 1 1 1]); %Some years have a leap year and thus 1464 time periods, but leave at 1460 so doesn't need adapting for leap years.
vwnd_all_temp = squeeze(vwnd_all_temp);
vMatrix((count+1):(count+length(vwnd_all_temp)),h) = vwnd_all_temp;
count = count+length(vwnd_all_temp);
end
end
Dmatrix = zeros(Time,Levels); % matrix of direction (rows) at each height (cols)
Imatrix = zeros(Time,Levels); % matrix of intensity (rows) at each height (cols)
AltitudeLabels = {'32.5 km' '31 km' '29.5 km' '28 km' '27 km' '26 km' '23.5 km' '21.5 km' '19.5 km' '17.5 km' '16 km' '14.5 km' '13.5 km' '12.5 km' '12 km' '11 km' '10.5 km' '9 km' '8 km' '7 km' '6.5 km' '5.5 km' '5 km' '4.2 km' '3.6 km' '3 km' '2.5 km' '2.2 km' '1.9 km' '1.7 km' '1.5 km' '1.2 km' '1 km' '800 m' '500 m' '300 m' '100 m'};
%To calculate and save direction and intensity per record with height:
for h = 1:Levels
Dmatrix(:, h) = mod(90-atan2d(vMatrix(:,h),uMatrix(:,h)), 360); %calculation from u and vmatrix... for Direction.
Imatrix(:, h) = sqrt((uMatrix(:,h).^2)+(vMatrix(:,h).^2)); %calculation from u and vmatrix... for Speed.
end
save(strcat('../../Output-Wind-Info/',Volcano,'_WindInfo_2009-2018/Dir-Int_Matrix.mat'),'Dmatrix','Imatrix');
%From: http://www.csgnetwork.com/pressurealtcalc.html
Altitude = {32435,30760,29675,28180,27115,25905,23315,21630,19315,17660,15790,14555,13505,12585,11770,11030,10360,9160,8115,7180,6340,5570,4865,4205,3590,3010,2465,2205,1950,1700,1455,1220,990,760,540,325,110};
AltAsNumber = cell2mat(Altitude);
AltAsNumber = reshape(AltAsNumber,37,1);
Has anyone an idea how to solve the problem?
Thanks in advance
SteffenSteffen Eiselehttps://de.mathworks.com/matlabcentral/profile/authors/16822020tag:de.mathworks.com,2005:Question/5742912020-08-03T07:44:51Z2020-08-03T07:44:51ZZeit brechnen in While Schleife Hello ,
I have a problem . I want to calculate the time in m / s from While loop so that I can integrate the values. I tried a lot, unfortunately that didn't work. I use the MPU6050 accelerometer . Can you help please, best regards
delete(instrfindall);
clear all
clc
serialPort = 'COM2';
s=serial(serialPort,'BaudRate',9600);
fopen(s);
%tic
%t=0.004
m=[];
%t0=0
vec_ax=[0];
vec_ay=[0];
vec_az=[0];
while 1
%t_start=datetime('now')
x = fscanf(s);
m = str2num(x);
if isempty(m); continue; end
ax = m(1);
ay = m(2);
az = m(3);
%t_end=
%t_delta=
%vec_ax=[vec_ax, ax]
%vec_ay=[vec_ay, ay];
%vec_az=[vec_az, az];
%vec_t=[vec_t, t_delta]
%vx = cumtrapz(vec_ax, vec_t)
%vy = cumtrapz(vec_ay, vec_t)
%vz = cumtrapz(vec_az, vec_t)
end
fclose(s);Yamen Madamanihttps://de.mathworks.com/matlabcentral/profile/authors/17203598tag:de.mathworks.com,2005:Question/5731092020-07-30T22:01:45Z2020-08-03T07:36:08ZFilter transfer function for impulse responseHello, guys
I need help
How to get filter transfer function from this scheme. Then i need make impulse response from filter transfer function and calculate impulse response the first 20 readings.
Thanks for help
I tried i get transfer function H(z)=z^-1*0.25/1+z^-1*0.25 <--- is this right?
ACICYhttps://de.mathworks.com/matlabcentral/profile/authors/17088872