https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2016-08-28T14:13:43Ztag:www.mathworks.com,2005:Question/3011522016-08-28T13:17:10Z2016-08-28T14:13:43ZHow to convert time from decimal to HH:MM format in plot?<p>I'm reading from Excel file and in Excel the time is showing in the correct HH:MM format but when I imported it to MATLAB it is showing in decimal. I want to plot a figure with time in the HH:MM format and not decimal. I'm using MATLAB R2013a.</p>Adelinehttps://www.mathworks.com/matlabcentral/profile/authors/4521533-adelinetag:www.mathworks.com,2005:Question/3011562016-08-28T14:07:13Z2016-08-28T14:07:13Zcan anyone give power factor correction code using MATLAB?<pre> Power factor correction code using MATLAB</pre>AL HAMZAhttps://www.mathworks.com/matlabcentral/profile/authors/8607224-al-hamzatag:www.mathworks.com,2005:Question/3008292016-08-25T06:12:52Z2016-08-28T13:45:25ZWhat is to be done for estimating parameters of model on MATLAB? <p>Especially how <b>Recursive Least Square (RLS) Algorithm</b> can be implemented on uncertain dynamic systems in MATLAB simulink or m-file?</p>Rishikesh Datarhttps://www.mathworks.com/matlabcentral/profile/authors/6878125-rishikesh-datartag:www.mathworks.com,2005:Question/3011552016-08-28T13:43:43Z2016-08-28T13:43:43ZcuDNN problem when training a convolution neural network<p>I have worked with the CNN training functionality of MATLAB R2016a for a few days and it worked great. However, I am now receiving the following error message:</p><p>*Error using nnet.internal.cnngpu.convolveForward2D
Unexpected error calling cuDNN: CUDNN_STATUS_BAD_PARAM.</p><p>Error in nnet.internal.cnn.layer.Convolution2D/doForward (line 218)
Z = nnet.internal.cnngpu.convolveForward2D( ...</p><p>Error in nnet.internal.cnn.layer.Convolution2D/forwardNormal (line 195)
Z = this.doForward(X,this.Weights.Value,this.Bias.Value);</p><p>Error in nnet.internal.cnn.layer.Convolution2D/forward (line 98)
[Z, memory] = this.forwardNormal( X );</p><p>Error in nnet.internal.cnn.SeriesNetwork/forwardPropagation (line 133)
[layerOutputs{currentLayer}, memory{currentLayer}] = this.Layers{currentLayer}.forward(
layerOutputs{currentLayer-1} );</p><p>Error in nnet.internal.cnn.SeriesNetwork/gradients (line 73)
[layerOutputs, memory] = this.forwardPropagation(data);</p><p>Error in nnet.internal.cnn.Trainer/train (line 58)
[gradients, miniBatchLoss, miniBatchAccuracy] = net.gradients(X, Y);</p><p>Error in trainNetwork (line 92)
trainedNet = trainer.train(trainedNet, dispatcher);</p><p>Error in train_CNN (line 39)
net = trainNetwork(imds,layers,opts);*</p><p>Any idea?</p>rc3002 Chttps://www.mathworks.com/matlabcentral/profile/authors/2145275-rc3002-ctag:www.mathworks.com,2005:Question/3011542016-08-28T13:38:30Z2016-08-28T13:38:30ZHow to simulink of PA（public address）system or acoustic feedback<pre> Dear all,
now,i'm study of acoustic feedback suppression,but...then i try to simulation to acoustic feedback,i meet some problem ,for example ,for simulink with public address,i don't know how to set up the amplifier.
so can someone tell me how to obtain code of acoustic feedback or tell me how to write it.
Thank you for reading this message. Hopefully someone can help me.</pre><pre class="language-matlab">regards
</pre>apollo https://www.mathworks.com/matlabcentral/profile/authors/8074244-apollotag:www.mathworks.com,2005:Question/3011532016-08-28T13:38:19Z2016-08-28T13:38:19ZCompute visible area of partically obscured object of 3D figure<p>I have 2 hemispheres (radius 10.5 and 2.5cm) with slits. In the center is a red cube of 1*1*1cm. I need to calculate the area of the cube that I see from various viewpoints. E.g. when I look from view(90,45) I have to calculate the area of the cube that I can see, but at view (50,60) I can not see the cube, so the area is 0.</p><img src = "/matlabcentral/answers/uploaded_files/58451/Untitled1111111111111111111.png">viet lehttps://www.mathworks.com/matlabcentral/profile/authors/8352252-viet-letag:www.mathworks.com,2005:Question/3011122016-08-27T20:49:42Z2016-08-28T13:30:34Zhi, i want partition largest interval(contain more than element) to 4 interval , and partition the second biggest interval to 3 interval,and partition the third biggest interval to 3 interval, But the rest remains the same.retaining orderofinterval<p>% i have n values z1,z2 , ...,zn this is numerical values . i partition this to seven interval as following and calculate the length for every interval(length for nonzero element), the interval contain more than element from z1,...zn i need partition it to 4 subinterval have same length While retaining the order and the second largest interval partition to 3 subinterval have same length and the third interval partition to 2 subinterval have same length and the remaining interval Remain the same . In the end we get to 13 interval .</p><pre class="language-matlab">n = 50;
z = 1000 * rand(1, n); % Sample data
a=min(z);
b=max(z);
k =7; % such that k is the number of intervals
L= (max(z)-min(z))/k; %such that L is length of each interval
% Here is my solution:
intK = round(k);
uMatrix = [linspace(a, b-L, intK)', linspace(a+L, b, intK)']
for i=1:n
for j=1:k
if (uMatrix(j,1)<=z(i)&z(i)<=uMatrix(j,2))
uMatrix(j,1,i)=z(i);
end
end
end
for i=1:k
temp1=uMatrix(i,:,:);
%whos temp1
temp2 = nonzeros(temp1);
%whos temp2
temp3 = length(temp2);
%w hos temp3
le(i)=temp3;
end
</pre>mohammed hamdyhttps://www.mathworks.com/matlabcentral/profile/authors/8604732-mohammed-hamdytag:www.mathworks.com,2005:Question/3010792016-08-27T12:09:09Z2016-08-28T13:27:24Zsimple linear regression slope calculation <p>i am new to using matlab
i have a trading system written in another language which uses linear regression slope in the algorithm. i thing that is the formula used by metastock originally.
now i am trying to port it into matlab.
Matlab has lots of linear regression models formulas etc. but i cannot decide which formula to use to define it .
suppose i have 10,000x1 rows of data
how can i calculate the slope of linear regression line for last 50 rows.</p><p>edit:
after much reading i am pretty sure the linearregression line formula in trading softwares means ,for last x points of data linearregression(x) is the solution/prediction of next datapoint using linear least squares method. Still i dont know how can i do this. I am very thankful for everyone trying to help. i hope this clarification will help. i am adding a calculated (by some trading software) price,linearregression and linearregressionslope data here.</p>kenan alicihttps://www.mathworks.com/matlabcentral/profile/authors/7819167-kenan-alicitag:www.mathworks.com,2005:Question/3011412016-08-28T11:42:00Z2016-08-28T13:25:00ZCalculating variance in loop<p>Hi, I have 8 years of data and I want to calculate the variance of the same month but different year all together. i.e. Variance of January for all the 8 years. My matrix is 74*115*22168. I know there is the function var, but I'm finding problems to incorporate everything in a loop that does everything in one run. Any help pls</p>MFhttps://www.mathworks.com/matlabcentral/profile/authors/7464912-mftag:www.mathworks.com,2005:Question/975602009-06-27T01:11:00Z2016-08-28T13:24:06ZHow can I monitor how much memory MATLAB is using?<p>I have a program that is memory intensive and I want to monitor how much memory MATLAB is using so that if it goes above a certain threshold, I can stop the program.</p>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/3011492016-08-28T12:41:24Z2016-08-28T13:23:25Zhow can I store values generated from a nested loop into an arrray ?<p>if I have this code :-</p><pre class="language-matlab">function S = triangle_wave(n)
S = zeros(1,1001); %preallocation
e = [];
for t = 0:((4*pi)/1000):(4*pi)
for k = 0:n
sigma = (((-1)^k)*sin((2*k+1)*t))/((2*k+1))^2;
e(1, *???*) = sigma; *(%what should I put here instead of (???)?)*
end
r = sum(e(:));
S(1, *???*) = r; *(%what should I put here instead of (???)?)*
end
end
</pre><p>I can't depend on the loop's variable because they are kinda of rational numbers, so how should i store ?</p>Omar Makladhttps://www.mathworks.com/matlabcentral/profile/authors/8331870-omar-makladtag:www.mathworks.com,2005:Question/3004442016-08-22T10:11:21Z2016-08-28T13:21:51ZSpeeding up code: vectorization and others<p>Hi,</p><p>Is there a way to speed this up even more? I did what I could already: everything is precomputed, preallocated etc. and compiled to .mex.</p><p>First, just to give you an idea about sizes of continers:</p><pre class="language-matlab">bessels = ones(1201, 1201, 101); % 1.09 GB
negMcontainer = ones(1201, 1201, 100);
posMcontainer = negMcontainer;
maxN = 100;
levels = maxN + 1;
xElements = 1201;
Aj1 = complex(ones(101, 101);
Aj2 = Aj1;
</pre><p>Code:</p><pre class="language-matlab">parfor i = 1 : xElements
for j = 1 : xElements
umn = complex(zeros(levels, levels)); % cleaning
for n = 0:maxN
mm = 1;
for m = -n:2:n
nn = n + 1; % for indexing
if m < 0
umn(nn, mm) = bessels(i, j, nn) * negMcontainer(i, j, abs(m));
end
if m > 0
umn(nn, mm) = bessels(i, j, nn) * posMcontainer(i, j, m);
end
if m == 0
umn(nn, mm) = bessels(i, j, nn);
end
mm = mm + 1; % for indexing
end % m
end % n
beta1 = sum(sum(Aj1.*umn));
betaSumSq1(i, j) = abs(beta1).^2;
beta2 = sum(sum(Aj2.*umn));
betaSumSq2(i, j) = abs(beta2).^2;
end % j
end % i
</pre><p>Best regards,
Alex</p>Alex Kurekhttps://www.mathworks.com/matlabcentral/profile/authors/4769629-alex-kurektag:www.mathworks.com,2005:Question/3011442016-08-28T12:02:17Z2016-08-28T13:10:04ZHow to find the amount of data generated/memory requirment for a program?<ul><li>How to know the computational memory requirement of a program?</li><li>Also I would like to plot between computational time(run and time) and computational memory during a single run of a program.</li><li>How to obtain a least computational time and least computational memory requirement for a given computational capacity?</li></ul><p>Thanks in advance!</p>Thanigaivel Raja Thttps://www.mathworks.com/matlabcentral/profile/authors/7128309-thanigaivel-raja-ttag:www.mathworks.com,2005:Question/2982442016-08-03T10:11:43Z2016-08-28T13:09:03Zaddtodate creates too many milliseconds<p>I wanted to create a vector of all milliseconds in a day, so I wrote</p><pre class="language-matlab">0:addtodate(0,1,'millisecond'):(1-addtodate(0,1,'millisecond'));
</pre><p>which resulted in a vector with 86767016 elements, instead of the expected 24*60*60*1000 = 86400000 ones.</p><p>The same with seconds worked just fine.</p><p>I assume this is due to some roundoff error, and of course I could just write (0:86400000-1)/86400000,
but I was wondering if this should be considered a bug.</p><p>Also was wondering what would be the better approach in the future when adding several milliseconds - I can think of three options:</p><pre class="language-matlab">addtodate(0,1,'millisecond') + addtodate(0,1,'millisecond');
2*addtodate(0,1,'millisecond');
2/86400000;
</pre><p>(The last one giving a different result than the first two)</p>d_moanhttps://www.mathworks.com/matlabcentral/profile/authors/8404250-d_moantag:www.mathworks.com,2005:Question/3008502016-08-25T10:00:48Z2016-08-28T13:05:40ZDividing the audio signal into frames and reodering the frames to create an unintelligent audio<p>I got a problem doing this MAT LAB code I have an audio signal of 10sec and i want to divide it into 100 samples or frames and i have to shuffle them and i have to rejoin to get a unintelligent audio</p><p>Please help me guys</p><p>thanks ;)</p>navtej Rudhttps://www.mathworks.com/matlabcentral/profile/authors/8590984-navtej-rudtag:www.mathworks.com,2005:Question/3011212016-08-28T00:34:33Z2016-08-28T13:05:20ZHow do I plot intensity of points on a scatter plot?<p>Hey all, I'm a beginner at this but would appreciate some help!</p><p>I have a plot of x and y coordinates and I would like to plot them to show the intensity of the points. For example if an (x,y) point occurs quite a bit then it will be dark red on the plot whereas a point that only occurs once will be light blue or something similar. I would greatly appreciate if anyone could help get me started as I haven't been able to find anything or figure it out on my own.</p>Rebecca Bullardhttps://www.mathworks.com/matlabcentral/profile/authors/5109732-rebecca-bullardtag:www.mathworks.com,2005:Question/3011162016-08-27T22:13:17Z2016-08-28T13:01:38Zhow i can get all row of data from a table ??<p>hi ;</p><p>please i want to get all data of row in the table , how can i</p><img src = "/matlabcentral/answers/uploaded_files/58450/ta.PNG"><p>do this ??</p>reda yagoubhttps://www.mathworks.com/matlabcentral/profile/authors/7685343-reda-yagoubtag:www.mathworks.com,2005:Question/3011512016-08-28T12:54:23Z2016-08-28T12:54:23ZHow can I get the outputs from the result of additional Test in a neural network Tool box?<p>I already tried a Fitting problem with inputs of 87x4 matrix and a target 87x22 matrix. The network performance was good enough, then I tried to perform additional test with a different 32x4 matrix as inputs and same targets a 32x19 matrix. I ran the Test network. It was ok but there is no way to get the outputs of this last performance. How can I get the outputs of this additional test?</p>Orlando Yaguashttps://www.mathworks.com/matlabcentral/profile/authors/4734652-orlando-yaguastag:www.mathworks.com,2005:Question/3011482016-08-28T12:38:20Z2016-08-28T12:47:54Zhow to draw two tailed t test .....<p>I want to draw picture like FIG1.(a) .</p><p>This paper said that calculations were based on a two-sided student's t-test with the effective degrees of freedom estimated by considering serial autocorrelation of data.</p><p>please tell me .... how to draw dots like FIG (a)..</p><img src = "/matlabcentral/answers/uploaded_files/58448/%EC%BA%A1%EC%B2%98!!.PNG">sangchul chahttps://www.mathworks.com/matlabcentral/profile/authors/7612815-sangchul-chatag:www.mathworks.com,2005:Question/3011362016-08-28T09:33:51Z2016-08-28T12:46:25Zcalling a subfunction failed<p>Hi there,</p><p>I tried to run a self-written code which called another self-written sub-function. The code message is attached below:</p><p>Undefined function 'name of the function' for input arguments of type 'char'.</p><p>But both codes are located in the same folder.</p><p>I am running matlab R2001b under a linux system. Matlab was started on a local machine and ran codes sitting on a remote server.</p><p>Any suggestions?</p><p>Thanks in advance.</p><p>Jun</p>Jun Zhaohttps://www.mathworks.com/matlabcentral/profile/authors/8100729-jun-zhaotag:www.mathworks.com,2005:Question/3007752016-08-24T18:44:15Z2016-08-28T12:40:40Zhow to form eucledian distance based clusters inside each rectangular grids b/w nodes present in each grid<p>plz help me further in this code that how to use for loop inside</p>kiranpreet kaurhttps://www.mathworks.com/matlabcentral/profile/authors/8132612-kiranpreet-kaurtag:www.mathworks.com,2005:Question/3011452016-08-28T12:06:25Z2016-08-28T12:31:53ZHow can I estimate the prestley's evolutionary spectrum in MatLab. <p>I want to estimate the Prestley's Evolutionary Spectrum for non stationary time series using MatLab. I'm wondering whether there is an inbuilt function for this.</p>Samithree Rajapakshahttps://www.mathworks.com/matlabcentral/profile/authors/8512092-samithree-rajapakshatag:www.mathworks.com,2005:Question/2947132016-07-10T09:42:32Z2016-08-28T12:31:05ZHow to train a neural network with genetic algorithm and back propagation?<p>Hello I want to train my neural network using a hybrid model of backpropagation and Genetic algorithm . Is it
possible to use the two ona neural network for extremely high performance and also better results in less amount of time? Are there any such model available in MATLAB?</p>Newman https://www.mathworks.com/matlabcentral/profile/authors/6636409-newmantag:www.mathworks.com,2005:Question/3011462016-08-28T12:15:56Z2016-08-28T12:28:41ZWTMM for 1-D <p>this function have rshift and lshift which is not defined.</p>NASSREhttps://www.mathworks.com/matlabcentral/profile/authors/5899324-nassretag:www.mathworks.com,2005:Question/3011432016-08-28T12:00:58Z2016-08-28T12:03:21ZHow to call sub or superclass constructor when recursively creating objects<p>Hi,</p><p>I'm writing a tree class. I'd like a superclass to contain generic construction / maintenance methods, then be able to subclass it for a range of different, more specific purposes.</p><p>Something like:</p><pre class="language-matlab">classdef SuperTree < handle
</pre><pre> properties
BranchLocation
Parent
Children
end</pre><pre> methods</pre><pre> function obj = SuperTree(varargin)
% construct the the object
end</pre><pre> function subdivide(obj, limit_criterion)
% Lots of code that's difficult to maintain and
% shouldn't be overloaded in a subclass
if limit_criterion
% Create child branches
chld1 = SuperTree(args);
chld2 = SuperTree(args);
obj.Children = [chld1; chld2]
end</pre><pre> end
end</pre><p>The problem is that if I create a subclass, then the subdivision method still makes a call to SuperTree() to construct its children.</p><p>Is there a way of getting (say) a handle to the constructor function of the current object? I don't want to be overloading the subdivide method for each of my subclasses. Something like this would be ideal:</p><pre> function subdivide(obj, limit_criterion)
% Lots of code that's difficult to maintain and
% shouldn't be overloaded in a subclass
if limit_criterion
% Create child branches
chld1 = obj.Constructor(args);
chld2 = obj.Constructor(args);
obj.Children = [chld1; chld2]
end</pre><p>At the moment I'm working around this with a small utility method, that I overload in each subclass. Working? Yes. Elegant? No. So I'd be interested in any 'proper' solutions.</p><p>Thanks!</p><p>Tom</p>Tom Clarkhttps://www.mathworks.com/matlabcentral/profile/authors/5402650-tom-clarktag:www.mathworks.com,2005:Question/3011422016-08-28T11:55:36Z2016-08-28T11:55:36ZCan i find a simple example for using USRP as a transmitter or a receiver and control the frequency with matlab or simulink code?<p>using USRP with matlab or simulink</p>ahmed alihttps://www.mathworks.com/matlabcentral/profile/authors/8545635-ahmed-alitag:www.mathworks.com,2005:Question/3010362016-08-26T23:34:07Z2016-08-28T11:52:57ZReading column labels in a Matrix<p>I have a 65536x93 dataset with column labels which are numbers. I want to store the column labels in a 1x93 matrix with the labels as numbers which will be used as the x-axis in a plot.</p><p>Please help</p>Shiladitya Chatterjeehttps://www.mathworks.com/matlabcentral/profile/authors/6983150-shiladitya-chatterjeetag:www.mathworks.com,2005:Question/3007842016-08-24T19:53:37Z2016-08-28T11:51:42Zhow to use "for loop" for firstly entering into each rectangular grids then find minimum distance b/w nodes in each grid<p>here i want to apply for loop for each 16 rectangular grids then after entering into the grid i want to find eucledian distance b/w the nodes present in that grid</p>kiranpreet kaurhttps://www.mathworks.com/matlabcentral/profile/authors/8132612-kiranpreet-kaurtag:www.mathworks.com,2005:Question/2986042016-08-05T17:16:30Z2016-08-28T11:43:45Zusing wavelet coefficients for fault location<p>dear all: I modeled arbitrary faulted radial network using PSCAD and I extracted the voltage signals from four points. I have 2000 samples/0.5 second, power frequency 60hz, 33kv, I converted the aerial voltage signals to wavelet transform using MATLAB, this is the code:</p><p>[Lo_D,Hi_D] = wfilters('db4','d');
[Lo_R,Hi_R] = wfilters('db4','r');
[cs,ls] = wavedec(vs_1,4,Lo_D,Hi_D);
[cds1, cds2, cds3, cds4] = detcoef(cs,ls,[1 2 3 4]);
[c1,l1] = wavedec(v1_1,4,Lo_D,Hi_D);
[cd11, cd12, cd13, cd14] = detcoef(c1,l1,[1 2 3 4]);
[c2,l2] = wavedec(v2_1,4,Lo_D,Hi_D);
[cd21, cd22, cd23, cd24] = detcoef(c2,l2,[1 2 3 4]);
[c3,l3] = wavedec(v3_1,4,Lo_D,Hi_D);
[cd31, cd32, cd33, cd34] = detcoef(c3,l3,[1 2 3 4]);
T=0:((0.5-0)/length(cds1)):(0.5-((0.5-0)/length(cds1)));
figure, plot(T,cds1.^2),title('Ds1');
figure, plot(T,cd11.^2),title('D11');
figure, plot(T,cd21.^2),title('D21');
figure, plot(T,cd31.^2),title('D31');</p><p>I faced this problem:</p><p>from wavelet coefficients point at scale 1, 2, 3 & 4, the faulted time is exactly same for all four signal. that is mean no time difference between four measurements, since the faulted point in PSCAD far away from four measurement devices by different distances this will be impossible, what is missing in my code? is the wavelet order and level right? please help me.</p>abdulmajeedhttps://www.mathworks.com/matlabcentral/profile/authors/3872678-abdulmajeedtag:www.mathworks.com,2005:Question/126402011-07-28T22:30:46Z2016-08-28T11:42:25ZPlot on different figures during a loop<p>Hi,</p><p>I'm extracting from different files some data that have ot plot on the same plot, I use a loop like</p><pre> figure, hold on</pre><pre> for j=1:m
s=load(fileA{j});
t=load(fileB{j});
plot (t(:,1),t(:,2),'-r+')
end</pre><p>I'd like to plot t(:,1),t(:,2) on figure 1, and for example t(:,1),t(:,3) on another figure. Is it possible to do it in the same loop?</p><p>thanks for your help</p><p>n</p>Nicolashttps://www.mathworks.com/matlabcentral/profile/authors/4862182-nicolastag:www.mathworks.com,2005:Question/3006272016-08-23T17:03:21Z2016-08-28T11:41:49ZWhich solver can be used for a non linear curve fitting with some variables being constrained to integers?<p>I have a non linear curve fitting problem, say e^(x1+x2)-y=0, where x1,x2 are variables and y is the data against which fitting is done. Here x1 should be an integer and x2 can be a non integer. Which solver can handle such problems?</p>Thanigaivel Raja Thttps://www.mathworks.com/matlabcentral/profile/authors/7128309-thanigaivel-raja-ttag:www.mathworks.com,2005:Question/561792012-12-10T11:41:43Z2016-08-28T11:21:46Zhow can i give m-file output to simulink model as input<p>i am trying to link a m-file out put to a simulink model as input</p>renu avinaashhttps://www.mathworks.com/matlabcentral/profile/authors/3557216-renu-avinaashtag:www.mathworks.com,2005:Question/3011382016-08-28T09:50:54Z2016-08-28T11:16:40ZDimensions of matrices being concatenated are not consistent error for cell2mat<pre class="language-matlab">out =
</pre><pre> '01'
'0.5846023560E-002'
'405504.0000'
'0.9652538155'
'-0.7828897534E-008'
'5153.587402'
'0.2494223175E+001'
'0.529637577'
'0.1359485230E+001'</pre><p>out = 9*1 cell.
I need to convert numeric values of each element of out.
I applied</p><pre class="language-matlab">cell2mat(out)
</pre><p>but it gives "Dimensions of matrices being concatenated are not consistent" error. But when I apply</p><pre class="language-matlab">str2num((cell2mat(out(2))))
</pre><p>second element of out converted numeric value. How can I convert numeric values of each element of out?</p>sermethttps://www.mathworks.com/matlabcentral/profile/authors/3951076-sermettag:www.mathworks.com,2005:Question/3011232016-08-28T01:09:05Z2016-08-28T10:35:58ZI am messing up Eigenvalues in a loop...Help me please.<pre class="language-matlab">clear
</pre><pre class="language-matlab">g=0.1; E0=9.8; A=1; B=0;
</pre><pre class="language-matlab">E = 5:0.01:15;
</pre><pre class="language-matlab">for i=1:length(E);
</pre><pre class="language-matlab">H=[E(i),g/sqrt(2),g/sqrt(2);g/sqrt(2),E0,A;g/sqrt(2),B,E0];
</pre><pre class="language-matlab">[EIGVEC,EIGVAL]=eig(H);
</pre><pre class="language-matlab">EIGVAL1(i)=EIGVAL(1); EIGVAL2(i)=EIGVAL(5); EIGVAL3(i)=EIGVAL(9);
</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">figure
</pre><pre class="language-matlab">plot(E,real(EIGVAL1),'g',E,real(EIGVAL2),'r',E,real(EIGVAL3),'b')
</pre><p>Matlab is calculating the eigenvalues for every i. The calculated valus are allright the problem is that i am not able to give them any order. If you watch the plot you can see that Matlab is switching between eigenvalue number 1,2,3.</p><p>If you want to see the final plot without mistakes i have made it allready with other methods, but i need the working code for following physics problems (and for learning how to Matlab of course).</p><img src = "/matlabcentral/answers/uploaded_files/58438/untitled.jpg">Philipp Marxhttps://www.mathworks.com/matlabcentral/profile/authors/8605377-philipp-marxtag:www.mathworks.com,2005:Question/2985432016-08-05T08:22:09Z2016-08-28T10:33:54ZShould I remap keyboard shortcuts?<p>Hi,</p><p>I am new with MATLAB, but it has already saved me a lot of work by making programming simple.</p><p>I would just like to ask about the keyboard shortcuts. They are not the same standard as Windows or Linux. I now use Ubuntu and I got the following, for example:
alt/w copy,
ctr/y paste (requires long fingers ;)),
ctr/shift/- undo.</p><p>I am an older guy and change is difficult ;) I sometimes lean too long on the alt/w and end up in the view panel.</p><p>So far everything I have seen about MATLAB has been well considered and well worked out. So the choice of shortcuts is no coincidence, I am sure.</p><p>Before I remap the keyboard shortcuts I would just like to ask if there will be any negative consequences if I remap to ctr/c, ctr/x, ctr/v, ctr/z etc</p><p>Thank you</p>John Lofhttps://www.mathworks.com/matlabcentral/profile/authors/8340488-john-loftag:www.mathworks.com,2005:Question/3011322016-08-28T05:53:25Z2016-08-28T10:20:47Zchecking for positive syms<p>Hello</p><p>I have an element which is syms and I want to check if the items are positive
integers. I have not found a function like is real.</p><p>such that for example :</p><pre> syms h, assume(0<h<pi),</pre><p>I want to know if sin(h-pi/4) is positive or not.</p><p>Does anyone have a solution?</p>Muner Abou Hasanhttps://www.mathworks.com/matlabcentral/profile/authors/7312809-muner-abou-hasantag:www.mathworks.com,2005:Question/3011402016-08-28T10:05:49Z2016-08-28T10:05:49Zhi, How Can I make fire and smoke detector algoritm that in real time video or saved image files. Please help me for this project.<p>fire and smoke detection in video real time or in image files</p>Mehmet Ali EROGLUhttps://www.mathworks.com/matlabcentral/profile/authors/3887433-mehmet-ali-eroglutag:www.mathworks.com,2005:Question/1419122014-07-15T12:48:41Z2016-08-28T09:56:05ZHow to sum the fuel consumed at idle (vehicle speed=0)?<p>I have some vectors of data for time, vehicle fuel consumption, and vehicle speed for a certain driving trip. I am confused about how to tell Matlab to sum up the fuel used for all time when vehicle speed=0...any help with this would be sincerely and greatly appreciated! Here is what I have right now:</p><pre class="language-matlab">[ZeroSpeed, IdleFuelIndex] = min(VSPD);
IdleFuelTime = time(IdleFuelIndex);
IdleFuel=0;
for n=1:length(time)-1
IdleFuel(n+1) = Fuel_Consumed(IdleFuelTime)(n+1) + IdleFuel(n);
</pre><pre class="language-matlab">end
</pre><p>min(VSPD)=0, so IdleFuelTime should return the times when VSPD=0. (VSPD is the variable for vehicle speed). The problem is, Matlab is only returning for the first time that vehicle speed is zero! Also, I'm not sure about the for loop...perhaps I'm on the right track though? IdleFuel (the fuel consumed while the vehihcle is idling) is supposed to be equal to the summation of the fuel consumed by the vehicle at IdleFuelTime (whenever VSPD=0).</p><p>Thank you so much for your help with this, in advance! I'm really stuck on this.</p>Kelseyhttps://www.mathworks.com/matlabcentral/profile/authors/3821026-kelseytag:www.mathworks.com,2005:Question/3011392016-08-28T09:51:00Z2016-08-28T09:53:13Zenumeration class in simulink displayes signals wrongly ?<p>I have 2 enumeration classes</p><pre class="language-matlab">classdef clientRequest < Simulink.IntEnumType
enumeration
None(0)
Connect(1)
Send(2)
end
end
</pre><p>and</p><pre class="language-matlab">classdef serverResponse < Simulink.IntEnumType
enumeration
None(0)
Connect(1)
Send(2)
Listen(3)
end
end
</pre><p>At command prompt</p><pre class="language-matlab">int16(serverResponse.Listen)==int16(clientRequest.Send)
</pre><p>returns 0</p><p>But when i log the signals of this type in Simulation Data inspector there is a vertical tick called Listen
and with a Data cursor it shows both Send and Listen as values for this tick after a time
How is this possible ?
Is this a bug ?</p>timohttps://www.mathworks.com/matlabcentral/profile/authors/3366238-timotag:www.mathworks.com,2005:Question/3011372016-08-28T09:38:59Z2016-08-28T09:38:59ZHow can detect crushes?<p>I'm doing project about how to detect car accident automatically, and stopped in features extract, can you please help me</p>Alaa Abdelazizhttps://www.mathworks.com/matlabcentral/profile/authors/8606540-alaa-abdelaziztag:www.mathworks.com,2005:Question/3011352016-08-28T08:59:23Z2016-08-28T08:59:23Zcant extract surf features<p>i cant extract surf features from 120 folders when i use to detect surf features from the folders i shows and error undefiend function or variable here is my code..</p><pre class="language-matlab">if true
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Start with a folder and get a list of all subfolders.
% Finds and prints names of all PNG, JPG, and TIF images in
% that folder and all of its subfolders.
% Similar to imageSet() function in the Computer Vision System Toolbox: http://www.mathworks.com/help/vision/ref/imageset-class.html
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
</pre><p>% Define a starting folder.
start_path = fullfile(matlabroot, '\toolbox\images\imdemos');
% Ask user to confirm or change.
topLevelFolder = uigetdir(start_path);
if topLevelFolder == 0
return;
end
% Get list of all subfolders.
allSubFolders = genpath(topLevelFolder);
% Parse into a cell array.
remain = allSubFolders;
listOfFolderNames = {};
while true
[singleSubFolder, remain] = strtok(remain, ';');
if isempty(singleSubFolder)
break;
end
listOfFolderNames = [listOfFolderNames singleSubFolder];
end
numberOfFolders = length(listOfFolderNames)</p><p>% Process all image files in those folders.
for k = 1 : numberOfFolders
% Get this folder and print it out.
thisFolder = listOfFolderNames{k};
fprintf('Processing folder %s\n', thisFolder);
% Get PNG files.
filePattern = sprintf('%s/*.png', thisFolder);
baseFileNames = dir(filePattern);
% Add on TIF files.
filePattern = sprintf('%s/*.tif', thisFolder);
baseFileNames = [baseFileNames; dir(filePattern)];
% Add on JPG files.
filePattern = sprintf('%s/*.jpg', thisFolder);
baseFileNames = [baseFileNames; dir(filePattern)];
numberOfImageFiles = length(baseFileNames);
% Now we have a list of all files in this folder.
if numberOfImageFiles >= 1
% Go through all those image files.
for f = 1 : numberOfImageFiles
fullFileName = fullfile(thisFolder, baseFileNames(f).name);
fprintf(' Processing image file %s\n', fullFileName);
end
else
fprintf(' Folder %s has no image files in it.\n', thisFolder);
end
end
end</p>ahmed SHAHhttps://www.mathworks.com/matlabcentral/profile/authors/8063956-ahmed-shahtag:www.mathworks.com,2005:Question/3011342016-08-28T08:35:34Z2016-08-28T10:03:01ZChange x axis labels at specific locations<p>I have made a double y axis plot that uses the same x axis with the following:</p><pre class="language-matlab">plotyy(w,DB09CS(1:209,1),w,UVI09CS(1:209,1))
</pre><p>For the x axis there must be a label at location 0,63,108 and 153.</p>David du Preezhttps://www.mathworks.com/matlabcentral/profile/authors/7651225-david-du-preeztag:www.mathworks.com,2005:Question/2720562016-03-08T08:01:26Z2016-08-28T08:08:27ZThe model Discrete-time scatter plot isn't in simulink<p>Hi,I install MATLAB 2015b in may PC,but i can't find Discrete-time scatter plot model in SIMULINK.Could you help me?</p>lanu chaurhttps://www.mathworks.com/matlabcentral/profile/authors/4584811-lanu-chaurtag:www.mathworks.com,2005:Question/3011262016-08-28T03:12:30Z2016-08-28T07:52:59ZWhat does "File I/O error on file 'rti1104.tlc' " mean?<p>I'm making a controller with Simulink. However,when it comes to the build up, "File I/O error on file 'rti1104.tlc';"Operation that caused an error: open" is always read in the diagnostic viewer. I don't know where to find the answer, since there is few hints for me from the software. Has anyone ever met a similar problem? Thanks a lot.</p>michelle Dihttps://www.mathworks.com/matlabcentral/profile/authors/8219479-michelle-ditag:www.mathworks.com,2005:Question/3011272016-08-28T03:49:21Z2016-08-28T07:50:51ZHow to convert video file to bitstream in matlab ?<p>Hi,
Do you know, how can i convert a video file with avi format to bitstream in Matab?
i should convert avi file to bitstream and then send it as 2048-by-1 column vectors to a channel.
it would be appreciated if you could help me.</p>Mahdiyeh fvhttps://www.mathworks.com/matlabcentral/profile/authors/7550932-mahdiyeh-fvtag:www.mathworks.com,2005:Question/3011292016-08-28T05:19:07Z2016-08-28T07:45:12ZHow to insert a saved .png figure into a subplot which is being created in a for loop?<p>Hello Friends,</p><p>I have the following code</p><pre class="language-matlab">for k = 1:2
subplot(1,3,k)
plot(randi(10,k));
end
</pre><p>I want to insert a saved <b>.png</b> (I prefer <b>.png</b>, but if it is easier for <b>.fig</b>, it is also ok) into this subplot which is being created in for loop at position <b>subplot(1,3,1)</b>. This way, the inserted figure will come at the first position moving other two subfigures to the next available positions.</p><p>I will appreciate any advise!</p>hello_worldhttps://www.mathworks.com/matlabcentral/profile/authors/5403394-hello_worldtag:www.mathworks.com,2005:Question/3011332016-08-28T06:01:44Z2016-08-28T07:31:28Zjpeg Image Compression Implementation<p>Hey All,</p><p>How is image compression done in real digital devices, laptops, cameras and mobile phones? Is it hardware or software implemented?</p><p>Regards,
Yasmine</p>Yasmine Tamimihttps://www.mathworks.com/matlabcentral/profile/authors/2779437-yasmine-tamimitag:www.mathworks.com,2005:Question/3011312016-08-28T05:30:16Z2016-08-28T06:45:23Zquad8 in matlab 7<pre> quad8 is higher-order terms and this function available in matlab 6.5 however, not in matlab 7. Gone through your side side and found the following : quad8, a higher-order method, has the same calling sequence as quad.</pre><p>1) Can i replace my quad8 function to quad and will that work as higher order term as quad8?</p><p>Please assist.</p>Ana Roycehttps://www.mathworks.com/matlabcentral/profile/authors/7133000-ana-roycetag:www.mathworks.com,2005:Question/3011242016-08-28T01:32:46Z2016-08-28T06:39:10ZPlease help me , how coding in matlab to create GIF files with LZW compression and RLE ? on its support I thanked<p>Please help me , how coding in matlab to create GIF files with LZW compression and RLE ?
on its support I thanked</p>ardi homsahttps://www.mathworks.com/matlabcentral/profile/authors/8605404-ardi-homsatag:www.mathworks.com,2005:Question/3011302016-08-28T05:24:02Z2016-08-28T06:37:37Zflops on matlab 7<p>I copied flops.m file into matlab\toolbox\optim\optim\flops.m then went to matlab command window typed : which flops ...system prompts
which flops
'flops' not found.</p><p>any reason? where should i store this file?</p>Ana Roycehttps://www.mathworks.com/matlabcentral/profile/authors/7133000-ana-royce