https://se.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-12-10T11:14:51Ztag:se.mathworks.com,2005:Question/4348902018-12-10T10:27:49Z2018-12-10T11:12:58Zhow to fit implicit function to dataI have these data points
data=[0 1
0.355257 0.726061
0.749002 0.382696
1 0
2.401699 -0.9817
3.049682 -1.49588
4.105308 -2.51708
3.419108 -2.79514
1.784289 -2.188
0.763907 -1.56124
0 -1];
I need to fit this implicit function to the data
f = @(x,y) abs(x)^a + abs(y)^b +c*x*y-1;
where a, b, c are the 3 positive parameters to be estimated.
Can anyone help me?Alessandrarohttps://se.mathworks.com/matlabcentral/profile/authors/14337397-alessandrarotag:se.mathworks.com,2005:Question/4349002018-12-10T11:11:33Z2018-12-10T11:11:33ZI get an error when starting the Network boot server in SLRT Explorer saying "Can not get interface ip address". Where am I going wrong?Hello,
I have configured a TargetPC in the SLRT Explorer for network boot. I have entered the MAC id. I get an error shown below when I try to start the network boot daemon.
My software config:
Win7 SP1
MS Visual Studio 2015 Enterprise
Java version 8 update 25 (build 1.8.0_25-b18)
Can anyone please help me and point to my error? Please let me know if any other pertinant info would be required.
Regards,
SwaroopSwaroop Hangalhttps://se.mathworks.com/matlabcentral/profile/authors/14337766-swaroop-hangaltag:se.mathworks.com,2005:Question/4348992018-12-10T11:08:01Z2018-12-10T11:10:54Zplotting a graph for celli have a cell array. it has a 12 rows and 1 column. i want to plot the graph for each cell element in the same graph. each cell element should differ in appearance. like circles, triangles and so on. johnson saldanhahttps://se.mathworks.com/matlabcentral/profile/authors/10681723-johnson-saldanhatag:se.mathworks.com,2005:Question/4348972018-12-10T11:04:53Z2018-12-10T11:08:54ZHow can i find the length of the horizontal and vertical line present only in the white pixel region for the attached binary image. sumaiya khanhttps://se.mathworks.com/matlabcentral/profile/authors/9728390-sumaiya-khantag:se.mathworks.com,2005:Question/4348862018-12-10T10:19:20Z2018-12-10T11:08:18ZHow can I threshold a matrix and get the coordinates of those values?I have a matrix, X with dimensions 132X132, with values ranging from -0.1 to 0.4. I'd like to threshold it to values above 0.2, and most importantly, obtain the coordinates to which those values belonged to in the previous matrix.
Thank you.Nativehttps://se.mathworks.com/matlabcentral/profile/authors/12921279-nativetag:se.mathworks.com,2005:Question/4348932018-12-10T10:43:33Z2018-12-10T11:06:32ZHow to fix error done by pressing 'Cancel' button using App Designer?Hi!
I'm creating an application using App Designer. When I cancel the dialog box, it gives me an error.
I tried to solve the problem this way, but it seems not to work.
app.FieldFolderName.Value = uigetdir('','Select training Folder');
%if no folder is chosen, anything is done
if isempty(app.DictionaryLabel.Value)
return
else
...
Thanks!Almudena Martínezhttps://se.mathworks.com/matlabcentral/profile/authors/6227906-almudena-martineztag:se.mathworks.com,2005:Question/4348242018-12-10T02:19:20Z2018-12-10T11:05:50ZHello. How to create such a matrix?1 0 2 0 ..
0 2 0 3 ..
2 0 3 0 ..
0 3 0 4 ..
3 0 4 0 ..
: : : :Azad Asadovhttps://se.mathworks.com/matlabcentral/profile/authors/14335067-azad-asadovtag:se.mathworks.com,2005:Question/4348982018-12-10T11:05:20Z2018-12-10T11:05:20Zinstalled simscape electrical but still after installation and if i run the model there it is showing no license with red letters and in the error box like simscape electrical has not installed.why it is so?????installed simscape electrical but still after installation and if i run the model there it is showing no license with red letters and in the error box like simscape electrical has not installed.
PLEASE FOLLOW THE ATTACHED FILES TO SEERAJENDRA PRASADhttps://se.mathworks.com/matlabcentral/profile/authors/11200905-rajendra-prasadtag:se.mathworks.com,2005:Question/4348942018-12-10T10:51:22Z2018-12-10T11:14:51Zhow can i find the numbers and their indices which are same this is my data
1 3 4 36
3 2 2 5
5 5 6 8
3 4 1 23
3 12 6 34
1 5 3 1
11 17 12 9
17 19 26 26
16 1 1 27
18 10 18 15
i want to return those indices and their numbers which are repeating. for example row one has no repeating value so skip it.row 2, row 3 ,row 6, row 8 row 9 and 10 has the repeating numbers. so i want to obtain these numbers and their indices.
thanks in advanceFarman Shahhttps://se.mathworks.com/matlabcentral/profile/authors/13190684-farman-shahtag:se.mathworks.com,2005:Question/4347892018-12-09T21:28:32Z2018-12-10T11:03:52Zsource of the python benchmarksHere in this page MATLAB team has mentioned that they have a dozen of benchmarks shwoing MATLAB is faster than Python:
However I can't find the source code to these benchmarks. I would appreciate if you could provide me with those. I very much like to study them. Thanks in advance.Foad Sojoodi Farimanihttps://se.mathworks.com/matlabcentral/profile/authors/4034063-foad-sojoodi-farimanitag:se.mathworks.com,2005:Question/4348962018-12-10T10:57:50Z2018-12-10T10:57:50ZHow to 'crop' a graph?Question refers to the last section of code, which produces a graph of U vs time. I want to know how to remove the first cycle of that graph. Thanks in advance!
%% Solves 2 PDE's for ETA and U using finite differencing
% (centralised with lagged friction)
close all;
clear all; % Initial Clearing
clc;
% Discretise Domain
n = 21; % Number of eta points in our domain
disp(['Number of elevation points in the grid = ',num2str(n)])
Channel_Length = 22000; % m (thus 20km in length) we will have three
% time-levels per space discritisation because of
% the time filter employed (which requires t-1:t+1
% for each i point.
% Set up values
eta(1:n,1:2) = 0;
eta(1:n,3) = NaN;
u(1:n-1,1:2) = 0; % Velocity staggard grid (eta drives velocity)
u(1:n-1,3) = NaN;
% Set up domain
d = zeros(1,n)+10; % Create coinstant bathyemtry at 10m
b(1:n) = 180; % Channel width (note spatially constant)
% Set grid size and timestep
dx = Channel_Length/(n-1); % Length/n of point = dx
% Domains
xeta = 0:dx:(n-1)*dx; % x-values for plotting eta
xu = dx/2:dx:(n-1)*dx-dx/2; % x-values for plotting u
%
dt = 20; % Timestep
c = dt/dx;
% CFL check for time-step stability
if dt >= dx/sqrt(9.81*min(d))
disp('Warning!: dt is too large')
end
tmax = 8000; % Number of timesteps in simulation
time = 0:dt:tmax*dt; % Sim_time in seconds
cd = 0.001; % Bottom drag coefficient. **Change this!**
% To get the hydrodynamics stated in the assignment
disp(['The bottom drag coefficent is = ',num2str(cd)])
r = 0.05; % Constant for Asselin filter
%% Initialise variables and set initial conditions
h1 = 1.9; % Amplitude of boundary at point 1
g1 = 180; % Phase of boundary at point 1
hn = 2.6; % Amplitude of boundary at point n
Phase_Diff = ((24/60)/12.4224)*360;
gn = g1+Phase_Diff; % Phase of boundary at point n
% 12 degrees more than other boundary
% H1 = 0.0125*5; G1 = 100;
% Hn = 0.0750*5; Gn = 050;
g = 9.81;
count = 1; % Counter for output of eta and u history
nans = 50; % Output frequency (animation and u/eta history)
% Hint: (nans*dt*20)/3600
Eta = nan(1+tmax/nans,1); % Precondition output arrays
U = nan(1+tmax/nans,1); % "
% Store intial conditons
Eta(count) = eta(1,1);
U(count) = 0.5*(u(5,1)+u(6,1)); % Store initial condition
count = count+1;
%% Computation with Central Finite Difference and Lagged Scheme
for it = 1:tmax % Computational loop
% Time setting
t = it*dt;
tim = t/3600;
tc1 = tim/12.4224;
tc2 = tim/6.2112;
sim_tim(count) = tim; % For plotting
% Elevation boundary conditions
eta(1,3) = h1*cos(2*pi*tc1-g1*pi/180); % +H1*cos(2*pi*tc2-G1*pi/180);
eta(n,3) = hn*cos(2*pi*tc1-gn*pi/180); % +Hn*cos(2*pi*tc2-Gn*pi/180);
% Update elevations
for i = 2:n-1
eta(i,3) = eta(i,1)-c*((b(i)*(d(i)+eta(i,2))+b(i+1)*...
(d(i+1)+eta(i+1,2)))*u(i,2)-(b(i-1)*(d(i-1)+eta(i-1,2))...
+b(i)*(d(i)+eta(i,2)))*u(i-1,2))/b(i);
end
% Update velocities
for i = 1:n-1
db1 = -g*(eta(i+1,2)-eta(i,2))/dx;
db2 = -cd*(u(i,1)*abs(u(i,1)))/((0.5*(d(i)+eta(i,1)+d(i+1)+...
eta(i+1,1)))^(4/3));
u(i,3) = u(i,1)+2*dt*(db1+db2);
end
% Time smoothing (Asselin filter)
for i = 1:n
eta(i,2) = eta(i,2)+0.5*r*(eta(i,1)-2*eta(i,2)+eta(i,3));
end
for i = 1:n-1
u(i,2) = u(i,2)+0.5*r*(u(i,1)-2*u(i,2)+u(i,3));
end
% Store results and plot (animation)
if rem(it,nans) == 0
subplot(2,1,1)
plot(xeta,eta(:,3),'-ob','MarkerSize',5,'LineWidth',1.5);
title(num2str(tim,'%4.1f'))
ylabel('\eta (m)');
ylim([-2.5 2.5]);xlim([0 xeta(n)]);
subplot(2,1,2)
plot(xu,u(:,3),'-ob','MarkerSize',5,'LineWidth',1.5);
ylabel('u (m s^-^1)'); xlabel('distance (m)')
ylim([-2 2]);xlim([0 xeta(n)]);
drawnow
% Try to output the velcoity at the middle of the channel (note: Is
% this correct?)
U(count) = mean([u(10,3),u(11,3)]); % Output velocity history
E(count) = mean([eta(10,3),eta(11,3)]); % "
Ust(count) = u(1,3);
eta1(count) = eta(1,3);
Ue(count) = u(end-1,3);
eta22(count) = eta(end-1,3);
u(:,count) = u(:,3); % Why 3? = = for time-filtering
count = count+1;
end
% Shuffle (update time indices)
eta(:,1) = eta(:,2); eta(:,2) = eta(:,3);
u(:,1) = u(:,2); u(:,2) = u(:,3);
end
% Plot u time history
figure
Tim = 0:dt*nans:tmax*dt;
plot(Tim,U,'-ob','MarkerSize',5,'LineWidth',1.5);
hold on
plot([0 max(Tim)],[0 0],'--b','MarkerSize',5,'LineWidth',1.5);
title('U');
xlabel('Time (s)');
ylabel('U Mid Channel (m/s)');
Dan Williamshttps://se.mathworks.com/matlabcentral/profile/authors/13948340-dan-williamstag:se.mathworks.com,2005:Question/4348892018-12-10T10:24:54Z2018-12-10T10:55:48Zcould we convert or detect matrix value to logical scalar value in matlab ? if it could, please tell me how. because, when i try to do that, i got "Operands to the || and && operators must be convertible to logical scalar values." ber=[];
for EbN0=0:1:50
if EbN0<=26 && ber<=0.001
smod_total=bpsk_mod(s);
else EbN0<=32 && ber<=0.001
smod_total=qpsk_mod(s);
end
end
[noe, berr]=biterr(s,det);
ber=[ber berr];
Naufal Alihttps://se.mathworks.com/matlabcentral/profile/authors/14337482-naufal-alitag:se.mathworks.com,2005:Question/4348372018-12-10T05:15:41Z2018-12-10T10:52:39Zhow to read images in MATLAB when images are saved in one folder in the form of image(1),image(2)........image(2000).how to read images in MATLAB when images are saved in one folder in the form of image(1),image(2)........image(2000).Anuja Bhargavahttps://se.mathworks.com/matlabcentral/profile/authors/3578000-anuja-bhargavatag:se.mathworks.com,2005:Question/4348952018-12-10T10:52:21Z2018-12-10T10:52:21Zmultivariable curve fitting using cftoolbox
two other data set
1. one set
a - constant (ex. 1)
b - variable (ex. 1, 2, 3, 4,5, 6,7,8,9, )
T - result (ex. 11,12,13,14,.....,19)
2. next set
a' - constant ( it is different from a ) (ex. 2)
b' - variable (ex. 100, 101, 102, .... ,109)
T' - result (ex. 201,202,.....,209)
how do i get a function T( a, b) of variable a, b by using curve fitting ?
please any anwer is welcom. thank you very much!!
mijks100@cau.ac.krminkeun kookhttps://se.mathworks.com/matlabcentral/profile/authors/8851782-minkeun-kooktag:se.mathworks.com,2005:Question/4348612018-12-10T08:17:15Z2018-12-10T10:51:45Zxlswrite() misfunction with Officehello.
i am trying to write using xlswrite().
a new company Office version has been insatlled: 1811 (Build 1109.20079).
the function fails and I repeatedly get a comment that the file is already opened by another program.
any help will be greatly appreciated!
thanks!!
mat
mathttps://se.mathworks.com/matlabcentral/profile/authors/3626535-mattag:se.mathworks.com,2005:Question/4345052018-12-07T21:24:26Z2018-12-10T10:47:46ZScript doesn't seem to be execute properlyI was hoping to acquire some help on how to make my program work efficiently and not take a substantial amount of time to finish:
clear variables
a=...;
p=nextprime(a);
count=0;
limit=200000;
tic
while isprime((p-1)/2)~=1
a=a+1;
p=nextprime(a);
count=count + 1;
if count>limit
break
end
end
toc
This program outputs a number p greater than a such that p is prime and (p-1)/2 is prime. However I've noticed that for any number a greater than approximately 15 digits, the program will take an absurd amount of time to finish, which isn't ideal since I need to test numbers of the order 10^50.Manuel Barroshttps://se.mathworks.com/matlabcentral/profile/authors/13743191-manuel-barrostag:se.mathworks.com,2005:Question/4348562018-12-10T08:10:47Z2018-12-10T10:47:25ZI am having this error "Index in position 2 is invalid. Array indices must be positive integers or logical values." in my file. Can you please help me in resolving this. It is very urgent? I am very new to matlab and am having some syntax errors. The code is due for submission in a few days. I will be very grateful for solution. . . .
Sanchit Sharmahttps://se.mathworks.com/matlabcentral/profile/authors/13394492-sanchit-sharmatag:se.mathworks.com,2005:Question/4345652018-12-08T10:57:14Z2018-12-10T10:47:05Zdisadvantages of ode15s, ode23s, ode23tbFor example ode15s can solve stiff ODEs that ode23 and ode45 can't. Then is there any disadvantage of these solvers aimed at stiff ODEs? Obviously ode23 is the 1st default one one uses, so ode23 should have an advantage over the rest.a ahttps://se.mathworks.com/matlabcentral/profile/authors/11974203-a-atag:se.mathworks.com,2005:Question/4348602018-12-10T08:14:55Z2018-12-10T10:42:25ZVERY URGENT::::: My code is giving me this error: Index in position 2 is invalid. Array indices must be positive integers or logical values. Can you please resolve this for me? It is very urgent and due in two days!!!%####********Analytical Solutions *********#####
%#### This is simply plugging in the results from problem 1
%### Constants
sigmaa=0.005;
D=0.6;
L = (D/sigmaa)^0.5;
T=45;
So=10^8;
%### Slab Problem
x=linspace(0,45,10000);
U = (D/(2*L)-1/4)/(D/(2*L)+1/4);
C = (-So*T/sigmaa)*(T/4+D)/(-(D/(2*L)-1/4)^2/(D/(2*L)+1/4)*exp(-T/L)+(D/(2*L)+1/4)*exp(T/L));
A = U*C;
flux_slab=[];
for i = 1:x
ans1 = A*exp(-i/L)+C*exp(i/L)+(So*i^2)/sigmaa;
flux_slab = ans1;
end
%### Cylindrical Problem
x2=linspace(0,45/2,10000);
flux_cyl=[];
for i = 1:x2
ans1 = -So/(2*sigmaa*(0.5*besseli(0,T/(2*L))+(D/L)*besseli(1,T/(2*L))))*besseli(0,i/L)+(So/sigmaa);
flux_cyl = ans1;
end
%#### Sphere Problem
flux_sph=[];
for i = 1:x2
flux_sph = (-So*sinh(i/L)/(i*4*sigmaa*(sinh(T/(2*L))/(2*T)+(2*D/L)*(T/2*cosh(T/(2*L))-L*sinh(T/(2*L)))/(T^2))))+So/sigmaa;
end
flux_comp_slab_10 = Diffusion('slab', 45, 10, 0.005, 0.6, 10^8);
flux_comp_slab_100 = Diffusion('slab', 45, 100, 0.005, 0.6, 10^8);
flux_comp_slab_1000 = Diffusion('slab', 45, 1000, 0.005, 0.6, 10^8);
flux_comp_slab_10000 = Diffusion('slab', 45, 10000, 0.005, 0.6, 10^8);
flux_comp_cyl_10 = Diffusion('cylinder', 45/2, 10, 0.005, 0.6, 10^8);
flux_comp_cyl_100 = Diffusion('cylinder', 45/2, 100, 0.005, 0.6, 10^8);
flux_comp_cyl_1000 = Diffusion('cylinder', 45/2, 1000, 0.005, 0.6, 10^8);
flux_comp_cyl_10000 = Diffusion('cylinder', 45/2, 10000, 0.005, 0.6, 10^8);
flux_comp_sph_10 = Diffusion('sphere', 45/2, 10, 0.005, 0.6, 10^8);
flux_comp_sph_100 = Diffusion('sphere', 45/2, 100, 0.005, 0.6, 10^8);
flux_comp_sph_1000 = Diffusion('sphere', 45/2, 1000, 0.005, 0.6, 10^8);
flux_comp_sph_10000 = Diffusion('sphere', 45/2, 10000, 0.005, 0.6, 10^8);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PLOTTING OPTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x3=linspace(0,45/2,10);
x4=linspace(0,45/2,100);
x5=linspace(0,45/2,1000);
x6=linspace(0,45/2,10000);
x7=linspace(0,45/2,100000);
figure(1);
plot(x, flux_slab);
hold on
plot(x3*2, flux_comp_slab_10);
plot(x4*2, flux_comp_slab_100);
plot(x5*2, flux_comp_slab_1000);
plot(x6*2, flux_comp_slab_10000);
hold off
figure(2);
plot(x, flux_cyl);
hold on
plot(x3*2, flux_comp_cyl_10);
plot(x4*2, flux_comp_cyl_100);
plot(x5*2, flux_comp_cyl_1000);
plot(x6*2, flux_comp_cyl_10000);
hold off
figure(2);
plot(x, flux_sph);
hold on
plot(x3*2, flux_comp_sph_10);
plot(x4*2, flux_comp_sph_100);
plot(x5*2, flux_comp_sph_1000);
plot(x6*2, flux_comp_sph_10000);
hold off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS
function A = SOR(x, So)
S = zeros(length(x),1); % BLANK MATRIX
for i = 1:(length(S)-1)
S(i)=So*(x(i)^2);
end
A=S;
return
end
function B = SORSC(x, So)
S = zeros(length(x),1); % BLANK MATRIX
for i = 1:(length(s)-1)
S(i)=So;
end
B=S;
return
end
function C = Diffusion(geometry, Size, N, SigmaA, D, So)
x = linspace(0,Size,N) ; % Set the size to iterate and number of nodes
delta = (x(2)-x(1)); % Distance between nodes
L = zeros(length(x), length(x)); % Start with a blank matrix
% GEOMETRY TYPE
if geometry=='slab' % Depending on geometry make tridiagonal terms
S = SOR(x, So) / D; % Recieve source term from source def
for i = 1:(length(x)-1) % Iterate over tri diagonal
L(i,i) = 2/(delta^2)+SigmaA/D; % Diagonal Terms
L(i,i+1) = -1/(delta^2); % Above diagonal term
L(i,i-1) = -1/(delta^2); % Below diagonal term
end
% Set boundary conditions at ends (Vacuum conditions)
L(0,0) = 0.5*(0.5-D/delta);
L(0,1) = D/(2*delta);
L(length(x)-1,length(x)-1) = 0.5*(0.5-D/delta);
L(length(x)-1, length(x)-2) = D/(2*delta);
elseif geometry=='cylinder'
S = SORSC(x, So) / D ; % Recieve source term from source def
for i = 1:(length(x)-1) % Iterate over tri diagonal
L(i,i) = (x(i+1)/(x(i)*(delta^2))+1/(delta^2)+SigmaA/D); % Diagonal Terms
L(i,i+1) = -x(i+1)/(x(i)*delta^2); % Above diagonal term
L(i,i-1) = -1/(delta^2); % Below diagonal term
end
% Set boundary conditions at ends (Vacuum conditions 2/ symmetry)
L(0,0) = -1/delta;
L(0,1) = 1/delta;
L(length(x)-1,length(x)-1) = D/(2*delta);
L(length(x)-1, length(x)-2) = 0.5*(0.5-D/delta);
elseif geometry=='sphere'
S = SORSC(x, So) / D; % Recieve source term from source def
for i = 1:(len(x)-1) % Iterate over tri diagonal
% Diagonal Terms
L(i,i) = (x(i+1)^2)/((x(i)^2)*(delta^2)) + 1/(delta^2) + SigmaA/D;
L(i,i+1) = -x(i+1)^2 / (x(i)^2 * delta^2); % Above diagonal term
L(i,i-1) = -1/(delta^2); % Below diagonal term
end
% Set boundary conditions at ends (Vacuum conditions w/ symmetry)
L(0,0) = -1/delta;
L(0,1) = 1/delta;
L(length(x)-1,length(x)-1) = D/(2*delta);
L(length(x)-1, length(x)-2) = 0.5*(0.5-D/delta);
else
sprintf("Not a valid geometry option");
end
flux = linsolve(L,S);
C=flux;
return
end
Sanchit Sharmahttps://se.mathworks.com/matlabcentral/profile/authors/13394492-sanchit-sharmatag:se.mathworks.com,2005:Question/4348922018-12-10T10:41:58Z2018-12-10T10:41:58ZIssue with Simulink Model Simulation inside Parfor ?Hi,
I am trying to run multiple simulations with different data set on model 'ModelTest.slx' using parfor.
my code goes like this,
parfor
simout=sim(bdroot,<options>)
..
..
..
end
Parfor executes one simulation (sometime it runs two simulations). It geerates 'slprj' folder after first simulation.
Then it gets aborted with following error message.
"C:\Users\...\parllelTest\slprj\_jitprj\jitEngineAccessInfo.mat.
Not a binary MAT-file. Try LOAD -ASCII to read as text."
Below are the details of matlab version and model settings,
Matalb 2015b,
parpool with local profile.
Simulation Mode : Normal;
Solver :Fixed Step, discrete
Does anyone have any idea about this error. ?Shivaputra Narkehttps://se.mathworks.com/matlabcentral/profile/authors/3327626-shivaputra-narketag:se.mathworks.com,2005:Question/4348772018-12-10T09:48:57Z2018-12-10T10:41:21Zcurve start and finish at [0 0] [0 365] respectively?how can i impose the fitting curve to start from [0 0 ] and finish in [0 365] ? possibly using curve fitting toolbox?Davide Cerrahttps://se.mathworks.com/matlabcentral/profile/authors/13606109-davide-cerratag:se.mathworks.com,2005:Question/4348652018-12-10T08:47:37Z2018-12-10T10:37:31ZClassify image Alexnet MATLAB problem label "nematode"I trained the CNN Alexnet with the categories of images tagged at my disposal.
Why when I go to check an image as a label I get written "nematode"?
label = classify(alex, picture);
image(picture);
title(char(label));Andrea De Lucahttps://se.mathworks.com/matlabcentral/profile/authors/14322591-andrea-de-lucatag:se.mathworks.com,2005:Question/4348812018-12-10T09:54:23Z2018-12-10T10:37:24ZViolin plot has tails that go beyond real dataHi everyone,
I'm using the awesome "distributionPlot.m" from file exchange in order to plot some nice violins.
I've noticed that the violins have tails that don't reflect my data - it is under the lowest value and above the highest.
for example: here's violin of data that is ALL POSITIVE! how come it goes below zero?
appreciate any help,
shir
shir shalomhttps://se.mathworks.com/matlabcentral/profile/authors/8642690-shir-shalomtag:se.mathworks.com,2005:Question/4348852018-12-10T10:18:59Z2018-12-10T10:36:33Zhow to plot smooth contour using the data? I have data as attached. I have electron density values for different latitudes and longitudes. The latitude range (y axis) is 10 - 30 and the longitude range is 70 - 95 (x axis). Each value of latitude and longitude has a corresponding electron density value. I want a contour plot based on this data.SGMukherjeehttps://se.mathworks.com/matlabcentral/profile/authors/10029361-sgmukherjeetag:se.mathworks.com,2005:Question/4348592018-12-10T08:14:54Z2018-12-10T10:33:54Zhow to using autoencoder for dimension reduction in matalb2017b?I want dimension reduction by using three autoencoder.
the size of my data is 400*144; mean 400 sample whith 144 feature.
after run first autoencoder by hiden size 72.
What is the input for the next Autoencoder?zahra khalilparvarhttps://se.mathworks.com/matlabcentral/profile/authors/8582666-zahra-khalilparvartag:se.mathworks.com,2005:Question/4348912018-12-10T10:32:25Z2018-12-10T10:32:25Zisempty slow on GPUWhile profiling some code, I noticed that the GPU imoplementation for isempty is very slow. For example, see the following code:
chk = ones(512,512,5,32); % test variable
K = 10^5; % num of tests
% CPU loop
for m = 1:K
a = isempty(chk);
end
% GPU loop
chk = gpuArray(chk);
for m = 1:K
a = isempty(chk);
end
The profiling results attached, isempty for GPU seems very slow. I'm working on R2018a, GTX1070, CUDA 9. Is it MATLAB, GPU or CUDA related?
ShayEhttps://se.mathworks.com/matlabcentral/profile/authors/951384-shayetag:se.mathworks.com,2005:Question/4348872018-12-10T10:20:23Z2018-12-10T10:22:42ZDummy variable coding in mixed models (LME)Hi all,
I've been a little perplexed by the different ways to code dummy variables when fitting a linear mixed model (using fitlme). Specifically I have a model with two categorical fixed factors. I'd like to do contrasts between the different levels of each factor. Now several online sources tell me I should use 'effects' coding for this, but it isn't clear to me why this is, nor is it clear to me how I should code my contrast matrix when using 'effects' coding rather than reference coding.
For example, if I have a model with an intercept and one categorical fixed factor with three levels, such that:
T = table(y,var1); % y is my response variable, var1 a categorical variable with three levels
formula = 'y ~ var1';
m1 = fitlme(T,formula,'DummyVarCoding', 'reference');
me1 = fitlme(T,formula,'DummyVarCoding', 'effects');
Now I'd like to test whether there's a difference between the first and second categories. In the case of the m1 (reference coding) and me1 (effects coding) I would do this as follows:
[p,F,df1,df2] = coefTest(m1,[0 1 0]); % coefTest(lme,H)
[pe,Fe,df1e,df2e] = coefTest(me1,[1 1 0]);
This gives me very different results even though in both cases multiplying each contrast matrix with the associated fixed effects matrix gives me the same value (according to the documentation for coefTest: "It tests the null hypothesis that H0: Hβ = 0, where β is the fixed-effects vector."
When I try both options with some simulated data, where the first two levels of the fixed factor differ significantly, I only find this significant difference when using reference coding. Any insight would be greatly appreciated.
Here's the code for some simulated data:
d1 = zeros(100,1)+randn(100,1);
d2 = ones(100,1)+randn(100,1);
d3 = ones(100,1).*2+randn(100,1);
d = [d1;d2;d3];
cov1 = [zeros(100,1);ones(100,1);ones(100,1).*2];
T = table(d,categorical(cov1),'VariableNames',{'d','cov1'});
f = 'd~cov1';
m1 = fitlme(T,f);
me1 = fitlme(T,f,'DummyVarCoding','effects');
[p,F,df1,df2] = coefTest(m1,[0 1 0]); % coefTest(lme,H)
[pe,Fe,df1e,df2e] = coefTest(me1,[1 1 0]);
Paulhttps://se.mathworks.com/matlabcentral/profile/authors/3901068-paultag:se.mathworks.com,2005:Question/4348802018-12-10T09:52:16Z2018-12-10T10:19:41Znon linear equation "problem with not enough arguments"Im wriitng this to verify my non-linear equations..but having problem with this problem :
"nlinearval
Error using nlinearval (line 14)
Not enough input arguments.
function F=nlinearval(z)
Can anyone help me how i can solve this problem? Below are my coding:
function F=nlinearval(z)
%define constants
Isc=8.53;
Voc=44.9;
Vmp=36.1;
Imp=8.04;
Ns=72;
dv_di_oc=-0.48766;
di_dv_sc=-2.48797e-3;
q=1.6e-19;
k=1.381e-23;
T=298;
x = z(1);
y = z(2);
w= z(3);
Rsh = -1/(di_dv_sc);
b=exp(q*((Vmp+Imp*w)/(Ns*y*k*T)));
c=exp((Voc*q)/(Ns*y*k*T));
F(1)=[x-((Isc-(Voc/Rsh))/(c-1))-0];
F(2)=Imp-Isc+x*b+((Vm+Imp*w)/(Rsh));
F(3)=w+dv_di_oc+(1/((x*q)/((Ns*y*k*T)*c)));
end
nourihttps://se.mathworks.com/matlabcentral/profile/authors/14337317-nouritag:se.mathworks.com,2005:Question/4342402018-12-06T14:40:51Z2018-12-10T10:16:11ZQuestion on running fitldaI want to run fitlda, with the following specification:
* use Griffiths and Steyvers (2004) Gibbs Sampling algorithm for LDA as they ran it,
* 12 topics (i.e. K=12),
* a symmetric alpha of 50/K (no updating),
* a symmetric beta of .01 (no updating), and
* exactly 2000 iterations (without early termination).
Would that be:
numTopics = 12;
mdl = fitlda(bag,numTopics,'Verbose',1,'InitialTopicConcentration',50,'FitTopicConcentration',false,'WordConcentration',.01,'LogLikelihoodTolerance',0,'IterationLimit',2000);Stephen Bruestlehttps://se.mathworks.com/matlabcentral/profile/authors/11980706-stephen-bruestletag:se.mathworks.com,2005:Question/4348752018-12-10T09:44:39Z2018-12-10T10:14:27Zhow to implement autoregressive model AR_2D in image processing matlab codehow to implement autoregressive model AR_2D in image processing matlab codeayoub maahttps://se.mathworks.com/matlabcentral/profile/authors/14337165-ayoub-maatag:se.mathworks.com,2005:Question/4348692018-12-10T09:07:54Z2018-12-10T10:10:04ZError using sortrows, too many input argumentsCan somebody help me to understand the error? Why do i get it?
Error in zeroup (line 63)
srti(j,3)=sortrows(srt,[1,2],'descend'); %sorted in descending order
for j=1:length(listing(:,3));
srt(j,1)=listing(j,3); %wave height
srt(j,2)=listing(j,4); %wave period
end
srti(j,3)=sortrows(srt,[1,2],'descend'); %sorted in descending orderdjhttps://se.mathworks.com/matlabcentral/profile/authors/12931090-djtag:se.mathworks.com,2005:Question/4216152018-10-01T14:15:28Z2018-12-10T10:05:46ZSimulink library link not foundHi,
I recently got a file from file exchange and ran the simulink model on Matlab 2018b and it worked. Now I have successfully exported it to 2016b and it gives me an error saying that for one of the components inside- it could not link to it. It gives a 'blockerror'
Is this an issue with the path? If so, how can I find where it is?
Here's a link to the problem: https://youtu.be/Tl8eJgye7R8
Hope someone can help me! Thanks!Akash Menonhttps://se.mathworks.com/matlabcentral/profile/authors/10940699-akash-menontag:se.mathworks.com,2005:Question/4348492018-12-10T07:19:10Z2018-12-10T10:04:36ZI am getting an error "Data 'hhatdot' is inferred as a variable size matrix, while its specified type is something else." My equation is "hhatdot =p*(u(t-hhat)-u(t-h))*udot". So please can anyone help me with this.function [hhatdot,bufferutnew] = fcn(ut,h,hhat,hmax,taus,udot,bufferut)
%#codegen
p = 0.05;
n=hmax/taus+1;
%%% updating input buffer
bufferutnew=zeros(1,2001);
bufferutnew(1,1:n-1)=bufferut(2:n);
bufferutnew(1,n)=ut;
indicehhat=floor(hhat/taus+1);
indicehhat=n-indicehhat;
indiceh=floor(h/taus+1);
indiceh=n-indiceh;
hhatdot = p*(bufferutnew(indicehhat:n)-bufferutnew(indiceh:n))*udot;
hmax=2, taus=0.001, udot=d/dt(u(t-hhat)), h =0.5+0.25sin(2t) , ut is a control signalChiliveri Vinodhttps://se.mathworks.com/matlabcentral/profile/authors/13576941-chiliveri-vinodtag:se.mathworks.com,2005:Question/4348832018-12-10T10:03:38Z2018-12-10T10:03:38Zwhat are the features will be helpful for texture classification which are invariant to rotation, scale, illumination and viewpoint changes? what are the features will be helpful for texture classification which are invariant to rotation, scale, illumination and viewpoint changes? Shan Shahttps://se.mathworks.com/matlabcentral/profile/authors/13234420-shan-shatag:se.mathworks.com,2005:Question/4348822018-12-10T09:58:26Z2018-12-10T09:58:26ZUsing Matlab for solving 3d PDE and creating geometryHi I need to solve a 3D diffusion equation on a geometry of a sphere inside a cube.
However - I saw that in PDE toolbox I can only create a sphere inside a sphere or a cube inside a cube. Therefore I would like to ask:
How can I create this kind of geometry?
How would I then manage the boundary conditions?
What is the right syntax for coefficient speficiation in 3D (speficially here the sphere is a source and the cube has no source)?
Thanks.amit amithttps://se.mathworks.com/matlabcentral/profile/authors/7957208-amit-amittag:se.mathworks.com,2005:Question/4339842018-12-05T13:03:01Z2018-12-10T09:57:42ZAutosar Validation Branching inputI am trying to prepare a Autosar Component. It seems like there is a need to invoke Rte_Read for signal in both Initialization function (represented in simulink as initialization function) and in Periodic function (represented as function call subsystem).
It seems like simulink does not allow read input in both Initialization runnable and in Periodic runnable.
Is this violation of autosar rule? If so then which one?
My Setup:
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.3.0.925396 (R2017b) Update 8
MATLAB License Number: xxxxx
Operating System: Microsoft Windows 7 Enterprise Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.8.0_144-b01 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.3 (R2017b)
Simulink Version 9.0 (R2017b)
Embedded Coder Version 6.13 (R2017b)
MATLAB Coder Version 3.4 (R2017b)
MATLAB Report Generator Version 5.3 (R2017b)
Simulink Check Version 4.0 (R2017b)
Simulink Coder Version 8.13 (R2017b)
Simulink Coverage Version 4.0 (R2017b)
Simulink Report Generator Version 5.3 (R2017b)
Simulink Requirements Version 1.0 (R2017b)
Stateflow Version 9.0 (R2017b)Adrian Legowskihttps://se.mathworks.com/matlabcentral/profile/authors/10268423-adrian-legowskitag:se.mathworks.com,2005:Question/4348792018-12-10T09:51:32Z2018-12-10T09:56:27ZHow to select the values in 3 column matrices at a time?Hi,
I have three matrices
a =[0.1; 0.3; 0.4; 0.6; 0.5];
b =[0.2; 0.1; 0.6; 0.2; 0.8];
b =[0.5; 0.2; 0.3; 0.6; 0.7];
I want to select [a11,b11,c11] , [a21,b21.c21] from all the three matrices and so an at a time. Please let me know if anyone of you know this.Harithahttps://se.mathworks.com/matlabcentral/profile/authors/7060086-harithatag:se.mathworks.com,2005:Question/4348722018-12-10T09:33:55Z2018-12-10T09:53:33Zi need matlab code i need matlab code for:the least squares estimator of the parameter of the autoregressive models :application to texture
ayoub maahttps://se.mathworks.com/matlabcentral/profile/authors/14337165-ayoub-maatag:se.mathworks.com,2005:Question/4348782018-12-10T09:49:05Z2018-12-10T09:49:05ZHow to calculate Average Intensity (Z) Projection of a time laps image sequence?Hej!
I wonder if here exits any function to convenely calculate Average Intensity Projection (e.g. ImageJ Z Project function with average intensity as projection type) of a time laps image sequence, similar to Matlab funciton for maximal projection MIP=max(image,[],dim).
Thank you for any info!Marko Usajhttps://se.mathworks.com/matlabcentral/profile/authors/9378932-marko-usajtag:se.mathworks.com,2005:Question/4348732018-12-10T09:39:50Z2018-12-10T09:48:56ZTiming issue on every first stimulus in a loop with PsychtoolboxHi,
I am currently facing timing issue with Psychtoolbox. Indeed, in my script there is a loop displaying the same stimulus several consecutive times. Each trial this loop is called and each trial the first stimuli is displayed for a shorter duration or longer duration (about one frame) than the expected duration. Then the timing is perfect the rest of stimuli. I guess it is a synchronization issue because it is exactly the same loop, which display the stimuli every time. Has anyone ever had this problem?
Best,
SimonSimon Thibaulthttps://se.mathworks.com/matlabcentral/profile/authors/14261045-simon-thibaulttag:se.mathworks.com,2005:Question/4348762018-12-10T09:48:32Z2018-12-10T09:48:32Zwhy I recive a notification about deactivationI receive a notification about a inmediate deactivate of license
Igor Carneroshttps://se.mathworks.com/matlabcentral/profile/authors/10267083-igor-carnerostag:se.mathworks.com,2005:Question/4325312018-11-28T13:20:20Z2018-12-10T09:44:57ZSimulink UDP data splitHi,
i´m trying to send some data from Unity3D to Simulink and it works good. I send multiple data with a packet. The only thing i don´t know is how can i "split" the data so i can do some other calculations with it for example.
Below is a picture with the UDP receiver and the display which shows some values.
What do i need for the seperation of this data?
Thanks in advance.Lucas Weberhttps://se.mathworks.com/matlabcentral/profile/authors/12831800-lucas-webertag:se.mathworks.com,2005:Question/4348742018-12-10T09:40:36Z2018-12-10T09:44:36ZHow Do I Find variance and standard deviation of height?Sajeel Hassanhttps://se.mathworks.com/matlabcentral/profile/authors/14337243-sajeel-hassantag:se.mathworks.com,2005:Question/4214462018-09-30T06:09:34Z2018-12-10T09:41:02ZR2018b runs very slow on macOS 10.14Hi everyone,
I am using macOS 10.14 (Mojave) and just upgraded the MATLAB to R2018b yesterday and found a very strange problem. The editor runs EXTREMELY slow on my system and often freezes. When I click on somewhere on the editor or scrolling the view it usually takes 1-2 secs to response.
However, the strange point is, the problem only occurs when the MATLAB window is displayed on my external monitor. When I move the window to the macbook's internal monitor, everything is normal. And, the problem does not show on some specific files. I don't know if there are any features of those file, but if I make copies of those files, the problem may shows on the copies again.
I am not sure if it is a problem of MATLAB or my OS. How is the R2018b running on your systems? Chang Liuhttps://se.mathworks.com/matlabcentral/profile/authors/13139737-chang-liutag:se.mathworks.com,2005:Question/4345942018-12-08T14:52:36Z2018-12-10T09:40:49Z how can I output different array size than input by GPU arrayfun?I am doing particle simulations using matlab. So I have very large data sets which is the position of each particles, for example, [rx ry], where rx and ry are large column vecotrs containing the x and y coordinates of all the particles. So suppose there are 1e6 particles then the dimension of rx and ry both are 1e6 by 1. In the simulation I have to find the neighbor particles within a certain range R for each particles. Using CPU I wrote something like this using bruto force search
function [idx_Neighbor,d_Neighbor]=find_neighbors_Naive_func(rx,ry,N_par,r_neighbor,h_smo)
idx_Neighbor=cell(N_par,1);
d_Neighbor=cell(N_par,1);
for j=1:N_par
dj=(rx-rx(j)).^2+(ry-ry(j)).^2;
[idx_Neighbor_j]=find(dj<=r_neighbor^2);
d_Neighbor_j=((dj(idx_Neighbor_j)).^0.5)./h_smo;
idx_Neighbor{j}=idx_Neighbor_j;
d_Neighbor{j}=d_Neighbor_j;
end
This function output a N_par by 1 cell array idx_Neighbor whose individual elements are the indices of the neigbor particels for every particles in the domain. This works fine using CPU, but it is very slow so I want to write a GPU version of the code by using arrayfun. But as far as I know, the GPU arrayfun requires the output array the same size as the input array, and it does not support cell array. Is there any way to get around this or there is no simple way other than write a cuda c code? Thanks!
p.s. I realize the kd tree rangesearch function, but this function does not support GPU. And I want to avoid transfering data between GPU and CPU since I implement other part of the simulation code also on GPU.
some following up, through some experimental on Matlab GPU coder, I managed to translate the following matlab code to cuda knernal (mex):
function [Numpar_neighbor]=find_neighbors_Naive_func_test(rx,ry,r_neighbor)
Numpar_neighbor=zeros(size(rx),'single'); %%% number of neighbor particles for each particle j
coder.gpu.kernelfun;
for j=1:size(rx,1)
dj=(rx-rx(j)).^2+(ry-ry(j)).^2;
[idx_Neighbor_j]=find(dj<=r_neighbor^2);
Numpar_neighbor(j)=length(idx_Neighbor_j);
end
end
The cuda mex file runs fine, but it returns an ordinary array instead of gpuArray although the code runs on the GPU. So if I use the returned array Numpar_neighbor in the following part of the code I need to transfer it to the GPU, adding unnecessary overhead. Why is this and any way to force the mex file return gpuArray?
Thanks again!
Hao Zhanghttps://se.mathworks.com/matlabcentral/profile/authors/2574469-hao-zhangtag:se.mathworks.com,2005:Question/4348712018-12-10T09:27:05Z2018-12-10T09:38:41ZMATLAB memory allocation problemHi,
I am running my matlab code (which is only a line such as;
[fis_norm,trainError,stepSize] = anfis(sq_train_long);
however it takes more than 10 min. My data sq_train_long is an array (50.000x7 double)
Here my system info;
MATLAB 2018a
Windows Server 2016
processor:Intel Xeon CPU E3 1275 3,5Ghz
installed memory:24GB
Response of "memory" command in MATLAB is below;
>> memory
Maximum possible array: 39849 MB (4.179e+10 bytes) *
Memory available for all arrays: 39849 MB (4.179e+10 bytes) *
Memory used by MATLAB: 1865 MB (1.956e+09 bytes)
Physical Memory (RAM): 24475 MB (2.566e+10 bytes)
* Limited by System Memory (physical + swap file) available.
Below, you can se what I have tried so far;
Give higher priority to Matlab.exe task on task manager
Increase the page file size of your applications in general. currently :20,000 MB
Performance Settings, it is set for "Programs" and not for "Background services". "Programs" is the default.
Visual effects tab of "performance options" is set to "Adjust for best performance"
Matlab Preferences- Workspace- unchecked "Limit the maximum array size to a pecentage of RAM"
Matlab Preferences- Workspace - jAVA Heap Size updated to max 12,236MB
Parpool - Ia hav user paralled processing but didn't shortened the elapsed time at all.
Please help me on this. I've read and applied all the advice on this matter. some of the answers were asking for more detailed questions. I hope this one would give more information on the problem.aycan ayyilmazhttps://se.mathworks.com/matlabcentral/profile/authors/11486770-aycan-ayyilmaztag:se.mathworks.com,2005:Question/4348702018-12-10T09:15:19Z2018-12-10T09:37:28ZCreate a for loop and save the values in different columnsI have problems creating a for loop in my matlab script. Have tried for a while but don't really get the solution I want.
I have three different locations and the coordinates for these can be found in coordlat and coordlon. I want to run my program for all the locations after eachother and then finally save the answers in a matrix, a new column for each location.
Here follows the code I have right now.
format long
ncfil00 = 'met_forecast_1_0km_nordic_20180601T00Z.nc';
ncfil01 = 'met_forecast_1_0km_nordic_20180601T01Z.nc';
lat=ncread(ncfil00,'latitude');
lon=ncread(ncfil00,'longitude');
temp00 = ncread(ncfil00,'air_temperature_2m');
temp01 = ncread(ncfil01,'air_temperature_2m');
coordlat=[63.2831 65.0942 68.4217];
coordlon=[12.1246 14.5085 18.1719];
for i=1:length(coordlat)
for j=1:length(coordlon)
distance = ( coordlat(i) - lat(:) ).^2 + ( coordlon(j) - lon(:) ).^2;
[~, index] = min(distance);
Temperaturejune2018(1,i) = temp00(index)-273.15;
Temperaturejune2018(2,i) = temp01(index)-273.15;
end
end
Sofie Peterssonhttps://se.mathworks.com/matlabcentral/profile/authors/5773779-sofie-peterssontag:se.mathworks.com,2005:Question/4113972018-07-21T02:43:07Z2018-12-10T09:34:36ZHow Replicate module can generate variable number of replications using a signal in SimEvents?If the signal is *number of items departed from a server* or *number of entities in a queue* and I want *replicate* module to generate replications using that signal value.summyia qamarhttps://se.mathworks.com/matlabcentral/profile/authors/8556300-summyia-qamartag:se.mathworks.com,2005:Question/4012442018-05-17T15:03:54Z2018-12-10T09:33:33ZPID tuner not working for Simulink BLDC Motor ControllerHi,
I am using discrete PI controller for simulink BLDC Motor(Simpower systems) and controller, I have speed feedback from motor in rpm and trying to get PI block's output for duty cycle input of PWM generator. Whenever I press Tune button its says failed to linearized the model and sometimes it does not get launched. If I manually put the PI parameters my motor and controller is working fine.
CBhttps://se.mathworks.com/matlabcentral/profile/authors/3829023-cbtag:se.mathworks.com,2005:Question/3843722018-02-23T09:33:42Z2018-12-10T09:29:28ZFatal Alert : Protocol_version ?! i was installing the hardware package ( using the internet )
but my internet went off in the middle of it since then i can't install it ... i keep getting this message (Fatal Alert : Protocol_version) and then it says that matlab is in the middle of a downloading operation ... Thanks for your helpEbram Habibhttps://se.mathworks.com/matlabcentral/profile/authors/9202424-ebram-habib