https://jp.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-08-17T11:36:10Ztag:jp.mathworks.com,2005:Question/3527102017-08-14T14:46:55Z2017-08-17T11:36:10ZUsing fzero to find the second intercept of the two curves.<p>So I have function f(x)=-ln(x+0.01)+e^x that plots the cross sectional area of a shape and then a horizontal line segment given by g(x)=f(x)x=0. I need to find the second intercept of the curves. Easy to visual if you graph it. Now I need to use the fzero function to solve this and I have been searching for hours for an example like this and can't find anything similar.</p>Andy Parsonshttps://jp.mathworks.com/matlabcentral/profile/authors/10612766-andy-parsonstag:jp.mathworks.com,2005:Question/3530502017-08-17T08:56:21Z2017-08-17T11:36:00ZHow to select the maximum points of the absolute values of a sin function <p>I would like to get all the maximum values of x in another matrix any idea? Sorry I am new</p><pre> fs = 500;
t = 0:1/fs:10-1/fs;
x = abs(sin(2*pi*3*t));</pre>Mauricio Galván García Lunahttps://jp.mathworks.com/matlabcentral/profile/authors/10729778-mauricio-galvan-garcia-lunatag:jp.mathworks.com,2005:Question/3530312017-08-17T05:17:54Z2017-08-17T11:31:36Zload mat table to gui table<p>hello,
i need to load specific data from my mat file to gui table
u can see mat file in the picture https://www.mathworks.com/matlabcentral/answers/uploaded_files/85736/image.png
i need to show specific data,</p><pre class="language-matlab">load Data_Plat.mat
[row,~] = size(Database_All);
data2 = cell(row,4);
for n = 1:row
data2{n,1} = Database_All.Plat{n};
data2{n,2} = Database_All.Nama{n};
data2{n,3} = Database_All.Jurusan{n};
data2{n,4} = Database_All.Status{n};
end
set(handles.uitable1,'Data',data2);
</pre><p>this is my code for show all data from mat file in to gui table, the question is, how can i just show 1 data, for example, data with number plat DD6713MT</p>Yusran Saidhttps://jp.mathworks.com/matlabcentral/profile/authors/9940828-yusran-saidtag:jp.mathworks.com,2005:Question/3528682017-08-15T22:53:52Z2017-08-17T11:31:11ZWhy is the pause function not activating?<p>I don't understand why this code isn't pausing normally. I'll run this section of the script and it'll speed through without pausing, and then I'll type in the same parts of the code piece-by-piece into the command window and pause WILL work.</p><p>Short background on the code: I'm controlling two simple servos using Arduino packages.</p><pre class="language-matlab">stepTime = goalTime/(length(invPath(:,1))-1) % This value is about 0.5
lastq = qStart;
</pre><pre class="language-matlab">step = 0;
tic
for i=1:length(invPath(:,1))
step = step + 1;
</pre><pre> % Simultaneously Map on Plot
simMoveRR(.03,lastq,qend,base,L1,L2); % This plots the results to mock the robot.
lastq = qend; </pre><pre> %Send Command to Arduino; ServoInputVal converts degree input to 0-1 value.
writePosition(s1, ServoInputVal(rad2deg(invPath(i,1)),s1InputRange,s1ArmRange));
pause(stepTime/2); % Doesn't work
writePosition(s2, ServoInputVal(rad2deg(invPath(i,2)),s2InputRange,s2ArmRange));
pause(stepTime/2); % Doesn't work
toc</pre><pre> if mod(step,20)==0; % An attempt to pause the code to review the position.
pause % This doesn't work either.
end
end</pre><p>EDIT: fixed mod input ; still doesn't explain problem with pause.
I'm running MATLAB R2016a</p>Grant Joneshttps://jp.mathworks.com/matlabcentral/profile/authors/10446214-grant-jonestag:jp.mathworks.com,2005:Question/3527792017-08-15T02:29:26Z2017-08-17T11:23:48ZHow to encode edge features in Matlab?<p>I am making a simple demo in Matlab. I want to extract edge maps from video sequences then encode both frame & edge maps to bit stream. Then I will decode bitstream to have frame & edge maps, and leverage edge maps to upscaling that frame.</p><p>This is not a new idea, I used huffmanenco to encode image, but I'm facing some difficulties to encode edge maps.
May anyone can give me an idea to solve this problem?
Sorry if my question trouble you because I'm newbie in both Matlab and Computer Vision.</p><p>Thank you so much.</p>Thien Thu Ngohttps://jp.mathworks.com/matlabcentral/profile/authors/9316910-thien-thu-ngotag:jp.mathworks.com,2005:Question/3530642017-08-17T10:38:57Z2017-08-17T11:23:42Zhow to open datafiles with an exe-file<p>Hi,
I have an exe-file, which converts datafiles in a special format into csv files. To use it, I drag and drop the datafiles on to the exe file, and the exe file converts it, and saves the generated csv in the same folder as the datafile. I would like to generate a script, to do the conversion automatically. Does anyone have an idea how to do this ?
Thanks
Hans</p>Hans Jørgen Jensenhttps://jp.mathworks.com/matlabcentral/profile/authors/2458933-hans-jorgen-jensentag:jp.mathworks.com,2005:Question/3530692017-08-17T11:15:46Z2017-08-17T11:22:48Zvision.BlobAnalysis to HDL<p>Hello!
I'm not very familiar with hdl coder, but I want to learn more about it. Is it possible to create a synthesizable HDL description for the vision.BlobAnalysis unit using HDL coder?
I would like to apply a model-oriented approach to FPGA development.</p>Alexey Gordienkohttps://jp.mathworks.com/matlabcentral/profile/authors/10608137-alexey-gordienkotag:jp.mathworks.com,2005:Question/3530632017-08-17T10:36:08Z2017-08-17T11:17:23ZPlotting a spectrum-like figure<p>Hello,
I am aware of the spectrogram function of MATLAB. But I can't use that, and my question is
I have three vectors-time, frequency, and energy of each frequency. I want to plot a figure where in x-axis I have time, in y-axis I have frequency and the energy of each frequency is visualized by different colors. Can you please explain how to plot?</p>Tahmid Chowdhuryhttps://jp.mathworks.com/matlabcentral/profile/authors/8854948-tahmid-chowdhurytag:jp.mathworks.com,2005:Question/3530622017-08-17T10:34:44Z2017-08-17T11:08:46ZTabulate hates non-finite parties.. When they are incomplete<p>Hello everyone ;)
I wonder if this problem with tabulate is my madness or an epidemic.</p><p>tabulate([17;17;20;78;80;Inf;Inf;Inf;Inf;NaN])</p><p>Error using :
Maximum variable size allowed by the program is exceeded.</p><p>Error in tabulate (line 48)
[counts values] = hist(y,(1:maxlevels));</p><p>But if we invite the -Inf to the party... solved</p><p>tabulate([17;17;20;78;80;Inf;Inf;Inf;-Inf;NaN])</p><pre class="language-matlab">Value Count Percent
-Inf 1 11.11%
17 2 22.22%
20 1 11.11%
78 1 11.11%
80 1 11.11%
Inf 3 33.33%
</pre><p>Greetings</p>Numa Nigeriohttps://jp.mathworks.com/matlabcentral/profile/authors/7870177-numa-nigeriotag:jp.mathworks.com,2005:Question/3530522017-08-17T09:06:14Z2017-08-17T11:08:14ZCan anyone help me to get results from the program given below? <p>Below program is running well (for let say, Testsmooth(1,1,0,1)), but when I change the "F3(ss)" to "1/F3(ss)", it doesn't give any result while showing some warnings.Could anyone help to identify possible problem associated with this program.</p><p>For running this code; Fie, galag and ntrpfie files are in attachments. Thanks</p><pre> function TestSmooth(lambda,a,b,AbsTol,RelTol,c)
behavior =1;</pre><pre> if nargin < 4 || isempty(AbsTol)
AbsTol = 1e-6;
end
if nargin < 5 || isempty(RelTol)
RelTol = 1e-3;
end</pre><pre> if nargin < 6 || isempty(c)
c = -1;
end</pre><pre> % Compute and plot the solution:
[soln,errest,cond] = Fie(lambda,a,b,behavior,@kernel,@RHS,AbsTol,RelTol);
t = soln.s; sol = soln.x;
nfinal = length(t) - 1;
% Interpolate the solution for assessing the error and if necessary,
% use to get a smooth graph.
tint = linspace(a,b,150);
xint = ntrpFie(soln,tint);
if nfinal < 150
plot(tint,xint)
else
plot(t,sol)
end</pre><pre> %====Nested functions=======================================================
function kst = kernel(s,t)
nn=32;
aa=17.6e-6;
height=5.*aa;
F3=@(ss)(exp((ss./aa).*height)-exp(-(ss./aa).*height))./(exp((ss./aa).*height)+exp(-(ss./aa).*height));
f21=@(ss)ss.*(F3(ss)-1).*besselj(0,ss.*s.^2).*besselj(0,ss.*t.^2);
f2=@(ss)-2.*t.*s.*t.*f21(ss);
kst=galag(f2,nn);
end % kernel</pre><pre> function ts = true_soln(t)
ts = 0;
end % true_soln</pre><pre> function rs = RHS(s)
rs=s;
end % RHS
end</pre>Richardson Josephhttps://jp.mathworks.com/matlabcentral/profile/authors/7190873-richardson-josephtag:jp.mathworks.com,2005:Question/3527962017-08-15T08:24:44Z2017-08-17T11:07:32ZComputing difference between maximum values in columns of matrix within predefined time interval<p>Hello,
I have a matrix of values of size 8760 x 6 (a small excerpt is shown below), in which 1st column is the year, 2nd month, 3rd is the day, 4th is the hour, 5th is value 1 and 6th is value 2. The nature of graph for val 1 and val 2 is sinusoidal, hence there is alternate peaks and troughs. I need to identify the peaks in val 1 and corresponding peaks in val 2 within +/- 3 hr window and then difference between the two values. For example, in the matrix below, the 1st peak value is 2.08 in val 1 and next value is +1 hr next to it, i.e., 1.75 in val 2. In the next positive cycle, the peak value is 2.02 and corresponding peak value in val2 is 1.82 and so on.</p><pre class="language-matlab">Year Mo Day hr val 1 val 2
2014 1 1 0 1.84 1.67
2014 1 1 1 1.74 1.56
2014 1 1 2 1.26 1.04
2014 1 1 3 0.47 0.23
2014 1 1 4 -0.4 -0.65
2014 1 1 5 -1.11 -1.40
2014 1 1 6 -1.43 -1.78
2014 1 1 7 -1.30 -1.68
2014 1 1 8 -0.76 -1.12
2014 1 1 9 0.078 -0.27
2014 1 1 10 0.89 0.58
2014 1 1 11 1.62 1.29
2014 1 1 12 2.08 1.74
2014 1 1 13 2.06 1.75
2014 1 1 14 1.61 1.33
2014 1 1 15 0.87 0.56
2014 1 1 16 -0.05 -0.37
2014 1 1 17 -0.87 -1.25
2014 1 1 18 -1.47 -1.86
2014 1 1 19 -1.59 -2.00
2014 1 1 20 -1.28 -1.63
2014 1 1 21 -0.56 -0.87
2014 1 1 22 0.327 0.022
2014 1 1 23 1.181 0.85
2014 1 2 0 1.85 1.521
2014 1 2 1 2.020 1.819
2014 1 2 2 1.736 1.637
2014 1 2 3 1.074 1.021
2014 1 2 4 0.142 0.115
2014 1 2 5 -0.81 -0.83
2014 1 2 6 -1.54 -1.58
2014 1 2 7 -1.82 -1.90
2014 1 2 8 -1.59 -1.68
2014 1 2 9 -0.92 -0.98
2014 1 2 10 0.002 -0.058
2014 1 2 11 0.892 0.825
2014 1 2 12 1.693 1.529
2014 1 2 13 2.138 1.914
2014 1 2 14 2.057 1.829
2014 1 2 15 1.547 1.287
2014 1 2 16 0.696 0.4018
</pre><p>Finally, the desired output is:</p><pre class="language-matlab">2014 1 1 2.08 1.76 0.32
2014 1 2 2.02 1.82 0.20
2014 1 2 2.14 1.91 0.22
</pre><p>Any help?</p>Poulomi Gangulihttps://jp.mathworks.com/matlabcentral/profile/authors/8312343-poulomi-gangulitag:jp.mathworks.com,2005:Question/3529372017-08-16T12:37:31Z2017-08-17T11:05:57ZEvaluating Principal Value Integral<p>Dear All,</p><p>I have a problem to do numerical integration of improper integral. I need to calculate the principal value of integral below, from zero to infinity. My final aim is to evaluate this integral for any values of alpha, H, c, and z. So, the singular point(s) are always changing and it means I can’t just do trial and error to find the limit of the integration to avoid the pole(s), right? The function is depicted below</p><pre class="language-matlab">fun =@(S) (2*(S+alpha).*exp(-S.*H).*cosh(S.*(H+c)).*cosh(S.*(H+z)))./((S.*sinh(S.*H))-(alpha*cosh(S.*H)))
integral(fun,0,inf)
</pre><p>Note: alpha, H, are real positive whereas c, and z are real negative with abs(c) and abs(z) < H</p><p>Any idea will be highly appreciated.</p><p>Thank you very much before.
Regards,</p><p>Fredo Ferdian</p>fredo ferdianhttps://jp.mathworks.com/matlabcentral/profile/authors/8081530-fredo-ferdiantag:jp.mathworks.com,2005:Question/3530412017-08-17T07:03:53Z2017-08-17T11:05:43ZUsing filepath input in fopen<p>Hi all, I can't seem to use fopen to open a file using a variable that stores the name and path of the file. For example, the variable [pathvariable] stores /imper/codec/data.txt. I am doing fid = fopen([pathvariable],'r') but it is not working.</p><p>I've tried the following too:</p><pre class="language-matlab">fid = fopen(pathvariable,'r')
fid = fopen('pathvariable','r')
</pre><p>In all cases, I get a fid of -1.</p><p>Could someone please help. Thanks.</p>Suhahttps://jp.mathworks.com/matlabcentral/profile/authors/10734780-suhatag:jp.mathworks.com,2005:Question/3530672017-08-17T10:58:35Z2017-08-17T10:58:35ZCan we find the transparency of an overlay on an image ?<p>If I have an image with a transparent overlay on it, can we find the percentage of transparency from the alpha channel of the image?</p>Arjun V Shttps://jp.mathworks.com/matlabcentral/profile/authors/9623135-arjun-v-stag:jp.mathworks.com,2005:Question/3530662017-08-17T10:49:12Z2017-08-17T10:55:59Zupdating record in mysql<p>In the above code, it is executing with out showing errors but the record is not update in the database.</p><pre class="language-matlab">function Reg_pwd_gen(uname1)
mm = floor(1000+(rand()*8999));
conn = database('mani','root','MARUTHI');
tablename='user2';
colnames = {'pwd'};
data={'mm'};
whereclause={'WHERE uname = ''{uname1} '''};
update(conn,tablename,colnames,data,whereclause);
commit(conn);
close(conn);
Reg_pwd = uicontrol('Style','text','FontSize',10,'FontWeight','bold',...
'Position',[10 500 200 50],...
'String','Please Remember the Password for Authention. ')
pwd1= uicontrol('Style','edit','FontSize',12,'FontWeight','bold',...
'Position',[550 500 100 60],...
'String',mm)
% code
end
</pre><p>Please help me for my project and also send me the reply as early as posssible.</p>Maruthi Maruthihttps://jp.mathworks.com/matlabcentral/profile/authors/7719143-maruthi-maruthitag:jp.mathworks.com,2005:Question/3530652017-08-17T10:49:00Z2017-08-17T10:49:00ZI want to find the Euclidean distance between Imposters for Biometric authentication.<p>Sir/Mam,
I have a 40x3 matrix (10 subjects having 4 instances each => 4*10=40)out of which first 4 rows are 4 features vecctors/4 instances of Subject1(Person 1)and next 4 rows are 4 feature vectors/instances of subject 2 and so on upto subject 10. IMPOSTERS FOR SUBJECT1: (I want to find the Euclidian distance between imposters. i.e ED between Ist row and all other rows except row number 2, 3, and 4 as they are Genuine i.e of Subject 1. Then I want to find ED between 2nd row and all other rows of other subjects except row number 1,3,and 4. and so on upto row 4.). Similarly I want to find imposter EDs for all other subjects (say 10) also. Can u please help me in making a loop for this in MATLAB as in practice I have hundreds of subjects which makes finding ED between imposters more complex without a loop.</p>mahroosh bandayhttps://jp.mathworks.com/matlabcentral/profile/authors/5046573-mahroosh-bandaytag:jp.mathworks.com,2005:Question/1103362013-11-19T05:00:00Z2017-08-17T10:46:12ZHow do I install MATLAB Production Server or configure a new MATLAB Production Server Instance?<p>How do I install MATLAB Production Server or configure a new MATLAB Production Server Instance?</p>MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:jp.mathworks.com,2005:Question/3530472017-08-17T08:32:22Z2017-08-17T10:31:09Z what does imloadfunc do?<p>I 'm working on non-negative matrix factorization. I have come across a GitHub code for the same. Here, they have used global imloadfunc .im unable to understand why it is been used.</p><p><a href = "https://github.com/aludnam/MATLAB/blob/master/nmfpack/code/cbcldata.m">https://github.com/aludnam/MATLAB/blob/master/nmfpack/code/cbcldata.m</a></p>kitty varghesehttps://jp.mathworks.com/matlabcentral/profile/authors/10557526-kitty-varghesetag:jp.mathworks.com,2005:Question/3530592017-08-17T10:08:02Z2017-08-17T10:27:42ZModelization of a PSA - Pressure Swing Adsorption unit with coupled ODE and PDE with the Method of Lines<p>Dear all,</p><p>I would like to ask a question regarding how to solve coupled differential equations using the method of lines.
I've brosed through the previous answered questions and I got some good starting points, but now I am stuck with a set of data that I can't fit in the model.
I am working on the modelization of an adsorption unit, in which there are a set of differential equations to consider.</p><p>I attach here the set of differential equations I want to take care of, and especially for the first model I would like to have number (2),(4) and (6) (which are a mass balance, energy balance and the model for adsorption in a solid).
I first worked on the coupling between equations 2 and 4, and later on I would like to add as well the influence of temperature on the
I am starting with the mass balance equation and the adsorption equation, but my issue is that I don't get the shapes of the variables as I would like to.
Here is the code I have written; in the script there are the general data about the conditions and the spacing, while in the function the boundary conditions and equations are considered.</p><pre class="language-matlab">if true
clear all
close all
clc
%Parameters:
Re=15; %suggested Reynolds
v=0.001; %velocity m/s
Temp_in=300; %K
q_sat= 0.1; %mmol/g
mi=1.10*10^-5; %Pa*s, dinamic viscosity
epsilon=0.3;
d_p=1.85*10-3; %[m], particle diameter
ro_g= 14*100000/((8314/16)*(273+30));
ro_s=670; %kg/m3
k_ldf=0.005;
%Boundary Conditions:
C_feed=5;% BC for space, concentration at x=0, feed concentration
%space setup
L=0.1; %space length
n=200; %space points
% dx=L/n;
dx=L/(n-1); %space interval
space=linspace(0,L,n);
%time setup
t0=0; %lower bound for time
tf=400; %upper bound for time
m=100; %time points
time_vct=linspace(t0,tf,m); %time vector
% dt=tf/m;
dt=tf/(m-1);
%Initial Condition:
for i=1:n
u0(i)=0; %C initialiation
u0(n+i)=0; %q initialization
%u0(3,i,j)=Temp; %T initialization
end
u=zeros(1,2*n); %matrix of solutions
for i=1:n
C(i)=0;
q(i)=0;
%T(i)=Temp;
end
u(1:n)=C(1:n);
u(n+1:2*n)=q(1:n);
[t,u]=ode45(@(t,u)Fluid_Flow_forIN(u,n,v,C_feed,dx,epsilon,ro_s,k_ldf,q_sat),time_vct,u0);
C_sol=u(:,[1:n]);
q_sol=u(:,[n+1:2*n]);
figure (1)
plot(t,q_sol(:,1))
hold on
plot(t,q_sol(:,2))
plot(t,q_sol(:,3))
plot(t,q_sol(:,4))
legend('z=1','z=2','z=3','z=4')
xlabel('time')
ylabel('q adsorbed')
%
%
%
function [dudt]=Fluid_Flow_forIN(u,n,v,C_feed,dx,epsilon,ro_s,k_ldf,q_sat)
%this function creates an array of ODE that can be solved by calling them
%through ode45 in the main file
%array initialization
dudt=zeros(2*n,1);
dqdt=zeros(2*n,1);
dCdt=zeros(2*n,1);
%the different variables are taken from the array u
C(1:n)=u(1:n);
q(1:n)=u(n+1:2*n);
for i=1:n
if(i==1)
dqdt(i)=k_ldf*(q_sat-q(i));
dCdt(i)= -1*v*((C(i)-C_feed))/dx -(1-epsilon)/epsilon*ro_s*dqdt(i);
else
dqdt(i)=k_ldf*(q_sat-q(i));
dCdt(i)= -1*v*(C(i)-C(i-1))/dx -(1-epsilon)/epsilon*ro_s*dqdt(i);
end
dudt(i)=dCdt(i);
dudt(n+i)=dqdt(i);
end
end
% code
end
</pre><p>The main issue from my point of view is that q(i) is initialized to 0, and then this value is never updated and gives thus constant derivative with a wrong plot that physically doesn't make sense.</p><p>I have tried to put he "for" cycle out of the function, but I still don't get proper results. My idea is that dqdt should be already properly calculated before ode45 solves the array, and that at every cycle the result is updated.</p><p>I attached a link in which there is an already commented question on a similar issue, but I couldn't make it work (maybe because of some basic mistake from my side!).</p><p>Any kind of help would be very appreciated, thank you very much for you collaboration!</p><p>Regards,
Alessandro</p>Ale Panhttps://jp.mathworks.com/matlabcentral/profile/authors/10574894-ale-pantag:jp.mathworks.com,2005:Question/3522402017-08-10T06:19:55Z2017-08-17T10:26:10Zi have a signal with many frequencies. how to find this frequencies and reconstruct the signal from these frequencies <p>I've attached a MATLAB code, in that timeseries is the signal for which frequencies have to be found.
I've tried using FFT but not getting the answer.
my code for frequency and regeneration:
t =0:1:2048;
y=timeseries;</p><p>ffty = fft(y);</p><p>ffty = abs(ffty(1:ceil(length(y)/2)));
% ffty(ffty<2)=0;
[~,locs] = findpeaks(ffty);
freqs = (locs-1)/t(end);
signal_1=0;
for n=1:1:length(freqs)
signal_1 = (signal_1+sin(2*pi*freqs(n)*t));
end
hold on
plot(smooth(signal_1));</p><p>hold on
plot(y,'b');</p>rohith bharadwajhttps://jp.mathworks.com/matlabcentral/profile/authors/10485449-rohith-bharadwajtag:jp.mathworks.com,2005:Question/3530602017-08-17T10:16:03Z2017-08-17T10:21:39Zhow to read multiple pgm images ?<p>I'm working with a database which has 472 pgm files inside a folder named faces.
I want to read all 472 and store it I</p><p>also each file inside the folder is name cmu_0000.pgm..........cmu_00471.pgm</p>kitty varghesehttps://jp.mathworks.com/matlabcentral/profile/authors/10557526-kitty-varghesetag:jp.mathworks.com,2005:Question/3421622017-05-27T10:00:03Z2017-08-17T10:13:08ZHow to save image in database<p>hi, i try insert image in database together with sting information about image but always got error.
Maybe you know how to solve that.
Error: Error using cell2mat (line 46)
All contents of the input cell array must be of the same data type.</p><p>Error in pildymas>pushbutton2_Callback (line 301)
exdata = {vardas,pavarde,laipsnis,pareigos,telefonas,marke,numeris,tarnyba, cell2mat(nuotrauka)};</p><p>Error in gui_mainfcn (line 96)
feval(varargin{:});</p><p>Error in pildymas (line 42)
gui_mainfcn(gui_State, varargin{:});</p><p>Error in @(hObject,eventdata)pildymas('pushbutton2_Callback',hObject,eventdata,guidata(hObject))</p><p>Error while evaluating uicontrol Callback</p><pre class="language-matlab">% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.jpg','*.bmp'},'File Selector');
image1 = imread(strcat(pathname, filename));
axes(handles.axes1);
I = imshow(image1);
</pre><pre class="language-matlab">guidata(hObject,handles)
% save the updated handles object
% guidata(hObject,handles);
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
</pre><pre class="language-matlab">% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
%Use handles structure to recall the selected file
conn = database('baze', 'root', 'root', 'Vendor', 'MYSQL', 'Server', 'localhost', 'PortNumber', 3306);
setdbprefs('DataReturnFormat','cellarray');
vardas = get(handles.edit1, 'string');
pavarde = get(handles.edit2, 'string');
laipsnis = get(handles.edit3, 'string');
pareigos = get(handles.edit4, 'string');
telefonas = get(handles.edit5, 'string');
marke = get(handles.edit6, 'string');
numeris = get(handles.edit7, 'string');
tarnyba = get(handles.edit8, 'string');
I = handles.I(:)'; % transpose it
I = im2uint8(I); % convert it to uint8
s = dec2hex(I, 2)'; % convert it to hexcode
image_str = s(:)';
clear I s
nuotrauka = {[1],'.jpg',image_str,[42],[42]}; % define the input data
exdata = {vardas,pavarde,laipsnis,pareigos,telefonas,marke,numeris,tarnyba, cell2mat(nuotrauka)};
fastinsert(conn, 'info', {'vardas','pavarde','laipsnis','pareigos','telefonas','marke','numeris','tarnyba','nuotrauka'},exdata)
guidata(hObject, handles);
close(conn);
</pre><p>thanks in advise</p>Gytis Raudoniushttps://jp.mathworks.com/matlabcentral/profile/authors/7132005-gytis-raudoniustag:jp.mathworks.com,2005:Question/3528602017-08-15T20:32:14Z2017-08-17T10:11:10ZHow to display rgb image of 256*256*3? <p>I display using imshow function, however, it shows a grey scale image.i.e the image is not color-coded.</p><p>Can anyone please help me?</p><p>thanks</p>Jeshttps://jp.mathworks.com/matlabcentral/profile/authors/2953127-jestag:jp.mathworks.com,2005:Question/3530562017-08-17T09:44:28Z2017-08-17T10:08:45ZWhat does "Struct(1).file=Out_mat" mean?<p>I have a script that begins as follows:</p><pre> clearvars -except Struct
program =2;
addpath(genpath('G:\DATA SUM\ISI\310815\Aug.31,2015 15.44.55\TimtomlineData'));</pre><pre> if program ==2
clear all
close all
clc</pre><pre> load('Cycle_1.mat'); </pre><pre> Struct(1).file=Out_mat;</pre><p>Can someone help me figure what line: "Struct(1).file=Out_mat" does?</p><p>If the rest of the script is needed I would happily add it.</p><p>Thank you all,
Sigal.</p>Sigal Cohenhttps://jp.mathworks.com/matlabcentral/profile/authors/10562517-sigal-cohentag:jp.mathworks.com,2005:Question/3530582017-08-17T10:06:37Z2017-08-17T10:06:37Zregression learner equation output<p>I've generated an svm prediction module using Matlab's regression learner. I now wan't to use that module to predict new data. My system is a power or electricity load forecast that takes the previous load data in addition to previous weather data to predict the load on the next hour. I know that the data should include predictors (features) and response. the predictors are the training data and the response is the expected output. I wan't my system to take say the last 10 samples of previous data and use it to predict the next hour. How can I establish that in Matlab? I mean, how does it know that this portion (10 samples) of the predictor vector is supposed to give response #x in the response vector? When I fed the regression learner a big vector of inut data and it's corresponding expected response I got the following response with RMSE of 1.18 which is good. I just want to understand how its controlled for further use.</p><img src = "/matlabcentral/answers/uploaded_files/85762/learner5(data4_6months).PNG"><p>I guess to wrap what I mean by all of that is how to represent my system in a function that will be called to predict the next hour based on the load from the past few hours' data.</p><p>thanks</p>Isra Harounhttps://jp.mathworks.com/matlabcentral/profile/authors/10657055-isra-harountag:jp.mathworks.com,2005:Question/3530512017-08-17T09:06:11Z2017-08-17T10:04:55Zcan any one tell me differences between the face detection and face localization<p>can any one tell me differences between the face detection and face localization</p>suresh khttps://jp.mathworks.com/matlabcentral/profile/authors/6227735-suresh-ktag:jp.mathworks.com,2005:Question/3530432017-08-17T07:15:35Z2017-08-17T10:03:22ZI'm having trouble drawing lines.<pre class="language-matlab">There are two lines from 102 to 103 but they do not appear;
</pre><img src = "/matlabcentral/answers/uploaded_files/85746/1.2.JPG">Muhendisleksihttps://jp.mathworks.com/matlabcentral/profile/authors/8930166-muhendisleksitag:jp.mathworks.com,2005:Question/3530572017-08-17T09:50:52Z2017-08-17T10:02:11ZUsing slice in a fuction and from command window<p>Hi everyone:
I am using slice to display views of a Ultrasound created image volume. When I run it from the comman window I get the error of "Index exceeds matrix dimensions" but if I create a function in which I call slice and produce the cuts then it works. I have tried with simple examples like the one included in the description of the slice function usage and I get the same results. Being a the volume with dimensions (149x148x200):</p><p>-------------------------------------------</p><p>Command Window:
sizevol=size(a);</p><p>% %slice and visualise cross sections for volume</p><p>[xgrid,ygrid,zgrid]=meshgrid(1:sizevol(2),1:sizevol(1),1:sizevol(3));</p><p>a=double(a);</p><p>h=slice(xgrid,ygrid,zgrid,a,100,100,10);</p><p>ERROR - Index exceeds matrix dimensions</p><p>-------------------------------------------</p><p>Function:
slicefcn(a);</p><p>"""""</p><p>function slicefnc(V)</p><pre> figure;</pre><pre> [x,y,z] = meshgrid(1:size(V,2),1:size(V,1),1:size(V,3));</pre><pre> hslices=slice(x,y,z,V,size(V,2)/2,size(V,1)/2,size(V,3)/2);% </pre><pre> colormap(gray);</pre><pre> xlabel('x');ylabel('y');zlabel('z');</pre><pre> end</pre><p>""""</p><p>getting the desired result attached;</p><p>Has anyone an idea why this happens? am I missing or ignoring something?
Cheers</p><p>Sergiusz</p>Sergio Moraleshttps://jp.mathworks.com/matlabcentral/profile/authors/8418839-sergio-moralestag:jp.mathworks.com,2005:Question/3519942017-08-08T14:30:26Z2017-08-17T09:53:01ZHow can we create a distributed array for specific number of workers (cores) in MATLAB?<p>I have a question: How can we create a distributed array for specific number of workers in MATLAB? In other words, if we have 4 workers(cores) in our computer and we would like to designate just 3 workers to process a distributed array, how can we do that. I used the existing commands in this way:</p><p>a=[1 2 3 4 5 6];
b=codistributed(a);</p><p>Unfortunately, this instruction use all four workers!</p><p>Please, any idea how to solve this problem?</p><p>Kind regards Ammar</p>Ammar https://jp.mathworks.com/matlabcentral/profile/authors/6713588-ammartag:jp.mathworks.com,2005:Question/3530492017-08-17T08:47:11Z2017-08-17T09:49:13ZHow can I solve an integral problem included of cumulative distribution function of chi-square distribution?<p>Excuse me,
does anyone know how to solve an integral problem included of cumulative distribution function of chi-square distribution?
For example, there is a question like the attached picture:</p><p>I want to use the int() function to solve it, however, there are two probability distribution in it, and i don't know how to deal with it.</p><p>I hope you can tell me how to solve it like using which function or method instead of giving me the correct answer. Thanks! <b>c = 1.00, n = 100, c</b> = 1.15, Cp = 1.12</p>Louis Liuhttps://jp.mathworks.com/matlabcentral/profile/authors/10735142-louis-liutag:jp.mathworks.com,2005:Question/3530552017-08-17T09:21:33Z2017-08-17T09:21:33ZHow can I identify the available Pins on a Servo/PWM Pi HAT!?<p>I attached a Servo/PWM Pi HAT! to a RaspberryPi 3. Now I want to display the available Pins on the <b>Servo/PWM Pi HAT!</b> , to controll Servos via MATLAB eventually.</p><p>Thanks in advance !</p>Ludwig Aminhttps://jp.mathworks.com/matlabcentral/profile/authors/10405759-ludwig-amintag:jp.mathworks.com,2005:Question/3530542017-08-17T09:20:50Z2017-08-17T09:20:50ZSearch for all the Divide block in a subsystem and its children<p>Hello,</p><p>I am trying to find for all the Divide blocks in a model subsystem (and its children) but with no success.
Here is the code that I use</p><pre class="language-matlab">Global_path = 'MyModel/MySubsystem';
blks = find_system(Global_path,'BlockType','Divide');
</pre><p>but with no success.
On the other hand, as I think that Divide block is basically a Product block, I use this syntax instead:</p><pre class="language-matlab">Global_path = 'MyModel/MySubsystem';
blks = find_system(Global_path,'BlockType','Product','Inputs', '*/');
</pre><p>The latter code seems to work a bit better. However, I have two questions:</p><p>1. Are we sure that I am searching only in 'MyModel/MySubsystem'? I DON'T want to search in any other submodel, i.e. 'MyModel/AnotherSubsystem' shall be exluded</p><p>2. This method is not very robust as it search only blocks that has exactly '*/' as input. If I have a block that instead would have '**/' will be excluded. How can I robustify my code? For example by searching for all the blocks that CONTAIN the string '/'?</p><p>Many thanks!</p>Ubaldohttps://jp.mathworks.com/matlabcentral/profile/authors/5040504-ubaldotag:jp.mathworks.com,2005:Question/3530532017-08-17T09:07:56Z2017-08-17T09:15:32ZWhy MATLAB swaps the nibbles while reading a byte as two nibbles. ?<p>I have a binary file with 12 bit data. If I read the data nibble wise in C++, say as ABC DEF GHI JKL then I get wrong values. If I use MATLAB function to read as nibble stream then I get correct output, though on exploring I found Matlab reads the data as BAD CFE HGJ ILK. Here each alphabet is a nibble. Three nibbles thus make one data point for me in 12 bit. Is it possible that FPGA writing the binary data also writes it as swapped nibbles so that when MATLAB reads it as swapped nibbles the data gets read correctly ?</p>Sunilhttps://jp.mathworks.com/matlabcentral/profile/authors/807332-suniltag:jp.mathworks.com,2005:Question/3529222017-08-16T09:38:14Z2017-08-17T09:10:49ZHow to assign a lat and lon value to 1 variable?<p>This may be simple but I keep getting stuck. I have a file with 3 columns and 66 rows. The second column is latitude and the third column is longitude. I need to plot them all on a map. I was wondering how to do this and if there was a way for matlab to generate the variables for me since there are 66. I would like it to be something like</p><pre class="language-matlab">station1 = (lat,lon)
station2 = (lat, lon)
</pre><p>so far all I have is</p><pre class="language-matlab">cmtable = readtable('cmtable.csv');
%% create stations
lat = cmtable(:,2);
lon = cmtable (:,3);
</pre>andrea molinahttps://jp.mathworks.com/matlabcentral/profile/authors/9708862-andrea-molinatag:jp.mathworks.com,2005:Question/3529332017-08-16T11:39:27Z2017-08-17T09:09:22ZGUIDE listbox context menu callback fails to update handles using guidata<p>Hey everybody,</p><p>has anyone encountered the following problem when trying to make a GUI using GUIDE. I wanted to have a labeltool, which contains a pushbutton named "add category". When the user press this button, he/she will be prompted to enter a name for a new label category. The GUI also contains a listbox showing/listing all categories the user has ever entered. Now what i want is to have a context menu showing up when right-clicking on an item on the listbox. I achieved this with the help from <a href = "http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions">Undocumented Matlab</a> by modifying the java component underneath the Matlab uicontrol. On the emerging context menu, i have a submenu named "add new category", when selected, it will call the callback of pushbutton "new category". Now the problem is the following:</p><p>When i press the pushbutton, every thing works just fine. The pushbutton_Callback(hObject, eventdata, handles) gets called and executes. It also stores the new listitem (using guidata(hObject, handles)) in an handle to feed the listbox, which then shows the new added category. Now when I try to call the pushbutton_Callback from the context menu within the listbox, an error occurs, because the callback input arguments <b>hObject</b> and <b>eventdata</b> are now no longer Matlab UIcontrols, but Java objects. So guidata(hObject, handles) won't work as desired.</p><p>I uploaded the corresponding .fig and .m file for the gui. I really appreciate any kind of suggestion and help. The function findjobj.m will be needed for this code to work. This can be downloaded from <a href = "https://de.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects">hier</a>. Just put them all in one folder and the code should run.</p><p>This is how the pushbutton callback looks like:</p><pre> % --- Executes on button press in pushbutton_addCategory.
function pushbutton_addCategory_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_addCategory (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</pre><pre> % prompt user to enter name for new label category
prompt = {'Enter category name:'};
dlg_title = 'Add new label category';
num_lines = 1;
defaultans = {'MyLabelCategory'};
thisLabelCategory = inputdlg(prompt,dlg_title,num_lines,defaultans);</pre><pre> if ~isempty(thisLabelCategory)
% update list box by adding new category
handles.labelCategories{end+1} = char(thisLabelCategory);
set(handles.listbox_labelCategories,'Value',1);
set(handles.listbox_labelCategories,'String',handles.labelCategories);
end
guidata(hObject, handles);</pre><p>And this is where it gets called from when using the context menu:</p><pre class="language-matlab">% --- Executes on selection change in listbox_labelCategories.
function listbox_labelCategories_Callback(hObject, eventdata, handles)
% Get the listbox's underlying Java control
jScrollPane = findjobj(handles.listbox_labelCategories);
</pre><pre class="language-matlab">% We got the scrollpane container - get its actual contained listbox control
jListbox = jScrollPane.getViewport.getComponent(0);
</pre><pre class="language-matlab">% Convert to a callback-able reference handle
jListbox = handle(jListbox, 'CallbackProperties');
</pre><pre class="language-matlab">% Prepare the context menu
menuItem1 = javax.swing.JMenuItem('Add new category');
</pre><pre class="language-matlab">% Set the menu items' callbacks
set(menuItem1,'ActionPerformedCallback',{@pushbutton_addCategory_Callback, handles}); % called here!!!!!!
</pre><pre class="language-matlab">% Add all menu items to the context menu (with internal separator)
jmenu = javax.swing.JPopupMenu;
jmenu.add(menuItem1);
jmenu.addSeparator;
</pre><pre class="language-matlab">% Set the mouse-click event callback
set(jListbox, 'MousePressedCallback', {@mousePressedCallback,handles.listbox_labelCategories,jmenu});
</pre><p>Thanks a lot in advance.</p>Jian Zhouhttps://jp.mathworks.com/matlabcentral/profile/authors/10449436-jian-zhoutag:jp.mathworks.com,2005:Question/3521872017-08-09T19:03:42Z2017-08-17T08:54:00ZIs there a way to average sequential data on an array and then be able to split the array?<p>I want to be able to split an array of n rows and 5 columns into sections every time the data of a specific column (let's call it column3) crosses zero, and every time there is a peak or valley. I want the split of the array to happen to all the data (the conditions are based on column3, but are applied to all the columns).</p><p>The data also has repeated values for the whole data set; for those values I want to average the data of each column by considering the data that was averaged for a specific column per section.</p><pre class="language-matlab">if true
%code example
column3 = [-6 -6 -6 -6 -5 -5 -3 -3 -3 -1 -1 -1 0 0 2 2 2 3 3 5 5 5 5 6 6 6 6 4 4 4 3 3 3 3 3 3 3 2 2 2 1 1 1 1 0 0 -1 -1 -2 -3 -5 -5 -5 -5 -5 -5 -5 -6 -6 -6];
</pre><p>end</p><p>I want this to end up looking like</p><pre class="language-matlab">if true
%code result
column3_1 = [-6 -5 -3 -1 0]
column3_2 = [0 2 3 5 6]
column3_3 = [6 4 3 2 1 0]
column3_4 = [0 -1 -5 -3 -5 -6]
end
</pre><p>Then these changes should be also applied to the other columns based on the rows that were averaged for column3.</p><p>-----</p><p>My line of thought is first I must apply a code to average all the values that are repeated and in sequence using a loop, then separate the sections based on peaks, valleys, and crossing zeroes.</p><pre class="language-matlab">if true
% code thought process
%first average all values
column3_avg = [-6 -5 -3 -1 -0 2 3 5 6 4 3 2 1 0 -1 -2 -3 -5 -6]
%then divide into sections
column3_1 = [-6 -5 -3 -1 0]
column3_2 = [0 2 3 5 6]
column3_3 = [6 4 3 2 1 0]
column3_4 = [0 -1 -5 -3 -5 -6]
</pre><pre class="language-matlab">end
</pre><p>The main issue is that I can't seem to average only equal sequential data. Is there an effective way to do this on Matlab with a loop or am I better off doing it all by hand?</p><p>Thank you in advance</p>yzhttps://jp.mathworks.com/matlabcentral/profile/authors/7028367-yztag:jp.mathworks.com,2005:Question/846702013-08-13T17:15:13Z2017-08-17T08:45:57ZHow to continuously real-time plotting graph from arduino to matlab (10k Variable Resistor)<p>Hello and good day to all the experts and visitors of Mat-Lab,
I am a mechatronic student and now facing problem trying to interface matlab and arduino..</p><p>I am trying to real-time plotting graph from arduino to matlab with (10k variable resistor), but the graph will stop plotting after reach the Maximun X-axis (I set 0-1000).</p><p>Can it continuously real-time plotting the graph non stop?
full of appreciation or teaching me to solve it.</p><p>the code is shown below:</p><pre class="language-matlab">a = arduino('COM3');
interv = 1000;
passo = 1;
t=1;
x=0;
while(t<interv)
b=a.analogRead(0);
x=[x,b];
plot(x);
axis([0,interv,0,1024]);
grid
t=t+passo;
drawnow;
end
</pre>Charles Limhttps://jp.mathworks.com/matlabcentral/profile/authors/4390156-charles-limtag:jp.mathworks.com,2005:Question/3530342017-08-17T05:52:59Z2017-08-17T08:42:43ZHow can i extract 4,6,7th row of my input image then i have to place 4,6th,7th row in diffrent mask image into the same position of that mask like 4th,6th,7th position.<p>How can i extract 4,6,7th row of my input image then i have to place 4,6th,7th row in diffrent mask image into the same position of that mask like 4th,6th,7th position.</p>Somhttps://jp.mathworks.com/matlabcentral/profile/authors/8113137-somtag:jp.mathworks.com,2005:Question/3529482017-08-16T13:43:24Z2017-08-17T08:42:15ZHello, can any one help me out? I have an mxn matrix with repeated columns. How can I get another matrix from this very one which is having no repetition of columns. Many thanks for anticipated assistance.<p>For example,
A=[2 3 4 4 3;
1 2 4 4 2;
2 4 6 6 4].
I wish to have a unique matrix B from A:
That is B=[2 3 4;
1 2 4;
2 4 6] having unique columns.</p>PASCHAL NYIAMhttps://jp.mathworks.com/matlabcentral/profile/authors/6820099-paschal-nyiamtag:jp.mathworks.com,2005:Question/3526592017-08-14T07:59:21Z2017-08-17T08:41:15ZI have hourly data from satellite and concurrent daily data from gauges of 11 years. how can I divide each daily data with the proportion of hourly data. Thank in advance! Girma<p>proportional division</p>Girmay Tesfayhttps://jp.mathworks.com/matlabcentral/profile/authors/10714208-girmay-tesfaytag:jp.mathworks.com,2005:Question/3530482017-08-17T08:35:17Z2017-08-17T08:35:17ZControlling *Servo Motor*s with an *RaspberryPi* + *Servo/PWM-Pi Hat!* using *MATLAB*<p>Hi,
I have to control one or more Servo motors which are plugged in a Servo/PWM-Pi Hat which is plugged in a RaspBerryPi 3 on the other hand. VIA Matlab.</p><pre class="language-matlab">if true
% >> rpi = raspi
</pre><p>rpi =</p><pre class="language-matlab">raspi with properties:
</pre><pre> DeviceAddress: 169.254.0.2
Port: 18732
BoardName: Raspberry Pi 3 Model B
AvailableLEDs: {'led0'}
AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
AvailableSPIChannels: {'CE0','CE1'}
AvailableI2CBuses: {'i2c-1'}
AvailableWebcams: {}
I2CBusSpeed: 0 </pre><pre class="language-matlab">Supported peripherals
</pre><p>>> showPins(rpi)
>> rpi.AvailableI2CBuses</p><p>ans =</p><pre class="language-matlab">cell
</pre><pre> 'i2c-1'</pre><p>>> rpi.I2CBusSpeed</p><p>ans =</p><pre> 0</pre><p>>> scanI2CBus(rpi,'i2c-1')</p><p>ans =</p><pre class="language-matlab">1×2 cell array
</pre><pre> '0x40' '0x70'</pre><p>>> i2csensor = i2cdev(rpi,'i2c-1','0x70')</p><p>i2csensor =</p><pre class="language-matlab">i2cdev with properties:
</pre><pre> Bus: 'i2c-1'
Address: '0x70'</pre><p>>> output1 = read(i2csensor,2)</p><p>output1 =</p><pre class="language-matlab">1×2 uint8 row vector
</pre><pre> 17 17</pre><p>>> output2 = readRegister(i2csensor,14)</p><p>output2 =</p><pre class="language-matlab">uint8
</pre><pre> 0</pre><p>>> i2csensor</p><p>%what do I type in here, to define the Servo motor which is connected to Pin 0 at the Servo/PWM Hat ?</p><p>>> s = servo(i2csensor,0)
Undefined function 'servo' for input arguments of type 'raspi.internal.i2cdev'.</p><pre class="language-matlab">end
</pre><p>THANKS IN ADVANCE !!!!</p>Ludwig Aminhttps://jp.mathworks.com/matlabcentral/profile/authors/10405759-ludwig-amintag:jp.mathworks.com,2005:Question/3518182017-08-07T11:45:18Z2017-08-17T08:34:03ZHow do I use image processing to determine the length of an object in an image?<p>I have two images, each with a white object of different lengths on a black background. I know the starting length but I need to calculate the final length using image processing. I have attached the images and the histograms. Is there a way of using MatLab to calculate the length of the two images or should I work out the difference in length of the two?</p><p>EDIT: Since posting this I have began my experiments. The actual images I am trying to process are the tyres with white stripes on them. The white stripes skew and increase in length in y but all I am interested in is the length in x direction</p><img src = "/matlabcentral/answers/uploaded_files/84855/grey_test.jpg"><img src = "/matlabcentral/answers/uploaded_files/84856/grey_hist.jpg">Malcolm Armstronghttps://jp.mathworks.com/matlabcentral/profile/authors/10084453-malcolm-armstrongtag:jp.mathworks.com,2005:Question/3530462017-08-17T08:12:27Z2017-08-17T08:12:27Z伝達関数tfの使い方について<p>1/S,1/s^2のインパルス応答を求めたいと考えています。</p><p>そこでtfを用いてインパルス応答を出したいと考え以下のコードを作成いたしました。</p><p>sys = tf(1,[1 0]);</p><p>impulse(sys)</p><p>本コードを実行したところ</p><p>エラー: DSM_TF (line 10)</p><p>sys = tf(1,[1 0]);</p><p>という風にエラーが発生し、実行することができませんでした。何に対してエラーが出ているのでしょうか。</p>O.Ehttps://jp.mathworks.com/matlabcentral/profile/authors/9008779-o-etag:jp.mathworks.com,2005:Question/3530452017-08-17T08:04:15Z2017-08-17T08:04:15ZSample Time Issue Using Pulse Generator Inside a If Action Subsystem<p>I have a Simulink model running in discrete time. Inside one portion of a subsystem I have a if action subsystem, inside of this is a pulse generator running a Stateflow chart. I get the following error:</p><pre class="language-matlab">Sample time 0.05 of 'System/SystemPerCar/Determine/Protection/Level Protection/Pulse Generator2' does not match the sample time [0, 1] of the If block 'System/SystemPerCar/Determine Mode/Level Protection/If' controlling its execution.
</pre><p>It's a bit unusual that I had this working previously, until a coworker added some work in another subystem (if-enabled) that uses some of the outputs, and then I started receiving this error. His subsystem is within the same reference model as mine and everything is running at the same Sample Time. Unfortunately, I cannot attached the model as it's work related.</p><p>The image below is the two different set of settings I have tried to get this working. I had the TimeBased one previously working, but including the Sample Based to show I had tried.</p><img src = "/matlabcentral/answers/uploaded_files/85754/PulseGenerators.PNG"><p>.</p><p>As the issue didn't start until my co-worker added his work I am unsure if fixing it at the generator is even the issue.</p><p>Thank you for any help,</p>umichguy84https://jp.mathworks.com/matlabcentral/profile/authors/2726879-umichguy84tag:jp.mathworks.com,2005:Question/3528042017-08-15T10:39:37Z2017-08-17T07:58:08ZIssues with parfor, strsplit and MATLAB path<p>Hi</p><p><i>(MATLAB 9.2.0.556344 (R2017a) on Windows 10)</i></p><p>I am testing out the parfor function, and I run into some unexpected behaviour:</p><p>1) It seems like the order in MATLAB path changes during parfor</p><p>2) The MATLAB function strsplit seems to not work as expected in parfor</p><p>(Using parfor in the examples below is of course meaningless. But the strsplit is only a small part of a larger code which is supposed to run in parallel).</p><p><b>Example of #1:</b></p><p>I use the function library of Peter J Acklam, which had a strsplit before MATLAB introduced this function. His function takes the separator as first argument and string as second (reversed compared to MATLAB's strsplit). I am using other of his functions, so I have him added to my MATLAB path, but with lower priority than MATLAB functions. When I run this code:</p><pre class="language-matlab">a = 'hello_world';
disp('Strsplit before parfor:');
disp(strsplit(a, '_'));
disp(' ');
disp('Strsplit during parfor:');
parfor (n = 1 : 1, 4)
disp(strsplit('_', a));
end
disp(' ');
disp('Strsplit after parfor:');
disp(strsplit(a, '_'));
</pre><p>I get the following output</p><pre class="language-matlab">Strsplit before parfor:
'hello' 'world'
</pre><pre class="language-matlab">Strsplit during parfor:
** Using strsplit to Peter J. Acklam **
'hello' 'world'
</pre><pre class="language-matlab">Strsplit after parfor:
'hello' 'world'
</pre><p>Note that I added a comment inside Peter's strsplit (** Using strsplit to Peter J. Acklam <b>**</b>), and I am also forced to change the order of input arguments to make the code run.</p><p><b>Example of #2:</b></p><p>To avoid #1 from happening for strsplit, I can just rename Peter's strsplit to e.g. xstrsplit. But when I do that and update my code, MATLAB's strsplit seems to fail in parfor. After renaming, I run this code:</p><pre class="language-matlab">a = 'hello_world';
disp('Strsplit before parfor:');
disp(strsplit(a, '_'));
disp(' ');
disp('Strsplit during parfor:');
parfor (n = 1 : 1, 4)
disp(strsplit(a, '_'));
end
disp(' ');
disp('Strsplit after parfor:');
disp(strsplit(a, '_'));
</pre><p>and I get this output</p><pre class="language-matlab">Strsplit before parfor:
'hello' 'world'
</pre><pre class="language-matlab">Strsplit during parfor:
'hello_world'
</pre><pre class="language-matlab">Strsplit after parfor:
'hello' 'world'
</pre><p>Any input on what I am doing wrong is welcome.</p>Erling Hugohttps://jp.mathworks.com/matlabcentral/profile/authors/5920934-erling-hugotag:jp.mathworks.com,2005:Question/288942012-02-13T10:20:54Z2017-08-17T07:56:19ZProblem trying to load .dll library using 'loadlibrary', error is, A 'Selected' compiler was not found. You may need to run mex -setup.<p>I am a beginner on using the loadlibrary function and using .dll files, so I will appreciate any help I can get.</p><p>I am trying to load a .dll file with a header file, I am using:</p><p>>> loadlibrary('nameoflibrarydll', 'nameofheaderfile')</p><p>and it comes up with the error:</p><p>??? Error using ==> loadlibrary at 264
A 'Selected' compiler was not found. You may need to run mex -setup.</p><p>I do not understand what 'mex' is?</p><p>I think a problem is is that the .dll file is written using an old version of Matlab, and it needs to be used using Matlab 2011a. This is so that I can access functions from the header file, the codes of which probably need updating also to run in the new version of Matlab.</p><p>I also tried the same line of code for loadlibrary on a different computer and it comes up with the error:</p><p>C:\Users\User One\Documents\MATLAB Pentools\Wintab32.dll is not a
valid Win32 application.</p><p>I understand the problem is to do with 32 bit and 64 bit versions of windows, but I do not understand what this means. If anyone could help explain what all the terminology means and how you think I may be able to proceed with accessing the .dll file, I would be most grateful.</p>hdehttps://jp.mathworks.com/matlabcentral/profile/authors/3317595-hdetag:jp.mathworks.com,2005:Question/3530442017-08-17T07:25:13Z2017-08-17T07:54:04ZSolve a system of 6 equation<p>Hi, i have a system from 6 equation and 6 variables, but there not linear, the max order in a equation is 4</p><p>(for example T^4=A B^2 C^3 D E),
how can i solve it in matlab ?</p>antonio chahinehttps://jp.mathworks.com/matlabcentral/profile/authors/5281316-antonio-chahinetag:jp.mathworks.com,2005:Question/988322009-06-27T01:11:00Z2017-08-17T07:50:34ZWhy does DATENUM give me an error message when I pass German date strings as input arguments in MATLAB?<p>I have set the locale settings on my computer to German. When I execute the following command in MATLAB:</p><pre class="language-matlab">d = dir;
</pre><p>A structure is returned that contains a field called 'date'. However, this field contains German time stamps. For example:</p><pre> 11-Dez-2007 08:23:16</pre><p>When I pass the above date string to DATENUM as follows:</p><pre class="language-matlab">datenum('11-Dez-2007 08:23:16')
</pre><p>I receive the following error message:</p><pre class="error"> </pre><pre> ??? DATENUM failed.</pre><pre> Failed to parse date string.</pre><pre> Error using ==> datevec at 217</pre><pre> Failed to lookup month of year. </pre>MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:jp.mathworks.com,2005:Question/3530392017-08-17T06:39:38Z2017-08-17T07:45:09ZA bug im simplify in the new Symbolic Toolbox?<p>Dear developpers
Recently I run my codes in my book in the new versions of MATLAB</p><pre class="language-matlab">if true
A=[-7,2,0,-1; 1,-4,2,1; 2,-1,-6,-1; -1,-1,0,-4];
syms t, A1=(expm(A*1j*t)-expm(-A*1j*t))/(2*1j);
A2=(expm(A*1j*t)+expm(-A*1j*t))/2;
simplify(A1), simplify(A2)
end
</pre><p>I found that the results are not the same as the ones in the earlier versions such as R2011a, R2008a, which yield the saame results as funm(A*t,'sin'). Obviously the simplify function in the new Symbolic Math Toolbox did not apply Euler's formula.</p>Dingyu Xuehttps://jp.mathworks.com/matlabcentral/profile/authors/18133-dingyu-xuetag:jp.mathworks.com,2005:Question/3528072017-08-15T10:57:31Z2017-08-17T07:44:50ZHow can I change the line color in the output of imhist?<p>imhist provides the output in blue lines;i want to change it into say either red or green</p>Suresh Kumarhttps://jp.mathworks.com/matlabcentral/profile/authors/9801109-suresh-kumar