http://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-10-25T10:00:54Ztag:www.mathworks.com,2005:Question/1600302014-10-25T10:00:39Z2014-10-25T10:00:54Zgreat ways of solving geometry<p>great ways of solving geometry <a href = "http://www.reddit.com/r/muragwafokokaron/comments/2k9xv7/">http://www.reddit.com/r/muragwafokokaron/comments/2k9xv7/</a></p>gtrhyrj roshek/matlabcentral/answers/contributors/5812305-gtrhyrj-roshektag:www.mathworks.com,2005:Question/1599892014-10-24T22:23:18Z2014-10-25T09:31:28ZHow can I create a 10x4 matrix with a for loop?<p>I came across the following problem in my Matlab textbook:
Write a loop that generates a column vector A with ten random numbers. Then create a 10 × 4 matrix having A as its fi rst column, with the remaining columns the product of the first column and the column number.</p><p>The solution they gave is the following:</p><pre class="language-matlab">for ind = 1:10;
A(ind) = rand;
end
for ind2 = 1:4;
B(1:10, ind2) = A*ind2;
end
</pre><p>However, although I understand each line of the code, I can't understand the logic behind the following:</p><p>1. How does the program know that 1:10 in the second for loop refers to vector A (indeed, when i run the code, the first column is vector A);</p><p>2. What sort of expression is the last one</p><pre class="language-matlab">B(1:10, ind2) = A*ind2;
</pre><p>i.e., shouldn't A*ind2 be in the parenthesis to indicate the other 3 columns? What does the "=" stand for here?</p><p>Also, I tried to solve it for quite a while and this is what I came up with:</p><pre class="language-matlab">A = rand(10,1);
for ii = 1:4;
ii;
x = A*ii;
B = horzcat(A,x,x,x)
end
</pre><p>The last command basically creates a 10x4 matrix, however, instead of creating 3 different x vectors, it just reapeats x 3 times.</p><p>Could you please tell me how to amend my code, so that it works?</p><p>Thanks a lot!!
I appreciate greatly any help and comments</p><p>Silvi</p>Silviya/matlabcentral/answers/contributors/5756340-silviyatag:www.mathworks.com,2005:Question/1600272014-10-25T08:59:18Z2014-10-25T09:31:07Zcomputer crashes when joining two large tables<p>Hi,
i have two large tables and i wish to join them but my computer crashes each time. Is there a way to cut the file in small pieces abd then paste it bit by bit. The table has one million rows ans i want to join it with a table that has about 4 million rows.</p>AA/matlabcentral/answers/contributors/5703029-aatag:www.mathworks.com,2005:Question/1600242014-10-25T08:11:13Z2014-10-25T09:29:17Zhow to get rid of uint8 type error?<p>doing me research on iris recognition using libor mask code. while doing segmentation getting error of undefined parameter of type uint8 in implementing a particular function have also tried uint16 and double but of no use....please suggest some solution</p>SANDEEP/matlabcentral/answers/contributors/5817329-sandeeptag:www.mathworks.com,2005:Question/1600292014-10-25T09:18:25Z2014-10-25T09:18:25ZMatlab student version not the latest version. How do I get a refund?<p>I bought the student version of Matlab yesterday.
Although version 2014b is available, I got version 2014a. Why?</p><p>As most mac users know, Matlab 2014a is practically unusable with a Retina display.
I know about the "tricks" concerning this issue (switch to low-res or change JRE), however, I don't want to do that.
I want to install Matlab and then just use it.</p><p>I ask for a refund. What should I do?</p><p>Thanx.</p>Pierre/matlabcentral/answers/contributors/5803375-pierretag:www.mathworks.com,2005:Question/1599952014-10-24T23:12:12Z2014-10-25T09:16:51Zwelcom please help me<p>What are the algorithms seven feature extraction in biometrics</p>fatima ali/matlabcentral/answers/contributors/5601917-fatima-alitag:www.mathworks.com,2005:Question/1599472014-10-24T15:21:37Z2014-10-25T09:12:03ZWhat is the effect of data gaps in obtaining power spectral density using periodogram?? please help<p>Dear all I have computed power spectral density using periodogram of my time series data. But there is data gaps in the time series, how periodogram takes account of the data gaps...pleas help me</p>Chris Martin/matlabcentral/answers/contributors/3732386-chris-martintag:www.mathworks.com,2005:Question/1599702014-10-24T18:08:08Z2014-10-25T09:09:17ZMATLAB in VB.net interface integration<p>Hi</p><p>I'm master in VB.Net and want to use MATLAB abilities and my m-files in vb.net interface. Would you please help me to find a complete reference(As PDF file, web site, online resources, sample code ore project, etc.) to learn more and more about it?</p><p>Thanks a lot</p><p>Mani</p>Mani Ahmadian/matlabcentral/answers/contributors/4207149-mani-ahmadiantag:www.mathworks.com,2005:Question/1600262014-10-25T08:48:16Z2014-10-25T09:03:23ZI'm using Matlab 7.0. How can I call a function? "File/New/Function" is missing.<img src = "/matlabcentral/answers/uploaded_files/19964/function.jpg"><p>Or should I write an .m file instead beginning with:</p><pre class="language-matlab">function F = magic(x)
...
end
?
</pre>Übel/matlabcentral/answers/contributors/5788878-ubeltag:www.mathworks.com,2005:Question/1594172014-10-20T20:23:47Z2014-10-25T08:54:02ZHow to calculate the confidence interval<p>Hi</p><p>I have a vector x with e.g. 100 data point. I can easy calculate the mean but now I want the 95% confidence interval. I can calculate the 95% confidence interval as follows:</p><pre class="language-matlab">CI = mean(x)+- t * (s / square(n))
</pre><p>where s is the standard deviation and n the sample size (= 100).</p><p>Is there a method in matlab where I just can feed in the vector and then I get the confidence interval?</p><p>Or I can write my own method but I need at least the value of t (critical value of
the t distribution) because it depends on the number of samples and I don't want to lookup it in a table everytime. Is this possible?</p><p>Would be very nice if somebody could give an example.</p><p>Last but not least, I want 95% confidence in a 5% interval around the mean. For checking that I just have to calculate the 95% confidence interval and then check if the retrieved value is less than 5% of my mean, right?</p>Sepp/matlabcentral/answers/contributors/5293424-sepptag:www.mathworks.com,2005:Question/1600252014-10-25T08:30:21Z2014-10-25T08:30:21ZHow can i determine the amplitude, phase, period, sampling frequency, circular frequency (Hz), and angular frequency (rad/sec) of the sine wave<p>i have this code</p><p>M=10; %samples/sec</p><p>n=-3:1/M:3;</p><p>A=2;</p><p>phase=0;</p><p>f=1;</p><p>x=A * sin(2*pi*f*n + phase);</p><p>stem(n,x,'linewidth', 2)</p><p>title('Discrete-Time Sine Wave: A sin(2*\pi*f*n + \phi)')</p><p>xlabel('Time Index')</p><p>ylabel('Signal Amplitude')</p><p>axis([n(1) n(end) -A A])</p><p>grid</p>BINTUZZAIN11 ORIANTO/matlabcentral/answers/contributors/5817375-bintuzzain11-oriantotag:www.mathworks.com,2005:Question/1599222014-10-24T11:36:58Z2014-10-25T08:20:24Zscale range for neural network<p>Dear All;</p><p>I have in neural network, :
My input range is starting with small value , then it become big ( 1000 times of the small values)
which a lot of data accumulate in small range and make conflict between detail in this range , how can we solve it .
Also, if I have data range overlap at the boundary which may lead to misinterpretation, what is the best way to overcome this issue.</p><p>Regards;</p>mustafa alnasser/matlabcentral/answers/contributors/2435851-mustafa-alnassertag:www.mathworks.com,2005:Question/1599832014-10-24T21:15:46Z2014-10-25T08:16:01ZBumblebee 2 image acquisition problem<p>Hi I am trying to capture images with a bumblebee 2 stereo camera, however whenever I attempt to declare a video object, I get the error:</p><pre class="language-matlab">"Error using videoinput (line 379)
winvideo: Image acquisition device is not
accessible.
The parameter is incorrect.
Make sure no other objects or applications
are accessing the same device."
</pre><p>The code I am using to declare the video object is:</p><pre class="language-matlab">vid = videoinput('winvideo', 1, 'RGB24_1024x768')
</pre><p>Also, I am not attempting to access the camera using any other application, therefore I do not understand why it shows that it is inaccessible.</p>Sarisha/matlabcentral/answers/contributors/5548493-sarishatag:www.mathworks.com,2005:Question/1600202014-10-25T07:06:21Z2014-10-25T08:01:31ZCannot compute the following expression using "Symsum"<img src = "/matlabcentral/answers/uploaded_files/19961/MAt.PNG"><p>B is a Vector which is 1 x 29 ......</p><p>I need a row vector which is [B(1), B(1)+B(2) , B(1)+B(2)+B(3) , ........ ]</p><p>I am using Symsum /// But i am getting error....</p>Ashish/matlabcentral/answers/contributors/4801875-ashishtag:www.mathworks.com,2005:Question/1600232014-10-25T07:53:14Z2014-10-25T07:53:14ZHow can i find a parameter in a formula when i have three series od data and wanna to find best answer for fourth parameter?<p>I have three series od data for x,y and z
I wanna find the fourth parameter m(like the best fit for it)in a Maxwell relaxation formula which that is:
z=2*m*x*y
and the series of other parameters are:
z=[0.0892 .158 0.890 1.26 2.47 3.64 6.71 11.6 18.1 27.7 42.0 65.4 97.5 141.0 196.0 283.0 440.0 661.0 863];
x=[0.05 0.628 0.0791 0.0995 0.125 0.158 0.199 0.25 0.315 0.396 0.5 0.628 0.79 0.995 1.25 1.58 1.99 2.5 3.15];
y=[1.42 1.78 2.25 2.83 3.56 4.49 5.65 7.08 8.79 11.01 13.87 17.46 21.8 27.16 33.75 42.34 53.53 67.03 84.11];
I will be grateful for helping me on this case.</p>amir/matlabcentral/answers/contributors/5817272-amirtag:www.mathworks.com,2005:Question/1600182014-10-25T06:35:54Z2014-10-25T07:46:47ZIs it possible to do contrast stretching without using imadjust.<p>Hi, Is it possible to do contrast stretching without using imadjust.</p><p>If possible can anyone give me an example.</p>vetri veeran/matlabcentral/answers/contributors/5421907-vetri-veerantag:www.mathworks.com,2005:Question/1600222014-10-25T07:41:00Z2014-10-25T07:45:37ZTextscan with blocks of data with headers to individual block<p>Hi All,</p><p>I am trying to extract to following data with textscan. But I am not able to implement it correctly. Each block consists of 11 data lines and 8 unnecessary lines to exclude.</p><p>Data file (testdata.dat) is :</p><pre class="language-matlab">Title
</pre><pre class="language-matlab">Data Header: Time: 100.16064 Sec 10/8/2012 3:32:17 PM
Data Acquisition: T
Station Name: default
Test File Name:
Axial Axial Axial
segments mm kN
0 -0.19470811 -0.0067140702
0 -0.19806515 -0.0033570339
0 -0.19806515 -0.0033570339
0 -0.19470811 -0.0067140702
0 -0.16785182 -0.0033570339
0 -0.16785182 -0.0067140702
0 -0.13763849 -0.0067140702
0 -0.12421035 -0.0067140702
0 -0.10742517 -0.0033570339
0 -0.11413924 -0.0033570339
0 -0.14099553 -0.0033570339
</pre><pre class="language-matlab">Data Header: Time: 100.16064 Sec 10/8/2012 3:32:17 PM
Data Acquisition: T
Station Name: default
Test File Name:
Axial Axial Axial
segments mm kN
0 -0.16785182 -0.0033570339
0 -0.20813625 -0.0067140702
0 -0.2316355 -0.0067140702
0 -0.25513476 -0.0067140702
0 -0.29206216 -0.0033570339
0 -0.35584584 -0.0067140702
0 -0.40620136 -0.0067140702
0 -0.47334209 -0.0067140702
0 -0.55055392 -0.0067140702
0 -0.61098057 -0.0067140702
0 -0.70162052 -0.010071106
</pre><p>My implementation is</p><pre class="language-matlab">fileID = fopen('testdata.dat');
formatSpec = '%d %f %f';
clear C
k = 0;
N = 11;%Block size
while ~feof(fileID)
k = k+1;
C(k,1:3) = textscan(fileID,formatSpec,N,'HeaderLines', 8);%'CommentStyle','##',
end
fclose(fileID)
</pre><p>Please correct my code. Thanks in advance.</p>Raj Raj/matlabcentral/answers/contributors/1611869-raj-rajtag:www.mathworks.com,2005:Question/1599672014-10-24T17:44:10Z2014-10-25T07:38:10ZHow to enter this program in matlab?<p>Projectile motion equations describe:
X= v0* cos(fi)*t
Y= v0*sin(fi)*t-0,5*g*t
Where g = 9.81 m / s2. Create a program that graphically shows the trajectory of the projectile entered the
value of the angle and the initial speed of 5 m / s. (The calculation by adding the condition that the calculation ends if y <= 0 If !. plot function call in each step of the loop, it is desirable to define the fixed before the loop spans the axes)</p>user1996/matlabcentral/answers/contributors/5815781-user1996tag:www.mathworks.com,2005:Question/1600212014-10-25T07:16:41Z2014-10-25T07:32:21ZHighlighting text in Editor<p>Is there a way to highlight %Comments in my code within the editor? I would like to do it as reminders.
Thank you.</p>Richard/matlabcentral/answers/contributors/5410950-richardtag:www.mathworks.com,2005:Question/1600192014-10-25T06:51:35Z2014-10-25T07:32:01ZHow do I fix my elements in my code so that they can be the same?<p>%I keep getting the error of 'In an assignment A(I) = B, the number of elements in B and I must be the same.' I believe the problem is with Bn, but I am not sure how to fix this.</p><p>clear all, close all, nfig = 0;</p><p>%Data in Problem</p><p>S = 1200;
To = 40;
k = 0.16;
HH = 16; H = 16*(0.0254);
WW = 10; W = 10*(0.0254);
Ly = H/2;
Lx = W/2;
Nx = 101;
x = linspace(0, W, Nx)';
nmax = 50;
tol = 0.001;</p><p>Ln = zeros(1,nmax); Bn = zeros(1,nmax);
for n = 1:nmax
Ln(n)= ((2*n-1)*pi)/(2*Lx);
Bn(n) = ((2*S)/(k*Lx))*((-1)^n)./((Ln.^3).*cosh(Ln*Ly));
end</p>Yianni/matlabcentral/answers/contributors/5617616-yiannitag:www.mathworks.com,2005:Question/1594882014-10-21T11:01:21Z2014-10-25T07:31:00Zproblem with cellular automata code?<p>i found this code here, and i try to initialize it with [1 0 1 1 0 1 1] but it didn't work.</p><p><a href = "http://www.mathworks.com/matlabcentral/fileexchange/39492-ca-code-for-matlab/content/wolfram.m">http://www.mathworks.com/matlabcentral/fileexchange/39492-ca-code-for-matlab/content/wolfram.m</a></p><p>the code is long to paste it here.
and how to locate the image?</p>sara/matlabcentral/answers/contributors/5790085-saratag:www.mathworks.com,2005:Question/1599262014-10-24T12:43:48Z2014-10-25T07:26:53Zhow to swap rows between matrix?<p>hi guys,,,
i have two matrix A & B, and i want to swap the rows between these matrix according to their Distance.
the swap should be from B to A.it swap A rows with lower distance with B rows which have higher Distance.
like row no.2 has D=14 and row 2 in B has D=16, so B_row should be swapped with A_row.
how to do this? the matrix is below.
help needed guys.</p>sara/matlabcentral/answers/contributors/5790085-saratag:www.mathworks.com,2005:Question/1599612014-10-24T17:03:37Z2014-10-25T06:52:09ZPlane fitting for openings<img src = "/matlabcentral/answers/uploaded_files/19940/%E6%93%B7%E5%8F%96.JPG"><p>As shown in the figure of a human's foot, I want to make the openings at the position around the toes and the ankle look better like a sock's opening.
I can now find the boundary vertices for each opening. Could anyone tell me if there are any methods for plane fitting, making the boundary points more or less lie on the same plane?</p><p>Or are there any other approaches can do? Thanks for all helps!</p>Patrick/matlabcentral/answers/contributors/5670568-patricktag:www.mathworks.com,2005:Question/1600172014-10-25T06:30:48Z2014-10-25T06:30:48ZHow do I fix my elements in my code so that they can be the same?<p>When I run my program below, I keep running into the error message of 'In an assignment A(I) = B, the number of elements in B and I must be the same.'. I can tell there is a problem with my term for Bn, but I don't know how to fix it.</p><p>clear all, close all, nfig = 0;</p><p>%Data in Problem</p><p>S = 1200; %Internal Heating (W/m^3)
To = 40; %Initial Temperature (C)
k = 0.16; %Thermal Conductivity (W/(m*c))
HH = 16; H = 16*(0.0254); %Height of long wooden beam (converted to m)
WW = 10; W = 10*(0.0254); %Width of long wooden beam (converted to m)
Ly = H/2; %Height of Upper Right Quadrant of beam (m)
Lx = W/2; %Width of Upper Right Quadrant of beam (m)
Nx = 101; %Number of x values
x = linspace(0, W, Nx)'; %Vector of points to evaluate function
nmax = 50; %Max # of nonzero terms in expansion
tol = 0.001; %Tolerance to stop series evaluation</p><p>%Calculations of Ln and Bn</p><p>Ln = zeros(1,nmax); Bn = zeros(1,nmax);
for n = 1:nmax
Ln(n)= ((2*n-1)*pi)/(2*Lx); Bn(n) = ((2*S)/(k*Lx))*((-1)^n)./((Ln.^3).*cosh(Ln*Ly));
end</p>Yianni/matlabcentral/answers/contributors/5617616-yiannitag:www.mathworks.com,2005:Question/1600162014-10-25T06:30:08Z2014-10-25T06:42:56Z3d Fitting using a matlab function<p>Hi~
Could you show me the answer to solve a 3d fitting problem?
I want to calculate xyz using xyz_s and a fitting function of the Matlab.</p><p>Thank you.
WEST</p><p>% My Matlab code is started here</p><p>clear all; clc;</p><p>x = linspace(-1,1,100);
y = linspace(0,1,200);
z = linspace(-2,-1,300);</p><p>subplot(221); plot(x); title('x'); ylim([-3,3]); subplot(222); plot(y); title('y'); ylim([-3,3]); subplot(223); plot(z); title('z'); ylim([-3,3]);</p><p>temp = round(linspace(1,100,3+2)); x_3 = x(temp(2:4))
% three positions on 100 : 26 51 75</p><p>temp = round(linspace(1,200,5+2)); y_5 = y(temp(2:6))
% five positions on 200 : 34 67 101 134 167</p><p>temp = round(linspace(1,300,7+2)); z_7 = z(temp(2:8))
% seven positions on 300 : 38 76 113 151 188 225 263</p><p>xyz_s = rand(3,5,7);</p><p>xyz = zeros(100,200,300); % ??</p><p>whos</p>Seok Bae SEO/matlabcentral/answers/contributors/5817160-seok-bae-seotag:www.mathworks.com,2005:Question/1600142014-10-25T05:56:47Z2014-10-25T05:56:47Zhi, need to find circles in the attached image.<p>i would like to know the code or concept to find out the circles in the image along with the coordinates and the cropping concept.</p>Trinath Karri/matlabcentral/answers/contributors/5768457-trinath-karritag:www.mathworks.com,2005:Question/1600102014-10-25T04:44:02Z2014-10-25T05:50:19ZError using histeq Expected input number 1, I, to be two-dimensional. Error in histeq (line 70) validateattributes(a,{'uint8','uint16','double','int16','single'}, ...<p>my code is</p><pre class="language-matlab">a=imread('cameraman.jpg');
r=size(a,1);
c=size(a,2);
ah=uint8(zeros(r,c));
n=r*c;
f=zeros(256,1);
pdf=zeros(256,1);
cdf=zeros(256,1);
out=zeros(256,1);
</pre><pre class="language-matlab">for i=1:r
for j=1:c
value=a(i,j);
f(value+1)= f(value+1)+1;
pdf(value+1)= f(value+1)/n;
</pre><pre> end
end</pre><pre class="language-matlab">sum=0; l=255;
for i=size(pdf)
sum=sum+f(i);
cum(i)=sum;
cdf(i)=cum(i)/n;
out(i)=round(cdf(i)*l);
end
</pre><pre class="language-matlab">for i=1:r
for j=1:c
ah(i,j)=out(a(i,j)+1);
end
end
</pre><pre class="language-matlab">figure,imshow(ah);
he=histeq(a);
figure,inshow(he);
</pre><p>I am getting an error as,</p><pre class="language-matlab">Error using histeq
Expected input number 1, I, to be two-dimensional.
</pre><pre class="language-matlab">Error in histeq (line 70)
validateattributes(a,{'uint8','uint16','double','int16','single'}, ...
</pre><pre class="language-matlab">Error in Untitled5 (line 40)
he=histeq(a);
</pre><p>can somebody help me in this</p><p>Thanks in advance.</p>vetri veeran/matlabcentral/answers/contributors/5421907-vetri-veerantag:www.mathworks.com,2005:Question/1600122014-10-25T05:46:51Z2014-10-25T05:46:51ZHow can I access different excel files and plot the data from each file on a single figure?<p>Hi there,</p><p>I would like some assistance in accessing data from different excel files and then plotting the data from each of these files on a single figure.</p><p>Right now the code looks like this:</p><p>comparisons=input('How many graphs to plot?')</p><p>for i=1:comparisons</p><p>[a b c]=uigetfile('*xlsx','Select the Excel file')</p><p>[strain]=xlsread(a,'H1:H1000');</p><p>[stress]=xlsread(a,'J1:J1000');</p><p>figure (1)</p><p>hold on</p><p>plot(strain,stress,'b.')</p><p>xlabel('Strain')</p><p>ylabel('Stress')</p><p>legend(a)</p><p>hold off</p><p>i=i+1</p><p>end</p><p>I do not know how to include the name of all of the plots in the legend and I also do not know how to vary the plotting colour for each of the different plots. The number of plots that I require can vary from 1 plot on a certain figure to 5 plots on another figure.</p><p>Any help with this problem would be much appreciated</p>Khensani/matlabcentral/answers/contributors/5443729-khensanitag:www.mathworks.com,2005:Question/1600002014-10-25T01:02:01Z2014-10-25T05:27:05ZUsing Fzero for one variable in a nonlinear equation with multiple variables<p>Hi,
If I have a non linear equation with multiple variables but I want to solve for one variable (in terms of those other variables) then can I use fzero? If so, how?</p><p>Thanks</p>EeeJay/matlabcentral/answers/contributors/4270770-eeejaytag:www.mathworks.com,2005:Question/1600112014-10-25T05:10:31Z2014-10-25T05:10:31Zwrev function on Matlab R2014a (Student) doesn't work ?<p>I keep getting an error when I try to run my following script.</p><pre class="language-matlab">if true
% code
end
RL=[];
for s=1:length(subj),
x=[];
sr = [wrev(result_s{1,s}(1:5,dp)); wrev(result_s{1,s}(6:10,dp)); wrev(result_s{1,s}(14:15,dp))];
sl = [result_s{1,s}(21:25,dp); result_s{1,s}(16:20,dp); result_s{1,s}(11:12,dp)];
x(:,1)=sr;
x(:,2)=sl;
RL=[RL;x];
end;
</pre><p>>> Undefined function 'wrev' for input arguments of type 'double'.</p>Anna/matlabcentral/answers/contributors/5816454-annatag:www.mathworks.com,2005:Question/1600092014-10-25T04:10:37Z2014-10-25T04:58:38ZHow can I superimpose 1D streamline (color) on 2D grayscale image?<p>Hi,</p><p>I have a 2D grayscale image (128x128 double) and a 1D streamline with color (400x1 double).
I can overlay the streamline color on the 2D grayscale image, but the streamline color would change to grayscale too.</p><p>I check that function imoverlay can do this but it requires both inputs in 2D.
Anyone can help me to superimpose the 1D streamline color on 2D grayscale image by having different colormap?</p><p>Thanks.</p>Abbie/matlabcentral/answers/contributors/4169519-abbietag:www.mathworks.com,2005:Question/1127102014-01-17T09:46:59Z2014-10-25T04:43:58ZReusable functions (embedded coder) and model reference<p>I have a model A which contains two other models B and C through the model referencing. All this models use a block defined in a custom library.
I have set "Function packaging: Reusable function" for the library block. By this way each model (A, B or C) reuse code for the block. However in the generated C code, for each model I have a different function (with different signature but the same implementation).
I would create reusable code for the library block. That is I want only one implementation for the function called by all the models A, B and C.
I tried to set function name and File name for the library block but I get an error</p><p>"Potential conflicting usages of identifier 'rtZCSV_GainLib': a global identifier from model B, and a global identifier from model C
The conflict may be resolved by increasing the maximum identifier length on the Symbols pane of the Configuration Parameters dialog box. Otherwise the conflicting identifiers need to be renamed."</p><p>Is it possible generate only one implementation for the library block in a given c files and configure all the models A, B, C in a way that they call the same function? What are the settings I have to use?</p><p>Thanks,</p><p>Paolo</p>Paolo/matlabcentral/answers/contributors/3337868-paolotag:www.mathworks.com,2005:Question/1597192014-10-22T18:30:33Z2014-10-25T04:43:56Zhow to normalize a matrix?????<p>hello everyone...
i need a code to normalize( between 0 and 1) a matrix 7*50. the normalization process should be for each column not row**. in other words, the program should seek for the largest value in each column and divide all the elements in that column by it.
can anybody help plzz</p>abdulkader helwan/matlabcentral/answers/contributors/4753564-abdulkader-helwantag:www.mathworks.com,2005:Question/1594072014-10-20T18:49:47Z2014-10-25T04:32:56ZElite feature of genetic algorithm<p>hi all</p><p>i successfully make a Matlab program for Genetic algorithm (without using elite feature) and achieve goal which was desired. i have tried for various number of chromosomes like.5,6,10 and 20. but didn't notice any significant change. i logically believe, there must me some impact on output response by increasing the number of chromosome. and my second question is i want to know, at which stage elite strategy is used and how. i am following the below link: <a href = "http://www.mathworks.com/help/gads/how-the-genetic-algorithm-works.html">http://www.mathworks.com/help/gads/how-the-genetic-algorithm-works.html</a> in which a line is written "Some of the individuals in the current population that have lower fitness are chosen as elite. These elite individuals are passed to the next population." i am confused at this stage , means if a individual have low fitness then how it is processed to a next level?.</p><p>kindly share information if any one have, thanks in advance :)</p>Mudasir Ahmed/matlabcentral/answers/contributors/4786921-mudasir-ahmedtag:www.mathworks.com,2005:Question/1600082014-10-25T04:04:39Z2014-10-25T04:04:39Zcode generated by ntstool<p>May i know whats the code generated by ntstool for? it always give a different predicted outputs (sometimes with huge errors even though i thought i have saved it due to the small MSE produced)..</p><p>May i know why is this happening? thanks</p>WT/matlabcentral/answers/contributors/5646906-wttag:www.mathworks.com,2005:Question/1600072014-10-25T04:04:18Z2014-10-25T04:04:18ZModel code generation error with Two model reference blocks both of which include one library block<p>Dear all,
I met with a problem with the embedded model reference blocks.
(1)I have one parent model
(2) in (1),there tow referenced model: modelRef1 and modelRef2.
(3) in modelRef1 and modelRef2,there is a library named with 'AddSum',the library block configuration is as a reusable funcion and the stored name is 'AddSum'.</p><p>When building the parent model, after modelRef1 and modelRef2 build completeness, during starting parent buid process, there is error poping up wih the conflicting usage of 'AddSum.h'.</p><p>It is ok to fix the problem to change the library code generation configuration page by selecting auto system code.
but I want to put the library function into one file which seems clear to check code.</p><p>Is there anyone encountered with the same problem as mine?
any comments would be appreciated very much.</p>Yihe Zuo/matlabcentral/answers/contributors/3009641-yihe-zuotag:www.mathworks.com,2005:Question/1600052014-10-25T03:38:06Z2014-10-25T03:56:48ZHow can pick a specific values (rows,columns) from a matrix?<p>Hi all,</p><p>I want to process a part of large a matrix. Let's assume we have a matrix with 10 rows and 10 columns, I want to pick a small matrix from it with 4 rows and 5 columns. How can I do it?</p><p>Thank you</p>Abdulatif Alabdulatif/matlabcentral/answers/contributors/5216840-abdulatif-alabdulatiftag:www.mathworks.com,2005:Question/1600062014-10-25T03:54:27Z2014-10-25T03:54:27ZHow can I determine color value at any point after texture mapping?<p>I have texture mapped an image to the surface of a sphere using the example at <a href = "http://www.mathworks.com/help/matlab/visualize/coloring-mesh-and-surface-plots.html#f0-9250">http://www.mathworks.com/help/matlab/visualize/coloring-mesh-and-surface-plots.html#f0-9250</a>.</p><p>I have a separate list of points on the sphere, which are in no particular format (i.e. not in meshgrid or ndgrid format). I need to know the color value at each point in this separate list. Does anyone know how to access the texture colors at any location?</p>Nathan/matlabcentral/answers/contributors/5042742-nathantag:www.mathworks.com,2005:Question/1598852014-10-24T02:01:57Z2014-10-25T03:52:41ZHow to predict next value using time series?<p>Hi, is there a way to use neural network toolbox to predict the next value in a time series?</p>WT/matlabcentral/answers/contributors/5646906-wttag:www.mathworks.com,2005:Question/1599852014-10-24T21:34:15Z2014-10-25T03:36:16ZIs Matlab R2014b license different from R2014a?<p>I get a license manager error -25 when I attempt to run R2014b after updating from R2014a. Is a different license file or LM configuration needed for R2014b?</p>Richard Young/matlabcentral/answers/contributors/58851-richard-youngtag:www.mathworks.com,2005:Question/1599912014-10-24T22:53:43Z2014-10-25T03:36:06ZGenerate a cell with 10 elements<p>Hello,</p><p>I have the following assignment:</p><p>1.3 Generate a cell with ten elements.
Each element is a vector of random
length (between 1 and 10) containing
ones if the length is odd and zeros
if the length is even.</p><p>For which I've been given the following solution:</p><pre> NumofVec = 10;
for 1 = 1:NumofVec;
Vlen = floor(rand*10)+1;
V{i} = ones (1, Vlen)*rem(Vlen,2);
end</pre><p>Could you please explain to me the meaning of the last two lines?</p><pre> Vlen = floor(rand*10)+1;
V{i} = ones (1, Vlen)*rem(Vlen,2);</pre><p>Thanks a lot!</p><p>Massive thanks to anyone attempting to help!!</p><p>Silvi</p>Silviya/matlabcentral/answers/contributors/5756340-silviyatag:www.mathworks.com,2005:Question/1589422014-10-17T00:45:58Z2014-10-25T03:24:04Zerror while using comm.QPSKModulator object<p>I am working on simulation a Tx-Rx system with BPSK and QBPSK. Input is a .wav file of a 3 musical notes for a duration of 6 minutes.</p><p>No problem getting it to work for BPSK (using pskmod function).</p><p>However, I am struggling with QBPSK using the comm.QPSKModulator object.</p><p>The error message I'm getting is not descriptive so it's not helpful. It simply says: "Error in transmitter (line 56) modData = step(hModulator, adjustedIndex);"</p><p>I suspect it is related to the coded signal format.</p><p>Attached are all files used (program is ran from main.m, comm.QPSKModulator is in transmitter.m file).</p><p>Any assistance will be greatly appreciated.</p>Franklin/matlabcentral/answers/contributors/5728087-franklintag:www.mathworks.com,2005:Question/1599552014-10-24T16:27:23Z2014-10-25T03:23:17Zi'm doing feature extraction using gabor filter<p>so please send a sample code to perform gabor based feature extraction?????????????????</p>guru/matlabcentral/answers/contributors/5500210-gurutag:www.mathworks.com,2005:Question/1600042014-10-25T02:33:10Z2014-10-25T02:40:33Zhow to design a gabor filter for feature extraction?/<p>hi friends, i'm doing feature extraction based on gabor filter... how to design that filter?/////// what are the parameters have to be considered in the design of filter.</p>guru/matlabcentral/answers/contributors/5500210-gurutag:www.mathworks.com,2005:Question/1599122014-10-24T09:31:16Z2014-10-25T02:30:37ZHow to get the intersection points of a line and a curve which was fit to data?<p>Hi,</p><p>I have a line and a curve that was fit to a data. I also get Coefficients of Equation of the Curve, but don't know how to find its equation to make two equations equal to find the points of the tangency. Could someone give me some recommends?</p><p>Here is my code:</p><pre class="language-matlab">clc
array=[515 525 561 600 632 700 761 800 900 1000 1014 1750;
0 150 300 394 450 540 600 631 696 745 750 865];
x=linspace(array(1,1),array(1,end),101)
y=interp1(array(1,:),array(2,:),x,'pchip')
x=transpose(x)
y=transpose(y)
%
f=fit(y,x,'pchip')
a=coeffvalues(f)
plot(f,y,x)
hold on
% Equation of line that pass through origin
x1=0:1000;
slope=tan(51.5*pi/180);
y1=slope*x1
plot(x1,y1)
</pre><img src = "/matlabcentral/answers/uploaded_files/19921/Untitled.png">Khanh/matlabcentral/answers/contributors/5599261-khanhtag:www.mathworks.com,2005:Question/1600032014-10-25T02:14:51Z2014-10-25T02:14:51ZWhy doesn't referenced model have proper tcl files?<p>I have a simulation that runs just fine without a referenced model. When I change one of the blocks to a referenced model, it passes all of the checks and builds the model just fine. But when I then run the simulation with the referenced model replacing the original block, I get the following error: (in response to command SimOut=sim(mdl))</p><p>Error reported by S-function 'PV_Inv_Ctrls0_msf' in 'AvgAndSW_141017/3PH
INV/TmpSFcnForModelReference_PV Inv Ctrls':
S-function discreteVariableTransportDelay does not have a tlc file. It cannot use macros that access
regDataType field in simstruct.</p>Jay/matlabcentral/answers/contributors/4577052-jaytag:www.mathworks.com,2005:Question/1600022014-10-25T02:06:39Z2014-10-25T02:06:39ZHow to solve situation showing picture below?<p>Actually my simmechanics stewart platform model works great and below you can se rotation around z-axis(yaw).
Just one problem is spherical joints turning and moving independently which is not effecting moving trajectory but demonstration is little bit disturbing for formal presentation.How can i solve this problem?</p><p>Thank you for any suggestion.</p><img src = "/matlabcentral/answers/uploaded_files/19956/dg4u7.gif">Enes/matlabcentral/answers/contributors/4087219-enestag:www.mathworks.com,2005:Question/1596002014-10-22T03:20:41Z2014-10-25T02:01:42ZHello, I'm trying to write the Gabor ternary pattern, Please help me with this!<p>Hello, I'm trying to write the GAbor ternary pattern:</p><img src = "/matlabcentral/answers/uploaded_files/19812/gaborternary.jpg"><p>The answer should be like below:</p><img src = "/matlabcentral/answers/uploaded_files/19813/answer.jpg"><p>Please tell me where did I wrong in code!</p><p>MATLAB Code:</p><pre class="language-matlab">clc
</pre><pre class="language-matlab">close all
</pre><pre class="language-matlab">clear all
</pre><pre class="language-matlab">[fn fp]=uigetfile('*.*');
</pre><pre class="language-matlab">I=(rgb2gray(imread([fp,fn])));
</pre><pre class="language-matlab">[m n]=size(I);
</pre><pre class="language-matlab">kv=pi/2;
</pre><pre class="language-matlab">GTP=zeros(m,n);
</pre><pre class="language-matlab">for x=1:m
</pre><pre> for y=1:n</pre><pre> for ii=0:3</pre><pre> phi=ii*pi/4;</pre><pre> z=[x y]';</pre><pre> k=kv*[cos(phi) sin(phi)]';</pre><pre> psi(x,y)=((norm(k))^2)*exp(-(((norm(k))^2)*((norm(z))^2))/2)*...</pre><pre> (exp(sqrt(-1)*k'*z)-exp(-1/2));</pre><pre> G(x,y)=imag(psi(x,y));</pre><pre> f(x,y)=conv(G(x,y),I(x,y));</pre><pre> if f(x,y)<-.03
pp=-1;
else pp=0;
end</pre><pre> GTP(x,y)=3^ii*(pp+2*(f(x,y)>.03))+GTP(x,y);
end
end
end</pre><pre class="language-matlab">figure,imshow(GTP)
</pre><p>Thanks for your considration</p>Mehran Kh/matlabcentral/answers/contributors/5767477-mehran-khtag:www.mathworks.com,2005:Question/1591452014-10-18T16:36:51Z2014-10-25T01:39:33ZLinprog - How define lb and ub as interval containing zero<p>I'm using the function linprog of the optimization toolbox. I have defined an interval by use of lb and ub: 0 <= x <= 90.</p><p>But actually I would like 'x' getting values between 15 <= x <= 90 AND containing zero. I don't want 'x' getting values between 0 and 15.</p><p>The reason is that there's a power station and it's not useful when the power station charges with power less than 15 MW. But it should be possible that the power station has power 0 MW when it's off (not charging).</p><p>The background is that I want to charge a power station while the electricity costs are cheap.</p><p>Is there any solution?</p>Lare/matlabcentral/answers/contributors/5788643-lare