https://ww2.mathworks.cn/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-04-21T08:33:27Ztag:ww2.mathworks.cn,2005:Question/4575482019-04-20T16:09:33Z2019-04-21T08:33:27ZQueue length simulation problemI have created a code to simulate the length of a queue at a drive-in, which should be somewhat correctly made (at least as my assignment explains the problem). The problem I have, is that I need to minimize the waiting time in the queue, while also minimizing the amount of service stations used during the simulation. In other words, the amount of service stations needs to change as a function of the queue length. I really don't know how I should approach this optimization problem. I've attached the code I've written until now below.
function [] = queue_simulation2()
% This function simulates the length of a queue
% that is Poisson-distributed
%% Initializations
lambda=40/(60*60); % Arriving cars, cars/second
mu=4*60; % Average service time, seconds/customer
s=2; % Amount of service stations
time=1; % Time to observe, seconds
t_span=8*60*60; % One working day, seconds
%% Function loops and plotting
% Create a figure window
figure('Name','Queue simulation')
hold on
% For-loop to consider 10 simulations
for k = 1:1:10
% Reset the parameters
t=1;
arrived=zeros(1+t_span,1);
left=zeros(1+t_span,1);
queue=zeros(1+t_span,1);
% While-loop for one simulation
while t <= t_span
% People arrive in the queue
arrived(t+1)=poisson_time(lambda,time);
% Calculating mu_j depending on the queue length
Ej=queue(t);
j=Ej+arrived(t+1);
if j <= s
mu_j=mu/j; % If Ej=0, then mu_j=inf
else
mu_j=mu/s;
end
% Calculating how many people receive their orders in
% the given time.
% Note that the amount of people getting their service depends
% on the queue length at the end of the loop before + the
% people that arrive during the time period.
if j == 0
% Since, if there are no people in the queue, then there
% are no people to serve
left(t+1)=0;
else
left(t+1)=poisson_time(1/mu_j,time);
end
% Queue length at time t+1
queue(t+1)=Ej+arrived(t+1)-left(t+1);
% Correct the queue length so that it cannot be negative
if queue(t+1) <= 0
queue(t+1)=0;
else
queue(t+1)=queue(t+1);
end
% Update the time
t=t+time;
end
% Plot the simulation
stairs(0:1:t_span,queue)
end
% Add title and labels to the plot
title('Queue length simulation')
xlabel('Time, [s]'); ylabel('Queue length')
grid on; grid minor; axis tight
end
function n = poisson_time(lambda,time)
% This function counts the Poisson events in a fixed time
%% Initializations
t=0.0; % Time in the beginning
n=0; % Events in the beginning
%% Function
while t < time
dt=-log(1-rand(1,1))/lambda;
t=t+dt;
n=n+1;
end
n=n-1;
return;
endHenri Södergårdhttps://ww2.mathworks.cn/matlabcentral/profile/authors/13534691-henri-sodergardtag:ww2.mathworks.cn,2005:Question/4576332019-04-21T08:02:18Z2019-04-21T08:28:36ZExtract Previous Cell ValueI have a cell with char values next to each other as seen below
Cell 1 | Cell 2
____________
'Hello' | 'World'
I would like to define a function that extracts the previous cell value along with the current cell value. I wrote the following code to do so:
t = x{1,i} - Current Cell Value
f = x{2,i-1} - Previous Cell Value, starting with Cell 2 with the previous value of Cell 1
But I keep getting the error
Index in position 2 is invalid. Array indices must be positive integers or logical values.
I believe the error is with regards to the defined function f. It has to do with the i-1 value. At this point, I am stuck. Any thoughts on how to fix that so it works?
Jeffrey Panghttps://ww2.mathworks.cn/matlabcentral/profile/authors/14936261-jeffrey-pangtag:ww2.mathworks.cn,2005:Question/4576342019-04-21T08:26:29Z2019-04-21T08:26:29ZHow to add KeyListener for java GUI to call matlab command?Here I build a JFrame object using java. I want to make the GUI response to the mouse click and key press:
To make response to mouse click:
import javax.swing.*;
JF = JFrame;
JF.setSize(300,300);
set(JF,'MouseClickedCallback','disp(''pressed the button'')')
JF.setVisible(true)
Then if I click the GUI, the message appeared in command window.
However, how to add the listener for key event so that when I stroke a key (e.g., Enter ) in the GUI, some matlab function could be run?
Thanks.raymhttps://ww2.mathworks.cn/matlabcentral/profile/authors/8743272-raymtag:ww2.mathworks.cn,2005:Question/2983242016-08-03T18:51:40Z2019-04-21T08:25:33ZHelp with ntstool future value predictions?Hi all,
I am currently using the ntstool app to attempt to predict future data points. I have 1405 output points which I can successfully receive a plotted response for using the app once trained. Just unclear as to how to output the following 10 (predicted) data points. Any help would be greatly appreciated!
ThanksBenhttps://ww2.mathworks.cn/matlabcentral/profile/authors/5358162-bentag:ww2.mathworks.cn,2005:Question/579612013-01-04T13:04:14Z2019-04-21T08:16:23ZSimulating a Markov chainHello,
Would anybody be able to help me simulate a discrete time markov chain in Matlab?
I have a transition probability matrix with 100 states (100x100) and I'd like to simulate 1000 steps with the initial state as 1.
I'd appreciate any help as I've been trying to do this myself all week with no success and have not been able to source suitable code online.
Kind Regards
JohnJohnhttps://ww2.mathworks.cn/matlabcentral/profile/authors/2960907-johntag:ww2.mathworks.cn,2005:Question/4575522019-04-20T17:01:08Z2019-04-21T08:14:52Zhow to remove the repetitive elements from a structure>> a = struct('position', {[200 300 1],[300 200 1],[250 250 0.5],[230 280 0.6],[300 200 1],[270 150 1]}, 'cost', {[50;90],[60;80],[65;89],[60;70],[60;80],[55;85]})
I have a structure with two fields, I need to two remove the duplicates?
I tried useing the code below but it did not work.
[~, idx] = unique([a.position].', 'rows', 'stable'); %stable optional if you don't care about the order.
a = a(idx)
I hope I can find a sulotion for this problem.khalil alkebsihttps://ww2.mathworks.cn/matlabcentral/profile/authors/6516458-khalil-alkebsitag:ww2.mathworks.cn,2005:Question/4575912019-04-20T22:06:54Z2019-04-21T08:05:31ZHow can i coding binary array using RNA codingHello every one
pls if any one know .
How can i coding binary array using RNA codingRNA coding?
ammar mohammedhttps://ww2.mathworks.cn/matlabcentral/profile/authors/14858931-ammar-mohammedtag:ww2.mathworks.cn,2005:Question/4576322019-04-21T07:58:38Z2019-04-21T07:58:38Z3-D Brain Tumor Segmentation Using Deep LearningMy question is reated to the example in the object. I tried to exactly replicate the example with any modification to the orignal script.
I downloaded the data, preprocessed it, created the graph and started the training process. The first step of the training process are displayed in the folowing fig.
I was wondering if things are going right. I would have expected a more slow accuracy increase. Is this correct? Are the iteration still too few?
I think the behavior is too different respect the images in the matlab "3-D Brain Tumor Segmentation Using Deep Learning" example.
ThanksPierpaolo Crocehttps://ww2.mathworks.cn/matlabcentral/profile/authors/13170293-pierpaolo-crocetag:ww2.mathworks.cn,2005:Question/4575722019-04-20T19:58:05Z2019-04-21T07:53:04ZHow to remove weekend from a TimeTable PlotHi!
I want to plot CandleStick pattern based on a TimeTable I have. In this case, I want to remove the gap on my chart caused by weekends. The following code simply remove the weekends from the timetable
T = T(~isweekend(T.DateTime),:);
However, I still have the gap when I plot the Candls since the xaxis shows the weekends gap! How can I remove this gap?
Siahttps://ww2.mathworks.cn/matlabcentral/profile/authors/3787650-siatag:ww2.mathworks.cn,2005:Question/4569502019-04-17T14:26:41Z2019-04-21T07:49:05ZSymbolic system of odesHey!
So, I've been working on this physics problem where I face a system of four coupled differential equations which I can't seem to find the answer to
TT0 = 0; %initial release angle Theta
l0 = 1; %initial left line length (in meters)
m = 1;
M = 3;
R = 0.3;
g = 9.8;
mu = 0.5;
syms t Ti(t) Tx(t) TT(t) l(t);
ode1 = (M*g) - Tx == -M*(diff(l,t,2)+R*diff(TT,t,2));
ode2 = m*g*sin(TT) - Ti == m*(R*diff(TT,t,2)-l*(diff(TT,t))^2 + diff(l,t,2));
ode3 = m*g*cos(TT) == m*(R*(diff(TT,t))^2 + 2*diff(l,t)*diff(TT,t) + l*diff(TT,t,2));
ode4 = Tx == Ti*exp(mu*(pi/2 + TT));
odes = [ode1; ode2; ode3; ode4];
conds = [TT(0) == TT0; l(0) == l0;Ti(0) == 0; Tx(0) == M*g];
D = dsolve(odes,conds);
Here's the code I've written. There are four equations and four indeterminates but I get this error when I run the code:
"
Error using mupadengine/feval (line 163)
Cannot reduce to the square system because the number of equations differs from the number of indeterminates.
Error in dsolve>mupadDsolve (line 332)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 193)
sol = mupadDsolve(args, options);
Error in Untitled (line 16)
D = dsolve(odes,conds)
"
I've searched the internet and altered my code several times but it didn't seem to work. I'll highly appreciate any kind of help. Thanks. Web Junkiehttps://ww2.mathworks.cn/matlabcentral/profile/authors/15318641-web-junkietag:ww2.mathworks.cn,2005:Question/4575922019-04-20T22:15:40Z2019-04-21T07:42:48ZHow canI i generate chaotic map 3 Dimension and convert it into hexadecimal ?Hello every one
I want code of How can I generate chaotic map 3 Dimension and convert it into hexadecimal ?
pls If anyone can help me
Aliammar mohammedhttps://ww2.mathworks.cn/matlabcentral/profile/authors/14858931-ammar-mohammedtag:ww2.mathworks.cn,2005:Question/4576312019-04-21T07:38:35Z2019-04-21T07:38:35ZSerial interrupt to automatically update edit boxes, I want to design a GUI that automatically updates an edit box every time it receives new data over the serial port. I cannot figure out the proper syntax GUIDE/Matlab uses to pass arguments to functions or what arguments are necessary.
I have looked https://www.mathworks.com/matlabcentral/answers/280169-gui-serial-communication-interrupt-function but the syntax makes no sense to me and I can't find documentation that explains it past the basic user level.
% --- Executes on button press in Connect.
function Connect_Callback(hObject, eventdata, handles)
% hObject handle to Connect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
instrreset
handles.s = serial('COM9');
handles.s.ReadAsyncMode = 'continuous';
handles.BytesAvailableFcnMode = 'byte';
handles.s.BytesAvailableFcnCount = 1;
handles.s.BytesAvailableFcn = @Serial_int_Fcn;
set(handles.s,'BaudRate',115200);
fopen(handles.s);
function Serial_int_Fcn (hObject, eventdata, handles)
%
i = 1;
Serial_in = strsplit(fscanf(hObject),';') ? Why does this work and not handles.s as argument?
ADC_raw1(i) = str2double(Serial_in(1,1)) **Error - Not enough input arguments.
Filter_out(i) = str2double(Serial_in(1,2))
WSB_voltage(i) = str2double(Serial_in(1,3))
AmbientT(i) = str2double(Serial_in(1,4))
set(handles.Loadcell1,'String',ADC_raw1(i)) **Error - Not enough input arguments.
set(handles.Loadcell2,'String',ADC_raw1(i))
set(handles.Loadcell3,'String',ADC_raw1(i))
set(handles.TotalWeight,'String',Filter_out(i)+Filter_out(i)+Filter_out(i))
set(handles.AmbientT,'String',AmbientT(i))
set(handles.FluidT,'String',WSB_voltage(i))
i = i + 1;
Corne van Zylhttps://ww2.mathworks.cn/matlabcentral/profile/authors/11043221-corne-van-zyltag:ww2.mathworks.cn,2005:Question/4576302019-04-21T07:32:19Z2019-04-21T07:33:00ZBlock reduction using MATLABHello
I'm using the command "connect" along with the "append" command to reduce block diagrams. But i just want to know how to stop MATLAB from dividing by the leading denominator coefficient? How to skip that step?
ThanksRMThttps://ww2.mathworks.cn/matlabcentral/profile/authors/13865416-rmttag:ww2.mathworks.cn,2005:Question/4574882019-04-20T05:48:56Z2019-04-21T07:16:27ZParameter estimation using shooting methodHi All,
I want to do the following,
I have a set of 20 first order differential equations and I want to estimate some of the parameters . I've the following initial and boundary conditions.
The initial conditions of 20 variables (at t=0)
Boundary values of 20 variables (at time , t = 2000s)
Using shooting method , I want to estimate the values of 10 parameters using least square minimization ,using fmincon. The objective function will
minimize the difference between the target(Boundary values of 20 variables (at time , t = 2000s)) and the values obatined at the end of shoot using ode15s.
I'm not sure how to implement this. Could someone help?
I have a function which solves the 10 differential equation using ode15s, how do I proceed after this step?Deepa Maheshvarehttps://ww2.mathworks.cn/matlabcentral/profile/authors/8575091-deepa-maheshvaretag:ww2.mathworks.cn,2005:Question/4576262019-04-21T06:19:16Z2019-04-21T07:16:16ZI am first year mechanical engineering student. I am interested in software, is MATLAB useful for me I am first year mechanical engineering student. I am interested in software, is MATLAB useful for me? SANTHOSH shttps://ww2.mathworks.cn/matlabcentral/profile/authors/14775438-santhosh-stag:ww2.mathworks.cn,2005:Question/4549112019-04-07T13:23:01Z2019-04-21T07:14:35ZParameter estimation - How to input experiment data?Hi All,
I want to perform parameter estimation of the following ode model.
5 parameters have to be estimated after performing a least square error minimization of the cost function. The input that I have is steady state multi -experiment values of y1 to y10.
I found an example here that illustrated how to input time series experiment data. Could someone explain how to input staedy state multi-experiment data?
Deepa Maheshvarehttps://ww2.mathworks.cn/matlabcentral/profile/authors/8575091-deepa-maheshvaretag:ww2.mathworks.cn,2005:Question/4576292019-04-21T07:12:42Z2019-04-21T07:12:42Z Write a MTALB code that can find the area of a surface in any coordinate system. The user must select which coordinate system is required and specify the limits. Then, the code should calculate the required output.How can i solve this Question?Abdulrahman Almaqrashihttps://ww2.mathworks.cn/matlabcentral/profile/authors/15339350-abdulrahman-almaqrashitag:ww2.mathworks.cn,2005:Question/4553652019-04-09T19:04:56Z2019-04-21T07:11:19ZTimerFcn loop for arduino hi
I want to read some data from arduino with timer object and I want to read these data each 0.01 second as input datas and calculate datas and give output datas
the code that I want to use is:
t=timer('Period',0.01,'ExecutionMode','fixedRate');
t.TimerFcn=@(function1);
start(t)
function [T]=function1(x)
x=readCount(encoder);
k=5*x;
T=k+3;
end
is it correct?john whitehttps://ww2.mathworks.cn/matlabcentral/profile/authors/10514494-john-whitetag:ww2.mathworks.cn,2005:Question/4576272019-04-21T06:28:38Z2019-04-21T07:01:01ZPlotting 2d data Haven't touched Matlab in over two years, trying to create a graph plotting my answers. I'm getting an error "Index exceeds the number of array elements (1)."
%loop for thickness
for i = 3 : 1 : 10
%loop for number of fins
for j = 8 : 1 : 12
m(i) = sqrt((2*ho)/(k*t(i)/1000)); % m^-1
At(i,j) = fins(j)*Af+((2*pi*r2)-(fins(j)*t(i)/1000)); %m
n_o(i,j) = 1-(((fins(j)*Af)/At(i,j))*(1-(tanh(m(i)*(r3-r2))/(m(i)*(r3-r2)))));
R_to(i,j) = 1/(n_o(i,j)*ho*At(i,j)); % m*K/W
R_t(i,j) = R_conv + R_cond +R_to(i,j); % m*K/W
q(i,j) = (delta_T)/(R_t(i,j)); % W/m
plot(j,q(i,j),'b-',linewidth',2);
hold on
end
end
plot(fins,q,'r.','markersize',20,'linewidth',2);
set(gca,'fontsize',16,'fontweight','bold')
title('Heat Rate increase as fins and thickness increases');
xlabel('Number of Fins','fontsize',16);
ylabel('Heat Rate (W)','fontsize',16);Daryl Hurwitzhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15338772-daryl-hurwitztag:ww2.mathworks.cn,2005:Question/4576282019-04-21T06:54:35Z2019-04-21T06:54:35ZHow do I compare each binary image bit with each msb positions of an audio sample? Lsb encoding method to hide image in wav file.
I need to compare each bit from a binary image with msb's of audio samples.
If found equal I need to replace 3 lsbs of audio sample with binary equivalent of image bitMERIN CHERIANhttps://ww2.mathworks.cn/matlabcentral/profile/authors/10538522-merin-cheriantag:ww2.mathworks.cn,2005:Question/4576252019-04-21T06:13:08Z2019-04-21T06:52:10Zget RGB data from imageI was working on some code for a small assignment and can't seem to figure out why I can't get my bright vector to come out as [251,251,251] using this attached picture. The RGB values for the white section of the image are all 251.
picture = imread('ColorWheel.png')
[a,b,c] = size(picture);
bright = [0,0,0];
for y = 1:b
for x = 1:a
if picture(x,y,1) >= bright(1) && picture(x,y,2) >= bright(2) && picture(x,y,3) >= bright(3)
bright(1) = picture(x,y,1);
bright(2) = picture(x,y,2);
bright(3) = picture(x,y,3);
end
endSorin Peñahttps://ww2.mathworks.cn/matlabcentral/profile/authors/13317590-sorin-penatag:ww2.mathworks.cn,2005:Question/4576102019-04-21T02:47:54Z2019-04-21T06:27:12ZHow can I recognize shapes of simple geometrical objects using optimization toolsHere is the sample code to recognize a circle, looks like I need to create different functions to define a square, rectangle and a triangle first if I want recognize them. Can someone help me with it? Thanks.
clc
clear
M0=zeros(1024,1024); % Background of zeros
x=1:1024;
y=1:1024;
[X,Y]=meshgrid(x,y); % grid of pixel positions
for in=11
A=double(imread([num2str(in,'%4.3d'),'.jpg']))/255; % Load image and scale to 1
M=@(p) M0+double((X-p(1)).^2+(Y-p(2)).^2<(p(3))^2); % define your teplate
% You may need a separate funtion file
fun=@(p) sum(sum(abs(A-M(p)).^2)); % The objective funtion to minimize
% find the avergae center position and ditribution of the nonzero
% pixels in image
pos=find(A>0);
x0=mean(X(pos));
y0=mean(Y(pos));
d=(range(X(pos))+range(Y(pos)))/2;
trl=[x0 y0 d/2]; % The trial solution % number of parameters depend on the shape
lb=[0 0 0];% lower bounds of the prameters
ub=[1024 1024 512];% upper bounds of the prameters
% Optimization process
%You dont have to change the below lines
opts=optimoptions('ga');
opts.InitialPopulationMatrix=trl;
opts.Display='iter';
[sol,fval]=ga(fun,length(trl),[],[],[],[],lb,ub,[],opts);
if fval<100
'circle'
else
'unknown'
end
figure(1)
clf
surf(M(sol),'linestyle','none')
view(2)
daspect([1 1 1])
figure(2)
clf
surf(A,'linestyle','none')
view(2)
daspect([1 1 1])
end
TOKENhttps://ww2.mathworks.cn/matlabcentral/profile/authors/8807307-tokentag:ww2.mathworks.cn,2005:Question/19712011-02-24T17:31:12Z2019-04-21T06:22:25ZWhen using ODE45 (or similar functions), what is the benefit of using anonymous functions over passing additional parameters as trailing arguments?When I want to solve a differential equation with additional parameters
function dx = myfun(t, x, p1, p2)
...
using <http://www.mathworks.com/help/matlab/ref/ode45.html |ode45|>, I used to call it by passing the parameters as trailing arguments:
[T, Y] = ode45(@myfun, ts, x0, [], p1, p2);
Now, the <http://www.mathworks.com/help/matlab/math/bsgprpq-5.html documentation> recommends that I use anonymous functions instead:
[T, Y] = ode45(@(t,x) myfun(t, x, p1, p2), ts, x0);
What is the benefit of the latter method over the former?jirohttps://ww2.mathworks.cn/matlabcentral/profile/authors/869871-jirotag:ww2.mathworks.cn,2005:Question/4576202019-04-21T05:09:37Z2019-04-21T06:21:47Zi need to convert a folder of 200 .jpg images to .mat (to create 200 separate .mat files). i know there should be an easy matlab for loop to do this but I need help (newbie). thanks!i need to convert a folder of 200 .jpg images to .mat (to create 200 separate .mat files). i know there should be an easy matlab for loop to do this but I need help (newbie). thanks!Esther Meadhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15333278-esther-meadtag:ww2.mathworks.cn,2005:Question/4576242019-04-21T06:03:35Z2019-04-21T06:19:22Z Write a function called sparse2matrix that takes a single input of a cell vector as defined above and returns the output argument called matrix, the matrix in its traditional formcellvec = {[2 3], 0, [1 2 3], [2 2 -3]};
matrix = sparse2matrix(cellvec)
matrix =
0 3 0
0 -3 0
function [matrix]=sparse2matrix(incell)
msize = incell{1};
mdef = incell{2};
matrix = repmat(mdef,msize);
for n = 3:numel(incell)
RCV = incell{n};
end
matrix = sparse2matrix({[2 3], 0, [1 2 3], [2 2 -3]})
matrix =
0 0 0
0 0 0
Assessment result: incorrectA few simple cases
Variable solution has an incorrect value.
sparse2matrix( { [ 3 4 ], 0, [ 2 2 -3 ], [ 1 3 3 ] } ) failed...
Assessment result: incorrectRandom cases
Variable solution has an incorrect value.
sparse2matrix( { [ 10 10 ], 3, [ 9 9 0 ], [ 9 8 8 ], [ 8 6 -7 ], [ 7 7 4 ], [ 1 1 0 ], [ 4 8 7 ], [ 1 4 1 ], [ 4 8 -1 ], [ 8 7 6 ] } ) failed..Abhishek singhhttps://ww2.mathworks.cn/matlabcentral/profile/authors/14995171-abhishek-singhtag:ww2.mathworks.cn,2005:Question/4576232019-04-21T06:03:04Z2019-04-21T06:03:04Zhow can I use convenc function to encode an image?I'm trying to learn this new function I found after exploring the convolutional coding I found here: convenc - MathWorks. I'm trying to use it on an image but can't figure out how to do that. Can someone explain it to me?Shaurya Singhhttps://ww2.mathworks.cn/matlabcentral/profile/authors/10912409-shaurya-singhtag:ww2.mathworks.cn,2005:Question/4576082019-04-21T02:29:45Z2019-04-21T06:00:58Z¿Como puedo traspasar esta serie a una funcion?8fac = 1;
n=input('favor ingresar cantidadd e terminos: ');
x=input('Ingresar el valor de x: ');
s=x;
for i=2:n
fac = fac * ((i*2)-1);
if(mod(i,2)== 0)
s=1 - double((x^(i*2))/fac
else
s=1 + double((x^(i*2))/fac
end
end
disp('el valor de Cos(x) se aproxima a: ');
Es una serie del cos(x)Thomas Bustoshttps://ww2.mathworks.cn/matlabcentral/profile/authors/12620250-thomas-bustostag:ww2.mathworks.cn,2005:Question/4576222019-04-21T05:53:43Z2019-04-21T05:53:43ZLicens Problem at startAfter each reboot, I get the following message:
License checkout failed.
License Manager Error -9
This error may occur when:
-The hostid of this computer does not match the hostid in the license file.
-A Designated Computer installation is in use by another user.
If no other user is currently running this program, you may need to activate.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/R2019a/9
Diagnostic Information:
Feature: MATLAB
License path: /home/astra/.matlab/R2019a_licenses/license_astra_*********_R2019a.lic:/usr/local/MATLAB/R2019a/licen
ses/license.dat:/usr/local/MATLAB/R2019a/licenses/license_astra_*********_R2019a.lic
Licensing error: -9,57
I try to start in the folder
/ usr / local / MATLAB / R2019a / bin $ sudo activate_matlab.sh
, execute the activation again and then works through sudo ./matlabe to start the program, sometimes it will not work.
System Linux Mint 19.Eva Spomerhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15316827-eva-spomertag:ww2.mathworks.cn,2005:Question/4575022019-04-20T08:27:13Z2019-04-21T05:49:53ZSorting by multiple columns in a table with natural number sortingI have a table of data that I want to sort by pair number and by trial number.
The issue is that if I use:
data = sortrows(data, {'pairNum', 'trialNum'}, {'ascend', 'ascend'});
It sorts with trial 10 being before trial 1.
However, if I try and use Stephen Cobeldick's nat sort function, I can't take into account the pair number as well as the trial number so it ends up sorting with all trial 1s, then all trial 2s etc.. (doesnt preserve the order of the pairs).
Is there a way to sort my table so that my pairs go from 1-100, and within those pairs, the trial numbers go from 1-100?
Also, I tried adding zeros to the trial numbers so that it would hopefully sort 01 before 10, but when I convert to a number using str2num and/or str2double, it gets rid of the leading zeros.
data.trialNum = strsplit(sprintf('%02d ',data.trialNum))';
The datatset is attached as a .mat file.
Lilly Aureliushttps://ww2.mathworks.cn/matlabcentral/profile/authors/5748005-lilly-aureliustag:ww2.mathworks.cn,2005:Question/4575442019-04-20T15:36:56Z2019-04-21T05:43:10Z How can I set a starting point in a situation where I have multiple variables?
I am trying to use the fmincon function in Optimtool.
My objective function is objecfun (w, d) and my constraint function is nonlconstr (w, d, g, x).
The number of variable w is 30(w11, w12, w13, w14, w15, w21, ... , w65), the number of d is 30(d11, d12, d13, d14, d15, d21, ... , d65), g is 6(g1, g2, g3, g4, g5, g6), and x is 3(x1, x2, x3).
I entered a value within the constraint range of each variable at the starting point, but an error of 'x0: matched dimension of the concatenated matrix' occurred.
How do I set the starting point in optimtool?
I look forward to your reply. Thank you.TaeWan Kimhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15336820-taewan-kimtag:ww2.mathworks.cn,2005:Question/4575492019-04-20T16:12:27Z2019-04-21T05:36:55ZHow do I make sure variables aren't overwritten in loops?I need to create a program that can document info on various floors which that can be later used to find out certain info on that floor such as plot a floor plan using coords or tell me how many rooms on whichever floor. However the variables keep getting overwritting the previous loops variables. This is the code I've got so far which is still a WIP for main features.
answerFloor=inputdlg('Enter','Number of Floors');
numberOfFloors=str2double(answerFloor{1});
if numberOfFloors<=0
disp('Invalid');
return
end
numberOfSpaces=zeros(1,numberOfFloors);
spaceX={1,numberOfSpaces};
spaceY={1,numberOfSpaces};
spaceZ={1,numberOfSpaces};
X={1,numberOfSpaces};
Y={1,numberOfSpaces};
for i=1:1:numberOfFloors
answerSpaces=inputdlg('Enter','Number of Spaces');
numberOfSpaces=str2double(answerSpaces{1});
for n=1:1:numberOfSpaces
list = {'Residential','Office','Education','Toilet','Storage'};
[indx,tf] = listdlg('ListString',list);
spaceType=[indx,tf];
answerSpaceX=inputdlg('Enter','Width of Space (m)');
answerSpaceY=inputdlg('Enter','Height of Space (m)');
answerSpaceZ=inputdlg('Enter','Depth of Space (m)');
spaceX(n)=str2double(answerSpaceX{1});
spaceY(n)=str2double(answerSpaceY{1});
spaceZ(n)=str2double(answerSpaceZ{1});
answerX=inputdlg('Enter','X Co-ordinate on floor (m)');
answerY=inputdlg('Enter','Y Co-ordinate on floor (m)');
X(n)=str2double(answerX{1});
Y(n)=str2double(answerY{1});
end
endJack Smilliehttps://ww2.mathworks.cn/matlabcentral/profile/authors/14661874-jack-smillietag:ww2.mathworks.cn,2005:Question/4576152019-04-21T03:43:33Z2019-04-21T05:35:36ZPie Charts- Energy DataHow do I plot pie charts for energy data, for example I have an array that is 83520x1 and I want to plot that against time (which is also in an array that is 83520x1. Fatemah Ebrahimhttps://ww2.mathworks.cn/matlabcentral/profile/authors/14779500-fatemah-ebrahimtag:ww2.mathworks.cn,2005:Question/4576212019-04-21T05:16:13Z2019-04-21T05:24:06Zlength of arrey in cell and remove 0A={[113],[112],[42],[29],[113],[69],[86],[0],[0]};
B={[18],[14],[5],[39],[27],[11],[9],[0],[0]};
C=cellfun(@(m,u) length(m)+length(u),A, B, 'uni',0);
as 2 last element in both A and B is 0
I want to have this result
C={[2],[2],[2],[2],[2],[2],[2],[0],[0]}
Naimehttps://ww2.mathworks.cn/matlabcentral/profile/authors/13711668-naimetag:ww2.mathworks.cn,2005:Question/4576042019-04-21T02:07:13Z2019-04-21T05:16:52ZHow can I use 'yalmip' to solve the Quadratic stability range of uncertain model in control system?How can I solve the value '0.6812' by using 'yalmip' or 'LMI'?I would appreciate it if you could give me an example.Karry Mahttps://ww2.mathworks.cn/matlabcentral/profile/authors/15283432-karry-matag:ww2.mathworks.cn,2005:Question/4576142019-04-21T03:24:15Z2019-04-21T05:13:31ZFind specific cell in another cellsHi everyone,
Attachment is my file.
I would like to know the locations of this cells containes a specific cell-{21 31 1}
I try to use like below:
Match = {21 31 1};
CorrectMatch = find (cellfun(@(x) isequal (x,Match), condition(1,:)));
but it return 0.
Could any one help me? Ting-Yu Chuehhttps://ww2.mathworks.cn/matlabcentral/profile/authors/14644923-ting-yu-chuehtag:ww2.mathworks.cn,2005:Question/4576062019-04-21T02:21:46Z2019-04-21T05:12:26Zdifferent font sizes for y labelsHello,
I want to have different font sizes for y-labels. for example in this simple plot, I want to have -2 and 2 in y-axis in font 16 and the rest in font 12:
x = -1:0.01:1;
y = 3*asin(x);
plot(x,y)
set(gca,'Ytick',[-4, -2, 0, 2, 4])Hamidhttps://ww2.mathworks.cn/matlabcentral/profile/authors/8477485-hamidtag:ww2.mathworks.cn,2005:Question/4575412019-04-20T14:56:34Z2019-04-21T05:10:30Zregexrep for the neophyteHow to write expression to find and convert financial strings written with comma separator to be able to parse numerically?
Example stirng is something like:
recipients={'John Doe $200, Freddy Flint $132.40 SP19; Mary Lamb $1,423.00-SP19, Joe Blow $1,200'};
which is a list of student scholarship awards entered, unfortunately, free-style in a remarks field in an Excel spreadsheet. I need to parse by student and extract each.
I managed to find/return the location/token of the amounts containing the punctuation, but I'm illiterate with regexp and haven't figured out how to locate the comma then within that substring to remove it.
K>> regexp(recipients,'([$]\d+[,]\d+)','match')
ans =
1×1 cell array
{1×2 cell}
K>> ans{:}
ans =
1×2 cell array
{'$1,423'} {'$1,200'}
K>>
As can be seen, the original text also has "issues" in that the separator between students isn't consistent--it may be a comma or semicolon, not sure what else I'll find as I progress.
For context, this is the next step past the previous Q? of piecing back together disparate databases/spreadsheets...now that I can compare the award to the billing by account, I can find coding or other errors--but need to be able compare the details.
dpbhttps://ww2.mathworks.cn/matlabcentral/profile/authors/28872-dpbtag:ww2.mathworks.cn,2005:Question/4576092019-04-21T02:32:51Z2019-04-21T05:08:13ZWhy is the last simulation value is "0",i can't find where is wrongI write an error probability of anti-podal,however,i found the last simulation value is zero,it means that there is no any error signal in the receiver at that time,but that is possible,and i can't find where do i wrong,can anyone help me?
Code
T_s=10^4;
SNR_dB=[-3 0 3 6 9];
SNR_Watt=10.^(SNR_dB./10);
anti_signal=rand(1,T_s)
%Create the anti-podal signal
for ii=1:length(SNR_dB)
for t=1:T_s
if anti_signal(t)>0.5
anti_signal(t)=1;
else
anti_signal(t)=-1;
end
end
%AWGN noise
noise=(1/sqrt(2)*[randn(1,T_s)+1i*randn(1,T_s)]);
%receive_signal
%10.^(-SNR_dB(ii)/20)*noise is the noise in "x" SNR,like -3dB,0dB,3dB,6dB and 9dB
receive_signal=anti_signal+10.^(-SNR_dB(ii)/20)*noise;
for q=1:T_s
if receive_signal(q)>0
receive_signal(q)=1;
else
receive_signal(q)=-1;
end
end
simulation(ii)=(T_s-sum(anti_signal==receive_signal))/T_s%(Total number-the number which is right)-Total number
end
theoretical=1/2*erfc(sqrt(SNR_Watt));
semilogy(SNR_dB,simulation,SNR_dB,theoretical)
The simulation result is as below,as we can see,the last number is always "0",why?i think there is something wrong in the code,but if this 0 is correct,i can't find a reasonable reason to convince to me
yang-En Hsiaohttps://ww2.mathworks.cn/matlabcentral/profile/authors/13220840-yang-en-hsiaotag:ww2.mathworks.cn,2005:Question/574462012-12-26T23:34:19Z2019-04-21T05:07:56ZFAQ: How can I process a sequence of files?How can I process a sequence of files?Janhttps://ww2.mathworks.cn/matlabcentral/profile/authors/869888-jantag:ww2.mathworks.cn,2005:Question/4576072019-04-21T02:29:13Z2019-04-21T05:07:14ZHow can I present a 3D particle with cube mesh? Hi,
I want to draw a spherical particle whick is made of small cubes in MALTAB. I can define the coordinate of each cube inside the particle, however, do not know how to show (or define) each mesh as a cube. Thank you in advance for your help.
Masoud Shabani nezhad navroodhttps://ww2.mathworks.cn/matlabcentral/profile/authors/10447316-masoud-shabani-nezhad-navroodtag:ww2.mathworks.cn,2005:Question/4575272019-04-20T13:32:28Z2019-04-21T05:04:11ZLAB color space components normalizationPlease help me...I want to Normalize L*A*B color space components...any one guide ne how, i can normalize them..SA Rehmanhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15086044-sa-rehmantag:ww2.mathworks.cn,2005:Question/4576122019-04-21T03:18:49Z2019-04-21T05:02:26ZHow to create a function to define a squareHow to create a function to define a squareTOKENhttps://ww2.mathworks.cn/matlabcentral/profile/authors/8807307-tokentag:ww2.mathworks.cn,2005:Question/4576172019-04-21T04:11:12Z2019-04-21T04:52:14Zphysical layer implementation of ieee 802.11ahwe have to write code for ieee 802.11ah transmitter and receiver with channel modellingThanmai Rachamalluhttps://ww2.mathworks.cn/matlabcentral/profile/authors/14283070-thanmai-rachamallutag:ww2.mathworks.cn,2005:Question/4576192019-04-21T04:51:26Z2019-04-21T04:51:26ZHow to get vorticity from velocity components u and v?[curlz,cav]= curl(X,Y,U,V)
If I am using this function, it only provides one ouput. How I can differentate between curlz and curvature and secondly how will be the vorticity calculated from this function. Thanks!Mahram Khanhttps://ww2.mathworks.cn/matlabcentral/profile/authors/13711549-mahram-khantag:ww2.mathworks.cn,2005:Question/4575822019-04-20T21:10:51Z2019-04-21T04:48:54ZConverting user input char to an array As part of my university matlab module i was assigned to do an assigment from one of 4 options. I'm on a bit of a road block, part of code is requesting the user to type in 6 numbers for a lottery game, being that this data is recorded as a char i want to convert this to a numerial array (matrix). I have tried the following with no luck.
player_numbers = input ('Please enter your number: ','s');
player_lotto_numbers = str2num(player_numbers);
Mehmet Saglamhttps://ww2.mathworks.cn/matlabcentral/profile/authors/12224026-mehmet-saglamtag:ww2.mathworks.cn,2005:Question/4576182019-04-21T04:37:55Z2019-04-21T04:37:55ZSimulink error,STM32-MAT package,Invalid index:Component:Simulink | Category:Block diagram error.
Matlab version:2018b
STM32-MAT version:4.4.2
Before I used the simple demo from ST ,I tried to build a model for STM32F407 which is very simple.It just contains a pulse generators and a GPIO block,when i click the simulation button, everything go right.But if I want to bulid it in C/C++,matlab report a error.I don't know whitch block makes mistakes.Maybe there is several mistakes in configuration?So I decide to use the demo from ST,but it doesn't work out.The same problem occurs.
The installation path is set.I have checked the configuration two times,it should be right.
How to fix it?
By the way,the demo is saved by matlab 2016b.
If someone can help me,thanks for your kindness. :)Dante Paynehttps://ww2.mathworks.cn/matlabcentral/profile/authors/15338769-dante-paynetag:ww2.mathworks.cn,2005:Question/1163552014-02-16T15:54:43Z2019-04-21T04:32:26Zmatlab code for simple LSB audio steganographyhi
need a simple code for simple LSB audio steganographyMamathahttps://ww2.mathworks.cn/matlabcentral/profile/authors/5067750-mamathatag:ww2.mathworks.cn,2005:Question/3891132018-03-19T00:21:29Z2019-04-21T03:56:37ZWhy the final Validation accuracy appears on the plot different than the accuracy that is calculated by the law of accuracy ?I create and train a simple convolutional neural network for deep learning classification on Matlab, when training finishes, the final validation accuracy that appears on the right side of the plot is different than the accuracy I have gotten from the following law for the validation set
accuracy = sum(predictedLabels == valLabels)/numel(valLabels);Nusaiba Mnayyishttps://ww2.mathworks.cn/matlabcentral/profile/authors/8515744-nusaiba-mnayyistag:ww2.mathworks.cn,2005:Question/4576162019-04-21T03:56:12Z2019-04-21T03:56:12ZWhich code of BVP4C replaces the code xSol(t) = simplify(xSol(t)) OR pretty([xSol(t);ySol(t)]) of DSOLVEWhich code of BVP4C replaces the code xSol(t) = simplify(xSol(t)) OR pretty([xSol(t);ySol(t)]) of DSOLVEMINATIhttps://ww2.mathworks.cn/matlabcentral/profile/authors/10813789-minatitag:ww2.mathworks.cn,2005:Question/4576052019-04-21T02:08:05Z2019-04-21T03:39:02ZFor an nx3 matrix, filter out the rows with a maximum 3rd column when the first and second are the sameFor a matrix such as:
mat=[0 0 0
1 1 2
1 1 3
1 1 5
2 1 6
3 3 2
3 3 1]
Is there a way to filter this matrix to obtain the following matrix
final=[0 0 0
1 1 5
2 1 6
3 3 2]
Appreciate any help thanksJoseph Maloneyhttps://ww2.mathworks.cn/matlabcentral/profile/authors/13297175-joseph-maloney