http://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-05-24T17:26:51Ztag:de.mathworks.com,2005:Question/2184362015-05-24T17:25:48Z2015-05-24T17:26:51ZI am trying to run a DFT code but I am getting a single line constant plot versus time instead of getting samples in the plot. <p>Even though values of samples are changing but not been shown in the final plot. Can anybody help me with it?</p><p>I can share the code too if anyone is up for assistance please.</p>Hafsa Mustafahttp://de.mathworks.com/matlabcentral/profile/authors/5579892-hafsa-mustafatag:de.mathworks.com,2005:Question/2184322015-05-24T16:33:20Z2015-05-24T17:18:04ZStop the execution of a function with a push button (GUIDE)<p>Hiya!</p><p>I have a program, which analyzes a series of images extracting data from them. Now, I have been asked to make a gui in order to be more easily used. I have gotten stuck in the part where I call the program itself from the gui (which, by the moment, is a separate program (m-file)).</p><p>The calling of the program is easy, and it works. But, the proccess is long, and sometimes the user wants to stop it, in order to change configuration, for example. I can't do the cancelling part. Here is a scheme of what I've got, and what do I want</p><p>[GUIDE]</p><p>button
-> Calls program.m (and it runs well)</p><p>button2
-> Stops program.m (this doesn't work) by changing the 'closing' variable to 1</p><p>[program.m]</p><p>while i< number of images
if 'closing' == 1 -> exit program
if not -> analyze the i image</p><p>Thank you in advance for your time and your response</p>Lednion Bazarhttp://de.mathworks.com/matlabcentral/profile/authors/5571446-lednion-bazartag:de.mathworks.com,2005:Question/2183212015-05-23T22:31:02Z2015-05-24T17:14:24ZCD statment and connection from matlab to C# ?<p>i have created matlab file (function) which contains save statment
i have to save image histogram value(Hist)</p><pre class="language-matlab">folder_name= 'query' ;
addpath(folder_name);
file_name = [folder_name 'image(1)'];
save(file_name,'Hist');
</pre><p>this runs perfectly using matlab with no problem
the problem occurs when i run the code using C# after converting the matlab file to .dll file
it cannot addpath to folder_name or find it although i have added the folder to the package of deployment tool</p>sara selimhttp://de.mathworks.com/matlabcentral/profile/authors/6555274-sara-selimtag:de.mathworks.com,2005:Question/2184222015-05-24T14:32:28Z2015-05-24T17:11:26ZHow to get rid of the error message set(0,'RecursionLimit',N) ?<p>Error message:</p><pre class="language-matlab">??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
</pre><p>Hi Jan Simon,</p><p>The code is as follows.</p><p>1) The code below is run for an output</p><p>clear all
close all
clc</p><p>a=1;
b=1;
c=1;
dvec=[1 0 0]; %direction vector for prolate spheroid</p><p>uinfinity=[1 0 0]'; %flow at infinity</p><p>N=8;</p><p>% mesh for collocation
mesh='triangles'; % 'triangles', 'cuboid' or 'tensorproduct'
meshparam=5; % this parameter changes depending on 'mesh'
% 'triangles': number of subdivisions for triangle mesh (n yields grid with 2^(2*(n+2)) points)
% 'cuboid': size of face-subdivisions for cuboid grid (n yields grid with 6*n^2 points provided n is even. If n is odd, poles are removed)
% 'tensorproduct': number of theta-subdivisions for
% tensorproduct grid (n yields grid with 2n^2 points)</p><p>thDragGrid=15; % mesh for drag integration
phiDragGrid=2*thDragGrid;</p><p>tic;F=CalculateCoefsSquimmer(a,b,c,uinfinity,N,mesh,meshparam);toc</p><p>2) The subprogram CalculateCoefsSquimmer(a,b,c,uinfinity,N,mesh,meshparam) is called in the above code in 1)</p>Debajyoti Choudhurihttp://de.mathworks.com/matlabcentral/profile/authors/6556497-debajyoti-choudhuritag:de.mathworks.com,2005:Question/2184352015-05-24T17:10:43Z2015-05-24T17:10:43ZLeast Square Method Output: 2 parameters and residual<p>Hi there,</p><p>for an university project we need urgent help.</p><p>1) We need to estimate 2 parameters (intercept with y-axes, and the slope of the line) and the residual of a stochastic model by using 2 columns. The problem is if we use lsqr we only get the slope and the residual.</p><p>2) We imported some data using xlsread and matlab created a variable as a table. We want to create a Matrice with some data out of the table and don't know the correct syntax for doing that, because the colummns and rows are not named with letters, so we don't how to adress for example row 2 and column 3.</p><p>Best wishes and thank you for your help!
Steffen</p>Stefan Meyerhttp://de.mathworks.com/matlabcentral/profile/authors/6556971-stefan-meyertag:de.mathworks.com,2005:Question/2184342015-05-24T17:10:24Z2015-05-24T17:10:24ZUnit Commitment with capacity market<p>Hi,nice to meet you. I have to build a simulation model of wholesale Energy market with a capacity market.
How could I create and link these two markets?</p>Andrea Grengahttp://de.mathworks.com/matlabcentral/profile/authors/6556982-andrea-grengatag:de.mathworks.com,2005:Question/2184202015-05-24T14:12:18Z2015-05-24T17:08:17ZHow to find minimal N so that the error<10^-7?<p><<</p><img src = "/matlabcentral/answers/uploaded_files/31457/20150524_170415.jpg"><img src = "/matlabcentral/answers/uploaded_files/31456/1.PNG"><p>>></p>david davidhttp://de.mathworks.com/matlabcentral/profile/authors/6556603-david-davidtag:de.mathworks.com,2005:Question/2184332015-05-24T17:07:04Z2015-05-24T17:07:04ZPlotting 2 functions with respect to each other<p>I defined the following functions:</p><pre class="language-matlab">function alpha = error1(T)
syms x y
P0 = 1/(2*pi*0.6)*exp(-1/(2*0.36)*(x^2+y^2-2*0.8*x*y));
P1 = 1/(2*pi*1)*exp(-1/(2*1)*(x^2+y^2));
L1 = int(P1,x,-inf,0)/int(P0,x,-inf,0);
L2 = int(P1,x,0,+inf)/int(P0,x,0,+inf);
I1 = int(P0,x,-inf,0);
I2 = int(P0,x,0,+inf);
</pre><pre class="language-matlab">alpha = int(I1,y,L1>T)+ int(I2,y,L2>T);
end
</pre><pre class="language-matlab">function beta = error2(T)
syms x y
P0 = 1/(2*pi*0.6)*exp(-1/(2*0.36)*(x^2+y^2-2*0.8*x*y));
P1 = 1/(2*pi*1)*exp(-1/(2*1)*(x^2+y^2));
L1 = int(P1,x,-inf,0)/int(P0,x,-inf,0);
L2 = int(P1,x,0,+inf)/int(P0,x,0,+inf);
I1 = int(P1,x,-inf,0);
I2 = int(P1,x,0,+inf);
</pre><pre class="language-matlab">beta = int(I1,y,L1<T)+ int(I2,y,L2<T);
end
</pre><p>I don't if there's a problem in the expressions of alpha and beta, but what I mean is that Im trying to integrate I1 for example over the domain L1(y) < T.</p><p>After that I defined:</p><pre class="language-matlab">t = 0:0.01:30;
y1 = error1(t);
</pre><p>I get the following error:</p><pre class="language-matlab">Error using mupadmex
Error in MuPAD command: The argument is invalid. [Dom::Interval::new]
</pre><pre class="language-matlab">Error in sym/int (line 124)
rSym = mupadmex('symobj::intdef',f.s,x.s,a.s,b.s,options);
</pre><pre class="language-matlab">Error in error2 (line 10)
beta = int(I1,y,L1<T)+ int(I2,y,L2<T);
</pre>Maggie Mhannahttp://de.mathworks.com/matlabcentral/profile/authors/6549073-maggie-mhannatag:de.mathworks.com,2005:Question/2181412015-05-22T13:09:44Z2015-05-24T16:59:28ZDefining and plotting 2 parametric functions <p>I'm new to Matlab, I defined the following functions:</p><pre class="language-matlab">function L1 = Like1(y)
P0 = 1/(2*pi*0.6)*exp(-1/(2*0.36)*(x^2+y^2-2*0.8*x*y));
P1 = 1/(2*pi*1)*exp(-1/(2*1)*(x^2+y^2));
L1 = int(P1,x,-inf,0)/int(P0,x,-inf,0);
end
</pre><pre class="language-matlab">function L2 = Like2(y)
P0 = 1/(2*pi*0.6)*exp(-1/(2*0.36)*(x^2+y^2-2*0.8*x*y));
P1 = 1/(2*pi*1)*exp(-1/(2*1)*(x^2+y^2));
L2 = int(P1,x,0,+inf)/int(P1,x,0,+inf);
end
</pre><pre class="language-matlab">function I1 = Int1(y)
P0 = 1/(2*pi*0.6)*exp(-1/(2*0.36)*(x^2+y^2-2*0.8*x*y));
I1 = int(P0,x,-inf,0);
end
</pre><pre class="language-matlab">function I2 = Int2(y)
P0 = 1/(2*pi*0.6)*exp(-1/(2*0.36)*(x^2+y^2-2*0.8*x*y));
I2 = int(P0,x,0,+inf);
end
</pre><pre class="language-matlab">function I3 = Int3(y)
P1 = 1/(2*pi*1)*exp(-1/(2*1)*(x^2+y^2));
I1 = int(P1,x,-inf,0);
end
</pre><pre class="language-matlab">function I4 = Int4(y)
P1 = 1/(2*pi*1)*exp(-1/(2*1)*(x^2+y^2));
I2 = int(P1,x,0,+inf);
end
</pre><p>and I'm trying to plot the following two functions:</p><pre class="language-matlab">function alpha = error1(T)
syms y;
alpha = int(Int1(y),y,solve(Like1(y)>T,y))+ int(Int2(y),y,solve(Like2(y)>T,y));
end
</pre><pre class="language-matlab">function beta = error2(T)
syms y;
beta = int(Int3(y),y,solve(Like1(y)<T)) + int(Int4(y),y,solve(Like2(y)<T))
end
</pre><p>I have 2 questions , when I run this function editer, I keep getting the error "Undefined function or variable 'T'".</p><p>Once I solve this issue, what would be the next step to plot error2(T) vs. error1(T).</p>Maggie Mhannahttp://de.mathworks.com/matlabcentral/profile/authors/6549073-maggie-mhannatag:de.mathworks.com,2005:Question/2184282015-05-24T15:36:09Z2015-05-24T16:57:10ZHow can I define a a column of 180 rows as variable "x" in order to use the fmincon function?<p>Dear all,</p><p>First of all, I'd like to say that I'm not experienced in working with Matlab, and please excuse me if I make mistakes.</p><p>I have to maximize an objective function using fmincon, as my obj. fun. is a linear programming problem with linear constraints "Aeq" and a non-linear constraint "nonlcon". Basically, my objective function is a sumproduct function :
f=sum(a(1:180).*x(1:180)), where a(1:180) are my parameters (known). What I don't know how to do, is to define the X (my 1 column and 180 rows matrix containing 180 variables). Kindly think of X as X(1), X(2) to X(180).</p><p>Thank you a lot in advance!</p><p>Kind regards,
Alex</p>Alex Stefhttp://de.mathworks.com/matlabcentral/profile/authors/6555807-alex-steftag:de.mathworks.com,2005:Question/2183852015-05-24T08:08:44Z2015-05-24T16:57:06ZHow can I convert individual guis into a single tabbed gui?<p>I have a gui that pops up another gui when a button is pressed. I'd like to convert this into a single gui with two tabs. Can anybody help me to do this without rewriting the whole thing?</p>John Billinghamhttp://de.mathworks.com/matlabcentral/profile/authors/126241-john-billinghamtag:de.mathworks.com,2005:Question/2184302015-05-24T16:07:00Z2015-05-24T16:56:44Zi have matrix A and C how can i find the relation between element of matrix B? A*B=C<p>hello every one i have 3 different matrix such as A=[a b;c d] and B=[X1;X2] and C=[K;K2] then A*B=C how can i find i find the relation between element of matrix B? can you explain thank you</p>amina shafanejadhttp://de.mathworks.com/matlabcentral/profile/authors/6444926-amina-shafanejadtag:de.mathworks.com,2005:Question/2184312015-05-24T16:31:41Z2015-05-24T16:48:45ZHow do I iterate a cell?<p>Hello everyone,</p><p>I'm trying to code something in Matlab using the cogent toolbox to have a text box appear on the screen after subjects complete a portion of a particular task. This text box should cycle through the cell "warning.text" so that the first textbox says "none", the second "strong", the third "weak", and back to "none" etc.. ad infinitum. My code is found below; Matlab is showing an error on this line: "warning.text = {warning_state};".</p><p>What exactly can I do to fix my code?</p><pre> %%Create Warning Screen
warning_state = 1
warning = expBuilder.TextBox();
warning.text = {'NONE','STRONG','WEAK'};
warning.text = {warning_state};
warning.fontSize = 30;
warning.width = 500;
warning.height = 40;
warning.frontColor = foreground;
[warning.elementBackColor, warning.backColor] = deal(background);
warning.make();
%% your thingy.text = text{... selector ...}</pre><pre> warning_state = warning_state + 1;
%% thingy.remake
% warning.remake();
%% thingy.draw(); or drawNow -> remove flip
warning.draw();
% drawnow;</pre><pre class="language-matlab">%% wait ...
WARNING_TIMEOUT = 2000/SPEED
% wait(WARNING_TIMEOUT);
</pre><pre> cgflip(background);</pre><pre> wait(WARNING_TIMEOUT);</pre>Jonathan Pricehttp://de.mathworks.com/matlabcentral/profile/authors/6061727-jonathan-pricetag:de.mathworks.com,2005:Question/2184292015-05-24T15:52:15Z2015-05-24T16:47:48ZCommand 'hold on' does not work for boxplot when overlapping a figure<p>Hello,</p><p>I've got a boxplot with xlimits from 0.1 to 1.0 and from ylimits from 0 to 1.6.</p><p>I want to overlap a plot of just 5 points (plotted as dots) with xlimits from 0.18 to 0.4 and the y values being only 2.0.</p><p>However, the hold on function does not seem to work.</p><p>Any thoughts of that?</p><p>Thank you!</p>Christinahttp://de.mathworks.com/matlabcentral/profile/authors/2037804-christinatag:de.mathworks.com,2005:Question/2184212015-05-24T14:15:06Z2015-05-24T16:36:52ZHow to make a string == one string in a cell array<p>I need to make a chatbot for an assignment and im having trouble with this part of the script</p><pre> x = input('+ ', 's');
if x == {'hey','hi','hello'};
disp('Hello')</pre><p>So if the user says hi, hey or hello, the script will print hello.</p><p>But when I type in, for example, 'hey' I get the error</p><p>Undefined function 'eq' for input arguments of type 'cell'.</p><p>Error in Bot (line 3)
if x == {'hey','hi'};</p><p>Cheers</p>ali bhttp://de.mathworks.com/matlabcentral/profile/authors/6556593-ali-btag:de.mathworks.com,2005:Question/2183892015-05-24T09:11:47Z2015-05-24T16:19:28Zfinding the index of str's charachter from another vector<p>hello
who can help me for correcting this error:
str vector contains 57 character and X vector 1560 charaters.
i was finding the index of str's charachter from excel data and results become 56 while i was estimating 57 because the size of str vector was 57.
so i need help for this problem.</p><pre class="language-matlab">X={'as modeling of changes in backbone conformation still lacks a computationally efficient solution, we developed a discretisation of the conformational states accessible to the protein backbone similar to the successful rotamer approach in side chains. The BriX fragment database, consisting of fragments from 4 to 14 residues long, was realized through identification of recurrent backbone fragments from a non-redundant set of high-resolution protein structures. brix contains an alphabet of more than 1,000 frequently observed conformations per peptide length for 6 different variation levels. analysis of the performance of brix revealed an average structural coverage of protein structures of more than 99 percent within a root mean square distance of 1 angstrom. globally, we are able to reconstruct protein structures with an average accuracy of 0.48 angstrom rmsd. as expected, regular structures are well covered, but, interestingly, many loop regions that appear irregular at first glance are also found to form a recurrent structural motif, albeit with lower frequency of occurrence than regular secondary structures. larger loop regions could be completely reconstructed from smaller recurrent elements, between 4 and 8 residues long. finally, we observed that a significant amount of short sequences tend to display strong structural ambiguity between alpha helix and extended conformations. when the sequence length increases, this so-called sequence plasticity is no longer observed, illustrating the context dependency of polypeptide structures.'};
str='steganography is the art and science of covered or hidden';
for m = 1:numel(X)
Y = bsxfun(@eq,X{m}(:),str);
for n = 2:size(Y,2)
Y(:,n) = Y(:,n) & cumsum(Y(:,n-1))>0;
end
Z = find(any(diff([false(size(str));cumsum(Y)>0],1),2))
end
</pre>abdulkarim hassanhttp://de.mathworks.com/matlabcentral/profile/authors/6394246-abdulkarim-hassantag:de.mathworks.com,2005:Question/2183842015-05-24T08:07:27Z2015-05-24T16:16:48ZAre there commands to close desktop windows like workspace, figure, command history?<p>We can close those windows using 'x' mark on the window but I want to close using commands at the prompt. Are there any commands? Of course, I know at least one command that opens a window - workspace.</p>Seetha Rama Raju Sanapalahttp://de.mathworks.com/matlabcentral/profile/authors/4039479-seetha-rama-raju-sanapalatag:de.mathworks.com,2005:Question/2184262015-05-24T15:05:17Z2015-05-24T16:09:38ZWarning: The data cannot be plotted because it is incompatible with the size of the plot or is missing<p>I'm not resolve this error Matlab 2011a.</p><p>My script should work normally but I n unable to view.</p><p>Could you help me ??</p><p>script:</p><pre class="language-matlab">% VIENNA rectifier analysis - state space
L=3.15e-3; %Filter Inductor
C=66E-6; %Filter Capacitor
rc=0.8; %Filter Capacitor ESR
Dp=0.384; %Positive duty cycle
Dn=1; %Negative duty cycle
RL=490; %Equivalent Output Load
vp=143.7; %Positive voltage
vn=-71.85; %Negative voltage
Ip=4.64;
In=-2.32;
Vref=2.5; %Reference voltage
Vout=700; %Output voltage
Rsense=0.17; %Sensing resistance
Vm=1.92;
VLL=176; %RMS input voltage
% main program
syms s Dp Dn X30 X40
X10=Ip;
X20=In;
sI=[[s 0 0 0];[0 s 0 0];[0 0 s 0];[0 0 0 s]];
%(1-Dp) terms
A_1=[[0 0 -2/(3*L) 0];[0 0 1/(3*L) 0];[1/C 0 0 0];[0 0 0 0]];
B_1=[[0];[0];[0];[0]];
C_1=[0 0 0 0];
% (1-Dn) terms
A_2=[[0 0 0 -1/(3*L)];[0 0 0 2/(3*L)];[0 0 0 0];[0 -1/C 0 0]];
B_2=[[0];[0];[0];[0]];
C_2=[0 0 0 0];
% Constant terms
A_3=[[0 0 0 0];[0 0 0 0];[0 0 -1/(C*(2*rc+RL)) -1/(C*(2*rc+RL))];[0 0 -1/(C*(2*rc+RL)) -1/(C*(2*rc+RL))]];
B_3=[[vp/L];[vn/L];[0];[0]];
C_3=[0 0 1 1];
S=solve( ((1-Dp)*A_1(1,:)+(1-Dn)*A_2(1,:)+A_3(1,:))*[[X10];[X20];[X30];[X40]]+(1-Dp)*B_1(1)+(1-Dn)*B_2(1)+B_3(1), ((1-Dp)*A_1(2,:)+(1-Dn)*A_2(2,:)+A_3(2,:))*[[X10];[X20];[X30];[X40]]+(1-Dp)*B_1(2)+(1-Dn)*B_2(2)+B_3(2), ((1-Dp)*A_1(3,:)+(1-Dn)*A_2(3,:)+A_3(3,:))*[[X10];[X20];[X30];[X40]]+(1-Dp)*B_1(3)+(1-Dn)*B_2(3)+B_3(3), ((1-Dp)*A_1(4,:)+(1-Dn)*A_2(4,:)+A_3(4,:))*[[X10];[X20];[X30];[X40]]+(1-Dp)*B_1(4)+(1-Dn)*B_2(4)+B_3(4));
S.Dp=double(S.Dp(1));
S.Dn=double(S.Dn(1));
V1=double(S.X30(1));
V2=double(S.X40(1));
V1=Vout/2;
V2=Vout/2;
A=(1-S.Dp)*A_1+(1-S.Dn)*A_2+A_3;
sI_A=sI-A;
inv_sI_A=inv(sI_A);
X=[[Ip];[In];[V1];[V2]];
[N1,D1]=numden(inv_sI_A(1,1));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_11=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(1,2));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_12=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(1,3));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_13=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(1,4));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_14=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(2,1));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_21=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(2,2));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_22=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(2,3));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_23=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(2,4));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_24=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(3,1));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_31=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(3,2));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_32=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(3,3));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_33=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(3,4));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_34=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(4,1));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_41=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(4,2));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_42=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(4,3));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_43=tf(Npoly,Dpoly);
[N1,D1]=numden(inv_sI_A(4,4));
Npoly=sym2poly(N1);
Dpoly=sym2poly(D1);
Npoly=Npoly/Dpoly(1);
Dpoly=Dpoly/Dpoly(1);
A_44=tf(Npoly,Dpoly);
ip=[(-A_13*Ip/C+2*A_11*V1/(3*L)-A_12*V1/(3*L)) (A_14*In/C+A_11*V2/(3*L)-2*A_12*V2/(3*L))];
in=[(-A_23*Ip/C+2*A_21*V1/(3*L)-A_22*V1/(3*L)) (A_24*In/C+A_21*V2/(3*L)-2*A_22*V2/(3*L))];
v2=[(-A_43*Ip/C+2*A_41*V1/(3*L)-A_42*V1/(3*L)) (A_44*In/C+A_41*V2/(3*L)-2*A_42*V2/(3*L))];
v1=[(-A_33*Ip/C+2*A_31*V1/(3*L)-A_32*V1/(3*L)) (A_34*In/C+A_31*V2/(3*L)-2*A_32*V2/(3*L))];
vo=v1+v2;
vctl_p=(Rsense)*(2*ip+in);
vctl_n=(Rsense)*(-2*in-ip);
Tfb=(Vref/Vout);
Out_matrix=[[v1];[v2]];
Ctl_matrix=[[vctl_p];[vctl_n]];
Ctl_matrix=minreal(Ctl_matrix);
det_Ctl_matrix=Ctl_matrix(1,1)*Ctl_matrix(2,2)-Ctl_matrix(2,1)*Ctl_matrix(1,2);
det_Ctl_matrix=minreal(det_Ctl_matrix);
inv_Ctl_matrix=(1/det_Ctl_matrix)*[[Ctl_matrix(2,2) -Ctl_matrix(1,2)];[-Ctl_matrix(2,1) Ctl_matrix(1,1)]];
inv_Ctl_matrix=minreal(inv_Ctl_matrix);
%Open loop transfer function analysis
Out_matrix=minreal(Out_matrix);
inv_Ctl_matrix=minreal(inv_Ctl_matrix);
Tol=Tfb*[[2] [2]]*(Out_matrix*inv_Ctl_matrix);
Tol2=minreal((Tol(1)+Tol(2)),0.5);
bode(Tol2,{1;100E3});
</pre>Louange Braxtyhttp://de.mathworks.com/matlabcentral/profile/authors/6087709-louange-braxtytag:de.mathworks.com,2005:Question/2183672015-05-24T07:14:47Z2015-05-24T15:59:56ZEfficient implementation of linprog<p>I am using linprog to solve a linear optimization problem with thousands of constraints. I have noticed that for constraints more than a few thousand the matlab implementation of linprog performs very slow. Are there any GPU(CUDA) or parallel implementations of linprog available within Matlab or elsewhere ?</p>sidhttp://de.mathworks.com/matlabcentral/profile/authors/4250706-sidtag:de.mathworks.com,2005:Question/2183932015-05-24T09:31:28Z2015-05-24T15:53:39Z[HELP] RGB histogram of an object<p>Hey guys!! I'm new on MATLAB and I was trying to build the RGB histogram of the object that appears in an image.
To do that I have the image of the background and the image of the same background with the object in the foreground.</p><p>I tried this code but it doesn't work :( Any ideas?</p><pre class="language-matlab">A = imread('background.jpg');
B = imread('image.jpg');
d = double(B)- double(A);
R = d(:, :, 1);
G = d(:, :, 2);
B = d(:, :, 3);
Color = d/255;
surf(R,G,B,Color);
</pre><p>Thank youuu!! =)</p>amelia_3http://de.mathworks.com/matlabcentral/profile/authors/6389300-amelia_3tag:de.mathworks.com,2005:Question/2184272015-05-24T15:26:27Z2015-05-24T15:49:10Zi have matrix A and C how can i find matrix B A*B=C<p>hello every one i have 3 different matrix such as A=[1 2;3 4] and B=[X1;X2] and C=[5;6]
then A*B=C how can i find matrix B?
can you explain thank you</p>amina shafanejadhttp://de.mathworks.com/matlabcentral/profile/authors/6444926-amina-shafanejadtag:de.mathworks.com,2005:Question/2184252015-05-24T15:02:36Z2015-05-24T15:24:45Zdraw eigenvalues of matrix in z-plane <p>hi how i can calculate and plot eigenvalues of state space matrix -A- in z-plane?</p><p>thanks</p>mohammadhttp://de.mathworks.com/matlabcentral/profile/authors/5679599-mohammadtag:de.mathworks.com,2005:Question/2183422015-05-24T05:21:14Z2015-05-24T14:52:43ZHow to do curve fitting to a custom model with two independent variables? <img src = "/matlabcentral/answers/uploaded_files/31444/fitting.png"><p>I have data in which response is dependent upon two variables. Three data series are given:[x1, y1], [x2, y2], [x3, y3].
On excel (file attached) I have made XY scatter plot which gives three response curves.
I want to fit these 3 curves to a custom model in the form: lnY = k*lnX + (a/T) + b
This model is used to describe such data in our field.
I just don't know how I will fit all three curves to this model? Please help!</p>wahab maqboolhttp://de.mathworks.com/matlabcentral/profile/authors/6555678-wahab-maqbooltag:de.mathworks.com,2005:Question/2184232015-05-24T14:51:43Z2015-05-24T14:51:43ZHow to calculate accuracy and precision of feature extraction<p>How to calculate accuracy and precision of Gabor Filter and Haar Wavelet Transform of feature extraction?</p>Chris Jademanhttp://de.mathworks.com/matlabcentral/profile/authors/6319024-chris-jademantag:de.mathworks.com,2005:Question/2173862015-05-18T15:22:57Z2015-05-24T14:49:07ZQuadratic numbers in matlab<p>I inverted a matrix H with entries from quadratic field, e.g., Q(sqrt(3)) and the inverted matrix G gives me entries also from Q(sqrt(3)), e.g., entry at (1,1) is 12 - 8*3^(1/2). However, is there a way to decouple integer coefficient 12 and -8? I want to store these integer values separately.</p><p>In fact I want to generate two integer matrices G1 and G2 from G which contains integer coefficients of each entry in G.</p><p>Can anyone suggest how can I do it??</p><p>Thanks in advance !</p>Mayur Punekarhttp://de.mathworks.com/matlabcentral/profile/authors/6536264-mayur-punekartag:de.mathworks.com,2005:Question/2183972015-05-24T10:17:30Z2015-05-24T14:34:59ZProblem with creating an array containing position of a mass on spring with external force.<p>I’m trying to simulate the position of a mass on a spring. An external force either pushes the mass so the spring is pulled, pushes the masse in the opposite direction so the spring is pushed or it doesn’t push at all.
The following array contains the external force as a function of time.</p><pre> F_c = [0,0,0,1,1,1,1,1,1,1,0,0,0,-1,-1,-1,0,0,0,-1,-1,-1,-1,-1,0,0,0,0,0,0,1,1,0,0,0,-1,-1,-1,0,0,0,0,0,0,1,1,1,0,0,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1,0,0,0,0,0,0,0,0,-1,-1,-1,-1,0,0,0,1,1,1,0];</pre><p>I’ve defined an empty array F_s with the same size as F_c. This should contain the spring force.</p><pre> F_s = zeros(1,size(F_c,2));</pre><p>Similarly I’ve also defined three arrays a, v, and f which should contain the acceleration of the mass, the velocity of the mass and the distance from rest respectively.</p><pre> a = zeros(1,size(F_c,2));
v = zeros(1,size(F_c,2));
f = zeros(1,size(F_c,2));</pre><p>Now I try to calculate the data for F_s, a, v and f in a loop.</p><pre> for s = 2:size(F_c,2)
F_s(s) = f(s-1)*(-k);
a(s) = (F_c(s)+F_s(s))/m;
v(s) = v(s-1)+a(s);
f(s) = f(s-1)+v(s);
end</pre><p>The first thing that happens in the loop is the spring force F_s is calculated. k is the spring constant.
Second, the acceleration is calculated as the sum of the forces divided by the mass. This is derived from Newton’ second law.
Then I calculate the velocity and distance from rest, from the acceleration and velocity.
The problem is that when I look at the calculated data, it doesn’t seems like the spring force changes before the last element in the array, which is 6.0629. I can’t see why this happens.
The data for a, v and f behaves the same way.
In addition, I’ve found out that, if I try to add the two force arrays, I get F_s, which doesn’t make sense.
In other words: if I type</p><pre> F_s+F_c == F_s</pre><p>it spits out 1s. So I guess it is in the loop when calculating a(s) the error occurs.</p><p>Do you have any solution for this, so I can simulate properly?</p>Kim Høghttp://de.mathworks.com/matlabcentral/profile/authors/5596777-kim-hogtag:de.mathworks.com,2005:Question/2183962015-05-24T09:53:06Z2015-05-24T14:10:37Zhow can i get to know that what is my email address for my mathswork account i want to login to maths work account<p>solution please</p>Muhammad Talhahttp://de.mathworks.com/matlabcentral/profile/authors/6427354-muhammad-talhatag:de.mathworks.com,2005:Question/2184192015-05-24T14:05:16Z2015-05-24T14:05:16ZSliding Mode Control for LTI systems?<p>Hello!
Is there any possibility to establish a SM Controller for a linearized uncertain system?
Any help, Ideas and <i>examples</i> will be welcome!
Thanks!</p>Aminehttp://de.mathworks.com/matlabcentral/profile/authors/5044218-aminetag:de.mathworks.com,2005:Question/2184172015-05-24T13:22:01Z2015-05-24T13:59:27ZHow to remove some charterers from the set of values<p>Hi there</p><p>I am trying to remove</p><p>#00:GEOPAK-WIN Scanning
#02:Contour 1
#04:XY(Z)
#05:Opn
#06:MM
#07:0.00000
#12
I tried to read the file and removed lines but it is not working , any suggestion ?
Thanks a lot for your help in advance</p>James Marashihttp://de.mathworks.com/matlabcentral/profile/authors/6393498-james-marashitag:de.mathworks.com,2005:Question/2159192015-05-09T17:18:52Z2015-05-24T13:59:25ZI don't know what is wrong with my code for calculating the legendre moments of an image? The method that I have used is given in the pdf attached.<p>I have used the method as described in the attached pdf file named fastlegendre. I have followed the given algorithm.
But the results that I am getting are not the correct ones.
If you can find any mistake please mention that.</p>Vishal Sharmahttp://de.mathworks.com/matlabcentral/profile/authors/6506329-vishal-sharmatag:de.mathworks.com,2005:Question/2184182015-05-24T13:58:21Z2015-05-24T13:58:21ZHi, I tried to use fmincon but I received the message. How I can overcome this problem?<p>" fmincon stopped because the size of the current step is less than the default value of the step size tolerance but constraints are not satisfied to within the default value of the constraint tolerance "</p>Muna Shehanhttp://de.mathworks.com/matlabcentral/profile/authors/4748028-muna-shehantag:de.mathworks.com,2005:Question/2165232015-05-13T11:31:37Z2015-05-24T13:50:25ZHow to extract videos after every 1 min interval and then how to subtract specific number of frames from background image.<p>The Code is :</p><pre class="language-matlab">clear all clc;
Z = imread('background.tif');
VR=VideoReader('traffic02.avi');
NumInFrames=get(VR,'NumberOfFrames');
</pre><pre class="language-matlab">count=0;
</pre><pre class="language-matlab">for (frame=1:60:150)
diff1 =read(VR,frame)-Z;
idx=diff1==0;
out=sum(idx(:));
% if (diff1==0)
% count=count+1;
%end
break;
</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">disp(out);
</pre>Chetanhttp://de.mathworks.com/matlabcentral/profile/authors/3942678-chetantag:de.mathworks.com,2005:Question/2163472015-05-12T08:02:25Z2015-05-24T13:48:07ZGoing to previous step while debugging<p>Hi</p><p>How to go to previous step while debugging in matlab just like we use F10 for next step? Is there any such option?</p><p>Thanks - Lalan</p>Lalanhttp://de.mathworks.com/matlabcentral/profile/authors/4132326-lalantag:de.mathworks.com,2005:Question/2182712015-05-23T10:29:45Z2015-05-24T13:47:43Zcan someone explain about this source code. its feature extraction for training back propagation. what is the input for training? whats mean by column 'number' through 'number' after run this. can someone explain details. thanks in advance<pre class="language-matlab">clc
close all
clear all
feature_extraction = [];
feature_extra = [];
j1=1;
j2=1;
% for j=65:70
for j=1:828
...for i=1:5
RGB = imread(['frame',num2str(j),'.jpg']);
img_crop = RGB;
I= rgb2gray(RGB);
I = imresize(I,[80 64],'bicubic');
</pre><pre> ...figure, imshow(I);
BW = edge(I,'canny',0.25); %Finding the edges of the image
[imx,imy]=size(BW);
msk=[0 0 0 0 0;
0 1 1 1 0;
0 1 1 1 0;
0 1 1 1 0;
0 0 0 0 0;];</pre><pre> B=conv2(double(BW),double(msk)); %smoothing the image to reduce the number of connected components
....figure,imshow(B);
bw_resize=imresize(B,[70,50]);</pre><pre> for fr=1:7
for fc=1:5</pre><pre> ...Atemp=sum(bw_resize((fr*10-9:fr*10),(fc*10-9:fc*10)))
temp=bw_resize((fr*10-9:fr*10),(fc*10-9:fc*10));
Atemp = sum(temp);
sum_feature((fr-1)*5+fc)=sum(Atemp)
end
end
sum_feature=((100-sum_feature)/100);
sum_feature=sum_feature;
feature = [sum_feature];
feature_extra = [feature_extra; feature];
data_target(j1,j2) = 1;
j2 = j2+1;
...end
j1 = j1+1;
end
...store these feature for training...</pre>midah idrishttp://de.mathworks.com/matlabcentral/profile/authors/6341191-midah-idristag:de.mathworks.com,2005:Question/2166262015-05-14T04:31:38Z2015-05-24T13:44:58ZI need a algorithm and its step by step process for extracting facial features from image in matlab<p>i need to extract facial features from image for biometrics project. please provide me algorithm and its step by step process for extracting features from face image in matlab</p>sorubahttp://de.mathworks.com/matlabcentral/profile/authors/5608964-sorubatag:de.mathworks.com,2005:Question/2174982015-05-19T06:20:19Z2015-05-24T13:38:27Zhow to calculate the image fidelity of an image whose size is[168 300 3] ?<p>I want to calculate the image fidelity of an image of size [168 300 3]</p>Soumyadip Chakrabortyhttp://de.mathworks.com/matlabcentral/profile/authors/6136046-soumyadip-chakrabortytag:de.mathworks.com,2005:Question/2182322015-05-23T04:56:53Z2015-05-24T13:35:15Zhow can i change the tetris program , ex) when player satisfied specific level then blocks are changed little bit difficult like ㄷ , ㅠ etc.<p>there are lots of tetris files so i want that program to be upgraded.... but because of my stupid head.. i can't make that source . help me guys..</p>JUNGHO LEEhttp://de.mathworks.com/matlabcentral/profile/authors/6548152-jungho-leetag:de.mathworks.com,2005:Question/2183912015-05-24T09:20:05Z2015-05-24T13:33:03ZI have a path with all x-y coordinate data also I have calculated 2D-two link robot data of theta1 and theta2 for respective x-y coordinates; now i want to make an animation for the same positions how do i do?<img src = "/matlabcentral/answers/uploaded_files/31450/pathplaneed1_robot1.jpg"><img src = "/matlabcentral/answers/uploaded_files/31451/pathplaneed1_robot1.jpg"><p>*Blue lines shows the respctive 2 arm 2d robot configutarion, i want to make animation of all these positions</p>chetan desaihttp://de.mathworks.com/matlabcentral/profile/authors/5982095-chetan-desaitag:de.mathworks.com,2005:Question/2183822015-05-24T07:49:45Z2015-05-24T13:32:50ZMatlab command to compute ridge count, valley count, white line count from fingrprint image<p>I am currently working on the topic " <b>Human Gender Classification based on fingerprint image using SVM</b> ". I am supposed to calculate the <b>ridge count, valley count, white line count from the fingerprint image</b> .</p><p>Please suggest some solutions related to the topic using <b>Matlab</b> .</p><p>Thanks in advance.</p>Sayantani Ghoshhttp://de.mathworks.com/matlabcentral/profile/authors/6097927-sayantani-ghoshtag:de.mathworks.com,2005:Question/2183662015-05-24T06:52:37Z2015-05-24T13:28:25ZWhy do I get the error message 'Attempt to execute SCRIPT as a function' ?<p>i am integrating the two columns like,</p><pre class="language-matlab">data=xlsread('book1.xlsx');
P=data(3:end,1);
t=data(3:end,2);
fun=(P.*t);
i=integral(fun,0,72);
</pre><p>i am not getting, please help me friends....</p><p>Actually for the excel file i need to integrate the column1 and 2 with a limits of 0 to 72;</p>nani kalyanhttp://de.mathworks.com/matlabcentral/profile/authors/6430489-nani-kalyantag:de.mathworks.com,2005:Question/2183982015-05-24T10:31:33Z2015-05-24T13:15:29Zhello, i have a question, how to build the value of an Edit Text and push it in a 'MyDrawing' button in gui; and where exactly should i put this change in my code?, this is my code<pre class="language-matlab">% --- Executes during object creation, after setting all properties.
function slfmin_CreateFcn(hObject, eventdata, handles)
% hObject handle to slfmin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
</pre><pre class="language-matlab">% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
</pre><pre class="language-matlab">% --- Executes during object creation, after setting all properties.
function MyDrawing_CreateFcn(hObject, eventdata, handles)
% hObject handle to MyDrawing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
epsl = get(hObject,'value');
set(findobj('Tag','editepsL'),'String',epsl);
</pre><pre class="language-matlab">% Hint: place code in OpeningFcn to populate MyDrawing
</pre><pre class="language-matlab">% --- Executes on button press in pbDessiner.
function pbDessiner_Callback(hObject, eventdata, handles)
% hObject handle to pbDessiner (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">global N fmin fmax df epsh epsl ah al
</pre><pre class="language-matlab">[T,R] = bragg(N, fmin,fmax,df,epsh,epsl,ah,al);
plot(fmin:df:fmax,R);
grid on;
</pre><pre class="language-matlab">% --- Executes on key press with focus on pbDessiner and none of its controls.
function pbDessiner_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to pbDessiner (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
</pre>Guedada Lahcenhttp://de.mathworks.com/matlabcentral/profile/authors/6556174-guedada-lahcentag:de.mathworks.com,2005:Question/2183992015-05-24T10:37:22Z2015-05-24T13:11:47ZDecision Tree classifier for classification of Brain MRI images and texture features<p>I have applied decision tree classifier using the direct function in MATLAB RegressionTree.fit and predict.
I have used texture features and applied for the classification of MRI images.
But I am getting very low accuracy that is 60%.
What can I do to increase this.</p>purti choudharyhttp://de.mathworks.com/matlabcentral/profile/authors/4672085-purti-choudharytag:de.mathworks.com,2005:Question/2183412015-05-24T05:20:14Z2015-05-24T13:09:33Zeig() shows positive eigenvalues while chol() failed<p>Hi guys,</p><p>I was LU-decomposing a supposed-to-be positive-definite matrix using "chol" in a loop. However, occasionally it failed with the warning</p><pre> " Error using chol
Matrix must be positive definite. "</pre><p>eig() shows that the smallest eigenvalue is 1.8*10^(-4) which I think should be well above zero. BTW, the largest one is 7.7*10^9.</p><p>How can I get around this dilemma? Your suggestions are greatly appreciated. Many thanks.</p>Allen Lauhttp://de.mathworks.com/matlabcentral/profile/authors/6555706-allen-lautag:de.mathworks.com,2005:Question/2184162015-05-24T12:50:22Z2015-05-24T13:01:08ZCellfun: check cell array for any value below 5, if yes return true<p>Hi all,
I have the following cell array</p><pre class="language-matlab">A = {4,5,6}
</pre><p>Is there a way to check whether any element is below 5 and return true if yes?</p><p>Been searching around but couldn't find any answers.</p><p>Cheers</p>darellonhttp://de.mathworks.com/matlabcentral/profile/authors/5964826-darellontag:de.mathworks.com,2005:Question/2182812015-05-23T12:49:13Z2015-05-24T12:40:17ZMatlab Rounding as Portfolio Constraint<p>Hi there,</p><p>I am optimizing a portfolio using the mean-CVaR optimization function in Matlab. One of the constraints I would like to set is that the portfolio weights for each asset class should be rounded to the nearest 0.05.</p><p>I have defined the rounding constraint as</p><p>round(x/5,2)*5</p><p>which works fine. However, I am wondering now how I can include this as a constraint in the optimization instead of just rounding the weights after the optimization.</p><p>Here is the code I am using for the portfolio optimization</p><pre class="language-matlab">pmc = PortfolioCVaR;
pmc = pmc.setAssetList(IndexList); % select index names
pmc = pmc.setScenarios(returns); % select return series
pmc = pmc.setProbabilityLevel(0.95); % cVaR confidence level
pmc = pmc.setDefaultConstraints; % Constraint 1: only positive
weights that sum to 1
pmc = pmc.setBounds(0.01, 0.1); % Constraint 2: min/max weights
</pre><p>I would be happy about any hints!</p><p>Thanks a lot, Carolin</p>Carolin Brueckmannhttp://de.mathworks.com/matlabcentral/profile/authors/6486163-carolin-brueckmanntag:de.mathworks.com,2005:Question/2177712015-05-20T15:04:38Z2015-05-24T12:34:44ZInaccuracy when using 'mrdivide' and backslash '/' for Solving xA=b<p>Hi everyone I would like to solve the equation xA=b where:</p><pre class="language-matlab">b=
0 21.8182 0 -7.2727
1.6154 -4.8462 -0.5385 1.6154
2.4000 -12.0000 -0.8000 4.0000
-0.8824 0.2941 0.2941 -0.0980
0.6000 1.0909 0 0
0.0814 0.1407 0 0
</pre><pre class="language-matlab">A=
-3 0 1 0
0 -3 0 1
</pre><p>Since both the b and A matrices have the same number of columns, I use the backlash '/' function in Matlab as follows:</p><pre> x=b/A;</pre><p>Which returns the following value of x</p><pre> 0 -7.2727
-0.5385 1.6154
-0.8000 4.0000
0.2941 -0.0980
-0.1800 -0.3273
-0.0244 -0.0422</pre><p>However when I multiply this value of x with A, instead of getting the matrix 'b' I get the following result which is identical to 'b' fo the first four columns but is totally inaccurate for the last two columns : xA=</p><pre> 0 21.8182 0 -7.2727
1.6154 -4.8462 -0.5385 1.6154
2.4000 -12.0000 -0.8000 4.0000
-0.8824 0.2941 0.2941 -0.0980
0.5400 0.9818 -0.1800 -0.3273
0.0733 0.1266 -0.0244 -0.0422</pre><p>I think I must be missing something theoretically, please do guide me on how I can rectify this inaccuracy..Thanks!</p>Ahmadhttp://de.mathworks.com/matlabcentral/profile/authors/2962446-ahmadtag:de.mathworks.com,2005:Question/2184152015-05-24T12:30:01Z2015-05-24T12:30:01ZOverlap in the mscohere function<p>Hi everybody,</p><p>I'm calculating the magnitude-squared coherence for signals like:</p><pre class="language-matlab">[Cxy,F] = mscohere(xdata,ydata,[],noverlap,[],samp_rate);
</pre><p>With the window size being the entire length of the data [] (one second here), f as default and sampling rate at 200 (same as data). However, even though the window size is the same length as the data I can change the result by inserting different values in 'noverlap'. How can that be? Does it make sense to use 50% overlap when the window size is the same as data length?</p><p>Best,</p><p>Eric</p>Erichttp://de.mathworks.com/matlabcentral/profile/authors/5076936-erictag:de.mathworks.com,2005:Question/2179062015-05-21T11:01:14Z2015-05-24T12:23:48Zproblems in the classification<p>hello matlab community .....
I'm working with a neural network capable of classifying patterns, I have no one to turn to ... my network is not ranking very well .... it classifies all results in just a standard ... and in fact I have to classify three types ... if someone can help me to improve this algortimo'll be very grateful not know where I am going wrong ... I am so frustrated right now ... thank you</p><p>clear all
close all
clc</p><p>n = input('enter the first layer of neurons number\n') ;</p><p>m = input('enter the number of the neurons of the second layer\n') ;</p><p>a = input('digite 1-(40),2-(45),3-(50),4-(60),5-(70),6-(80) \n') ;</p><p>p = input('enter the number of samples you want to test\n') ;</p><p>switch a</p><pre> case 1
[x] = xlsread('d_40S.xlsx') ;
case 2
[x] = xlsread('d_45S.xlsx') ;
case 3
[x] = xlsread('d_50S.xlsx') ;
case 4
[x] = xlsread('d_60S.xlsx') ;
case 5
[x] = xlsread('d_70S.xlsx') ;
case 6
[x] = xlsread('d_80S.xlsx') ;
end</pre><p>[y] = xlsread('target_3eS.xlsx') ;</p><p>[w,k] = size(y) ;</p><p>%grouping the data matrix and target</p><p>matriz_dados = [x y] ;</p><p>%scrambling the matrix so as to become more random</p><p>dados = permutation(matriz_dados) ;</p><p>[l,c] = size(dados) ;</p><p>%separating training samples and testing randomly</p><p>idx = randperm(l);</p><p>id_teste = (idx <= p) ;</p><p>id_treino = (idx > p) ;</p><p>%matrix with complete set of data</p><p>dado_treino = dados(id_treino,:) ; %sample for training</p><p>dado_teste = dados(id_teste,:) ; %Test sample</p><p>%samples for training</p><p>dadotreino = dado_treino(:,1:c-k)' ;</p><p>tagtreino = dado_treino(:,c-(k-1):c)' ;</p><p>%samples for validation</p><p>dadoteste = dado_teste(:,1:c-k)' ;</p><p>tagteste = dado_teste(:,c-(k-1):c)' ;</p><p>%---------------------------------------------------------</p><p>rede = network ; %network name</p><p>rede.numinputs = 1 ;%amount of input that the network layers have</p><p>rede.numlayers = 3; %number of network layers that have</p><p>rede.biasConnect = [1; 1;1] ;%Is defined now the layers that have associated bias</p><p>%1 = will bias,0 =You will not have bias</p><p>rede.inputConnect = [1 ;0 ;0] ;%connecting the inputs network layers</p><p>rede.layerConnect = [0 0 0 ; 1 0 0;0 1 0] ;%Connection between layers</p><p>rede.outputConnect = [0 0 1] ;%layers that have connection with the output</p><p>rede.inputs{1}.range = [0 1] ;% maximum and minimum value that can take the variables</p><p>t = c -(c-k) ;</p><p>rede.inputs{1}.size = c-k ;</p><p>rede.layers{1}.size = n ;</p><p>rede.layers{2}.size = m ;</p><p>rede.layers{3}.size = t ;</p><p>for j=1:t</p><pre> rede.layers{j}.transferFcn ='logsig' ;</pre><pre> rede.layers{j}.initFcn = 'initnw' ; </pre><p>end</p><p>rede.performFcn = 'mse';</p><p>rede.trainFcn = 'trainrp';</p><p>rede.trainParam.epochs = 10000 ;</p><p>rede.view</p><p>rede = init(rede) ;</p><p>train_rede = train(rede,dadotreino,tagtreino) ;</p><p>output = rede(dadoteste) ;</p><p>output_final = vec2ind(output)' ;</p><p>% Y = sim(rede, dadoteste) ;
% z = vec2ind(Y)' ;</p><pre> tagtest2 = vec2ind(tagteste)' ;</pre><pre> M = confusionmat(tagtest2,output_final)</pre>felipe gonzalezhttp://de.mathworks.com/matlabcentral/profile/authors/6470774-felipe-gonzaleztag:de.mathworks.com,2005:Question/2182972015-05-23T15:32:18Z2015-05-24T12:15:59ZHow to sum over indexed arrays<p>I have 3 arrays of the same dimension, having the same name but with indexes. How can one sum over the elements.</p><pre> clear all; close all;</pre><pre> It=3; %Number of created arrays
for ii=1:It
a(ii) = [1 1 rand()]
end</pre><pre> abc = zeros(size(a(1))); %array abc has zero entries of same dimension as the a-arrays</pre><pre> for ii = 1:It %summation over a-arrays
abc = abc + a(ii)
end</pre><pre> abc %final array with summed elements</pre><p>What is wrong with it?</p>Luciushttp://de.mathworks.com/matlabcentral/profile/authors/6401786-luciustag:de.mathworks.com,2005:Question/2181082015-05-22T11:43:42Z2015-05-24T12:14:11ZHow to input an array into a matrix through looping?<p>I am trying to take an looped array of 10 integers, such as x= [ 2 4 .... 20] below (generated from a loop - so each will be different), rotate it (if needed), and then populate a 10:1000 matrix, keeping each 10 integers looped array output. In other words, no just repeating the output 1000x. I have been experimenting to no avail with the code below. It seems to produce the matrix correctly, but I have yet to be able to populate it with the array of 10, 1000 times across.:</p><p>clear all
clc</p><p>R = 10 %number of rows</p><p>C = 1000 %number of columns</p><p>A = zeros(R,C)</p><p>x = [2 4 6 8 10 12 14 16 18 20];</p><p>z = rot90(x)</p><p>for i = 1:R</p><pre> for j = 1:C</pre><pre> A(i,j)= z</pre><pre> end</pre><p>end</p>jefkei92http://de.mathworks.com/matlabcentral/profile/authors/6314157-jefkei92