http://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-03-03T09:27:03Ztag:www.mathworks.com,2005:Question/1811682015-03-02T23:32:17Z2015-03-03T09:27:03Zhow to convert integer array to one value??<p>hi , i want to convert array such as x=[1;2;3;4;5] to one value as y=12345</p>Abdalla Mansourhttp://www.mathworks.com/matlabcentral/profile/authors/5969365-abdalla-mansourtag:www.mathworks.com,2005:Question/1812112015-03-03T06:35:37Z2015-03-03T09:26:16ZCan i find points between two points in a plot?<p>how to find points on a line plotted with two end points in matlab</p>Harpithahttp://www.mathworks.com/matlabcentral/profile/authors/2247035-harpithatag:www.mathworks.com,2005:Question/1812412015-03-03T08:19:14Z2015-03-03T09:22:02ZHow to extract nail bed(excluding grown nail plate) from this image?<p><<</p><p><<</p><img src = "/matlabcentral/answers/uploaded_files/26454/ring%20nail.jpg"><p>>></p><p>>></p>SATHISH KUMARhttp://www.mathworks.com/matlabcentral/profile/authors/6238389-sathish-kumartag:www.mathworks.com,2005:Question/1812492015-03-03T09:16:41Z2015-03-03T09:16:41Zhow to calculate distance between radial basis center in hidden neuron and input vector?????please anyone help me for implementation?????<p>how to calculate distance between radial basis center in hidden neuron and input vector?????please anyone help me for implementation?????</p>sruthi vshttp://www.mathworks.com/matlabcentral/profile/authors/6090474-sruthi-vstag:www.mathworks.com,2005:Question/1812452015-03-03T08:59:57Z2015-03-03T09:25:26ZDepth map merging or Point Cloud Merging<p>Hi All,
My goal is to create a single 3D point-cloud based on 2 pairs of images(AB, BC) and their projection matrices. Each image comes from the same camera (not video) with 3 distinct positions.</p><p>I use the "standard process": Point matching (sift or surf), keeping inliers only, finding the position, doing the bundle adjustment...images rectifications. Up to now everything works.</p><p>Then I use the function "disparity" to create the 2 disparity maps, one for each pair of images.
Then i create the 3d point clouds using the projection matrices.</p><p>But, how can i merge the 2 points clouds coming from AB and BC.
Apparently, the 3D coordinates depends on the "DisparityRange" parameters of the function disparity.</p><p>Did i miss a step in the process ?</p><p>Thanks in advance for any help
Alvaro</p>Alvarohttp://www.mathworks.com/matlabcentral/profile/authors/5314735-alvarotag:www.mathworks.com,2005:Question/1812292015-03-03T07:31:15Z2015-03-03T08:53:31ZGraph with origin other than zero<p>Hello,
I have a questions regarding plotting data in graphs.
I have data for two scales ranging from 1-10, which I would like to plot on the x- and y-axis in a graph.
However I would like to have the axes crossing in scale point 5 in each of the axis. I.e. I want the origin to be in 5 instead of 0.</p><p>Would be very thankful for help in this!</p>rejhttp://www.mathworks.com/matlabcentral/profile/authors/3215670-rejtag:www.mathworks.com,2005:Question/1812442015-03-03T08:43:30Z2015-03-03T08:43:30Zabout sum in for loop <img src = "/matlabcentral/answers/uploaded_files/26455/QQ%E6%88%AA%E5%9B%BE20150303163714.png"><p>how to complement the part of diejia row?
deltat=1,f=16000;n=20;
can any function make this sum ?or how to make this code ?please</p>Rogerhttp://www.mathworks.com/matlabcentral/profile/authors/4198367-rogertag:www.mathworks.com,2005:Question/1812422015-03-03T08:28:47Z2015-03-03T08:41:10Zwhat is the size of the matrix of an image.will it is different for color images. <p>matrix size of an image</p>cliquehttp://www.mathworks.com/matlabcentral/profile/authors/5973788-cliquetag:www.mathworks.com,2005:Question/1812432015-03-03T08:31:01Z2015-03-03T08:31:01ZFind the circle for the image using imfindcircles<p>Hello,</p><p>I have an image for which i need to determine the outer circle and then find the centre for the outer circle.I am using the function</p><pre class="language-matlab">imfindcircles()
</pre><p>I have the following code to do this :</p><p>img2 = imread('Image.bmp');
imshow(img2);</p><pre class="language-matlab">% Find all the circles with radius >= 15 and radius <= 30
[centers, radii, metric] = imfindcircles(img2,[15 416]);
</pre><pre> % Retain the five strongest circles according to metric values
centersStrong5 = centers(1:1,:);
radiiStrong5 = radii(1:1);
metricStrong5 = metric(1:1);
% Draw the circle perimeter for the five strongest circles
viscircles(centersStrong5, radiiStrong5,'EdgeColor','b');</pre><p>but when i run this code i am getting the following error.</p><pre class="language-matlab">Error in Cap_Test (line 16)
centersStrong5 = centers(1:1,:);
</pre><p>Please let me know the reason for this and how to solve this.</p><p>I am attaching the image here for which I need to find the centre.</p><p>The radius for this is around 416.</p><p>Looking forward to hear from you.</p><p>Thanks
Pankaja</p>Pankaja Tanjorehttp://www.mathworks.com/matlabcentral/profile/authors/5880940-pankaja-tanjoretag:www.mathworks.com,2005:Question/364282012-04-24T17:52:50Z2015-03-03T08:25:36Zsine wave plot<p>Hi,</p><p>I am having some trouble plotting a sine wave and i'm not sure where i am going wrong.</p><p>i have</p><pre class="language-matlab">t = [0:0.1:2*pi]
a = sin(t);
plot(t,a)
</pre><p>this works by itself, but i want to be able to change the frequency. When i run the same code but make the change</p><pre class="language-matlab">a = sin(2*pi*60*t)
</pre><p>the code returns something bad. What am i doing wrong? How can i generate a sin wave with different frequencies?</p>aaahttp://www.mathworks.com/matlabcentral/profile/authors/2946316-aaatag:www.mathworks.com,2005:Question/1779772015-02-12T23:18:21Z2015-03-03T08:24:01ZNeural nw : Inputs and targets have different numbers of samples<p>Hi All</p><p>I have a code , I am just checking how it works , my input matrice is :</p><pre class="language-matlab">input = [0.0600000000000000 0.00100000000000000 45 0.0508000000000000 0.0127000000000000]
</pre><p>and the target is a 6 by 6 matrix</p><p>so using this code bellow , I get the mentioned error : <i>Inputs and targets have different numbers of samples</i> ,</p><pre class="language-matlab">Error in Neural (line 17) , [net,tr] = train(net,xn_tr,yn_tr);
</pre><p>here is the full code :</p><pre class="language-matlab">clc
clear
clear all
load('input.txt')
%load input
load ('taget.txt')
%normalizing data
[xn_tr,xs_tr] = mapstd(input);
[yn_tr,ys_tr] = mapstd(taget);
%% network
net=newff(xn_tr,yn_tr,[7 7],{'tansig'},'traingda');%7 hidden tanh layer gradian descent adaptive
net.trainParam.epochs =70;
net.trainParam.lr = 0.05;
net.trainParam.lr_inc = 1.05;
%training network
net.trainFcn='traingda';
[net,tr] = train(net,xn_tr,yn_tr);
%randomizing initial value f weight matrix
net = init(net);
net.trainParam.show = NaN;
u_t=mapstd('apply',x,xs_tr);
%simulating output
y_hat=sim(net,u_t);
%plotting performance
plotperform(tr)
mse=mse(y-y_hat)
</pre>farzadhttp://www.mathworks.com/matlabcentral/profile/authors/2231846-farzadtag:www.mathworks.com,2005:Question/1812302015-03-03T07:46:52Z2015-03-03T08:21:31ZHow do I perform this integration?<p>H=[11 22 33 44 55 66];</p><p>R=[1 2 3 4 5];</p><p>f_low=[1000 3000 5000 7000 9000];</p><p>f_high=[2000 4000 6000 8000 10000];</p><p>Const=5;</p><p>RESULTS=[];</p><p>for i=1:length(H)</p><p>val=quadgk(@(f)MyFunction(f,H,R,Const),f_low(i),f_high(i));</p><p>RESULTS=[RESULTS val];</p><p>end</p><p>+++++++++++++++++++++++++++++++++++</p><p>+++++++++++++++++++++++++++++++++++</p><p>function int_out=MyFunction(f,H,R,Const)</p><p>AAA=Const+2.*sum(H.*cos(2*pi*f*R));</p><p>int_out=AAA.^2;</p><p>+++++++++++++++++++++++++++++++++++</p><p>+++++++++++++++++++++++++++++++++++</p><p>I get the following Error:</p><p>Error using *
Inner matrix dimensions must agree.</p><p>Error in MyFunction (line 3)
AAA=Const+2.*sum(H.*cos(2*pi*f*R));</p><p>Error in @(f)MyFunction(f,H,R,Const)</p><p>Error in quadgk/evalFun (line 330)
fx = FUN(x);</p><p>Error in quadgk/f1 (line 348)
[y,too_close] = evalFun(tt);</p><p>Error in quadgk/vadapt (line 249)
[fx,too_close] = f(x);</p><p>Error in quadgk (line 188)
[q,errbnd] = vadapt(@f1,interval);</p>Dipankar Narayananhttp://www.mathworks.com/matlabcentral/profile/authors/6238274-dipankar-narayanantag:www.mathworks.com,2005:Question/1812402015-03-03T08:17:02Z2015-03-03T08:17:02ZWorking with Image Stacks (or Arrays)<p>I am reading images from a camera and displaying them on on an axes.</p><p>Every time I press a "Snap" button, the axes component updates with the new image. I am wanting to keep all the images I collect in a stack or array.</p><p>My initial thought is to use something along the lines of</p><pre class="language-matlab">imgArray=cat(3,image1,image2,image3,...)
</pre><p>But after I have collected image1, then assign it to the array imgArray, Im not sure how to then add the second image to this array, and then the third to this array.</p><p>2: How would I save each image individually from the imgArray once i have finished (the are tiffs)</p>Jasonhttp://www.mathworks.com/matlabcentral/profile/authors/1217570-jasontag:www.mathworks.com,2005:Question/1812332015-03-03T08:00:59Z2015-03-03T08:00:59ZInstead of Hebrew characters I can see only gibberish <p>Hi,</p><p>Iv'e written a Matlab code (using PsychToolbox) that includes printing hebrew characters on the screen. If I run the code on my PC it works fine, I can see the hebrew characters in the right way. But if I run the code on a different PC the characters are printed as gibberish and I cant understand why and how to fix it.</p><p>Any suggestions?</p><p>Thank in advance,
Lior.</p>Liorhttp://www.mathworks.com/matlabcentral/profile/authors/3232743-liortag:www.mathworks.com,2005:Question/1805132015-02-26T11:42:13Z2015-03-03T07:59:49ZTo optimize a neural network of multiple inputs using a genetic algorithm. <p>I have found the answer from the matlab team but the code is applied for a single input. I have tried to modify for 4 inputs but it was not success. Could you please give me the code to modify the below code for the 4 inputs?</p><p>The GA function requires a function handle as an input argument to which it passes a 1xN vector, where N is the number of variables in the system to be optimized.</p><p>For a neural network, the weights and biases are a Mx1 vector. These may be optimized using GA.</p><p>A function can be written to accept the network, weights and biases, inputs and targets. This function may return the mean squared error based on the outputs and the targets as GA requires a function handle that only returns a scalar value.</p><p>The following code example describes a function that returns the mean squared error for a given input of weights and biases, a network, its inputs and targets.</p><p>function mse_calc = mse_test(x, net, inputs, targets)</p><p>% 'x' contains the weights and biases vector</p><p>% in row vector form as passed to it by the</p><p>% genetic algorithm. This must be transposed</p><p>% when being set as the weights and biases</p><p>% vector for the network.</p><p>% To set the weights and biases vector to the</p><p>% one given as input</p><p>net = setwb(net, x');</p><p>% To evaluate the ouputs based on the given</p><p>% weights and biases vector</p><p>y = net(inputs);</p><p>% Calculating the mean squared error</p><p>mse_calc = sum((y-targets).^2)/length(y);</p><p>end</p><p>The following code example describes a script that sets up a basic Neural Network problem and the definition of a function handle to be passed to GA. It uses the above function to calculate the Mean Squared Error.</p><p>% INITIALIZE THE NEURAL NETWORK PROBLEM %</p><p>% inputs for the neural net</p><p>inputs = (1:10);</p><p>% targets for the neural net</p><p>targets = cos(inputs.^2);</p><p>% number of neurons</p><p>n = 2;</p><p>% create a neural network</p><p>net = feedforwardnet(n);</p><p>% configure the neural network for this dataset</p><p>net = configure(net, inputs, targets);</p><p>% create handle to the MSE_TEST function, that</p><p>% calculates MSE</p><p>h = @(x) mse_test(x, net, inputs, targets);</p><p>% Setting the Genetic Algorithms tolerance for</p><p>% minimum change in fitness function before</p><p>% terminating algorithm to 1e-8 and displaying</p><p>% each iteration's results.</p><p>ga_opts = gaoptimset('TolFun', 1e-8,'display','iter');</p><p>% PLEASE NOTE: For a feed-forward network</p><p>% with n neurons, 3n+1 quantities are required</p><p>% in the weights and biases column vector.</p><p>%</p><p>% a. n for the input weights</p><p>% b. n for the input biases</p><p>% c. n for the output weights</p><p>% d. 1 for the output bias</p><p>% running the genetic algorithm with desired options</p><p>[x_ga_opt, err_ga] = ga(h, 3*n+1, ga_opts);</p>Chuthamathttp://www.mathworks.com/matlabcentral/profile/authors/4357216-chuthamattag:www.mathworks.com,2005:Question/1812322015-03-03T07:55:22Z2015-03-03T07:55:22ZHow to remove fading effect in Variant subsystem<p>Hi,</p><p>Is it possible to remove the fading effect in Variant subsystems ? (all items have a fading effect even if it is the currenty enabled variant subsystem)</p><p>If it is, how can i do?</p><p>Thanks in advance!</p>Aduhttp://www.mathworks.com/matlabcentral/profile/authors/5752032-adutag:www.mathworks.com,2005:Question/1811002015-03-02T16:15:17Z2015-03-03T07:53:46ZHi everyone im trying to solve a system of coupled ordinary differential equations using ODE45 and i keep getting this error: Error using odearguments (line 90) GSM_N must return a column vector. Error in ode23 (line 112) [neq, tspan, ntspan, next,<p>i put my code below for you guys to help me find my error thanks</p><pre class="language-matlab">function dy = gsm_n(t,y)
global D l rho k1 n1 nn Mn Jm Ui Ra Re La Oh a b p x
</pre><pre> m= rho*pi*((D*D)/4)*l; %Berechnung der Masse</pre><pre> Jg= 0.5*m*((D*D)/4); %Berechnung der Massenträgheitsmoment der GSM</pre><pre> phi= Ui./(k1*n1); %Berechnung der Fluss</pre><pre> dy1 = ((((n1-y(1))/(n1-nn))*Mn)-((k1*phi*y(2))/(2*pi)))/(2*pi*(Jg+Jm)); %mit y(1)= dndt</pre><pre> PHI= -a*cos(x)+b*(2*x-20); </pre><pre> We= 952*p; %gesamterregerwindungszahl</pre><pre> dy2= ((k1*phi*y(1))-((Ra+Re)*y(2)))./(La+((1+Oh)*We*PHI)); %mit y(2)= dIedt</pre><pre> dy = [dy1;dy2];</pre><pre class="language-matlab">and then i run this in a main like this:
</pre><pre class="language-matlab">global D p l rho k1 n1 Ra Re La x Oh a b nn Mn Jm Ui %definition von global Variable
</pre><pre class="language-matlab">D= 0.158;
p=2;
l=0.25;
rho=2700;
k1= 720;
n1=50;
Ra= 0.198;
Re= 115;
La= 0.0042;
Oh=0.1;
a= -0.01792;
b= 0.0002088;
x= (0:0.07:1.3);
nn= 48.8167;
Mn= 24;
Jm= 0.024;
Ui=[4.8 105 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440];
</pre><pre class="language-matlab">t = [0 10];
Y0= [50 0];
[T,Y] = ode23(@gsm_n, t, Y0);
</pre><pre class="language-matlab">plot(T,Y(:,1),'r',T,Y(:,2),'b');
</pre>kamdam Sophiahttp://www.mathworks.com/matlabcentral/profile/authors/3454301-kamdam-sophiatag:www.mathworks.com,2005:Question/1812312015-03-03T07:49:57Z2015-03-03T07:49:57ZHow to calculate the accuracy of PCA in face recognition? I am using FERET database.<p>I want to find out overall accuracy of PCA algorithm in face recognition. I am working on FERET database.</p>Manjirihttp://www.mathworks.com/matlabcentral/profile/authors/4663791-manjiritag:www.mathworks.com,2005:Question/1335842014-06-10T17:53:02Z2015-03-03T07:44:13ZHow can I force MatLab to display integers in function sprintf ?<p>Hi,</p><p>I would like to save graphs in a loop and use sprintf to change the file names, but don't want to have decimal places because this destroys the file extension. The loop is:</p><pre class="language-matlab">for i=1:5
x = [0 ; 0.44; 1.1; -1,1; -0.44];
sprintf('Graph %2d.png',x(i)*100)
end
</pre><p>When I use x(3) =1.1 sprintf('Graph %2d.png',x*100) gets displayed as " Graph 1.100000e+02 ". The same problem does not occur with sprintf('Graph %2d.png',110). If x = 0.44 is also works fine. How can I force MatLab to display integers for every number?</p><p>Thanks for your help!!</p>Juliahttp://www.mathworks.com/matlabcentral/profile/authors/3263957-juliatag:www.mathworks.com,2005:Question/1810842015-03-02T13:57:24Z2015-03-03T07:39:38ZHow can I solve a minimization with 3 linear constraints?<p>I don't understand what kind of function I can use to solve the problem on photo. It's a problem with Matrix and vector, x is a vector, also E, q_B and 1 are so, while V is a Matrix. G is a scalar number which changes (but with a for loop I can do so). z and VaR are numbers.</p><img src = "/matlabcentral/answers/uploaded_files/26400/IMG_20150302_144812.jpg">Camilla Lincettohttp://www.mathworks.com/matlabcentral/profile/authors/6091828-camilla-lincettotag:www.mathworks.com,2005:Question/1812282015-03-03T07:30:03Z2015-03-03T07:30:03ZHow to find area bounded by curves<p>The exercise question is - With defined integral find area bounded by curves: y=x^2, y=2x+3?</p><p>Can anyone give any quides with this?</p><p>Thanks</p>Gamna Montehttp://www.mathworks.com/matlabcentral/profile/authors/6238220-gamna-montetag:www.mathworks.com,2005:Question/1812102015-03-03T06:34:29Z2015-03-03T07:22:49ZSome help with loops<p>I have the following code which loads a NetCDF file, flips it around a few times then saves it as a ASCII file</p><pre class="language-matlab">ncload('20030101_Sg.nc')
twodim=squeeze(Sg)
a=rot90(twodim)
b=rot90(a)
final=fliplr(b)
dlmwrite('20030101_Sg.txt',final)
</pre><p>There are 365 of these NetCDF files in the folder and I want to loop this code to get ASCII outputs of all of them. As above I need the ASCII file name to be the same as the NetCDF file name.</p><p>Any help would be appreciated, I'm quite new to Matlab.</p>Roberthttp://www.mathworks.com/matlabcentral/profile/authors/5608705-roberttag:www.mathworks.com,2005:Question/1812272015-03-03T07:19:15Z2015-03-03T07:19:15Znot getting continuous line when plotting real time data<p>I am not able to get a continuous line when plotting real time data. I have tried using the notations "--r*" and similar to indicate the use of the line and markers, however MATLAB only respects the marker and color indicated, no lines are shown. I tried using 'comet' but it only shows one marker, my Matlab version is R2013b. Below is a section of the code:</p><pre> keepLooping = true;
while keepLooping</pre><pre> time(count)=toc;
count = count +1;
out = fscanf(s);
fprintf(s, '%s', datestr(now,'yyyy-mmm-dd HH:MM:SS'))
out1 = strsplit(out,',');
s.UserData = count;
p(count) = str2double(out1(12)); %SHARP
k(count) = str2double(out1(11)); %Raw
g(count) = str2double(out1(10)); %Temperature
h(count) = str2double(out1(9)); %Humidity
hold on
plotgraph1 = subplot(2,1,1);
plot(count,p(count),'--mo');</pre><pre> % plotting p
title(['SHARP: Temp = ' num2str(g(count)) 'C, Hum = ' num2str(h(count)) '%']);
xlabel('Time (s)','FontSize',10);
ylabel('Concentration (g/m3)','FontSize',10);
scrollWidth = 10;
delay = .01;
hold on
plotgraph2 = subplot(2,1,2);
plot(count,k(count),'--r*');</pre><pre> % plotting k
title(['SHARP: Temp = ' num2str(g(count)) 'C, Hum = ' num2str(h(count)) '%']);
xlabel('Time (s)','FontSize',10);
ylabel('Raw','FontSize',10);
scrollWidth = 10;
delay = .01;</pre><pre> drawnow
end</pre>Miguel http://www.mathworks.com/matlabcentral/profile/authors/5464220-migueltag:www.mathworks.com,2005:Question/1811802015-03-03T01:57:19Z2015-03-03T07:13:16ZWhy does dividing and multiplying by the same number cause a numerical error?<p>What is is that causes a numerical error when dividing and multiplying by the same number? For instance,</p><pre class="language-matlab">format long
13/1e5*1e5
</pre><p>gives</p><pre class="language-matlab">12.999999999999998
</pre><p>I'm shouldn't be running out of double precision floating point room, should I?</p><p>Incidentally,</p><pre> 13/sqrt(2)*sqrt(2)</pre><p>works fine.</p><p>For 1e5, let's display a list of all the numbers that don't work between 1 and 100:</p><pre class="language-matlab">myNumbers = [];
sr = 1e5
for i = 1:100
if (i/sr*sr-i) ~= 0
myNumbers(end+1) = i;
end
end
myNumbers
</pre><p>this returns:</p><pre> 7 13 14 15 26 28 30 51 52 56 60</pre><p>I'll live with it, but I'm just curious if it's something I should have expected...</p><p>cheers,</p><p>Will</p>William Paulhttp://www.mathworks.com/matlabcentral/profile/authors/1713728-william-paultag:www.mathworks.com,2005:Question/1811042015-03-02T16:35:28Z2015-03-03T07:10:12ZHow to read from a text file after skipping few characters in the file ?<p>Suppose I have a file like this :</p><p>ID: 100
Strength: 800e+001
Time: 4536.83736</p><p>I want to read only the numerical values. How can I do this ?</p>Swarnava Pramanikhttp://www.mathworks.com/matlabcentral/profile/authors/6096011-swarnava-pramaniktag:www.mathworks.com,2005:Question/1810792015-03-02T13:22:29Z2015-03-03T07:09:55ZHi, I want 2 timer objects to execute sequentially, one after the other. Please help<p>Suppose my program is as follows:</p><pre class="language-matlab">t = timer;
t.StartDelay = 3;
t.TimerFcn = @(myTimerObj, thisEvent)disp('hello');
start(t);
t1 = timer;
t1.StartDelay = 5;
t1.TimerFcn = @(myTimerObj, thisEvent)disp('world');
start(t1);
</pre><p>I want my program to display 'hello' after 3 seconds, which it does. But it displays 'world' 2 seconds after 'hello' is displayed. i.e. simultaneous execution takes place.</p><p>I want 'world' to be displayed 5 seconds after 'hello' is displayed. And making the delay 8 is not the answer I'm looking for! I need sequential execution because I want to put it in an infinite loop.</p><p>It should display 'hello' after 3 seconds, and 5 seconds later 'world'. Then 3 more seconds later 'hello' should be displayed, and 5 seconds after that, 'world'. This is needed in an infinite loop.</p><p>Please help</p><p>Thank you!</p>Mitra Bapathttp://www.mathworks.com/matlabcentral/profile/authors/6167118-mitra-bapattag:www.mathworks.com,2005:Question/1811902015-03-03T03:34:29Z2015-03-03T07:07:55Zi am executing the code below in which i am getting the error"Index exceeds matrix dimensions. Error in principale_peppers (line 7) g=X(:,:,2)/255;" how to solve it. can anyone solve it for me<p>X=imread('d:\images\peppers.bmp'); X=double(X);
[l1,l2,l3]=size(X);</p><p>r=X(:,:,1)/255;
g=X(:,:,2)/255;
b=X(:,:,3)/255;</p><p>%figure(1),imshow(r)figure(2),imshow(g)figure(3),imshow(b)
r2=zeros(l1,l2,3); r2(:,:,1)=r;
g2=zeros(l1,l2,3); g2(:,:,2)=g;
b2=zeros(l1,l2,3); b2(:,:,3)=b; m1=240;</p>tina jainhttp://www.mathworks.com/matlabcentral/profile/authors/5644128-tina-jaintag:www.mathworks.com,2005:Question/1299002014-05-16T16:06:34Z2015-03-03T07:07:33ZData labels above bars on grouped bar plot<p>I'm making a grouped bar plot (i.e., a bar plot with multiple bars in each category). I would like to add labels at the top of each bar to indicate its height. I was planning to just use the text function. However, bars within a given group all have the same x location (i.e get(h,'XData') is the same for all bar series). I'm not sure how to find the proper x location for each bar within a given group. Any ideas?</p><p>Thanks,
Justin</p><img src = "/matlabcentral/answers/uploaded_files/12893/Screen%20Shot%202014-05-16%20at%2011.57.36%20AM.png">Justin Solomonhttp://www.mathworks.com/matlabcentral/profile/authors/2738269-justin-solomontag:www.mathworks.com,2005:Question/1810732015-03-02T12:51:28Z2015-03-03T07:02:19ZHow can I plot a conditional function?<p>I am trying to combine logarithmic (BH2) and polynomial (BH1) trendlines into a blended trendline (BH3) that passes through the origin. My current code plots BH3 for the final condition for all t. Please could someone offer corrected code? Here are functions and problematic code is below. Many thanks in advance.</p><ul><li>BH1: y = 7.1851*ln(t)-2.62</li><li>BH2: y = -0.06*t^2+2.185*t</li><li>BH3:
<b>0<t<=3.07</b> y= BH2
<b>3.07<t<=7.92</b> y= 0.67*BH2+0.33*BH1
<b>t>7.92</b> y= 0.5*BH1+0.5*BH2</li></ul><pre class="language-matlab">t = 0:0.5:30; %define time vector
BH1 = 7.81*log(t)-2.625; %define logarithmic trend
BH2 = -0.06*t.^2+2.19*t; %define polynomial trend
</pre><pre> %now define combination of trends
if t <= 3.07 %force through origin
BH3 = BH2;
elseif 3.07 < t <= 7.92; %intial blend
BH3 = 0.67*BH2 + 0.33*BH1;
else %equal blend
BH3 = 0.5*BH2 + 0.5*BH1;
end</pre><pre> plot(t,BH1,'r',t,BH2,'r',t,BH3,'b');</pre>Duncan Cameronhttp://www.mathworks.com/matlabcentral/profile/authors/6234350-duncan-camerontag:www.mathworks.com,2005:Question/1730062015-01-29T04:26:50Z2015-03-03T07:00:06Z3 Phase unbalanced PQ load <p>I am trying to model 3ph unbalanced constant PQ load. Constant PQ load can be modeled using dynamic load and there is 3ph dynamic load in Simpower system, it is just not unbalanced. I have used 3 1ph dynamic load and connected them in Wye but the system does not converge.</p><p>It would be helpful if anyone can direct me in right direction?</p>Pawanhttp://www.mathworks.com/matlabcentral/profile/authors/4805832-pawantag:www.mathworks.com,2005:Question/1812262015-03-03T06:59:29Z2015-03-03T06:59:29ZRadiation Pattern with Polar Command<p>Hi all,</p><p>My desired function is a polar plot of a Sinc function.</p><p>When I determine weights to form a beam using two or three element antenna, my final plot based on the calculated weights does not match with the desired function.</p><p>I have two beams about 60 degrees apart when I wanted only one beam.</p><p>May I know how to eliminate the other unwanted beam?</p><p>Thank you.</p><p>Herman</p>Herman Kunseihttp://www.mathworks.com/matlabcentral/profile/authors/6084907-herman-kunseitag:www.mathworks.com,2005:Question/1812242015-03-03T06:57:02Z2015-03-03T06:57:02ZHow to Integrate a Function of Summations?<p>How can I integrate a summation:</p><p>For example:</p><p>h is a vector of size (1 X N)</p><p>K=4;</p><p>N=64;</p><p>L=K*N/2;</p><p>INDX=L+1;</p><p>I want to integrate the function:</p><p>h(INDX)+2*h(INDX-1)*cos(2*pi*f*1)+2*h(INDX-2)*cos(2*pi*f*2)+...+2*h(INDX-127)*cos(2*pi*f*127)</p><p>with respect to f.</p><p>The limiting values are f_low, f_high.</p><p>Can Anyone suggest me a solution</p>Diphttp://www.mathworks.com/matlabcentral/profile/authors/5631338-diptag:www.mathworks.com,2005:Question/1812182015-03-03T06:56:03Z2015-03-03T06:56:03ZHow can I find possible random discontinuities in DDE23?<p>How can I program a system of differential delay equations with discontinuities?
The main problem is how to handle the fact that discontinuities will arise at random
times and their total number is also not known beforehand.
Thanks for your help!</p>Aref Zalihttp://www.mathworks.com/matlabcentral/profile/authors/5796836-aref-zalitag:www.mathworks.com,2005:Question/1773902015-02-11T14:19:05Z2015-03-03T06:52:42ZI want to create an image using a matrix. <p>1) Suppose i have a (8x8) matrix and i want this matrix to be converted into image (as shown in below image).</p><img src = "/matlabcentral/answers/uploaded_files/25244/colour.jpg"><p>Note that each row of the matrix correspond to the each row of color in the image.</p><p>2) Also if i have R,G,B matrix, then how can i create the image (as shown in below image)</p>Nikhil Chourasiahttp://www.mathworks.com/matlabcentral/profile/authors/6168052-nikhil-chourasiatag:www.mathworks.com,2005:Question/1812132015-03-03T06:46:14Z2015-03-03T06:46:14Zquestion about convert rgb to hsv ?<p>i have an image</p><p>i convert it from rgb to hsv</p><p>i take just hue from picture (hsv)</p><p>as we know hue value berween (0.0 to 1.0)</p><p>my question is how i convert hue picture to (0,1 binary system)</p>jack browenhttp://www.mathworks.com/matlabcentral/profile/authors/6138335-jack-browentag:www.mathworks.com,2005:Question/1812122015-03-03T06:37:43Z2015-03-03T06:37:43ZHow to remove/eliminate the background outside the red boundingbox in the picture below?i just need inside the red boundingbox only.<p>boxPoints = detectSURFFeatures(boxImage1);
scenePoints = detectSURFFeatures(sceneImage1);</p><p>hold on;
plot(selectStrongest(scenePoints, 300));</p><p>%% Step 3: Extract Feature Descriptors
% Extract feature descriptors at the interest points in both images.</p><p>[boxFeatures, boxPoints] = extractFeatures(boxImage1, boxPoints);
[sceneFeatures, scenePoints ] = extractFeatures(sceneImage1, scenePoints);</p><p>%% Step 4: Find Putative Point Matches
% Match the features using their descriptors.</p><p>boxPairs = matchFeatures(boxFeatures, sceneFeatures);</p><p>% Display putatively matched features.</p><p>matchedBoxPoints = boxPoints(boxPairs(:, 1), :);
matchedScenePoints = scenePoints(boxPairs(:, 2), :);
%figure(8);
showMatchedFeatures(boxImage1, sceneImage1, matchedBoxPoints, matchedScenePoints, 'montage');
legend('matched Boxpoints 1','matched Scenepoints 2');
title('Putatively Matched Points (Including Outliers)');</p><p>%% Step 5: Locate the Object in the Scene Using Putative Matches
% <tt>estimateGeometricTransform</tt> calculates the transformation relating the
% matched points, while eliminating outliers. This transformation allows us
% to localize the object in the scene.</p><p>[tform, inlierBoxPoints, inlierScenePoints] = estimateGeometricTransform(matchedBoxPoints, matchedScenePoints, 'similarity');
%figure(9);</p><p>% Display the matching point pairs with the outliers removed</p><p>showMatchedFeatures(boxImage1, sceneImage1, inlierBoxPoints, inlierScenePoints, 'montage');
title('Matched Points (Inliers Only)');</p><p>% Get the bounding polygon of the reference image.</p><p>boxPolygon = [1, 1;... % top-left
size(boxImage1, 2), 1;... % top-right
size(boxImage1, 2), size(boxImage1, 1);... % bottom-right
1, size(boxImage1, 1);... % bottom-left
1, 1]; % top-left again to close the polygon</p><p>% Transform the polygon into the coordinate system of the target image.
% The transformed polygon indicates the location of the object in the
% scene.</p><p>newBoxPolygon = transformPointsForward(tform, boxPolygon);</p><p>% Display the detected object.</p><p>figure(10);
imshow(sceneImage1);
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'r');
title('Detected Box');</p><img src = "/matlabcentral/answers/uploaded_files/26449/bearingMathswork.png">norliana khamisanhttp://www.mathworks.com/matlabcentral/profile/authors/6075984-norliana-khamisantag:www.mathworks.com,2005:Question/1811712015-03-03T00:21:02Z2015-03-03T06:34:23Zsfit object. can't get coefficients.<p>Hello.
There is my code:</p><pre class="language-matlab">>> c = fit( [X, Z], Y, ft, opts );
>> c
</pre><pre> Linear interpolant:
c(x,y) = piecewise linear surface computed from p
where x is normalized by mean 0.5 and std 0.2745
and where y is normalized by mean 227.7 and std 80.16
Coefficients:</pre><pre> p = coefficient structure</pre><pre class="language-matlab">>> class(c)
</pre><pre class="language-matlab">ans =
</pre><pre class="language-matlab">sfit
</pre><pre class="language-matlab">>> coeffvalues(c)
</pre><pre> ans = </pre><pre> TriangleSurfaceInterpolant with properties:</pre><pre> Type: 'Linear'</pre><pre class="language-matlab">>> c.p
</pre><pre class="language-matlab">ans =
</pre><pre> TriangleSurfaceInterpolant with properties:</pre><pre> Type: 'Linear'</pre><pre class="language-matlab">>> c(0.3, 201)
</pre><pre class="language-matlab">ans =
</pre><pre> 26349</pre><p>Is it possible to get coefficient of</p><pre class="language-matlab">c() function?
</pre>almaz hamhttp://www.mathworks.com/matlabcentral/profile/authors/6161433-almaz-hamtag:www.mathworks.com,2005:Question/1811862015-03-03T02:50:54Z2015-03-03T06:33:34ZHow do I make a nested for loop function that finds the values of the variable matrix without using built-in functions?<p>What I have so far:</p><p>function [ X ] = my_matrix_solver(A,B)
%In this function, we are solving for the values of the variables by
%using the coefficient and result matrix.
A=input('Enter coefficient matrix in brackets')
B=input('Enter result matrix in brackets')'
[rows,cols]=[:,K]
for K=1:length(B)
X=A(K(1))\B(K(1))
break
for K=1:length(B)
Y=A(K(2))\B(K(2))
for
end</p>Alyssa http://www.mathworks.com/matlabcentral/profile/authors/6051757-alyssatag:www.mathworks.com,2005:Question/1812082015-03-03T06:23:40Z2015-03-03T06:23:40Zcan i use more than one hold on function in same code?<p>I am dividing an image in four quadrants recursively if they satisfy the condition. For that I am using following code:
figure;
imshow(lf);
div_rec_A(lf,rf,r,c,g1_squ,g2_squ);</p><p>function div_rec_A( lf,rf,r,c,g1_squ,g2_squ )
hold on;
xv1=[c/2,c/2];
yv1=[1,r];
line(xv1,yv1,'Color','r','LineWidth',1);
xh1=[1,c];
yh1=[c/2,c/2];
line(xh1,yh1,'Color','r','LineWidth',1);
if condition
%copy the part in another image
else
lf = AL;
rf = AR;
[r c] = size(lf);
g1_squ = AFL;
g2_squ = AFR;
div_rec_A(lf,rf,r,c,g1_squ,g2_squ);</p><p>here lf and rf are two images, r and c are dimension of the image and g1_squ and g2_squ are gradient of the lf and rf respectively. AL and RL is image portion of first quadrant of lf and rf images respectively. And AFL and AFR is image portion of first quadrant of g1_squ and g2_squ images respectively.</p><p>The above code works well and divides the first quadrant of the image but now I want to divide image of all four quadrants. So I made other three same functions namely div_rec_B(lf,rf,r,c,g1_squ,g2_squ), div_rec_C(lf,rf,r,c,g1_squ,g2_squ), div_rec_D(lf,rf,r,c,g1_squ,g2_squ) because the conditions are different for each quadrant. And all four functions are called in main function sequentially.</p><p>The problem is, the division of only first function is displayed. I tried adding</p><p>figure;
imshow(lf);</p><p>in each function at starting. It shows the result but I want all the divisions to be done on single image. So I guess the hold on function is not holding the image after first function. I didn’t write hold off in any of the function.</p><p>I hope the problem is clear. Plz HELP. Thanks in advance.</p>Dishahttp://www.mathworks.com/matlabcentral/profile/authors/3985038-dishatag:www.mathworks.com,2005:Question/1812092015-03-03T06:23:40Z2015-03-03T06:23:40ZHow to find the all minima points where minima exist in an multivariable equation ? <p>I have to find the multiple minimum values of an multivariable equation of 2 variables . Such that if my first minima don't satisfy the condition , the code will jump to the other minima .</p>Shivam Negihttp://www.mathworks.com/matlabcentral/profile/authors/5845866-shivam-negitag:www.mathworks.com,2005:Question/1128572014-01-18T20:22:38Z2015-03-03T06:20:42ZHow to automatically identify text lines from projection plot?<p>I have been reading about automatic text line recognition in Matlab and although there are many advanced methods to do this every paper mentions that the simplest way of detecting text lines is via horizontal projections. So I decided to try this method for myself.</p><p>I am very new to this and have hit a brick wall, I have reached a level beyond which I do not know how to proceed. This is what I have achieved so far:</p><p>I'm trying for a system that is language independent and only interested in text lines, so I chose Arabic text:</p><img src = "/matlabcentral/answers/uploaded_files/7010/1.jpg"><p>I used the function ``radon`` to get the projections.</p><pre> img = rgb2gray(imread('arabic.jpg'));
[R, xp] = radon(bw_closed, [0 90]);
figure; plot(xp,R(:,2)); title('at angle 90');</pre><p>This is the plot(projection)</p><img src = "/matlabcentral/answers/uploaded_files/7011/2.jpg"><p>So clearly the 5 peaks represent the 5 lines detected but how do I go from here to segmenting the original document?</p><p>Can anyone help me beyond this point? All the papers I read make no mention of how to proceed from this step, they just say that from the projections we have our detected lines.</p><p>What I'm asking is how, from the plot data can I tell matlab what is the line of text and what is the gab between lines?</p>Farazhttp://www.mathworks.com/matlabcentral/profile/authors/4967090-faraztag:www.mathworks.com,2005:Question/1812072015-03-03T06:20:33Z2015-03-03T06:20:33ZCan Matlab deal with Geographical Information?<p>I was wondering that if we can use Matlab to sense Latitude and Longitude for any specific datum or reference system and do the further processing and can write/draw on a new map based on similar datum. For some analysis I would like to plot the traffic volume with Geographic Information data on the road network for some city in Japan. Then would like to deduce the link travel speed/time by using Matlab. Can you suggest me in this regard? Thank you.</p>Mohammad Hannan Khanhttp://www.mathworks.com/matlabcentral/profile/authors/6207666-mohammad-hannan-khantag:www.mathworks.com,2005:Question/1812062015-03-03T06:15:57Z2015-03-03T06:15:57ZBy seeing histogram of an image can we identify whether it belongs to color image or black and white image<p>histograms</p>cliquehttp://www.mathworks.com/matlabcentral/profile/authors/5973788-cliquetag:www.mathworks.com,2005:Question/1812052015-03-03T06:06:30Z2015-03-03T06:06:30ZHello Dear sir/ma'm I'm doing M.Tech Project in Image Processing For Multiple Object Tracking&Detecting..<p>My Question Is CAN WE IDENTIFY WHETHER THE IMAGE IS BLACK&WHITE OR GRAY OR COLOR IMAGE BY SEEING HISTOGRAM.....</p>DANDE SRIKANTHhttp://www.mathworks.com/matlabcentral/profile/authors/6175393-dande-srikanthtag:www.mathworks.com,2005:Question/1812032015-03-03T05:44:11Z2015-03-03T06:04:04Zinflection point on sum of sinusoids<p>Hi,
I have a problem that may have a neat solution but I'm not certain of the approach. I'd like to find the inflection points of a function which is the sum (superposition) of sinusoids (tidal data).Its formulated like this:</p><p>y = A1*sin(w1*t + p1) + A2*sin(w2*t + p2) + ... + An*sin(wn*t + pn)</p><p>where
A1..An is the component Amplitude;
w1..wn is the component frequency;
p1..pn is the component phase. And each of these is known.</p><p>I think you can find the inflection by finding where the second derivative of y is zero. ie</p><p>y'' = 0 = -A1*w1^2*sin(w1*t +p1)+ A1*cos(w1*t +p1) + ..</p><p>Is there a fast way to determine the values of t (within a range) for which y'' =0? The timeseries is long (around 1 million points) so recreating the entire timeseries is time consuming.</p>Benhttp://www.mathworks.com/matlabcentral/profile/authors/4062263-bentag:www.mathworks.com,2005:Question/1812042015-03-03T05:59:03Z2015-03-03T05:59:03ZI am doing my project based on image detection and verification of obstacles for aircraft during take off time runway.so i am begineer can you please tell me step wise procedure to start up my project. <p>I have started with basic blocks</p>Sharadha N Aradhyahttp://www.mathworks.com/matlabcentral/profile/authors/6237906-sharadha-n-aradhyatag:www.mathworks.com,2005:Question/1811742015-03-03T00:41:26Z2015-03-03T05:52:53ZDifferentiation of a vector wrt a vetor<p>Hiii Friends,</p><p>Suppose i have two vectors</p><pre class="language-matlab">Ls = (1.2:0.0001:3.0).*1e-6;
delk = (x:y:z) %some vector
</pre><p>I would like to differentiate d(Ls)/d(delk).</p><p>How do i do it?</p><p>Advance thanks for the advice.</p><p>Pavan</p>Pavan Kumarhttp://www.mathworks.com/matlabcentral/profile/authors/2954213-pavan-kumartag:www.mathworks.com,2005:Question/1807062015-02-27T13:11:14Z2015-03-03T05:51:52ZWhat happend about my plotting style<p>As I know that starting in R2014b, MATLAB graphics titles use a bold and slightly larger font for better visibility.
I am using R2014b, what happend to my plotting style?</p><p>The left is a example picture from help center, the right is my plotting. You can see the difference between the titles.</p><img src = "/matlabcentral/answers/uploaded_files/26286/Untitled.png">sheng liuhttp://www.mathworks.com/matlabcentral/profile/authors/5853190-sheng-liutag:www.mathworks.com,2005:Question/1811922015-03-03T03:42:26Z2015-03-03T05:50:09Zusing ODE45 with condition<p>The problem I am dealing with is a circuit with diode.
so I have two different differential equations to solve based on a variable value measured at each time step. what I want to achieve is to run first ode45 and calculate a variable value (different from output) and if that value < threshold, continue running first ode45. Otherwise, run 2nd ode45. same with 2nd ode45.</p><p>so I guess what I want to do is having two different "states" (1st ode45 and 2nd ode45) and which to run is determined by the current variable value. how can I achieve this?
how can I make ode45 evaluate a value at each time step other than output?</p><p>thank you.</p>Februaryhttp://www.mathworks.com/matlabcentral/profile/authors/3328605-februarytag:www.mathworks.com,2005:Question/1811932015-03-03T03:47:40Z2015-03-03T05:42:30Zi am executing this code and getting the error""max" previously appeared to be used as a function or command, conflicting with its uis se here as the name of a variable" fow to solve thj<pre class="language-matlab">function [tab]=ezww3(X,d)
</pre><pre class="language-matlab">[h1,h2,g1,g2]=filtres2(d);
</pre><pre class="language-matlab">[x1000,x2000,x3000,x4000]=decomp_mat(X,h1,h2);%x1000=x1000/2;
[x100,x200,x300,x400]=decomp_mat(x1000,h1,h2);%x100=x100/2;
[x10,x20,x30,x40]=decomp_mat(x100,h1,h2);%x10=x10/2;
[x1,x2,x3,x4]=decomp_mat(x10,h1,h2);%x1=x1/2;
[xx1,xx2,xx3,xx4]=decomp_mat(x1,h1,h2);
</pre><pre class="language-matlab">[xxx1,xxx2,xxx3,xxx4]=decomp_mat(xx1,h1,h2);%
image([[[[[xx1,xx2;xx3,xx4],x2;x3,x4],x20;x30,x40],x200;x300,x400],x2000;x3000,x4000]),colormap(gray)
</pre><pre class="language-matlab">round(xxx2); xxx3=round(xxx3); xxx4=round(xxx4);
seuil=round(max(max(x1)));
</pre>tina jainhttp://www.mathworks.com/matlabcentral/profile/authors/5644128-tina-jain