https://kr.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-06-28T06:57:21Ztag:kr.mathworks.com,2005:Question/3454252017-06-20T02:06:20Z2017-06-28T06:57:21ZBinary solutions with GA<p>Hi</p><p>I am currently working with GA on resource allocation and the goal is to find binary solutions with a non linear objective and linear constraints.</p><p>At the beginning of the project, I had a problem with more than 700 variables with many constraints and the solutions that I had from GA were very irrelevant. I thought the size of the problem was the issue.</p><p>So I broke down the problem into many models in order to have less that hundreds variables (in occurrence 30 variables for the current model I am building) and around hundreds constraints too for each model (in occurrence 95 linear constraints for the same current model). Besides, some of the constraints are normally equality constraints that I transformed into inequality constraints to help GA to find a solution. BUT at the end I still have solutions that don't correspond to the constraints. For the instance, for example if we want to allocate 30 bags in 5 cabinets so that each bag is allocated only in one cabinet, I got some results where one bag is allocated in many cabinets, even though the inequality constraints that I wrote seem totally correct.</p><p>I have this report at the end "Optimization terminated: average change in the penalty fitness value less than options.FunctionTolerance and constraint violation is less than options.ConstraintTolerance".</p><p>I don't really know what to do with this problem and I am quite in a need of a solution for an industrial (confidential) problem after having purchased GA weeks ago (the trials for smaller sizes seemed to work previously). Please could you give any support for that?</p><p>Thanks,</p><p>Loic</p>Loic Wilfried Biakeu Njiahttps://kr.mathworks.com/matlabcentral/profile/authors/8327743-loic-wilfried-biakeu-njiatag:kr.mathworks.com,2005:Question/3465342017-06-28T06:21:41Z2017-06-28T06:51:07ZHow to make a timer execute an internal function in gui?<p>I am unable to call a function that is inside of GUI (not calling the external function). The timer works well if the
function is external, but I want it to be internal, that I will have just one file. I have the inicialization of timer in opening function:</p><pre> function GUI_OpeningFcn(hObject, eventdata, handles, varargin)</pre><pre> handles.t = timer('BusyMode', 'queue', 'ExecutionMode',...
'fixedRate', 'Period', 4.0, 'TimerFcn', 'funkcija');</pre><pre> start(handles.t);</pre><p>The function I want to run each time with usage of initialized timer:</p><pre> function funkcija(EventData, handles)</pre><pre> a = 1;</pre><p>I know there is something wrong with the input parameters, but I just cannot figure out what exactly.</p>Programerckhttps://kr.mathworks.com/matlabcentral/profile/authors/10532575-programercktag:kr.mathworks.com,2005:Question/3465332017-06-28T06:12:49Z2017-06-28T06:42:22ZUndefined function or variable 'validateBoundaryFcn'.<p>Hi all,
I have been working with the toolbox "ADAS", and is currently trying the documentation of the same.
The task involves working with determination of lanes and obstacles on roads.</p><p>While implementing the same, i am getting the following error:</p><pre class="language-matlab">Trial>> file1
Undefined function or variable 'validateBoundaryFcn'.
</pre><pre class="language-matlab">Error in vision.internal.ransac.msac (line 73)
isValidModel = funcs.checkFunc(modelParams, varargin{:});
</pre><pre class="language-matlab">Error in fitPolynomialRANSAC (line 102)
vision.internal.ransac.msac(xyPoints, ransacParams, ransacFuncs);
</pre><pre class="language-matlab">Error in findParabolicLaneBoundaries (line 135)
[~, inlierIdx] = fitPolynomialRANSAC(xyBoundaryPoints, N, maxDistance,...
</pre><pre class="language-matlab">Error in file1 (line 65)
[boundaries, boundaryPoints] = findParabolicLaneBoundaries(xyBoundaryPoints,boundaryWidth,'MaxNumBoundaries', maxLanes,
'validateBoundaryFcn', @validateBoundaryFcn);
</pre><p>This error is occurring when i am using the following function/command:</p><pre class="language-matlab">[boundaries, boundaryPoints] = findParabolicLaneBoundaries(xyBoundaryPoints,boundaryWidth,'MaxNumBoundaries', maxLanes, 'validateBoundaryFcn', @validateBoundaryFcn);
</pre><p>I have tried the suggestions from the Mathwork on how to fix this issue and have re-set the path as per the mentioned instructions.</p><p>Kindly help me in this regards.
Thanks</p>Ayush Sharmahttps://kr.mathworks.com/matlabcentral/profile/authors/6723545-ayush-sharmatag:kr.mathworks.com,2005:Question/3454642017-06-20T09:04:11Z2017-06-28T06:35:05Zrecurrence relation for any given 'n'.<p>How to compute A_j^(2n) for any 'n' using A_j^(2).</p><p>Here, n=2,3,4,...; and j=1:n-1.</p><img src = "/matlabcentral/answers/uploaded_files/81041/Eq.png"><p>Any kind of help is highly appreciated.</p><p>Thank you.</p>Venkatahttps://kr.mathworks.com/matlabcentral/profile/authors/2389187-venkatatag:kr.mathworks.com,2005:Question/3465352017-06-28T06:30:18Z2017-06-28T06:30:18ZHow is convolution neuron network evolved with supervised training in image classification?<p>There are tons of online blogs/papers introducing basic mechanism of how convolution neuron network process a single image. For a classification problem, for example classify a image of dog or cat, the result is normally the respective probabilities of the image being dog and cat categories.</p><p>However, I'm not clear <b>how such result is compared with ground truth then feed back into network and re-train it</b>.</p><p>The demo codes online either Python or Matlab normally start from splitting the images into two groups: training set and testing set. Then a CNN object is built. The training set is feed into the CNN object to build a model. <b>How does CNN process images? Does it process one by one?</b></p>Kylehttps://kr.mathworks.com/matlabcentral/profile/authors/2995873-kyletag:kr.mathworks.com,2005:Question/3464252017-06-27T12:03:06Z2017-06-28T06:19:11ZHow to add a boundary into a image for saving<p>As the title, I have an image A and boundary B = bwboundaries(C)
if I wanna show it, I can use
imshow (A);
hold on;
visboundaries(B,'Color','');
if I use save button. the image I save don't have the same resolution as my source image
so what should I do now?</p>R Ghttps://kr.mathworks.com/matlabcentral/profile/authors/9368027-r-gtag:kr.mathworks.com,2005:Question/3465232017-06-28T03:12:34Z2017-06-28T06:05:19ZHow to fit a polynomial with inequality constraints on the coefficients<p>I am trying to fit some data to the functional form:</p><p>f(x)=a(1)*exp(a(2)*x)+a(3)*(x^2)+a(4)*x-a(1)</p><p>I want to:</p><ol><li>force a(1)*a(2)+a(4) to have a maximum value of 10</li><li>force f(x) to be positive at all values of x>0</li></ol><p>I was trying to use lsqcurvefit, but it seems the function does not allow inequality constraints.</p><pre class="language-matlab">x_data=[1.26400000000000
2.04000000000000
3.54400000000000
4.76000000000000
6.26000000000000
7.64400000000000
11.7720000000000
13.6880000000000
18.3680000000000
18.3680000000000]
y_data=[8.36003800000000
14.0006040000000
32.5919380000000
47.0971720000000
50.7733640000000
46.9911360000000
41.1428660000000
37.6193000000000
39.4918400000000
39.0617800000000]
</pre><p>Thanks!</p>Kathleenhttps://kr.mathworks.com/matlabcentral/profile/authors/5228529-kathleentag:kr.mathworks.com,2005:Question/3444082017-06-12T15:30:31Z2017-06-28T06:03:59ZPolyspace nodesktop programs not running<p>Hello,</p><p>I'm setting up scripts that use the nodesktop.exe files for both Bug Finder and Code Prover. For both files though, when I pass the -h flag for pulling up help options, they output nothing and don't seem to run at all.</p><p>Additionally, Bug Finder (nodesktop) doesn't run in general despite using option files and configurations that the rest of my team uses successfully.</p><p>What could I be missing about their usage?</p>Jeff Campbellhttps://kr.mathworks.com/matlabcentral/profile/authors/8355601-jeff-campbelltag:kr.mathworks.com,2005:Question/3464222017-06-27T11:55:10Z2017-06-28T06:03:50ZBinary Classification _ problem with data structure <p>Hi, i want to create neural network for binary classification so when i read in matlab doc for patternet that Classification problems involving only two classes can be represented using either format. The targets can consist of either scalar 1/0 elements or two-element vectors, with one element being 1 and the other element being 0.(link= https://www.mathworks.com/help/nnet/gs/classify-patterns-with-a-neural-network.html) so i tried to set each scalar target value to either 0 or 1
but in the confusion matrix i got NAN values for the second class</p><pre> [ I N ] = [ 9 981 ] </pre><pre> [ O N ] = [ 1 981 ] </pre><p>And this is the code</p><pre> rng('default');
x = patientInputs;
t = patientTargets ;
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize =10;
net = patternnet(hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.performFcn = 'mse'; % Cross-Entropy</pre><pre> % Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotconfusion', 'plotroc'};</pre><pre> % Train the Network
net= configure(net,x,t);
[net,tr] = train(net,x,t);</pre><pre> y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);</pre><pre> % Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)</pre><pre> % View the Network
view(net)</pre><img src = "/matlabcentral/answers/uploaded_files/81566/nan.png"><p>i don't know why? can anyone tell me please?</p>afefhttps://kr.mathworks.com/matlabcentral/profile/authors/9902982-afeftag:kr.mathworks.com,2005:Question/3465302017-06-28T05:01:23Z2017-06-28T05:55:58Zhow can we find the intersection point of two polynomial equations?<p>I have two 10th ordrer equations,I want intersection points of these two equtions.</p>anuradha pujalahttps://kr.mathworks.com/matlabcentral/profile/authors/10532385-anuradha-pujalatag:kr.mathworks.com,2005:Question/3465322017-06-28T05:54:03Z2017-06-28T06:53:09ZHow to write a single line code for ‘n’ number of functions.<p>I would like to write a single line code for ‘n’ number of functions.</p><p>For example (here ‘v’ and ‘theta’ are variables)</p><pre> f(1)= v(1)cos(theta(1));
f(2)= v(2)cos(theta(2));
f(3)= v(3)cos(theta(3));
.
.
f(n)= v(n)cos(theta(n));</pre><p>I wrote my code as</p><pre> n=10;
syms v theta
for i=1:n
f(i)= v(i)*cos(theta(i));
end</pre><p>it gave the following errors</p><pre class="language-matlab">Index exceeds matrix dimensions.
</pre><pre class="language-matlab">Error in sym/subsref (line 814)
R_tilde = builtin('subsref',L_tilde,Idx);
</pre><pre class="language-matlab">Error in Untitled2 (line 6)
f(i)= v(i)*cos(theta(i));
</pre><p>Would appreciate your kind help.</p><p>Regards, Mustafa</p>Mohammed Rizvihttps://kr.mathworks.com/matlabcentral/profile/authors/8231128-mohammed-rizvitag:kr.mathworks.com,2005:Question/3464402017-06-27T13:37:45Z2017-06-28T05:52:06ZIndex are not used completely<p>Hello, me again.
I have a set of data. I have a to calculate small current. So I need max and min. But since is a noisy signal I can't use peak2peak. So what I did. In a range predetermine. I take the max.. find the index. later from that index I calculate a new range, to make the mean around that number. For each cell I have 5 traces. My problem is the following: I calculate the max for each trace, the index, then when I want to calculate the mean, the range it choose to find the new numbers is not taken in consideration. Only uses the first index I calculate.</p><pre class="language-matlab">[valmax, idxmax]= max(input.current(:,1002:1032),[],2);
indexFromZero (:,ii,jj)= 1002+idxmax-1;
MaximumMean(:,ii,jj)= mean(input.current(:,indexFromZero-1:indexFromZero+1),2);
indexMinimumRange(:,ii,jj)=indexFromZero (:,ii) +40;
[valmin, idxmin]= min(input.current(:,indexMinimumRange-1:indexMinimumRange+1),[],2);
MinmumMean(:,ii,jj)=mean(input.current(:,indexMinimumRange-1:indexMinimumRange+1),2);
Ih(:,ii)=MaximumMean(:,ii)-MinmumMean(:,ii);
</pre><p>So indexFromZero is a matrix with the index for all the traces.But it always calculates in the range of 1017, the first number.</p><pre class="language-matlab">1017
1016
1026
1024
1021
</pre><p>[ii and jj are the cell number and the sheet from excel where the information of the cell is]</p>Milagros ARIETTIhttps://kr.mathworks.com/matlabcentral/profile/authors/7139067-milagros-ariettitag:kr.mathworks.com,2005:Question/3464452017-06-27T14:12:42Z2017-06-28T05:46:23ZWhy do i have NAN values in the confusion matrix only in the validation test? <p>I wanted to create neural network for binary classification for dataset with input matrix with size [9 981] and output matrix [1 981]and this is the code that i used</p><pre> rng('default');
inputs = patientInputs;
targets = patientTargets;
x = mapminmax(inputs);
t=targets;
trainFcn = 'trainbr';
% Create a Pattern Recognition Network
hiddenLayerSize =10;
net = patternnet(hiddenLayerSize,trainFcn);</pre><pre> net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.performFcn = 'mse'; </pre><pre> % Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotconfusion', 'plotroc'};</pre><pre class="language-matlab">% Train the Network
net= configure(net,x,t);
[net,tr] = train(net,x,t);
</pre><pre> y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);</pre><pre> % Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)</pre><pre class="language-matlab">% View the Network
view(net)
</pre><p>At first i used the default trainFcn 'trainscg' then i tried to use 'trainbr' the accuracy improved but i got NAN values in the confusion matrix only in the validation test as you can see it here</p><img src = "/matlabcentral/answers/uploaded_files/81572/trainbr.png"><p>Can anyone help me please?</p>afefhttps://kr.mathworks.com/matlabcentral/profile/authors/9902982-afeftag:kr.mathworks.com,2005:Question/3464802017-06-27T17:50:48Z2017-06-28T05:43:06ZHow to control the apperance of a "ui control" from another gui?<p>Basically,
I have 2 GUIs opened at the same time: GUI1 and GUI2.
GUI1 includes a "Static Text"
while GUI2 includes a "Push Button".
I would like the Color property of the Static Text in GUI1 to change when I push the Push Button on GUI2</p><p>Please Advise</p>Ahmedhttps://kr.mathworks.com/matlabcentral/profile/authors/4078291-ahmedtag:kr.mathworks.com,2005:Question/3465312017-06-28T05:42:56Z2017-06-28T05:42:56Zhow can i implement beta method for MPPT of PV panel<p>PV model</p>manoranjan maharanahttps://kr.mathworks.com/matlabcentral/profile/authors/10514218-manoranjan-maharanatag:kr.mathworks.com,2005:Question/3465262017-06-28T03:55:18Z2017-06-28T05:36:37ZWhat will be on x and y axis of this graph?<pre class="language-matlab">f = 100
t = [0:0.00001:1/f] %time
x = sin(2*pi*f*t) %amplitude
plot(t, x)
hold on
plot(x, t)
</pre>Chinmay Chhajedhttps://kr.mathworks.com/matlabcentral/profile/authors/10532247-chinmay-chhajedtag:kr.mathworks.com,2005:Question/2343272015-08-18T05:13:56Z2017-06-28T05:32:49Zhow to do fft to a gaussian function<p>I have a Gaussian wave function that is psi = exp(-x.^2/sigma^2) with sigma = 1e-5 and x range x = -3e-5:1e-7:3e-5.
I can get a perfect Gaussian shape by plotting this function.
But when I do fft to this equation, I always get a delta function. Should I get a Gaussian function in momentum space?
Thanks very much for answering my question.
This is my code.</p><p>close all; clear all; clc;</p><p>sigma = 1e-5;</p><p>x = -3e-5:1e-7:3e-5;</p><p>psi = exp(-x.^2/sigma^2);</p><p>A = 1/sqrt(sum(abs(psi).^2*1e-7));</p><p>psi = A.*psi;</p><p>figure</p><p>plot(x,psi);</p><p>xlim([-3e-5,3e-5]);</p><p>xlabel('x axis (m)')</p><p>ylabel('psi')</p><p>title('gaussian distribution sigma = 10 um')</p><p>phi = fft(psi);</p><p>phi = fftshift(phi);</p><p>k = linspace(-1e-100,1e-100,length(phi));</p><p>figure</p><p>plot(k,abs(phi))</p><p><<</p><img src = "/matlabcentral/answers/uploaded_files/35840/gaussian.jpg"><p>>></p><img src = "/matlabcentral/answers/uploaded_files/35841/fft_gaussian.jpg">SHIJIE CHAIhttps://kr.mathworks.com/matlabcentral/profile/authors/6011697-shijie-chaitag:kr.mathworks.com,2005:Question/3464872017-06-27T18:36:24Z2017-06-28T05:28:30ZError in converting Cell array to double<p>Hi,</p><p>I'm converting some cell arrays to their equivalent numbers, but have an error for couple of them.
I attached the variables to this question.</p><p>The problem is in my cell array some elements are 'NaN' and also some other elements have different length.So when I'm using this command to convert:</p><pre class="language-matlab">G8_D=str2num(cell2mat(G8));
C1_D=str2num(cell2mat(C1));
</pre><p>I get this error:</p><pre class="language-matlab">Dimensions of matrices being concatenated are not consistent.
</pre><p>The important matter is 'I can not remove Nan elements and shift all cells up or down because the location of each element is meaningful for me, but that's ok if I get a number like 0 instead of Nan '</p><p>I was thinking to maybe add some zeros to the end of elements to make their length equal but couldn't get a good result.</p><p>Any idea to how to convert these two cell arrays to number?</p><p>Thanks</p>Mo Bahttps://kr.mathworks.com/matlabcentral/profile/authors/7769281-mo-batag:kr.mathworks.com,2005:Question/2721512016-03-08T17:16:05Z2017-06-28T05:20:28Z3 phase voltage source rectifier with Voltage Oriented Control , initial values issue<p>Hi,</p><p>Im working on an IGBT voltage source rectifier in SimPowerSystem. My controller is based on Voltage Oriented Control. the rectification is performed on the dc side, but the initial value of voltage and current stays at 740 between t=0 and t=20ms (one grid period). where could it come from ? when I set up the initial voltage on the dc link capacitor it does not change this value. But for conventionnal diode bridge without control, this is the initial value set for the capacitor that we can see at t=0....</p><p>Thank you</p><img src = "/matlabcentral/answers/uploaded_files/47149/dc_side_values.PNG">quentin sachothttps://kr.mathworks.com/matlabcentral/profile/authors/7801763-quentin-sachottag:kr.mathworks.com,2005:Question/3462232017-06-26T03:59:54Z2017-06-28T05:08:29Zvalue change each time when running the codes to estimate the Eb No vs BER plot???<p>value change each time when running this codes to estimate the Eb No vs BER plot??? any ideal why this happen? pls, help me. thanks</p><pre> M = 16;
k = log2(M);
EbNo = (0:10);
ber = zeros(size(EbNo));
trellis = poly2trellis(5,[25, 33, 37]);
codeRate = 1/3;</pre><pre> convEncoder = comm.ConvolutionalEncoder('TrellisStructure',trellis);
vitDecoder = comm.ViterbiDecoder(poly2trellis(5, [25 33 37]), ...
'InputFormat', 'Unquantized');</pre><pre> qamModulator = comm.RectangularQAMModulator('ModulationOrder',M, ...
'BitInput',true, ...
'NormalizationMethod','Average power');</pre><pre> qamDemodulator = comm.RectangularQAMDemodulator('ModulationOrder',M, ...
'BitOutput',true, ...
'NormalizationMethod','Average power');</pre><pre> errorRate = comm.ErrorRate;</pre><pre> for m = 1:length(EbNo)</pre><pre> errorStats = zeros(1,3);
noiseVar = EbNo(m) + 10*log10(k*codeRate);</pre><pre> while errorStats(2) < 100 && errorStats(3) < 1e7</pre><pre> data = randi([0 1],400,1);</pre><pre> encodedData = step(convEncoder, data);</pre><pre> modSignal = step(qamModulator,encodedData);</pre><pre> receivedSignal = awgn(modSignal,noiseVar);</pre><pre> demodSignal = step(qamDemodulator,receivedSignal);</pre><pre> receivedBits = step(vitDecoder, demodSignal);</pre><pre> errorStats =step( errorRate,data,receivedBits);
end</pre><pre> ber(m) = errorStats(1);
reset(errorRate)
end</pre><pre> semilogy(EbNo,ber,'-*')
grid
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')</pre><p><<</p><img src = "/matlabcentral/answers/uploaded_files/81429/222222222.PNG"><p>>></p>z mhttps://kr.mathworks.com/matlabcentral/profile/authors/7588122-z-mtag:kr.mathworks.com,2005:Question/3456192017-06-21T07:01:49Z2017-06-28T04:56:36ZHow can I deal with the struct 'mov(k).cdata'?<p>I want to deal with a movie consists of 256 images.</p><p>I used 'mmreader' to get the movie.
Now i have "mov(k).cdata" as a struct data of images.
How can i deal with the <tt>1×256 struct</tt>?
i want to play some codes for mov(k).cdata as images. for example,</p><p>for k=1:numframes</p><p>(~some binary codes for mov(k).cdata)</p><p>end</p>Sayaka Kamatahttps://kr.mathworks.com/matlabcentral/profile/authors/2100773-sayaka-kamatatag:kr.mathworks.com,2005:Question/3465292017-06-28T04:56:09Z2017-06-28T04:57:09ZIndex exceeds matrix dimensions (Thermal 1d model)<p>I'm trying to write a 1D thermal model using a finite difference scheme. I'm still an amateur programmer so I apologize for my ignorance. I keep getting this error: Index exceeds matrix dimensions. I know this means that I'm trying to access an element in an array using an index that exceeds the dimension of the array but I don't know what to do with that information.</p><pre class="language-matlab">N = 15;
% Geometrically increasing grid spacing
z = 0;
zs = [kappa*P/pi]^(1/2);
deltaz = zs/10;
for i = 1:N
deltaz(i+1) = deltaz(i)*(1+1/5);
z(i+1) = z(i)+deltaz(i);
T0 = [[(S0/R^2).*(1-A)]/(e*(5.67*10^-8))]^(1/4);
TN = T0/((2)^(1/2));
T(i+1) = TN - (TN-T0)*exp(-z(i+1)/0.06);
zor(i+1) = deltaz(i+1)*deltaz(i)*(deltaz(i+1)+deltaz(i));
alpha_model(i+1) = 2*K*deltaz(i+1)/zor(i+1);
beta_model(i+1) = 2*K*deltaz(i)/(zor(i+1));
for n= 1:N
T(i+1,n+2) = T(i+1,n+1) + [dt/(rho*cp)].*[alpha_model(i+1).*T(i,n+1)-(alpha_model(i+1) + beta_model(i+1)).*T(i+1,n+1) + beta_model(i+1).*T(i+2,n+1)];
end
end
</pre>Aditya Khullerhttps://kr.mathworks.com/matlabcentral/profile/authors/7045297-aditya-khullertag:kr.mathworks.com,2005:Question/1119712014-01-10T07:04:56Z2017-06-28T04:55:43ZHow to build a Fourier matrix?<p>How would I build a Fourier matrix in Matlab? Intuitively what is this matrix telling me and is there a difference between a Fourier matrix for a vector signal (x) vs. a Fourier matrix for an image (I) signal? My intuition is that it doesn't matter and that the matrix simply holds the frequencies I wish to capture. For example:</p><p>y = Fx,</p><p>where F is the Fourier matrix, x is a sparse vector and y are my signals. x could stand for my vectorized image, say x = I(:)</p><p>so far I have</p><pre class="language-matlab">F = dftmtx(numel(I))
</pre><p>Is this right?</p><p>p.s. Are there different names used to refer to this Fourier Matrix?</p><p>Thank you</p>Valentinhttps://kr.mathworks.com/matlabcentral/profile/authors/2483798-valentintag:kr.mathworks.com,2005:Question/3465282017-06-28T04:27:40Z2017-06-28T04:57:45ZReport generation along with successful Polyspace analysis results using command line option<p>i wanted to analyze and generate report for one of .c file,</p><p>for <b>Analysis i have used below command</b></p><p>"C:\Program Files\MATLAB\R2014a\polyspace\bin\polyspace-code-prover-nodesktop.exe" <b>-prog</b> LORD_VENKAT <b>-author</b> sharath <b>-I</b> "C:\Sarath\Renault_RACAM_Host\GEN_FILES" <b>-results-dir</b> "C:\Sarath\Renault_RACAM_Host\Applications\POLYSPACE_OUT\Polyspace-Doc" <b>-main-generator</b> <b>-lang</b> c <b>-batch</b> <b>-scheduler</b> HXXXXXXXXX <b>-sources-list-file</b> "FILES_LIST.txt"</p><p>for <b>report generation</b> below command</p><p>"C:\Program Files\MATLAB\R2014a\polyspace\bin\polyspace-report-generator.exe" <b>-template</b> "C:\Program Files\MATLAB\R2014a\polyspace\toolbox\psrptgen\templates\Developer.rpt" <b>-format</b> pdf <b>-results-dir</b> "C:\Sarath\Renault_RACAM_Host\Applications\POLYSPACE_OUT\Polyspace-Doc"</p><p>1.if i use both the commands in a single line i am getting error like "Error: Polyspace : Read access problem on ..."
even though i am having admin rights.</p><p>2.if i am giving individually</p><pre class="language-matlab">*analysis command* : i can see job status is running in schedule manager.
*Report generation command* : This report contains only Polyspace Code Verification Summary, Code Metrics,Configuration Settings,Definitions
</pre><p><b>*</b> In generated report i can see there is missing section <b>Polyspace Proven</b> which will gives details of number errors in detail.
and another section <b>Polyspace Run-Time Checks Results</b></p><p>***here my problem is how i can generate a report with all the list of warnings and with out missing sections (that i have mentioned above) using command line.</p><p>Is that commands that i have given correct or not.</p><p>could you please help me in this</p><p>Thanks in advance
Sharath Jakku</p>sharath jakkuhttps://kr.mathworks.com/matlabcentral/profile/authors/6698800-sharath-jakkutag:kr.mathworks.com,2005:Question/3464442017-06-27T14:11:25Z2017-06-28T04:16:29ZHow can i select 1 of the 2 outputs on the basis of conditions?<img src = "/matlabcentral/answers/uploaded_files/81609/problem%20ifelse.png"><p>I am designing a controller. I have certain logical conditions on which one of the two controllers i.e. Main controller and sub controller is to be selected . I am using an "if block" with two "if action" sub blocks for selection. The output of both the controllers is a 3x1 vector. Now "if block" will select the controller based on certain conditions. But how to select one of two outputs from the controllers is my problem!!
Kindly see the attached Simulink model for more clear idea of my problem.
I have already tried merge and mux blocks but both of these cannot select one of the outputs.</p>Matihttps://kr.mathworks.com/matlabcentral/profile/authors/10528699-matitag:kr.mathworks.com,2005:Question/3462612017-06-26T11:29:00Z2017-06-28T04:15:39ZWhy can't MEX find a supported compiler in MATLAB R2017a in macOS Sierra<p>I'm using the latest macOS (Sierra 10.12.5) and mex can not find the compiler, or SDK even if the latest Xcode (8.3.3) and Intel Paralell Studio are installed.</p>Peter Kerekeshttps://kr.mathworks.com/matlabcentral/profile/authors/10071291-peter-kerekestag:kr.mathworks.com,2005:Question/3465272017-06-28T04:05:08Z2017-06-28T04:10:20Zcan you tell me if I performed feedforwardnet correctly<p>Hi,
I'm trying to perform feedforwardnet on data set consist of input with 14 predictors and 1217 records, and the output is the class values either 0 or 1.
I wrote this code could you please tell if it is correct or not</p><pre class="language-matlab">if true
data = xlsread('CellDNA');
x= (zscore(data(:,1:13)));
y=(data(:,14)~=0);
[ I N ] = size(x); %[14 1217]
[ O N ] = size(y); %[1 1217]
net = feedforwardnet(3);
net = train(net,[I N],[O N]);
view(net)
Y_hat = sim(net, [I N]); end
</pre>SAMIA ALGHAMDIhttps://kr.mathworks.com/matlabcentral/profile/authors/10379124-samia-alghamditag:kr.mathworks.com,2005:Question/2217462015-06-01T04:26:09Z2017-06-28T04:04:18ZHow can I plot 3D contour plot for (x, y, z) Cartesian grid with values at each cell?<p>What code should I use to plot a 3D contour plot? I saw there are some contour3 functions, but I don't know how to create the 2*2 matrix for my data. I have data include (x,y,z) positioning data and value at each position. I attached part of my data looks like, not all y,z values are zero.</p><img src = "/matlabcentral/answers/uploaded_files/31825/1.PNG"><p>I also attached a plot that shows closely to what I want, but I also want scales shown on the figure.</p><img src = "/matlabcentral/answers/uploaded_files/31826/2.PNG">Jiahttps://kr.mathworks.com/matlabcentral/profile/authors/4739715-jiatag:kr.mathworks.com,2005:Question/3465252017-06-28T03:48:56Z2017-06-28T03:49:21ZMultiplying very large matrix on Multiple GPU<p>I am trying to multiply 2 very large matrices and need help finding a faster way. I have 2 1080gtx SLI, I know that in Matlab SLI is meaningless, and I also have 10core i7 6950x with 64Gbs of ram.</p><p>CUDADevice with properties:</p><pre> Name: 'GeForce GTX 1080'
Index: 1
ComputeCapability: '6.1'
SupportsDouble: 1
DriverVersion: 8
ToolkitVersion: 8
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 8.5899e+09
AvailableMemory: 6.9290e+09
MultiprocessorCount: 20
ClockRateKHz: 1860000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1</pre><p>what I am ultimately trying to do is slice one of the matrices and utilize the both GPUs and minimize iterations on a for loop</p><pre class="language-matlab">p=rand([1000000 10]); % realistically p is [4.5 million x 12]
Sim2=randn([20 50000 10]); % realistically Sim is [40 x 1 million x 12]
Sim{1}=(single(permute(Sim2(:,1:25000,:),[2 3 1])));
Sim{2}=(single(permute(Sim2(:,25001:end,:),[2 3 1])));
</pre><pre class="language-matlab">p2=p(1:50000,:);
p3=p(1:50000,:);
</pre><pre class="language-matlab">spmd
gd = gpuDevice;
idx = gd.Index;
disp(['Using GPU ',num2str(idx)]);
x1=gpuArray(single(p2));
x2=gpuArray(single(p3));
A=gpuArray(Sim{1});
B=gpuArray(Sim{2});
C =pagefun(@mtimes,A,x2');
D =pagefun(@mtimes,B,x3');
wait(gd)
end
</pre><p>I have bench-marked both computations and it looks like the recursively multiplying takes just as long as simultaneous multiplications. I need to speed this up by at least 2 fold please any ideas.</p>Mike Ahttps://kr.mathworks.com/matlabcentral/profile/authors/3494120-mike-atag:kr.mathworks.com,2005:Question/3455402017-06-20T16:40:57Z2017-06-28T03:43:56Zsim function of the neuralnetwork<p>I want to simulate the network that I got with the new data and I use results=sim(net, new data) should I normalize the new data? and to get the real value of the result of network I need to denormalize the results?
Thanks for any idea</p>Ritahttps://kr.mathworks.com/matlabcentral/profile/authors/3883383-ritatag:kr.mathworks.com,2005:Question/1820232015-03-07T22:35:11Z2017-06-28T03:38:01ZImage Processing Toolbox: function imregcorr not found<p>Hi everybody!</p><p>I have the following problem: I want to use the function 'imregcorr' from the Image Processing Toolbox. The toolbox seems to installed correctly:</p><p>------------------------------------------------------------------------------------------------
MATLAB Version: 8.1.0.604 (R2013a)
MATLAB License Number: STUDENT
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ Client VM mixed mode
------------------------------------------------------------------------------------------------
MATLAB Version 8.1 (R2013a)
Simulink Version 8.1 (R2013a)
Computer Vision System Toolbox Version 5.2 (R2013a)
Control System Toolbox Version 9.5 (R2013a)
DSP System Toolbox Version 8.4 (R2013a)
Data Acquisition Toolbox Version 3.3 (R2013a)
Image Acquisition Toolbox Version 4.5 (R2013a)
Image Processing Toolbox Version 8.2 (R2013a)
Instrument Control Toolbox Version 3.3 (R2013a)
Optimization Toolbox Version 6.3 (R2013a)
Signal Processing Toolbox Version 6.19 (R2013a)
Simulink Control Design Version 3.7 (R2013a)
Statistics Toolbox Version 8.2 (R2013a)
Symbolic Math Toolbox Version 5.10 (R2013a)</p><p>But when I want to use the function I get the following error:
Undefined function or variable 'imregcorr'.</p><p>Anyone an idea?</p>Letschihttps://kr.mathworks.com/matlabcentral/profile/authors/5046248-letschitag:kr.mathworks.com,2005:Question/3465202017-06-28T01:32:54Z2017-06-28T03:29:39ZFrom neuron network toolbox to code<p>Hello,
I'm using neural network toolbox to create and train neural network and I want to generate the code, So I can change some parameters. I tired genFunction() but it didn't work.
Is there any method to generate the code.
Kind regards</p>Meryeme BOUMAHDIhttps://kr.mathworks.com/matlabcentral/profile/authors/10195069-meryeme-boumahditag:kr.mathworks.com,2005:Question/3464952017-06-27T19:28:42Z2017-06-28T03:22:29ZIs it possible to resize a region in a grayscale image?<p>Is it possible to resize a white blob in a grayscale image without changing anything else? If so, how can I do so? I am trying to resize the largest blob while keeping the size of the other regions the same.</p>Tiffany Maohttps://kr.mathworks.com/matlabcentral/profile/authors/10512049-tiffany-maotag:kr.mathworks.com,2005:Question/3465242017-06-28T03:13:17Z2017-06-28T03:18:26Zwhat is Gabor wavelet transform in image processing?<p>I searched a lot on internet about gabor wavelet transform. But all I get is mathematical explanation which I am not able to understand. Does Gabor filter and Gabor wavelet transform are one and same? Or they are different? I have to apply gabor wavelet transform for retinal blood segmentation. Can anyone help me to understand what actually it is? And guide me about how to apply it on retinal images. Does the following links are implementation of 2D gabor wavelet transform?</p><p>https://cn.mathworks.com/help/images/ref/gabor.html
https://cn.mathworks.com/help/images/ref/imgaborfilt.html</p><p>I am totally confused kindly help me.</p>Sidra Aleemhttps://kr.mathworks.com/matlabcentral/profile/authors/9949650-sidra-aleemtag:kr.mathworks.com,2005:Question/3463952017-06-27T08:15:11Z2017-06-28T03:15:10ZHow can I eliminate small polygons in the image?<p>I want get the target image by eliminating small polygons.
I got the original image from a picture (detect edges) and bad small polygons left.
Maybe index every polygon and calculate the area to delete if it is small?</p>Amy JAMEShttps://kr.mathworks.com/matlabcentral/profile/authors/8563377-amy-jamestag:kr.mathworks.com,2005:Question/3463812017-06-27T04:14:44Z2017-06-28T03:11:56ZSolving "Undefined variable "curvefitlib" or class "curvefitlib.internal.getLegendItems"<p>Trying to use the curve fitting toolbox with cfit and get this error, cannot figure out what is wrong...</p><p>Undefined variable "curvefitlib" or class "curvefitlib.internal.getLegendItems
Error in cfit/plot>updatelegend (line 360)</p><p>[oldh, str] = curvefitlib.internal.getLegendItems( gca );</p><p>I am just using the plot function in the curve fitting toolbox
plot(fitresult,'fit',0.95);</p><p>fitresult is just a cfit file</p><p>any help is much appreciated</p>Braden Walshhttps://kr.mathworks.com/matlabcentral/profile/authors/6485560-braden-walshtag:kr.mathworks.com,2005:Question/3464652017-06-27T15:40:02Z2017-06-28T03:09:06ZArtificial Neural Network - Equations?<p>Let say I want to predict the strength of a composite material using ANN. Is it possible to return a series of equations in the output layer in ANN model? The reason I asked is simply because I want to know how the ANN correlates the independent variables in the input layer and hidden layers, also whether or not that relationship makes any sense in practice.</p><p>My gut tells me that it is not possible. Please correct me if I am wrong.</p>wesleynotwisehttps://kr.mathworks.com/matlabcentral/profile/authors/10338091-wesleynotwisetag:kr.mathworks.com,2005:Question/3465222017-06-28T03:06:46Z2017-06-28T03:06:46ZHow to use Matlab to test in MIL and SIL?<p>Hello, everyone</p><p>when I am doing a project for function safty,TUV ask me to provide a certification about my test software tools.If I use all MIL
and SIL test software tools developed by Matlab,what documents should I offer?</p><p>Owen</p>Owen Wanghttps://kr.mathworks.com/matlabcentral/profile/authors/10452753-owen-wangtag:kr.mathworks.com,2005:Question/3465192017-06-28T01:12:34Z2017-06-28T03:02:32ZImplement Matlab listener, that notifies, when matrix has a certain amount of data<p>Hello,</p><p>I am trying to implement a listener in my Matlab DAQ program, which notifies, if enough data are available in my acquired data matrix (and then saves a backup etc). I know that there is something similar existing in the Data Acquisition Toolbox with the event 'DataAvailable' and NotifyWhenDataAvailableExceeds (frequency, when the event is fired). Unfortunately my device is not supported by the toolbox and I set up a DAQ program by myself by using a timer and querying the instrument values with fprintf and fscanf (Instrument Control Toolbox). For a first approach to implement this, I read the documentation (i.a. Events and Listeners Syntax) and tried to implement an example, where an empty matrix is expanded by a for loop and a listener is notifying, when there are e.g. 100 data points available. However, I failed completely, because I couldn't figure out, how to implement, how the listener "notifies" this. Is it even possible to create "own" events or can Matlab only listen to already existing events given in the documentation? I am not sure if I got the concept right and would be glad if someone would give me a quick overview, if and how it is possible, what I am trying to do.</p><p>Many thanks in advance :)</p>Stefanie Armbrusterhttps://kr.mathworks.com/matlabcentral/profile/authors/10531790-stefanie-armbrustertag:kr.mathworks.com,2005:Question/3465022017-06-27T20:23:45Z2017-06-28T02:59:40ZConvert cell array to matrix to be able to export to excel<pre class="language-matlab">if true
SaveFileName = 'Sus-Ih5';
% Get Cell selection file
[FileName,PathName] = uigetfile('*.xlsx','Select Excel file','MultiSelect','on'); % get filename
FFN = [PathName FileName];
data_fid = fopen(FFN,'rt');
PathName=[PathName 'signal files\'];
cfsdir=PathName;
% Determine how many sheets are in the selection file
[bla,sheets]=xlsfinfo(FFN);
NumSheets=numel(sheets);
%For all sheets do
for jj = 1:numel(sheets)
Excel=[];
Sheet=sheets{jj}; %Convert sheet name in string
[Excel,bla]=xlsread(FFN,Sheet); %Read content Selection File
[CellNum bla]=size(Excel); %Determine number of cells
for ii = 1:CellNum
% Clear variables
input=[];
% Read File
fName=sprintf('MA%3.3d_%3.3d.cfs',Excel(ii,1),Excel(ii,2)); %Make data filename
input=ReadCFSFile(cfsdir, fName, chan_num,0); % Dir, FileName, Records (0=all)
disp([ 'File Name: ' fName]);
</pre><pre> A(:,ii,jj)= { input.current(:,1003:3003)};</pre><pre> end
v = cell2mat(A)
% xlswrite(fullfile(PathName,SaveFileName),A(:,:,:),Sheet,'A1');
end
end</pre><p>So this is the code I am working on, this files, have 5 traces (2000 points each). I need to extract part of the data from some cells, later on subtract one cell in one condition to another. so I created A a 1x6 cell. Inside there is 6 5x2000 matrix I want to use.
I want to transform the cell into matrix, 30x2000 (in this case because there are 6 cells to analyze) or something like that, so I can do it for all, later subtract.</p><p>cell2mat(A) just transforms it 5x120006 or something like that and I can't use it.
Could anybody help.</p><p>I am sorry I am very new to this coding thing.</p>Milagros ARIETTIhttps://kr.mathworks.com/matlabcentral/profile/authors/7139067-milagros-ariettitag:kr.mathworks.com,2005:Question/3464942017-06-27T19:27:25Z2017-06-28T02:59:30ZWhy does ifft of a complex matrix gives me another complex matrix rather than a real one?<p>Hello,
I have two matrices (complex numbers) and tried to you ifft command on both of them. So one of them gave me a real output while other gives a complex one. Can someone please tell me why is that? Before doing that i though ifft of a complex matrix gives a real matrix.</p><p>Thank you.</p>Atharva Hanshttps://kr.mathworks.com/matlabcentral/profile/authors/7520837-atharva-hanstag:kr.mathworks.com,2005:Question/3465122017-06-27T22:41:34Z2017-06-28T02:58:20ZHow to create a good looking surface plot with inconsistent mesh size?<p>I have data that forms a 3-dimensional surface that was gathered with an inconsistent mesh size. NOTE: I've now edited this post so that the data file is attached and the image files showing my attempt at plots are shown below.</p><p>An inconsistent mesh size was used in order to examine fine details. I would like to create a nice looking surface plot (maybe using interpolation?) to include in a publication. You can locate my data file here: https://pastebin.com/tKTzLSkL. EDIT: The data file is now attached to this post. I've posted some images below, with descriptions of what I've tried, so that folks have a better idea of what I'm talking about and struggling with. Here's an image of what a scatter plot of my data looks like:</p><img src = "/matlabcentral/answers/uploaded_files/81617/plot.jpg"><p>I'm pretty inexperienced with matlab and don't know what I'm doing. I've been able to create a plot in which a triangular mesh connects all of my data points, but the color scheme looks pretty ugly. It's certainly not something I'd put on a slide for a presentation, let alone in a publication.</p><p>Here's my attempt at a triangular mesh in matlab:</p><img src = "/matlabcentral/answers/uploaded_files/81618/triangplot.jpg"><p>Here's the code I tried using to generate the triangular mesh plot (note: I stored my data in a matrix called 'largecomp'):</p><p>x=largecomp(:,1);</p><p>y=largecomp(:,2);</p><p>gridDelaunay=delaunay(x,y);</p><p>trisurf(gridDelaunay,x,y,z,'EdgeColor','none')</p>meslier1986https://kr.mathworks.com/matlabcentral/profile/authors/10530565-meslier1986tag:kr.mathworks.com,2005:Question/3456622017-06-21T12:36:29Z2017-06-28T02:53:03ZHow do I make a wine barrel shape figure and plot 100 random points within it.<p>How do I make a wine barrel shape figure and plot 100 random points within it. I am totally new at Matlab. Thank you in advance</p>Aaron Dublinhttps://kr.mathworks.com/matlabcentral/profile/authors/9333269-aaron-dublintag:kr.mathworks.com,2005:Question/3465182017-06-28T01:10:20Z2017-06-28T02:45:55ZI want to draw a line 14 degrees above horizontal. How do I do this?<p>I am trying to draw a 14 degree angle on top of my diagram that I have already. How do I do this?</p>Antonio Varitimoshttps://kr.mathworks.com/matlabcentral/profile/authors/9471730-antonio-varitimostag:kr.mathworks.com,2005:Question/1637622014-11-21T18:59:30Z2017-06-28T02:44:30Zunexpected shift after downsampling using decimate<pre class="language-matlab">n = 1000;
t = 1:n;
x = rand(1,n) - 0.5;
x = sin(2*pi/100*t);
y = decimate(x,4);
figure('color','w');
ha = axes('nextplot','add','box','on');
plot(ha,t,x,'k','marker','.');
plot(ha,t(1:4:end),y,'r','marker','o'); addkeycb;
</pre><p>There is a shift of 3 points.</p><img src = "/matlabcentral/answers/uploaded_files/21485/QQ%E6%88%AA%E5%9B%BE20141121195849.png">Ray Leehttps://kr.mathworks.com/matlabcentral/profile/authors/1411057-ray-leetag:kr.mathworks.com,2005:Question/3464852017-06-27T18:26:19Z2017-06-28T02:22:24ZHow to normalize new inputs with mapminmax ? <p>Hello,
I have normalized my data with mapminmax which gives values between -1 and 1. However, when I present new inputs to my network, knowing that the max of these is greater than the maximum of the training data, I will have As the normalization interval [-1,1.5]. what do you think ?</p>Hamza Alihttps://kr.mathworks.com/matlabcentral/profile/authors/9525157-hamza-alitag:kr.mathworks.com,2005:Question/3465162017-06-28T01:00:10Z2017-06-28T02:19:23ZSimulating a geometric brownian motion in matlab?<p>How do you simulate a GBM in MATLAB using the risk-neutral measure?</p><p>Asking regarding generic GBMs without drift</p><p>St = S0exp[(r -sigma^�2/2)t + sigma�Wt];</p><p>Any advice is gratefully appreciated!</p>charliehttps://kr.mathworks.com/matlabcentral/profile/authors/10526396-charlietag:kr.mathworks.com,2005:Question/3464922017-06-27T19:07:19Z2017-06-28T01:48:43ZFinding the cell indices of a cell contains a specific text<p>Hi,
I am working with a large CSV file containing blood pressure data (approx 14 million datapoints). I managed to import the data successfully, creating 2 cell arrays (NUMBERS and TEXT). One contains the actual numbers that I want to use for my calculations (NUMBERS), the other (TEXT) contains the information (as a string) about the associated time-points. Since NUMBERS and TEXT run parallel, I can use the cell indices from TEXT, to get to the data in NUMBERS for further computation.</p><p>What I am trying to figure out is how to find a specific string in TEXT; e.g. what are the indices of a time point (e.g. 12:00:00)? I started to work with 'strfind' but this only gives me either 0 or 1; not the cell indices that I need. Moreover, the strings in TEXT contain 'Value, Time, Date' (eg. '103.9685,10:27:37,2016-02-03') which means that I only need the middle portion '10:27:37'of the string.</p><p>Can anyone provide me with insights/directions as to what strategy/method is best to use in this case?</p><p>Thanks!
Barry</p>B Janssenhttps://kr.mathworks.com/matlabcentral/profile/authors/2452373-b-janssentag:kr.mathworks.com,2005:Question/3465212017-06-28T01:38:08Z2017-06-28T01:38:08ZPolyspace 실행 실패 문의<p>하기 메세지와 함께 일부 설계자의 Polyspace 실행이 되지 않습니다.
- 메세지 : Could not create the java virtual machine.</p>EUIJIN JEONGhttps://kr.mathworks.com/matlabcentral/profile/authors/7494400-euijin-jeongtag:kr.mathworks.com,2005:Question/3460322017-06-23T17:37:30Z2017-06-28T01:17:47ZFind value in matrix that matches calculation<p>First my code does a calculation and sets it equal to ash.</p><p>I then need matlab to find all of the values that match ash in column 4 and average them. (The first three numbers should be the same but after the decimal will differ),</p><p>But there is a number next to it in column 3 that I need it to store (for each value found in column 4) and average of these numbers as well.</p><p>How would I do that.</p><p>Here is what I have so far. I look at column 4, starting with the second value to the end I have it compare to the ash value. But it doesn't seem to work.</p><p>eledata = (data(2:end,4))==ash;</p>hi heyhttps://kr.mathworks.com/matlabcentral/profile/authors/10452425-hi-hey