http://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-04-19T19:10:32Ztag:www.mathworks.com,2005:Question/2103972015-04-19T19:02:13Z2015-04-19T19:10:32ZCommunications Toolbox System Objects<p>I am trying to use the Communications Toolbox in Matlab. In this toolbox there are a number of built in Systems Objects for example</p><p>1) comm.LTEMIMOChannel</p><p>2) comm.SphereDecoder.</p><p>I want to examine the .m file and see how these system objects are implemented. So I wrote down the command</p><p>open comm.LTEMIMOChannel</p><p>However, that doesnt help. Does anyone know why it doesn't work or maybe one cant access such code?</p><p>Thanks</p>Georgehttp://www.mathworks.com/matlabcentral/profile/authors/5723273-georgetag:www.mathworks.com,2005:Question/2103962015-04-19T18:59:15Z2015-04-19T18:59:15ZCan some explain why when I tried to display two images side by side it not only didn't display the two images side by side but displayed one image that now had green in it.<p>I used imshowpair(I,B); (what I named the images) and it gave me one of my images with green in it. My only explanation is that the two iamges were folded on each other, but then why the green in it when they were both black and white? Please assist.</p><p>Thank you</p><p>P.S. - Still don't know how to display the images side by side</p>Neohttp://www.mathworks.com/matlabcentral/profile/authors/5733800-neotag:www.mathworks.com,2005:Question/2103672015-04-19T15:47:10Z2015-04-19T18:57:50ZRed Ball Tracking Problem <p>Hi. I have a question. A maked project wich should track a red ball. But appear the problem which bedevil me. There i put my code , if someone can help me, please.</p><pre class="language-matlab">if true
imaqhwinfo
dev_info = imaqhwinfo('winvideo',1)
%info=imaqhwinfo('winvideo')
</pre><pre> celldisp(dev_info.SupportedFormats)
vid=videoinput('winvideo',1,'YUY2_640x480');
%% Set the properties of the video object
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 5;
%Achizitie video
start(vid)
%Initializare arduino
ser=serial('COM3','Baudrate',9600);
fopen(ser)</pre><p>while(vid.FramesAcquired<150)
data = getsnapshot(vid);
%din gray extragem componenta rosie
r = data(:,:,1);g = data(:,:,2); b = data(:,:,3);
bw1 = ((r >=248) & (g <=2) & (b <=2));
%bw1 = (r - g/2 - b/2);
% % stergem pixelii mai mici deci 30
bw1 = bwareaopen(bw1,30);
bw = imfill(bw1,'holes');
[B,L] = bwboundaries(bw,'noholes');
%figure(1); subplot(224); imshow(bw1);
%nr de componente conectate din imagine
%bw = bwlabel(bw1, 8);
% bw1 = imfill(bw1,'holes');
% [B,L] = bwboundaries(bw,'noholes');
%Blob analiza
stats = regionprops(L,'Area','Centroid');
circle_threshold = 0.80;
figure(1);
imshow(data);
hold on
for g = 1:length(B)</p><pre> % obtain (X,Y) boundary coordinates corresponding to label 'g'
boundary = B{g};</pre><pre> % compute a simple estimate of the object's perimeter
delta_sq = diff(boundary).^2;
perimeter = sum(sqrt(sum(delta_sq,2)));</pre><pre> % obtain the area calculation corresponding to label 'g'
area = stats(g).Area;</pre><pre> % compute the roundness metric
metric = 4*pi*area/perimeter^2;
if metric > circle_threshold
bc = stats(g).Centroid;
plot(bc(1),bc(2),'ko');
a=text(bc(1)+16,bc(2),strcat('X: ',num2str(round(bc(1))),' Y: ', num2str(round(bc(2)))));
set(a, 'FontName', 'Arial', 'FontWeight','bold','FontSize',12,'Color','yellow');
%Poz=uint8(bc(1));</pre><pre> X = round(bc(1));
% valoarea_prag = 60;
% Xc = 320;%320;
[pancmd] = pantilt(X);
fwrite(ser,pancmd,'char');
% if (Xc-X) > valoarea_prag
% fprintf(ser,'r');
% %%Find out if the X component of the face is to the right of the middle of the screen.
% elseif (X-Xc) > valoarea_prag
% fprintf(ser,'l');
% end
else
[r,c] = find(L(:,:)==g);
% [r,c] = find(bwlabel(bw)==g);
bw(r,c)=0;
end
end</pre><pre> % pause
hold off
end
%b.servoWrite(9,0);
%pos = b.servoread(1);</pre><p>%oprire achizite video
closepreview(vid)
stop(vid);
%delete(vid)</p><p>fclose(ser)
%sterge toate variabilele
clear all
sprintf('%s','gata')
end</p>Stas Radionhttp://www.mathworks.com/matlabcentral/profile/authors/6431271-stas-radiontag:www.mathworks.com,2005:Question/2103952015-04-19T18:41:50Z2015-04-19T18:57:02Zchange the ploted node location every 1 second<p>suppose i plot some nodes on the graph and i wish to change the node location every second .</p><pre> node=20;
area=100;
X=rand(1,node)*area;
Y=rand(1,node)*area;
for i=1:node
plot(X(i),Y(i));
text(X(i),Y(i),num2str(i));
end</pre>singhhttp://www.mathworks.com/matlabcentral/profile/authors/6334127-singhtag:www.mathworks.com,2005:Question/2102192015-04-18T11:52:35Z2015-04-19T18:54:32ZI'm trying to find a second tumor within my data but I can't <p>my data contains three tumors where I was able to define the position of the first tumor by the max fuction however I can find the second max but the problem is that the force that is directly lower that the max force is also a part of that tumor but want I want is to skip all of these unnessacery forces that are part of that tumor and look for other tumors. I'll attach the picture so you can understand more ....</p><p>I appreciate any help thanks ...</p>Ahmed Alnahdihttp://www.mathworks.com/matlabcentral/profile/authors/6427362-ahmed-alnahditag:www.mathworks.com,2005:Question/2103252015-04-19T10:05:06Z2015-04-19T18:47:18Zto send a message to one another node<pre> node=20;
area=100;
X=rand(1,node)*area;
Y=rand(1,node)*area;
for i=1:node
plot(X(i),Y(i));
text(X(i),Y(i),num2str(i));
end</pre><pre> now i wish to send particular node detail(node no,node coordinates) send to another node.</pre><pre> suppose i want send node (no-5) details to node (no-14).</pre><p>and calculate how much time consume to reach this detail to destination node(no-14)</p>singhhttp://www.mathworks.com/matlabcentral/profile/authors/6334127-singhtag:www.mathworks.com,2005:Question/2103912015-04-19T18:19:04Z2015-04-19T18:46:35ZExponential curve fitting- "line" of best fit - basis functions - polyfit<p>I need to fit data to an exponential curve. I know the actual formula of the curve is:
v(T) = exp(c0 + c1*T) where T is Ti and c0 and c1 are unknowns that I am solving for to fit the curve of data points. So I am looking for c0 and c1, and then trying to plot them.</p><p>I'm trying to do this with basis functions, but if you can solve it with polyfit that would be ok.
MY basis functions are:
�A=[exp(Ti.^0),Ti]; %probably not correct
and then solve with formula "c=A\y" where A is as above and y is my y-values.
so my code for that is
c=A\log(vi); Then I try to put those c0 and c1, or c(1), c(2), into an anonymous function and trying to plot that, but it doesn't work correctly.</p><p>Could you please find c0 and c1 correctly and find a way to plot it correctly so it is a "line of best fit". (Doesn't have to be perfect, but I need it to go with the curve)</p><p>MY PROGRAM:</p><p>Ti=[10 20 30 40 50 60 70 80 90]'; % my x values - celsius temp</p><p>vi=[1.31 1.00 0.80 0.65 0.55 0.47 0.40 0.36 0.32]'; % my y values</p><p>A=[exp(Ti.^0),Ti]; % trying to use a basis function</p><p>c=A\log(vi);</p><p>%c(1)=exp(c(1));</p><p>%c(2)=c(2);</p><p>T=linspace(10,90,101); % GENERATING x values</p><p>Tk=T+273.15; % converting Ti, convert Celsius to kelvin</p><p>f=@(c,Tk) c(1)+c(2).*Tk; % my function, notice no exp() on outside, I mean it is of
% form v(T) = exp(c0 + c1*T)</p><p>plot(T,(f(c,Tk)),'b-',Ti,vi,'rd')</p>Ar Gofhttp://www.mathworks.com/matlabcentral/profile/authors/6428239-ar-goftag:www.mathworks.com,2005:Question/2102842015-04-18T22:49:40Z2015-04-19T18:42:20ZHow can I combine these two codes<p>I need help creating a plot of streamlines over an ellipse for a school assignment</p><p>The two codes that I am using are</p><pre class="language-matlab">% Plot streamlines and pressure coefficent of an unviscious,uncomprimibile,irrotational
% flow around a cylinder section (radius = 1) that spins around the z axis (coming out
% of the xy plane).
% This result is achieved by superimposition of elementary solution of the potential
% function PHI, where [Ux , Uy] = GRAD(PHI) which comprehend Uniform Stream,Doublet,Vortex.
% This case rappresents a good example of Magnus Effect,that is the reason why spinning
% balls have an effected trajectory.And rappresent the basis of Kutta-Joukowski theory.
%
%
% INPUT
% V_i = Asymptotic Speed
% G = Angular Speed (positive anti-clockwise)
%
% -----EXAMPLE------
% V_i = 20
% G = 50
%
% Created by: Dario Isola
% DATA : 24/03/2004
% Politecnico di Milano - Aerospatial Engeeniering Departement
%----------
%Modification log
%Author Date Description
%----------------------------------------------------------------------------------
%Yogesh PARTE,IMT Toulouse 15 Jan 2010 Added Cp distribution plot
% over a cylinder see
% figure(4), removed for loop, added comments
%----------------------------------------------------------------------------------
</pre><pre class="language-matlab">close all;
</pre><pre class="language-matlab">clear all;
</pre><pre class="language-matlab">%% Input section
V_i = input(' Asymptotic speed V_0 [m/s] = ');
G = input(' Circulation Value G [rad/s] [Anti-clockwise] = ');
</pre><pre class="language-matlab">%% Actual computation
%Radius of the circle
a = 3.5 ;
c =-a*2;
b =a*2;
</pre><pre class="language-matlab">% Number of intervals
n =a*50;
</pre><pre class="language-matlab">[x,y]=meshgrid([c:(b-c)/n:b],[c:(b-c)/n:b]');
</pre><pre class="language-matlab">warning off;
</pre><pre class="language-matlab">%%Preliminary DATA & purification
</pre><pre class="language-matlab">% Set values of X and Y inside the cylinder to zero
[I J]=find( (x.^2+y.^2) < a);
</pre><pre class="language-matlab">if ~isempty(I)
x(I,J) = 0;
y(I,J) = 0;
end
</pre><pre class="language-matlab">%Definition of polar variables
rho=sqrt(x.^2+y.^2);
</pre><pre class="language-matlab">theta=atan2(y,x);
</pre><pre class="language-matlab">% Creation of the streamline function
z=V_i.*sin(theta).*rho.*(1-(a^2./(rho.^2)))-G*log(rho)/(2*pi);
</pre><pre class="language-matlab">%% Generate unite cicle for plotting
n=100;
r=ones(1,n+1)*a;
t=[0:2*pi/n:2*pi];
</pre><pre class="language-matlab">Xcircle = r.*cos(t);
Ycircle = r.*sin(t);
%% Plot the data
</pre><pre class="language-matlab">% Streamline Plot
figure(1);
contour(x,y,z,25);
colorbar;
hold on;
fill(Xcircle,Ycircle,'k');
title('Stream Lines');
xlabel('x \rightarrow');
ylabel('y \rightarrow');
axis square;
</pre><p>This is code that I found online for streamlines over a circle.</p><p>The other code is</p><pre class="language-matlab">clc,clear
a=5.5; %horizontal radius
b=3.50; %vertical radius
x0=0; % x0,y0 ellipse centre coordinates
y0=0;
t=-pi:0.01:pi;
x=x0+a*cos(t);
w=y0+b*sin(t);
plot(x,w)
grid on
</pre><p>This is to plot an ellipse.</p><p>My problem is that I need the second code to be somehow integrated into the first code which is the stream line code.</p><p>Any help would be great because my professor would like to see some sort of MATLAB use out of our project.</p><p>Thank you.</p>Haim Matharuhttp://www.mathworks.com/matlabcentral/profile/authors/3975863-haim-matharutag:www.mathworks.com,2005:Question/2102852015-04-18T23:02:38Z2015-04-19T18:41:28ZHow can I store an array from a called function to another array?<p>I have a function Sysmodel(), which calculates the value of an array B based on random variables. What I want is to store different values of B to later take an average, something like monte carlo simulations. When I try to do this, I only get an array of zeros with the last row filled with B from the last iteration. My code is this:</p><pre class="language-matlab">for i = 1:1000
Sysmodel()
A(i,:)=B;
end
</pre><p>Could you point out where I am going wrong? Or give me a better way to carry out these simulations?</p>Kirtiman http://www.mathworks.com/matlabcentral/profile/authors/4656928-kirtimantag:www.mathworks.com,2005:Question/2103942015-04-19T18:40:54Z2015-04-19T18:40:54Zhow to divide an image diagonally into two part?<p>i want to divide an image diagonally,into two equal part. how can i do this?</p>Soumyadip Chakrabortyhttp://www.mathworks.com/matlabcentral/profile/authors/6136046-soumyadip-chakrabortytag:www.mathworks.com,2005:Question/2103932015-04-19T18:31:37Z2015-04-19T18:31:37ZHow can I solve the problem at the download of the file R2015a?<p>I have got Windows 8 64 Bit. I downloaded Matlab the version R2015a. But after unzipping the file there was an error which said "Error finding installer class. An exception occurred while looking for class."</p><p>How can I solve this problem.</p><p>I need the solution as far as possible.</p><p>Bye</p>Ömer Oralhttp://www.mathworks.com/matlabcentral/profile/authors/6430676-omer-oraltag:www.mathworks.com,2005:Question/2103922015-04-19T18:24:29Z2015-04-19T18:24:29Zhow to apply k-mean clustering method to exact the spot intensity in DNA microarray image<p>hi....
i m 4th fourth student currently doing a research project on image processing using matlab, as i seen in matlab the DNA MicroArray Image Processing Case Study.'http://www.mathworks.com/matlabcentral/fileexchange/2573-dna-microarray-image-processing-case-study'
the step it use is to seperate the image to 3 layer red,green and yellow. from there can get the color intensity and then make calculation to get final intensity.
what about if using k-mean clustering, i read some paper online it show that in k-mean cluster method, we cluster the pixel, how to cluster the image pixel using matlab. and how many group we need to cluster. thank</p>SK YONGhttp://www.mathworks.com/matlabcentral/profile/authors/6417768-sk-yongtag:www.mathworks.com,2005:Question/2103792015-04-19T18:11:31Z2015-04-19T18:17:09ZHow Do I Apply Multiple Conditions On An Array<p>I have found the center of masses of a stack of 148 images (64x32), what I want to do is divide the 64x32 image into quadrants, and to group all the center of masses (148x2) together in their respective quadrant (1,2,3 and 4).
This is what I am working with:</p><p>numpool = size(LA_maxDF_M, 3);
area = zeros(numpool, 1);
c = zeros(numpool, 2);</p><p>%% Converting to binary; Calculating center of mass and area
for pool = 1:numpool;
binimage = im2bw(LA_maxDF_M(:, :, pool),0.5);
area(pool) = bwarea(binimage); % calculate surface area of binary image.
binimage = double(binimage);
c(pool,:) = centerOfMass(binimage); % calculate centre of mass of binary image
plot(c(:,1),c(:,2),'.');
axis([min(c(:,1)) max(c(:,1)) min(c(:,2)) max(c(:,2))])
x_c = c(:,1);
y_c = c(:,2);</p><p>for example, for quadrant 3 ind and ind2 are the two conditions I want to satisfy:
ind = find(x_c < max(x_c)/2);
ind2 = find(x_c > min(x_c));
they work separately but I want both conditions to apply together, i.e. I want all the center of masses which are within the region: min(x_c) < x_c < max(x_c)/2 and
min(y_c) < c(:,2) < max(y_c)/2 to group together.
Help on this would be much appreciated.</p>Ahmed Ismailhttp://www.mathworks.com/matlabcentral/profile/authors/5780105-ahmed-ismailtag:www.mathworks.com,2005:Question/2103802015-04-19T18:13:41Z2015-04-19T18:13:41ZHow I can create matrices from a cell with a loop if the dimensions of matrices are not consistent?<p>Dear All,</p><p>I have an out(301,1) cell which contains data in function of longitude, latitude and time in each months from 1961 to 1990. The longitude and latitude dimensions are same but the time is different because its lenght depends on the number of days of months. So the out cell looks like:
out = {(464x201x31), (464x201x28), (464x201x31), (464x201x30)...}.
Could someone write me how I could create matrices from this cell with a loop?</p>Szabó-Takács Beátahttp://www.mathworks.com/matlabcentral/profile/authors/6427862-szabo-takacs-beatatag:www.mathworks.com,2005:Question/2040042015-04-16T23:50:16Z2015-04-19T18:11:21ZPlayers distribution in soccer field<p>Hello,</p><p>I have the coordinates (x,y) of a lot of soccer players and i want to know their field distribution.
I want to part the field (120m x 90m) in 1m2 bens. With this, i want to now how many times, players are in each bens.</p><p>Can you help me please with the best code to run this in matlab?</p><p>SQ</p>Sérgio Queridohttp://www.mathworks.com/matlabcentral/profile/authors/6420976-sergio-queridotag:www.mathworks.com,2005:Question/2103102015-04-19T08:49:35Z2015-04-19T18:05:05Zhow to perform jump condtion or alternative solution for calling <p>Suppose I take input at command window through input command</p><p>If it is in array then it show that value which was i enter</p><p>or if it is not in array then it will jump to take input again..</p><pre> N=input('enter the no: ');
N1=X(N,:) it will show the coordinate value of N in the array X</pre>singhhttp://www.mathworks.com/matlabcentral/profile/authors/6334127-singhtag:www.mathworks.com,2005:Question/2103782015-04-19T17:59:10Z2015-04-19T17:59:10ZHow to change the text on a pushbutton in the code, not using property inspector<p>We have one GUI where a user selects a region from a drop down menu, which is assigned to a number (1 through 6), we then pass that number to another GUI. The second GUI has two ouch buttons labeled city 1 city 2, but we need to change the string to actual city names based on what region the user selected. We set up an if statement for each region and within those if statements we can't figure out how to change the string that the user will see, or how to go about it.</p>Taylor Esteehttp://www.mathworks.com/matlabcentral/profile/authors/6431609-taylor-esteetag:www.mathworks.com,2005:Question/2103772015-04-19T17:54:29Z2015-04-19T18:42:07Zcan any one help me in detecting an error in matlab code please ? <pre class="language-matlab">pih=[];
for im=1:0.1:20
n=15;
</pre><pre> i=13;
k=8;
m=2;
h=3;
f=factorial(n)/(factorial(i)*factorial(n-i));</pre><pre> g=factorial((2^(k-(m*h)))*factorial(i)*factorial((2^(k-(m*h)))-i));
p=factorial((2^k))/factorial(i)*factorial((2^k)-i);
j=g/p;</pre><pre> o=factorial((2^k)-(2^(k-(m*h))))/factorial(n-i)*factorial((2^k) ...
-(2^(k-(m*h)))-(n-i));</pre><pre> u=factorial((2^k)-i)/factorial(n-i)*factorial((2^k)-i-(n-i));
z=o/u;
pih=f*j*z;
end</pre><pre> #
this is the code and this is the error message :
#??? Error using ==> factorial at 17
N must be a matrix of non-negative integers.</pre><p>Error in ==> marwa at 12
g=factorial((2^(k-(m*h)))*factorial(i)*factorial((2^(k-(m*h)))-i));</p><p>??? Error using ==> factorial at 17
N must be a matrix of non-negative integers.</p><p>Error in ==> marwa at 12
g=factorial((2^(k-(m*h)))*factorial(i)*factorial((2^(k-(m*h)))-i));
#</p>safi marwahttp://www.mathworks.com/matlabcentral/profile/authors/6431600-safi-marwatag:www.mathworks.com,2005:Question/2103762015-04-19T17:52:51Z2015-04-19T17:52:51ZBER simulation in cdma system<p>hi there, i'm doing one ber simulation in a cdma system, here is my code:
/////////////////////////////////////////////////////////////////////////////////
clear all;
close all;</p><p>N=30; %number of spreading sequence
K=10; %number of users
M=10^4; %total number of symbols
num=N*M;
snr=[-3:15];
snr_linear=10.^(snr/10);</p><p>S=sign(randn(N,K))/sqrt(N);
R=S'*S;
b=sign(randn(K,M));
n=1/sqrt(2)*(randn(N,M)+i*randn(N,M));
encode=S*b;</p><p>for i=1:length(snr)
n1=1./sqrt(2*snr_linear(i))*n
y=encode+n1;
%%Match filter
x_mf=sign(real(S'*y));
numErr_mf(i)=sum(sum(b~=x_mf));
end;
////////////////////////////////////////////////////////////////////////////////////////
But there is one problem. when i run this, there will be the situation that the spreading sequence could be worse, my supervisor suggest me move the equation 'S' 'b' 'n' inside the loop, so it could be generated new bits very time, then there no more questions. But i have try many time , still not work. So i hope someone can help me here, Thanks.</p>LINXIAN ZHUhttp://www.mathworks.com/matlabcentral/profile/authors/5216312-linxian-zhutag:www.mathworks.com,2005:Question/2103062015-04-19T07:25:24Z2015-04-19T17:50:46ZObtaning values and plotting Lennard-Jones function<p>I need to evaluate the below function which is the Lennard-Jones function defining the van der Waals forces between atoms. The function and the plot it must give are attached. Sigma and epsilon are constants in the function. I tried to write the code for it in couple of different forms and also tried to do it in MS Excel but all of those gave a curve that resembles a saturation curve. Any help would be very appreciated.</p>Ugur Batirhttp://www.mathworks.com/matlabcentral/profile/authors/6348799-ugur-batirtag:www.mathworks.com,2005:Question/2103382015-04-19T11:59:33Z2015-04-19T17:49:39ZHow to include min() in optimization constraint<p>Hi,</p><p>I have an optimization problem for which I want to find a solution using the GlobalSearch solver. I have several constraints of the form "X(20) <= 100 - max([max(X(1:3)) max(X(5:7)) max(X(10:17))])" which I implemented in the "c" argument:
"X(20) - (100 - max([max(X(1:3)) max(X(5:7)) max(X(10:17))]);" (<= 0)</p><p>However, these constraints seem to be ignored by Matlab during optimization. This leads me to suspect that it is not possible to use min() and max() when writing constraints. Is this true? If so, is there a convenient way to implement this without having to write out every single constraint, i.e. "X(20) - (100-X(1)); X(20) - (100-X(2)); etc."?</p><p>Thank you!</p>Greg76http://www.mathworks.com/matlabcentral/profile/authors/6221049-greg76tag:www.mathworks.com,2005:Question/2103342015-04-19T11:23:16Z2015-04-19T17:43:00ZI am getting noise at the output of MATLAB SCRIPT.<p>I need to plot the individual flow to total flow. suppose, i have taken the flow2_vs_totalflow and then i am getting the disturbances in MATLAB script.so, how to remove disturbances in the output graph and is there any filter to use for getting accurate curve.</p>nani kalyanhttp://www.mathworks.com/matlabcentral/profile/authors/6430489-nani-kalyantag:www.mathworks.com,2005:Question/2103752015-04-19T17:36:48Z2015-04-19T17:36:48ZI am using this code, so that every time my increasing array is matched with the features of next frame. But I am getting these errors. Please help me, what modification do I have to do to the following code. Please help.<p>%% The Code %%
function s=surfMatch2(str,name,st,en)
matches_arr=[];
total=0;
unmatches_arr=[];
unmatch_feature=[];</p><pre> for num_images=st:en-1
disp(['Processing frame:',num2str(num_images),' and ',num2str(num_images+1)]);
path1=[str,'\',name,'_',num2str(num_images),'.bmp'];
path2=[str,'\',name,'_',num2str(num_images+1),'.bmp'];
I1=imread(path1);
I2=imread(path2);
img_arr1=rgb2gray(I1);
img_arr2=rgb2gray(I2);
f1= detectSURFFeatures(img_arr1);
f2= detectSURFFeatures(img_arr2);
matchcount=0;
h=length(f1);
g=length(f2);
disp(['No. of features in frame ',num2str(num_images),'=',num2str(h)]);</pre><pre> disp(['No. of features in frame ',num2str(num_images+1),'=',num2str(g)]);
[features1, validf1] = extractFeatures(img_arr1, f1.selectStrongest(45));
[features2, validf2] = extractFeatures(img_arr2, f2.selectStrongest(45));
%strongestPoints = validf1.selectStrongest(1000);
%no_of_features1=length(strongestPoints);
unmatch_feature=horzcat(unmatch_feature,features1);
%disp(unmatch_feature);
%disp(['No. of matching features in block ',num2str(num_images),'=',num2str(no_of_features1)]);
indexPairs = matchFeatures(unmatch_feature, features2);
matchedIm1 = validf1(indexPairs(:,1),:);
matchedIm2 = validf2(indexPairs(:,2),:);
% matchedIm3 = validf2(indexPairs(:,3),:);</pre><pre> no_of_matchedPts=size(matchedIm1,1);
%[features3, validf3] = extractFeatures(indexPairs,1);
% m3 = matchFeatures(features3, features2);
%m4=length(m3);</pre><pre> disp(['No. of matching features in block ',num2str(num_images),',',num2str(num_images+1),'=',num2str(no_of_matchedPts)]);
matchcount=matchcount+no_of_matchedPts;
disp(['No. of overall matching features in block ','=',num2str(matchcount)]);
matches_arr=[matches_arr,no_of_matchedPts];
disp('No. of matching features of two consecutive frames stored in array ');
disp(matches_arr);
unmatchedIdx1 = true(1, size(features1, 1));
unmatchedIdx1(indexPairs(:, 1)) = false;
unmatchedFeatures1 = features1(unmatchedIdx1, :);
no_of_unmatched=length(unmatchedFeatures1);
disp(['The number of unmatched features of frame ',num2str(num_images),'=',num2str(no_of_unmatched)]);
unmatchedIdx2 = true(1, size(features2, 1));
unmatchedIdx2(indexPairs(:, 1)) = false;
unmatchedFeatures2 = features2(unmatchedIdx2, :);
no_of_unmatched1=length(unmatchedFeatures2);
disp(['The number of unmatched features of frame ',num2str(num_images+1),'=',num2str(no_of_unmatched1)]);
totalunmatchedpoints=no_of_unmatched1+no_of_unmatched;
disp(['No. of unmatching features in block ',num2str(num_images),',',num2str(num_images+1),'=',num2str(totalunmatchedpoints)]);
unmatches_arr=[unmatches_arr,totalunmatchedpoints];
disp('No. of unmatched features stored in array of the two consecutive frames');
disp(unmatches_arr);
% total=total+matchedIm1+unmatchedIdx1;
%t=length(total);
%disp((indexPairs));
%[tform, inlierf1, inlierf2] = estimateGeometricTransform(matchedIm1, matchedIm2, 'affine');
figure;
showMatchedFeatures(I1,I2, matchedIm1, matchedIm2,'montage');
%g=length(h);
%disp(['No. of matching features in block ','=',g]);
end
end</pre><p>After running the code, the error output</p><img src = "/matlabcentral/answers/uploaded_files/29349/Untitled.png">Sourav Dashttp://www.mathworks.com/matlabcentral/profile/authors/6388817-sourav-dastag:www.mathworks.com,2005:Question/1830962015-03-14T06:58:01Z2015-04-19T17:24:38ZHelp regarding Image Segmentation of B/W Image!!<p>Hello!
I am working on a project titled 'Yarn Hairiness determination using Image Processing'. The steps involved are- Image processing and Image analysis. In the processing, I converted the image to B/W. After that I am suppose to segment the core yarn from the its protruding fibres. I am stuck here. I have attached the the picture below. It would be a big help!</p>Samkit Muttahttp://www.mathworks.com/matlabcentral/profile/authors/6253158-samkit-muttatag:www.mathworks.com,2005:Question/2103742015-04-19T17:23:39Z2015-04-19T17:23:39ZCalculating Phase difference from workspace data<p>Hi,</p><p>As you can see from the diagram below, I have generated two wave functions from the workspace data and now I am interested in calculating/obtaining the phase difference between the two. Is there any efficient way of doing it in MATLAB or some mathematical formulation that I might be able to use?</p><p>FYI: My aim is to plot the bode plot eventually from different sets of data, let's say for an unknown system.</p><img src = "/matlabcentral/answers/uploaded_files/29348/graph.png">Jilan Samiuddinhttp://www.mathworks.com/matlabcentral/profile/authors/5701711-jilan-samiuddintag:www.mathworks.com,2005:Question/2103732015-04-19T17:08:56Z2015-04-19T17:21:07Zhow can I fix this error code ?<p>I have a project of CBIR (Content Based Image Retrieval) using wavelet transform and color histogram. I perform re-experiment from Singha and Hemachandran research. I have tried to code it, but when an image was added in database, there was an error. Matlab said :</p><pre class="language-matlab">Error using database/fastinsert (line 135)
Java exception occurred:
java.sql.SQLException: [MySQL][ODBC 5.3(a)
Driver][mysqld-5.5.8]Unknown column 'kd' in 'field list'
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLPrepare(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(Unknown
Source)
at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(Unknown
Source)
Error in koneksidbEkstraksi (line 11)
fastinsert(conn, 'ekstraksifitur', colciri, rowciri);
Error in metode_ekstraksi (line 157)
koneksidbEkstraksi(A, H, V);
Error in tambah>btn_tmbhcitra_Callback (line 361)
metode_ekstraksi(input);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in tambah (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)tambah('btn_tmbhcitra_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
</pre><p>I think it was caused by algorithm's code. I have attached the m-file of algorithm's code -- it is named metode_ekstraksi.m . Before that, I've also attached the m-file of database connection for result of extraction -- it is named koneksidbEkstraksi.m. I hope someone can help me solve this problem.</p><p>Thank you.</p>Sarita Putrihttp://www.mathworks.com/matlabcentral/profile/authors/6309737-sarita-putritag:www.mathworks.com,2005:Question/2103722015-04-19T17:07:48Z2015-04-19T17:07:48ZCancel some of the weights in a neural network<p>Hi,</p><p>Im using the network net = cascadeforwardnet() with two hidden layers.
I would like to have connections from the input to the two hidden layers but not to the output layer. However cascadeforwardnet() automatically set these weights.</p><p>1. Can I cancel it ? ( i don't mean only to set the weight to zero)</p><p>2. In general, can i cancel some of the weights? for example from the i'th unit of the first hidden unit to the j'th unit in the second hidden layer ?</p>Elia Frankinhttp://www.mathworks.com/matlabcentral/profile/authors/5916406-elia-frankintag:www.mathworks.com,2005:Question/2103692015-04-19T16:43:14Z2015-04-19T16:43:43ZHow do I plot a n-by-2 matrix?<p>I want to find out how to implement this ive tried this way but it doesn't seem to work.</p><p>accumluatedpredval is a n-by-2 matrix.</p><pre> plotmatrix(accumulatedpredval,'g--x','Linewidth', 1); % code</pre><p>Many Thanks,</p>Mauricio Ramirezhttp://www.mathworks.com/matlabcentral/profile/authors/5810409-mauricio-ramireztag:www.mathworks.com,2005:Question/2103682015-04-19T16:43:05Z2015-04-19T16:43:05Zhow to do coding of Filter designing using window techniques with FRFT?<p>actually i need the whole coding of FRFT with filter designing.</p>PRACHI TIWARIhttp://www.mathworks.com/matlabcentral/profile/authors/6431405-prachi-tiwaritag:www.mathworks.com,2005:Question/2103262015-04-19T10:13:59Z2015-04-19T16:39:30ZMatlab - FFT/PSD Problem for Preemphasis<p>So my plan is the following (create "adaptive" pre/deemp. using Matlab 2015a):</p><ul><li>1. Read an Audiodata ([y,fs]) and generate white Noise with a certain SNR ([n,fs])</li><li></li><li>2. Generate a Filter H which shapes the PSD(y) similiar to the PSD(n)</li><li></li><li>3. Generate an inverse Filter G=H^(-1) which reverts the effect of H.</li><li></li><li>4. Get the output signal</li></ul><p>The code I was thinking to use for this is the following:</p><pre> [y,fs]=audioread('test.wav');
snr=5;
n=awgn(y,snr,'measured')-y;
[pyy,f]=pwelch(y,[],[],length(y)*2-1,fs);
[pnn,fn]=pwelch(n,[],[],length(y)*2-1,fs);</pre><pre> H=sqrt(snr*pnn./pyy);
G=1./H;
outy=ifft(fft(y).*H.*G);
outn=ifft(fft(n).*G);
out=outy+outn;</pre><pre> [pout,fout]=pwelch(outy,[],[],length(outy)*2-1,fs);
[pnout,fnout]=pwelch(outn,[],[],length(outn)*2-1,fs);</pre><p>There are two problems when using the code above:</p><ul><li>1. The pnout should be shaped liked pout (which it isn't).</li><li>2. The outputsignals (outy,outn) are both complex and therefore it is not possible to play the outputfile.</li></ul><p>If I try it another way:</p><pre class="language-matlab">[y,fs]=audioread('test.wav');
snr=5;
n=awgn(y,snr,'measured')-y;
N=length(y);
bin_vals=0:N-1;
fax_Hz= bin_vals*fs/N;
N_2=ceil(N/2);
pyy=(fft(y).*conj(fft(y)));
pnn=(fft(n).*conj(fft(n)));
</pre><pre class="language-matlab">H=sqrt(snr*pnn./pyy);
G=1./H
outy=ifft(fft(y).*H.*G);
outn=ifft(fft(n).*G);
out=outy+outn;
</pre><p>I don't come across the previous problems but in this case I don't use a real PSD but the squared absolute of the frequencydomain-values. (and as I understand it this would give me the power spectrum and not the power spectral density)</p><p>Any ideas why my first way is wrong or how to change my second way to get a real "proper" PSD and not just the PS?</p><p>Thanks!
Klaus</p>klaus eberthttp://www.mathworks.com/matlabcentral/profile/authors/6430383-klaus-eberttag:www.mathworks.com,2005:Question/2103612015-04-19T15:08:52Z2015-04-19T16:30:22Zrounding given matrix towards zero and even number??<p>Im given a row matrix which contain negative and decimals values.
Im asked to round those negative values into zero and those positive with decimals values to even number using for loops and if statement.
how can i accomplish this</p>Victor Seawhttp://www.mathworks.com/matlabcentral/profile/authors/6244245-victor-seawtag:www.mathworks.com,2005:Question/2103522015-04-19T14:32:25Z2015-04-19T16:24:25ZOptimize/speed up a big and slow matrix operation with addition and bsxfun?<p>Hi. I have a fairly long line of code in my script that takes about 7 seconds to run, it was originally three separate calculations but are now done in one line that looks like this:</p><pre class="language-matlab">X = bsxfun(@times,reshape(bsxfun(@times,A,B),[1440,1,2251]),(1-C)./2)...
+bsxfun(@times,reshape(E,1440,1,2251),D)...
+bsxfun(@times,reshape(F,1440,1,[]),((1+C)/2));
</pre><p>Since I need to run it several tens of thousands times it is causing a fair amount of anxiety in my life at the moment. I don’t know how I would go about speeding it up further or if it is even possible. So I would really appreciate it if any of you optimization gurus here could give me some advice on how and if I can go about making this faster.</p><p>The input variables are of size:</p><pre class="language-matlab">A = 2251x1
B = 1440x2251
C = 1x181
D = 1440x181
E = 1440x2251
F = 1440x2251
</pre><p>Thanks!</p>PetterShttp://www.mathworks.com/matlabcentral/profile/authors/5894292-petterstag:www.mathworks.com,2005:Question/2102732015-04-18T19:56:13Z2015-04-19T16:16:32ZWhat can be the vectorization of this code?<p>I am trying to vectorize this code.. what can be the vectorization of this code with input data</p><pre> function hat_y=omp(s,T,N)</pre><pre> Size=size(T);
M=Size(1);
hat_y=zeros(1,N);
Aug_t=[];
r_n=s; </pre><pre> for times=1:M; </pre><pre> for col=1:N;
product(col)=abs(T(:,col)'*r_n);
end
[val,pos]=max(product);
Aug_t=[Aug_t,T(:,pos)];
T(:,pos)=zeros(M,1);
aug_y=(Aug_t'*Aug_t)^(-1)*Aug_t'*s;
r_n=s-Aug_t*aug_y;
pos_array(times)=pos; </pre><pre> if (abs(aug_y(end))^2/norm(aug_y)<0.05)
break;
end
end</pre><pre> hat_y(pos_array)=aug_y; </pre>Abeera Tariqhttp://www.mathworks.com/matlabcentral/profile/authors/5268285-abeera-tariqtag:www.mathworks.com,2005:Question/1218992014-03-17T14:23:32Z2015-04-19T16:14:43ZFrom where can I find my MATLAB R2014a 64-bit Student Version Activation Key? Explain in details.<p>Please, I need someone's help. I bought my Matlab R2014a student version 2 days ago, and I am still facing doubts in finding my Activation key for student version. <b>From where can I find my MATLAB R2014a 64-bit Student Version Activation Key?</b> Because I am trying to look for my Activation key before I install it. I really appreciate that someone could answer my question</p>Ramy Fareshttp://www.mathworks.com/matlabcentral/profile/authors/5109178-ramy-farestag:www.mathworks.com,2005:Question/2103532015-04-19T14:34:30Z2015-04-19T16:13:29Zusing solve function, to resolve trigonométrique systèm <p>hi,
i'am using 'solve' with system of equation with trigo function, so i have 2 problems:
the generate resualt is not numérical,and i must have it in degree ou radian, how can i do it?
too large time to compile it, how can'i to reduce it?</p><p>can some one help me?</p>studentUhttp://www.mathworks.com/matlabcentral/profile/authors/6410228-studentutag:www.mathworks.com,2005:Question/2103552015-04-19T14:42:10Z2015-04-19T16:12:47ZHow do I start Matlab ?<p>Hello, I have one question. ¿What is my license for my trial version ? I can not start Matlab on my computer.</p><p>Thanks for your answer.</p><p>milagros.</p>milagros inga rivashttp://www.mathworks.com/matlabcentral/profile/authors/6431066-milagros-inga-rivastag:www.mathworks.com,2005:Question/2103562015-04-19T14:45:09Z2015-04-19T16:09:28Zerror in cell segmentation <p>i want to make this overlapping cell segmentation same as this link. but when i using their coding in my coding they not work. they have some error. but i dont know how to solve it. please see the link and my coding in pdf</p><p><a href = "http://blogs.mathworks.com/steve/2006/06/02/cell-segmentation/">http://blogs.mathworks.com/steve/2006/06/02/cell-segmentation/</a></p><img src = "/matlabcentral/answers/uploaded_files/29339/N8.jpg">izyan hanumhttp://www.mathworks.com/matlabcentral/profile/authors/6273217-izyan-hanumtag:www.mathworks.com,2005:Question/2103662015-04-19T15:42:10Z2015-04-19T16:06:08Zrandom number generator question<p>Let X1, . . . , X20 be iid U(0, 1) and for each m = 1, . . . , 20 define
Sm =sum from k=1 to m (Xk)
and define fm to be the pdf of Sm.
(a) Express fm as an integral over (0, 1) involving only fm−1.</p>matlabhttp://www.mathworks.com/matlabcentral/profile/authors/5660131-matlabtag:www.mathworks.com,2005:Question/2095212015-04-17T13:59:35Z2015-04-19T15:42:03ZA problem in the loop<p>Hi,</p><p>Please I want to draw a patch from four corner points of each building in the image. However, I do not know how can I create a loop for this purpose.</p><p>I posted my codes and I will highly appreciate any help may I get.</p><p>aa = imread('test_8bit_vis.tif');</p><p>figure, image(aa)</p><p>[x, y] = ginput</p><p>save My_Coordinates.mat x y</p><p>hold on</p><p>plot(x,y,'xw');</p><p>for ii = 1:length(x-1)</p><pre> ind = x(1:4) + 4 * (ii-1);</pre><pre> patch(x(ind), y(ind),'yellow');</pre><pre> end</pre>Nada Kadhimhttp://www.mathworks.com/matlabcentral/profile/authors/5407251-nada-kadhimtag:www.mathworks.com,2005:Question/2103652015-04-19T15:33:47Z2015-04-19T15:33:47ZUnwanted spikes in Simulink with Matlab R2013a<p>I am trying a simulation of a power electronics circuit using simulink of Matlab R2013a. I am able to get correct output but the output contains many unwanted spikes. When I zoom into one of the spikes to the maximum possible limit then also the spike shows like just as a line. The spike is not getting enlarged when I zoom to the maximum level that is possible in scope. I have also checked by changing the "Model Configuration Parameters" but it didn't help. But When I tried the same program with Matlab R2010a then the output is perfect with no spike at all. So I whats the difference between the two version of Matlab and what settings has to be changed to make R2013a to get a spike free output.</p>Diptish Sahahttp://www.mathworks.com/matlabcentral/profile/authors/3992770-diptish-sahatag:www.mathworks.com,2005:Question/2102912015-04-19T03:00:28Z2015-04-19T15:31:57ZHow do you generate random numbers (integers) from zero to five ?<p>Hello , I have already read from the HELP section in matlab and I am still unable to find a solution. Can someone please help !</p><p>Generate random integers that are Non -repeating</p>Marco jacomehttp://www.mathworks.com/matlabcentral/profile/authors/4033781-marco-jacometag:www.mathworks.com,2005:Question/2103642015-04-19T15:29:02Z2015-04-19T15:29:02Zhelp me about integral inside integral<p>Hello everyone,</p><p>I wrote a code for a function that includes inner functions and integral but I get confused I is working but not a professional way can you help me to write it more professional ? Thank you :)</p><p>aa=(k*l*vi/(wr*ccons));
bb=@(w) (((1+w/wr*l)*vi/ccons).^(k-1));
cc=@(w) (2.71.^((-((1+w/wr*l)*vi/ccons)).^k));
f3 =@(w)bb(w).*cc(w);
for i=1:num;
dd=@(w)kr*(x1(i)-w);
dd2=@(w)kr*(x2(i)-w);
fw1 =@(w)f3(w).*dd(w);
fw2=@(w)f3(w).*dd2(w);
% x=in(:,3:4);
% Qscalarx = @(x)integral(@(w) kr*(in(:,3:4)-w)*(k*l*vi/(wr*ccons))*(((1+w/wr*l)*vi/ccons).^(k-1))*2.71.^((-((1+w/wr*l)*vi/ccons)).^k),0,x);
% Q = @(x)arrayfun(Qscalarx,x);
% Q(x);
Q1(i) = integral(fw1,0,x1(i));
% fw2 = @(w) kr*(x2(i)-w)*(k*l*vi/(wr*ccons))*(((1+w/wr*l)*vi/ccons).^(k-1))*2.71.^((-((1+w/wr*l)*vi/ccons)).^k);
Q2(i) = integral(fw2,0,x2(i));
end
Q=Q1'+Q2';
Cwsum=dc(1)*(in(:,3))+dc(2)*(in(:,4));
lam=abs(Pd+2.32-sum(in(:,1:4)'))';
totalcost=Cthermal+(Q)+Cwsum+100*lam;
Thank you :)</p>sarngonhttp://www.mathworks.com/matlabcentral/profile/authors/3289935-sarngontag:www.mathworks.com,2005:Question/2103632015-04-19T15:09:46Z2015-04-19T15:18:46Zfinding a curve to best fit data<p>I am new to MATLAB and have been given 3 coordinates. (1,7) (3,3) and (6,1) I am to plot these points and find a curve to fit them. I do not have any extra toolboxes installed. How do i go about doing a linear fit through these 3 coordinates? The specific question states "Find a curve of the form y=(a/x)+b that best fits the data. Plot the curve using MATLAB"</p>Alex Vishhttp://www.mathworks.com/matlabcentral/profile/authors/6184064-alex-vishtag:www.mathworks.com,2005:Question/2103472015-04-19T13:26:54Z2015-04-19T15:17:33ZHelp with for loop <p>Hi, I have a for loop where d is a 100x1 array and d0 is the average value of the elements in d. I would like to know how I can change it so after each iteration I have a 100x1 result in final_table and after all iterations are completed the variable final_table is a 100x100 array. The way I have implemented the if loop is incorrect since I finish with a 50x100 array. What I am trying to implement is to go through the different values of d, if less than the average d0 then calculate final (variables final_N1 and final_No) to hopefully finish with a 100x1 result and repeat 100 times to finish with 100x100 array in final_table. Thanks.</p><pre> for cnt=1:100
if d(cnt)<=d0</pre><pre> No=sum(d<=d0);
d_pos_No=find(d<=d0);
final_No=d_pos_No/No;
final_N1=zeros(size(final_No));</pre><pre> else
N1=sum(d>d0);
d_pos_N1=find(d>d0);
final_N1=d_pos_N1/No;
final_No=zeros(size(final_N1));
end</pre><pre> final_table(1:numel(final_No+final_N1),cnt)=final_No+final_N1;
end</pre>ajk1http://www.mathworks.com/matlabcentral/profile/authors/3936610-ajk1tag:www.mathworks.com,2005:Question/2103622015-04-19T15:09:14Z2015-04-19T15:09:14ZUsing while like for<p>I want to use while loop,like double for loop.I have a</p><p>while flag==0</p><p>for i+1:N</p><p>for j=1:V</p><p>if {part of code,flag becomes one (flag=1) }</p><p>end</p><p>end</p><p>end</p><pre> and i want to write it in while loop with a condition that stops when a variable flag becomes 1</pre>Giannakis Stoukashttp://www.mathworks.com/matlabcentral/profile/authors/6307629-giannakis-stoukastag:www.mathworks.com,2005:Question/2103602015-04-19T15:07:15Z2015-04-19T15:07:15ZHow can I use a function with a circuit?<p>Hello,
I would like to take the output voltage from a circuit I made in simulink and then manipulate through an equation. Then I want the output of this equation to act as a voltage so I can feed it into another part of my circuit?
How can I do this?
I essentially want to take the output voltage of the circuit, multiply it's magnitude, shift it's phase and then use this new number as a voltage elsewhere. It's just like a transformer, however I can't seem to get a single phase transformer to connect with my circuit.</p>Tom Smallhttp://www.mathworks.com/matlabcentral/profile/authors/6410571-tom-smalltag:www.mathworks.com,2005:Question/2103592015-04-19T15:06:16Z2015-04-19T15:06:16Zmeasure of the error contributed by each neuron in neural network<p>the NN is evaluated for a random training instance using forward propagation, and the error at the network output (with reference to the golden output) is computed. For each instance in the training dataset, the error at the output of the neural network is computed using forward propagation.
Next, backpropagation is invoked, the errors are propagated back to the outputs of individual neurons and their average error contribution over all inputs in the training set is obtained.
Thus, backpropagation quantifies the error contributed by each neuron in the network towards the global network error.</p><p>how can I provide a measure of the error contributed by <b>each neuron</b> to the outputs of the network by backpropagation in matlab? I would appreciate for any help.</p>Alihttp://www.mathworks.com/matlabcentral/profile/authors/5991467-alitag:www.mathworks.com,2005:Question/2103572015-04-19T14:52:56Z2015-04-19T18:43:42ZHow do I fix 'imread' related error ?<p>I installed Matlab R2015a on a 64bit windows 8 laptop and have the image processing toolbox. All folders and subfolders are in the matlab work path.</p><p>PROBLEM 1. READING AN IMAGE</p><p>>> A= imread('boy14.jpg');</p><p>Error using assert
Too many input arguments.
Error in isjpg (line 8)
assert(fid ~= -1, message('MATLAB:imagesci:validate:fileOpen', filename));
Error in imftype (line 50)
tf = feval(fmt_s.isa, filename);
Error in imread (line 359)
[format, fmt_s] = imftype(filename);</p><p>2. TO DISPLAY MULTIPLE IMAGES</p><p>image_folder = 'B:\Matlabcode2015\codes\Mboy';
filenames = dir(fullfile(image_folder, '*.jpg'));
total_images = numel(filenames);
for n = 1:total_images
full_name= fullfile(image_folder, filenames(n).name);%specifies images names, full path and extension
our_images = imread(filenames); % Read images
figure (n) % used index n so old figs are not over written by new new figs
imshow(our_images)
end</p><p>THE ERROR MESSAGE I GET :</p><p>>> read_image
Error using imread>parse_inputs (line 457)
The file name or URL argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in read_image (line 8)
our_images = imread(filenames); % Read images</p>Toyin Popoolahttp://www.mathworks.com/matlabcentral/profile/authors/6431051-toyin-popoolatag:www.mathworks.com,2005:Question/2103452015-04-19T13:01:19Z2015-04-19T14:31:02ZCross Correlation and time lag<p>So in my project work, i placed two accelerometers on a single vibrating body and i want to find the timelag between the signals at either end...</p><pre class="language-matlab">[Correlation,lag]=xcorr(voltage1,voltage2);
corrlength=numel(Correlation);
</pre><pre class="language-matlab">[mag,Index] = max(abs(Correlation));
</pre><pre class="language-matlab">sampletime=0.003 ;%data acquisition
timelag=lag(Index)*(sampletime);
</pre><p>-------------------------------------
voltage1 and voltage2 are bandpassed signals from the accelerometers in a specific noise range</p><p>But everytime i run the function, the timelag and lag amounts to zero, no matter how much i adjust the accelerometer sensitivity and position. Is it supposed to be zero? Or am i doing something wrong?</p>Jade Senhttp://www.mathworks.com/matlabcentral/profile/authors/6412278-jade-sentag:www.mathworks.com,2005:Question/2103322015-04-19T11:08:29Z2015-04-19T14:23:52ZRead and write data in Excel using matlab<p>Hi,</p><p>I have a set of data in excel that needed to be interpolated based on two variables called temperature and pressure. The code I have will read the interpolated data from one excel file(called testdata.xlsx), check the the temperature and pressure values in the excel file (results.xlsx)</p><p>The code will then place the interpolated answer in the third column of the excel sheet (results.xlsx). What I need is the ability to tell matlab which column the temperature comes from, which column the pressure comes from and which column to write the results in.</p><p>But on top of that I'd need it do this on all sheets as on my real results file there is a different temperature and pressure to calculate the interpolated data from. The columns temperature and pressure will be in will be the same for each sheet</p><p>Below are example excel files and current code</p><p>https://www.dropbox.com/s/0l6b1ngu1qszavj/results.xlsx?dl=0
https://www.dropbox.com/s/dbuzncyr5ie912y/testdata.xlsx?dl=0</p><pre class="language-matlab">if true
%%%%%%%
clear all
close all
fprintf('\n No excel files must be open when running the script')
fprintf('\n All files must be in current directory with the script File names \nare case sensitive and require extensions which are appropriate')
filename1=input('\n Enter the filename to read data from with\n extension (ex. testdata.xlsx) : ','s');
filename2=input('\n Enter the filename having values to which the \ndata is to be interpolated with extension (ex. results.xlsx ) : ','s');
data=xlsread(filename1);
xdata=data(1,2:end);
ydata=data(2:end,1);
V=data(2:end,2:end);
data2=xlsread(filename2);
xq=data2(:,1);
yq=data2(:,2);
str1=num2str(length(xq)+1);
rangeis=strcat('C2:C',str1);
intval=interp2(xdata,ydata,V,xq,yq);
xlswrite(filename2,intval,rangeis)
fprintf('\n Result written in third column of file %s (Re open to see it)(blank spaces means not a number )',filename2)
end
</pre>Alan Smithhttp://www.mathworks.com/matlabcentral/profile/authors/6276448-alan-smith