http://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-05-30T16:32:14Ztag:www.mathworks.com,2005:Question/2214842015-05-30T10:12:15Z2015-05-30T16:32:14ZHow do i find values from a fitted curve Matlab Curve Fitting?<p>Hello,,
Okay , So I have values of R and t . And I know that I can plot them . However the function I have is R=R0 * e^(xt) . I know how to make the plot , but I want to have all the values of R0 and x . Any idea how can I get
these ?
Thank you .</p>Altin Guberihttp://www.mathworks.com/matlabcentral/profile/authors/4839371-altin-guberitag:www.mathworks.com,2005:Question/2215772015-05-30T14:19:53Z2015-05-30T16:29:10Zerror calculation perfect fit <p>Hi guys, so I have experimental data in column matrix y. And I want to use the equation below to find x as a function of y. This means have constant b adjusted from 0 to 2 and hence want to obtain the ideal b value.</p><p>I'm thinking of using a double for loop however would anyone know how to calculate for error and set a desirable tolerance. Or tips on how to solve for it effectively?</p><p>Thanks in advance.
The equation is:</p><p>y= (1-0.05*x^(b))/(1-0.03*x^b)^2</p> sarahhttp://www.mathworks.com/matlabcentral/profile/authors/6366130-sarahtag:www.mathworks.com,2005:Question/2215842015-05-30T15:32:29Z2015-05-30T16:26:40ZWhat is the difference between the Asynchronous Machines (Specialized Technology) and the Asynchronous Machines (fundamental) (Simscape Components)?<p>What is the difference between the Asynchronous Machines (Simscape -> SimPowerSystems -> Specialized Technology -> Machines) and the Asynchronous Machines (fundamental) (Simscape -> SimPowerSystems -> Simscape Components -> Machines)? There must be something. Because why should there be two different components built up with same equations and also doing the same. So I would love to know what's different.</p><p>P.s.: I would appreciated if the answer is in German :)</p>Daniel Klimsahttp://www.mathworks.com/matlabcentral/profile/authors/5248261-daniel-klimsatag:www.mathworks.com,2005:Question/2215742015-05-30T13:36:43Z2015-05-30T16:21:57ZSimpson's rule for integration- finding area and centroid, program does not work.<p>I have written a program for finding the area and centroid for a mathematical function, unfortunately it does not seem to work, and i am getting various errors.</p><p>Here is my code in full:
main-</p><pre> function main()
global a b h n temp
a=(-0.5);
b=0.5;
n=100;
h=(b-a)/n;</pre><pre class="language-matlab">[area, temp]= simpson(fun, fun2);
area=2*area;
Xc=(1/area)*temp;
disp(area)
disp(Xc)
end
</pre><p>Simpson's method, the action itself-</p><pre class="language-matlab">function [ area, temp] = simpson( fun, fun2 )
%Simpson's 1/3 integration method and calculating required values
global a b h
[se1, se2]=sumev(h);
[so1, so2]=sumod(h);
area= (h/3)*(fun(a)+fun(b)+(2*se1)+(4*so1));
temp= (h/3)*(fun2(a)+fun2(b)+(2*se2)+(4*so2));
</pre><pre class="language-matlab">end
</pre><p>summing even intervals-</p><pre class="language-matlab">function [ se1, se2] = sumev( h )
%Looping function for summing the values in even intervals for
%each function
global n
for j=0:2:n-2
v=(2*j+2)*h;
se1=se1+fun(v);
se2=se2+fun2(v);
end
</pre><p>summing odd intervals-</p><pre class="language-matlab">function [ so1, so2 ] = sumod( h )
%Looping function for summing the values in odd intervals for
%each function
global n
for j=0:2:n-1
v=(2*j+1)*h;
so1=so1+fun(v);
so2=so2+fun2(v);
</pre><pre class="language-matlab">end
</pre><p>The first function-</p><pre class="language-matlab">function [ q ] = fun(v)
%The mathematical function to integrate for the area
q=(2*(v^2)+0.2*v+0.08)*sqrt(1-4*(v^2));
</pre><pre class="language-matlab">end
</pre><p>Second function, used to find the centroid-</p><pre class="language-matlab">function [ e ] = fun2(v)
%The mathematical function to integrate for the area
e=v*(2*(v^2)+0.2*v+0.08)*sqrt(1-4*(v^2));
</pre><pre class="language-matlab">end
</pre><p>As far as i see, it's a very simple program, i don't see any missed letters or variable names, yet i'm getting these errors when i try to run main-</p><p>Error using fun (line 3)
Not enough input arguments.</p><p>Error in main (line 8)
[area, temp]= simpson(fun, fun2);</p><p>Any ideas and help debugging would be much appreciated</p>Rob Dunhamhttp://www.mathworks.com/matlabcentral/profile/authors/6530624-rob-dunhamtag:www.mathworks.com,2005:Question/2215852015-05-30T16:12:48Z2015-05-30T16:18:14ZHow to load the specific data to a new variable as per the required condition?<p>I have 4 data sets for example..</p><pre class="language-matlab">a=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
b=[ 1 2 3 4 5 6 7 8 9]
c=[11 12 13 14 15 16 17 18 19]
d=[21 22 23 24 25 26 27 28 29]
</pre><p>In this case how to load the data from the specific variable 'c' if 'a'>0.2 && <0.7.</p><p>In this example the result is e=[13 14 15 16]</p><p>Thanks</p>R7 DRhttp://www.mathworks.com/matlabcentral/profile/authors/6121957-r7-drtag:www.mathworks.com,2005:Question/2214672015-05-30T09:39:35Z2015-05-30T16:14:36ZHow to combine blocks of image into single image?<p>I have divided an image of size 256*256 into blocks of size 32*32 and changed the pixel values.Now I want to join this blocks with changed pixel value into one image.</p>Anushkahttp://www.mathworks.com/matlabcentral/profile/authors/6068164-anushkatag:www.mathworks.com,2005:Question/2211612015-05-29T21:01:20Z2015-05-30T16:13:13ZUse copyobj for specific properties -> subplot<p>Hello everyone,
at the moment I'm trying to create a callback function which copies the main properties of some of my GUIs axes to a subplot in a new window.
The problem is that I don't know how to select just some specific properties and leave out others.
My callback works fine with</p><pre class="language-matlab">plotdata= findall(handles.axes1);
plotdata=plotdata(2:end);
%or plotdata=get(Axeshandle,'children'); but this doesn't give me the labels for example
sp=subplot(2,2,[1,3]);
copyobj(plotdata,sp);
</pre><p>but in this case it also copies the locations of the labels so that they seem misplaced on my subplot.
The properties I'm interested in copying are:
-xlim
-ylim
-xtick
-ytick
-the plot(with colour)
-xlabel(with colour, font and size)
-ylabel (with colour, font and size)</p><p>The rest, like the position of the subplot, should remain as in the default subplot-settings.(so that labels do not cross each other)</p><p><b>Is there a way to get all properties mentioned above into a structure which I can copy with copyobj?</b></p><p><b>And a second questions relating to this is whether there is a command to clear the subplot before using copyobj.</b></p><p>At the moment the plots overwrite each other. (I tried "cla;" but this clears all the subplots and not a particular one. "clear subplot(2,2,[1,3]);" doesnt work either.) It works if I do it with the subplot handles and always delete the handle previously to the plotting but then I also have to check if the subplot handle exists, which gives me another ifloop and kind of seems too complex for such a simple task)</p><p>Thank you for your help! Klaus</p>klaus eberthttp://www.mathworks.com/matlabcentral/profile/authors/6430383-klaus-eberttag:www.mathworks.com,2005:Question/2215822015-05-30T15:20:18Z2015-05-30T15:58:44ZI don't understand what is the problem.....i tried it, but get an error. So plz help me to solve the problem... <p>Write a function called integerize that takes as its input a matrix A of non-negative integers of type double, and returns the name of the “smallest” unsigned integer class to which A can be accurately converted. If no such class exists, the string 'NONE' is returned. For example, if the largest integer A is 14, then the function would return 'uint8', but if the largest integer in A is 1e20, then the function would return 'NONE'.</p>Darshan Kanungohttp://www.mathworks.com/matlabcentral/profile/authors/6453515-darshan-kanungotag:www.mathworks.com,2005:Question/2184172015-05-24T13:22:01Z2015-05-30T15:31:23ZHow to remove some charterers from the set of values<p>Hi there</p><p>I am trying to remove</p><pre class="language-matlab">#00:GEOPAK-WIN Scanning
#02:Contour 1
#04:XY(Z)
#05:Opn
#06:MM
#07:0.00000
#12
</pre><p>I tried to read the file and removed lines but it is not working , any suggestion ?</p><p>Thanks a lot for your help in advance</p>James Marashihttp://www.mathworks.com/matlabcentral/profile/authors/6393498-james-marashitag:www.mathworks.com,2005:Question/2215832015-05-30T15:30:48Z2015-05-30T16:24:12ZCombination of two hourly price forward curves (HPFC) - find minimum subsums<p>Basic problem: I need to charge a battery and have access to two energy sources (market/own production). The goal is to use the cheapest schedule to recharge the battery.</p><ul><li>I have two price forward curves in hourly resolution (24 values per day for a full year)</li><li>I am only allowed to switch after 4+ consecutive hours</li><li>The hour directly after the switch is lost/blocked because of hardware issues.</li></ul><img src = "/matlabcentral/answers/uploaded_files/31762/switch.png"><p>I've tried to apply Kadane’s Algorithm / Maximum subarray problem in Java and searched for contiguous subarrays with the smallest sum (minimum subarray problem) but it didn't really work out. Maybe someone is familiar with this question/problem.</p><p>There was a similiar problem once asked already <a href = "https://jp.mathworks.com/matlabcentral/newsreader/view_thread/289046">12 consecutive numbers in an array of 48</a> but frankly I do not really get it due to beeing a newbie in Matlab.</p>xaer030http://www.mathworks.com/matlabcentral/profile/authors/6576099-xaer030tag:www.mathworks.com,2005:Question/2211692015-05-30T00:44:43Z2015-05-30T15:28:32ZHow Can I fix the width of Bins?<p>Hi Every body, I would like to tell you that I am beginner in Matlab. So please I need your help.</p><p>I want to fix the width of bins of the histogram, My code is:</p><pre> % cd F:\Script\Center_Marsh\Center_Marsh_1992</pre><pre class="language-matlab">H= Dec_1992(:);
hist(H);
subplot(1,2,1)
hist(H)
xlabel('NDVI','fontsize',14)
ylabel('AVHRR Pixels','fontsize',14)
set(gca,'XMinorTick','on')
set(gca,'YMinorTick','on')
set(gca,'XGrid','on')
set(gca,'YGrid','on')
set(gca,'GridLineStyle',':','linewidth',1)
set(gca,'TickDir','out')
set(gca,'TickLength',[.015 .025])
axis([0.0 0.5 0 110])
save('Dec_Hist_1992.fig');
D= Dec_1992(:);
[hi,cx]=hist(D);
subplot(1,2,2), plot(cx, hi,'k', 'LineWidth', 3)
xlabel('NDVI','fontsize',14)
ylabel('AVHRR Pixels','fontsize',14)
set(gca,'XMinorTick','on')
set(gca,'YMinorTick','on')
set(gca,'XGrid','on')
set(gca,'YGrid','on')
set(gca,'GridLineStyle',':','linewidth',1)
set(gca,'TickDir','out')
set(gca,'TickLength',[.015 .025])
axis([0.0 0.5 0 110])
save('Dec_Hist_1992.fig');
</pre><p>Thank you</p><p>Reyadh</p>reyadh Albarakathttp://www.mathworks.com/matlabcentral/profile/authors/6292760-reyadh-albarakattag:www.mathworks.com,2005:Question/2211432015-05-29T17:30:03Z2015-05-30T15:25:02ZHow to add an additional tick on y-axis for a combined boxplot and scatter plot?<p>Hello all,</p><p>I've got 15 horizontal boxplots that reach up until y=1.6 and a scatter plot on the same figure, where the scatter plot are some x values at y=2 only.</p><p>I can see the boxplot ticks on the y-axis up until y=1.6. However, I cannot see a ytick on the y-axis at y=2. How can I add that?</p><p><b>**************************</b></p><p>My code until now is:</p><pre class="language-matlab">Ypos = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.5 1.6];
group_fordata = [repmat(Ypos(1),[size(x1),1]);
repmat(Ypos(2),[size(x2)],1); repmat(Ypos(3),[size(x3)],1);
repmat(Ypos(4),[size(x4)],1); repmat(Ypos(5),[size(x5)],1);
repmat(Ypos(6),[size(x6)],1); repmat(Ypos(7),[size(x7)],1);
repmat(Ypos(8),[size(x8)],1); repmat(Ypos(9),[size(x9)],1);
repmat(Ypos(10),[size(x10)],1); repmat(Ypos(11),[size(x11)],1);
repmat(Ypos(12),[size(x12)],1); repmat(Ypos(13),[size(x13)],1);
repmat(Ypos(14),[size(x14)],1); repmat(Ypos(15),[size(x15)],1)];
data = [x1;x2;x3;x4;x5;x6;x7;x8;x9;x1;x11;x12;x13;x14;x15]
</pre><pre class="language-matlab">figure
boxplot(data, group_fordata,'positions', Ypos,'orientation','horizontal')
hold on
scatter([0.4 0.6],[2.0 2.0],'g.')
ylim([0 2.1])
</pre>Christinahttp://www.mathworks.com/matlabcentral/profile/authors/2037804-christinatag:www.mathworks.com,2005:Question/2215782015-05-30T14:41:00Z2015-05-30T15:16:59Zhelp me with this problem<p>??? Error using ==> fmincon at 399
FMINCON cannot continue because user supplied objective function failed with the following error:
Error using ==> mtimes
Inner matrix dimensions must agree.</p><p>Error in ==> optimization at 27
[x,fval] = fmincon(@objfun,x0,A,b,Aeq,beq,lb,ub,@nonlconstr,options);</p>Hafiz Saharhttp://www.mathworks.com/matlabcentral/profile/authors/6576081-hafiz-sahartag:www.mathworks.com,2005:Question/2214492015-05-30T08:59:11Z2015-05-30T15:12:38ZI have solved the question but there is an error.....so plz give me a solution<p>Write
a
function
called
neighbor
that
takes
as
input
a
row
vector
called
v
and
creates
another
row
vector
as
output
that
contains
the
absolute
values
of
the
differences
between
neighboring
elements
of
v.
For
example,
if
v == [1 2 4 7],
then
the
output
of
the
function
would
be
[1
2 3].
Notice
that
the
length
of
the
output
vector
is
one
less
than
that
of
the
input.
Check
that
the
input
v
is
indeed
a
vector
and
has
at
least
two
elements
and
return
an
empty
array
otherwise.
You
are
not
allowed
to
use
the
diff
built-‐in
function.</p><pre class="language-matlab">function d = neighbor(v)
</pre><pre class="language-matlab">for ii = 1:length(v)-1
</pre><pre> d(ii) = abs(v(ii+1) - v(ii));</pre><pre> end
end</pre><p>Feedback: Your function performed correctly for argument(s) [1 2 3 4]</p><pre> Feedback: Your function performed correctly for argument(s) [2 1]</pre><pre> Feedback: Your function performed correctly for argument(s) [1 -2 3]</pre><pre> Feedback: Your function performed correctly for argument(s) [5 -3 6 -7 1 4 -4 6 -5 -1]</pre><pre> Feedback: Your function performed correctly for argument(s) [0.775665774190202 0.46043860784642 0.637754980094595 0.21592913366455 0.0321676971373623 0.777337876450925 0.979770397784413 0.221076297004035 0.063923583412422 0.129378479212439]</pre><pre> Feedback: Your function made an error for argument(s) [1 2;3 4]</pre><pre> Your solution is _not_ correct.</pre>Darshan Kanungohttp://www.mathworks.com/matlabcentral/profile/authors/6453515-darshan-kanungotag:www.mathworks.com,2005:Question/2215812015-05-30T15:12:05Z2015-05-30T15:12:05ZQuestion about Transformaion Method or Reject from pdf and cdf<p>I don't know well about using matlab. I have a question about solving cdf form pdf (how about intergral) and Generate 10,000 samples of using the transformation method or the rejection method. picture is pdf that i draw graph what making unit step function and plot (n,fn). give me a hint. Plz</p><p><<</p><img src = "/matlabcentral/answers/uploaded_files/31761/%EC%A0%9C%EB%AA%A9%20%EC%97%86%EC%9D%8C.png"><p>>></p>Min Wook Choihttp://www.mathworks.com/matlabcentral/profile/authors/6576112-min-wook-choitag:www.mathworks.com,2005:Question/2215762015-05-30T13:52:33Z2015-05-30T15:10:58ZGit and MAT files<p>Hi,</p><p>I'm using Git to manage a large number of small MAT files. To minimize the possibility of data loss, I always save all objects, even though most of them will not have changed. However since Git recognizes that the file has changed (due to the 'Platform/Created on' tag), a long list of changed files is presented when selecting them to be staged.</p><p>What possibilities exist to change Git's behaviour in such a way that it only shows the files as modified that have changes in their data?</p><p>Kind regards,
Moritz</p>Moritz Ulmerhttp://www.mathworks.com/matlabcentral/profile/authors/5091881-moritz-ulmertag:www.mathworks.com,2005:Question/2209702015-05-29T13:14:16Z2015-05-30T15:10:31ZI have a matrix with 360 columns. I want a 3D plot in which at every 1 degree one column is be ploted with diferent color. Can anyone suggest how to proceed? Let me know if you need further explaination about my problem?<p>Let me know if you need further explaination about my problem?</p>Sanjeev Kumar Singhhttp://www.mathworks.com/matlabcentral/profile/authors/5521557-sanjeev-kumar-singhtag:www.mathworks.com,2005:Question/2215792015-05-30T14:51:55Z2015-05-30T15:10:08ZWhat if I would like to force no bias term in multiclass logistic regression?<p>What if I would like to force no bias term in multiclass logistic regression? In this case, I cannot use the standard mnrfit function?</p>Mr M.http://www.mathworks.com/matlabcentral/profile/authors/4980938-mr-mtag:www.mathworks.com,2005:Question/2211632015-05-29T21:51:52Z2015-05-30T15:06:03Zhow can use static feedforward neural network to predict futre observation<p>As newff the appropriate choice or we must use others functions like feedforwardnet???</p>coquihttp://www.mathworks.com/matlabcentral/profile/authors/5461334-coquitag:www.mathworks.com,2005:Question/2181772015-05-22T17:36:04Z2015-05-30T14:58:38ZOverlap a surf() over an image() with different colormap<p>Hi!</p><p>I have to different objects, one is an image, the other is a surface wit x,y,z,and c components.</p><p>When I do surf() by itself i get a nice colormap from red to blue (the jet one), but when i do</p><pre class="language-matlab">% Image data
</pre><pre class="language-matlab">im1 = imagesc(pic); hold on
</pre><pre class="language-matlab">% Strain data
</pre><pre class="language-matlab">x1 = pic_data{1}{1};
</pre><pre class="language-matlab">y1 = pic_data{1}{2};
</pre><pre class="language-matlab">z1 = zeros(size(x1,1),size(x1,2));
</pre><pre class="language-matlab">c1 = strain_data{1}{variable};
</pre><pre class="language-matlab">s1 = surf(x1,y1,z1,c1,'FaceAlpha',0.5);
</pre><p>I can't observe the changes in the s1 surface colormap.</p><p>Any ideas?</p>Ricardo Ferreirahttp://www.mathworks.com/matlabcentral/profile/authors/4424527-ricardo-ferreiratag:www.mathworks.com,2005:Question/2214662015-05-30T09:25:18Z2015-05-30T14:54:04Zhow to trace ordered external counter of an object<p>Hello,I need to order point on boundary.I have a logical image so I use bwtraceboundary, but the results is a Bb matrix empty.Can someone help me to understand the reason?I wrote this code:</p><pre class="language-matlab">[filename,pathname]=uigetfile('*.jpg');
im=imread([pathname filename]);
figure,imshow(im,[])
T=graythresh(im);
It=im2bw(im,T);
figure, imshow(It,[])
Bb=bwtraceboundary(It,[12 33],'E',8,Inf,'clockwise')
</pre><p>where r=12 e c=33 is the first pixel of the boundary that I want to order. I attach also the image.
Thank you</p>Silvia Carusohttp://www.mathworks.com/matlabcentral/profile/authors/6379480-silvia-carusotag:www.mathworks.com,2005:Question/2209592015-05-29T12:06:34Z2015-05-30T14:49:40Zfitting data with equation<p>Hi guys, so I have alot of experimental data in column matrix y. And I want to use the equation below to find the best fit for my data y. This means have constant b adjusted with x varying, I know that x typically ranges from 1 to 5 with y and b ranges from 0 to 2.</p><p>I'm thinking of using a double loop. Would anyone give me tips on how to solve for it effectively? Thanks in advance. The equation is:</p><p>y= (1-0.05*x^(b))/(1-0.05*x^b)^2</p> sarahhttp://www.mathworks.com/matlabcentral/profile/authors/6366130-sarahtag:www.mathworks.com,2005:Question/2211592015-05-29T20:55:14Z2015-05-30T14:46:43ZHow to control lines in the legend?<p>In the legend there is small line element, but it is very ugly sometimes in case of dashed line. How to control its length?</p>Mr M.http://www.mathworks.com/matlabcentral/profile/authors/4980938-mr-mtag:www.mathworks.com,2005:Question/2214752015-05-30T10:04:46Z2015-05-30T14:44:24ZWriting headings AND data with the xlswrite function<p>I have a cell array named NomiDopo containing the names of the columns of my Excel output file and the data (of double) stored in matrix DataSet.
If I write</p><p>A = {NomiDopo; DataSet};
xlswrite('Guida_1_dopo.xlsx', A);</p><p>then the output file does not contain anything.
How can I write both the name of the columns and the data in the output file at the same time?
Thank you!</p>Mauro Baldihttp://www.mathworks.com/matlabcentral/profile/authors/5332658-mauro-balditag:www.mathworks.com,2005:Question/2209282015-05-29T10:45:05Z2015-05-30T14:28:40ZHow to use parfor in nested for loop?<p>Hi,
I have a nested for loop and I want to use parfor for the same, but the problem is that in my code the variable of first loop has not been used everywhere in the nested loop.
And due to which it is showing error.
Kindly help me out.</p><p>Thanks
Suraj</p>Suraj Srivastavahttp://www.mathworks.com/matlabcentral/profile/authors/3618019-suraj-srivastavatag:www.mathworks.com,2005:Question/2204572015-05-28T19:04:28Z2015-05-30T14:02:40ZHow can I specify publish and subscribe rate for ros topics using Simulink?<p>I have 2 robots exchanging position data. I am using ROS and SIMULINK subscriber and publisher blocks for each robot to receive and send position information, The subscriber keeps reading the same position over data and over again. How can I gt the publish and subscribe rates perfectly synced.</p>sirisha kallakurihttp://www.mathworks.com/matlabcentral/profile/authors/4881774-sirisha-kallakuritag:www.mathworks.com,2005:Question/2211772015-05-30T03:20:30Z2015-05-30T13:51:00ZHow can I extract relevant data from a text file using specific strings to identify relevant blocks of data?<p>I am attempting to extract data in the form of mean estimates and complementary cumulative distribution functions (CCDFs) for specific variables. The data reside in text files generated as output from a simulation code.</p><p>Each output text file contains several thousand records, many of which are not of interest. I need to be able to:</p><p>1. Search through the text file to identify specific records based on record type. Each record begins with a line that has the string 'BOR'. The second line specifies the record type (e.g., '0006 STAT_RESULTS' or '0007 CCDF_RESULTS' - which are the only record types I care about for my analysis).</p><p>2. Within the two record types of interest:</p><p>(1) Identify specific combinations of variables and associated qualifiers. The third line in the record specifies the variable using a tab-delimited string comprised of two elements/columns using the following form: '12 :Health Effect Cases'. The fourth through nth lines in the record identify qualifiers (e.g., boundaries of spatial intervals, values of other variables on which the variable depends) associated with the variable specified in the third line using a tab-delimited string comprised of three elements/columns using the following form: '2 "0.000000E+00" :QualifierDesc "Ldistance (mi)" QualifierValue;' - where the first element/column (integer) represents the qualifier ID, the second element/column (value in quotes) represents the qualifier value, and the string in double quotes in the third element/column represents the qualifier description. As a clarifying example, I might be interested in identifying the health effect cases predicted to occur in the spatial interval between 0 and 10 miles from a facility.</p><p>(2) Extract the relevant numeric results to MATLAB objects for subsequent manipulation and visualization. For example, the mean values I am interested in extracting can be found exactly 3 lines below the nth line that includes information about the last qualifier in the '0006 STAT_RESULTS' record type; the line is a tab-delimited string comprised of two elements/columns using the following form: '0 :Mean'. Likewise, the CCDF data can be found exactly 1 through 46 lines below the nth line that includes information about the last qualifier in the '0007 CCDF_RESULTS" record type: each of the 46 lines is a tab-delimited string comprised of three elements/columns using the following form: '1.00E-09 0.94579676 :X(1,1)X(1,2)' - where the first two elements represent one x,y pair of the CCDF.</p><p>Any help on how to perform these tasks would be much appreciated</p>Dan Hudsonhttp://www.mathworks.com/matlabcentral/profile/authors/4209509-dan-hudsontag:www.mathworks.com,2005:Question/2215752015-05-30T13:42:57Z2015-05-30T13:42:57ZPlot a Time Serie of the price of a share<p>I have to make the graph of a time series of prices of a share. The line should be red when the price goes below the average of the price, black when it goes above average. how can I do? thanks</p>Samuele Rossihttp://www.mathworks.com/matlabcentral/profile/authors/6264587-samuele-rossitag:www.mathworks.com,2005:Question/2211702015-05-30T00:58:56Z2015-05-30T13:31:41Z Compare pairs of elements in an array<p>I need to compare pairs of elements of a matrix (by row), but also some operations once compared. For example, I have the following matrix.</p><pre class="language-matlab">A=[300 105 110 100;
100 140 300 105];
10 140 300 200];
10 25 300 310];
</pre><p>I need to compare values within a row and see which are close to each other, if the values are within a range of +/- 20 between them, I keep them, if not that is filled with NaN. For example the first row got to the last three are in the range and the first not, then my new row is</p><pre class="language-matlab">B(1)=[NaN 105 110 100];
</pre><p>and the second one:</p><pre class="language-matlab">B(2)=[100 NaN Nan 105];
</pre><p>In case none other approaches, simply fill with NaN the row. As is the case of the third row.</p><pre class="language-matlab">B(3)=[NaN NaN Nan NaN];
</pre><p>The last case is that if I have two cores (two pairs close and the other two pairs close but not the first) and row 4, fill with NaN.</p><pre class="language-matlab">B(4)=[NaN NaN Nan NaN];
</pre><p>I hope you can help me, I have not been able to solve completely. I also hope I explained well.</p><p>Greetings and thank you in advance.</p><p>Francisco</p>Franciscohttp://www.mathworks.com/matlabcentral/profile/authors/2816695-franciscotag:www.mathworks.com,2005:Question/2200952015-05-28T11:03:30Z2015-05-30T13:31:29ZUsing csaps (or similar) to create a 3D smoothing spline<p>I have a series of 3D points and am looking to create any sort of smoothing spline, I was hoping to use scaps, but it only seems to take in 2D data, can anyone help with this? Is there for instance a way to input 3D data into it or another function I could use?</p>Laurence hutton-smithhttp://www.mathworks.com/matlabcentral/profile/authors/2590267-laurence-hutton-smithtag:www.mathworks.com,2005:Question/2213182015-05-30T06:26:39Z2015-05-30T13:09:48ZHow can I do Albanian flag using image processing toolbox ?<p>Hello,
I have basic knowledge on using Matlab Image Processing Toolbox , but I am not quite good at it yet . I can only basically manipulate colours , but I am not skilled enough at creating shapes or forms . I wanted to know if there is any anyone who can help me create a code from Matlab Image Processing Toolbox for Albanian Flag.
Thank you & Have a nice day.</p>Altin Guberihttp://www.mathworks.com/matlabcentral/profile/authors/4839371-altin-guberitag:www.mathworks.com,2005:Question/2215732015-05-30T12:44:19Z2015-05-30T13:01:05Zhow to work on fMRI data in matlab<p>to use matlab for fmri data which toolbox is needed. i am new to matlab. don't have any specific knowledge so need help.</p>ramandeep kaurhttp://www.mathworks.com/matlabcentral/profile/authors/6573833-ramandeep-kaurtag:www.mathworks.com,2005:Question/2211742015-05-30T02:50:32Z2015-05-30T12:57:49ZNeed help with a nested for loop<p>I have</p><p>L = 28x1 vector</p><p>D = 28x1 vector</p><p>My equation is: V = L*((pi*((D+0.064).^2)/4)-(pi*D.^2)/4)</p><p>I have tried</p><pre class="language-matlab">for n = 1:length(D1)
for m = 1:length(L1)
TankVol(n,m) = L1(m,:)*((pi*((D1(n,:)+0.064).^2)/4)-(pi*D1(n,:).^2)/4);
end
end
</pre><p>But it's not giving what I need</p><p>It's going through the loop too many times if that makes sense, I basically need a V value for each value in L and D.</p>Joel Coburnhttp://www.mathworks.com/matlabcentral/profile/authors/6515692-joel-coburntag:www.mathworks.com,2005:Question/2209092015-05-29T10:07:15Z2015-05-30T12:56:48Zhow to find sum of square sine wave<p>Hi every one;
I want to solve that question.Any assistance will be highly appreciable...
function
called
s_wave
that
computes
the
sum for
each
of
1001
values
of
t
uniformly
spaced
from
0
to
4π
inclusive.
The
input
argument
is
a
positive
scalar
integer
n,
and
the
output
argument
is
a
row
vector
of
1001
such
sums—one
sum
for
each
value
of
t.
You
can
test
your
function
by
calling
it
with
n
==
200
or
greater
and
plotting
the
result,
and
you
will
see
why
the
function
is
called
“s_wave”.</p><img src = "/matlabcentral/answers/uploaded_files/31730/s.jpg"><p>Again any assistance will be highly appreciable................</p>Muhammad Usman Saleemhttp://www.mathworks.com/matlabcentral/profile/authors/6394611-muhammad-usman-saleemtag:www.mathworks.com,2005:Question/2209692015-05-29T13:07:53Z2015-05-30T12:44:28Zbin2gray function's input is decimal.<p>if dec2bin converts decimal to binary.
and hex2dec converts hexadecimal to decimal.
then how come bin2gray converts DECIMAL to gray?</p>Eladhttp://www.mathworks.com/matlabcentral/profile/authors/5954393-eladtag:www.mathworks.com,2005:Question/2215662015-05-30T12:22:31Z2015-05-30T12:22:31Zlinear discriminant analysis: how to generate a simulation example with an outcome variable of 3 groups<p>Dear Community,
I've been trying to simulate data to use for a linear discriminant classification later.
below, you find the code for simulated data with the dependent variable "G" that has 2 classes (0 and 1). The N observations are assigned to G using the Sigmoid function.
Now, I would like to generate an example where the dependent variable "G" has 3 groups.
Could anyone help me how to proceed? Can I do it with the Sigmoid function as well?</p><p>Many thanks!!</p><pre class="language-matlab">N=3000;
C=20;
</pre><pre class="language-matlab">x=randn(N,C);
</pre><pre class="language-matlab">beta=zeros(C,1);
param_true = [1 3 5 7 9];
</pre><pre class="language-matlab">beta(param_true)=[+10 -10 +5 -1 +1];
z=x*beta;
</pre><pre class="language-matlab">L=1./(1+exp(-z));
G=rand(N,1)<L;
</pre>paaschttp://www.mathworks.com/matlabcentral/profile/authors/6210057-paasctag:www.mathworks.com,2005:Question/2215502015-05-30T10:58:35Z2015-05-30T11:38:49ZHelp with coverting matlab GUI to exe<p>I am using matlab 2014a trial version, I developed matlab gui. I want to convert it to exe file, which i will be able to open when my trial will be over. I serached up the web and found out that I have to use the matlab compiler in order to convert it. I installed the Compiler,MCR_R2014a_win64_installer.exe , in my computer succesfully but Matlab won't recognize the commands as deploytool, or mcr.Therefore now I can't convert it to exe. Any idea how can I fix the problem? Thank you</p>Guy Benhemohttp://www.mathworks.com/matlabcentral/profile/authors/5632649-guy-benhemotag:www.mathworks.com,2005:Question/2215612015-05-30T11:36:24Z2015-05-30T11:36:24Zafter installation of matlab i found an error license manager error.. i need to fix it<img src = "/matlabcentral/answers/uploaded_files/31750/Untitled.png">deepa BChttp://www.mathworks.com/matlabcentral/profile/authors/6535873-deepa-bctag:www.mathworks.com,2005:Question/2203192015-05-28T13:48:23Z2015-05-30T11:32:05ZFindout the peaks in each row of matrix with specific conditions<p>i would lime to find out the no of peaks in each row with a specific condtion (that is )
peakvalues with (peakvalue-minvalueof each row>1000)</p><p>Now i take a single row for easiness.In reality i have a big matrix.</p><p>A= [1000 8000 1000 1800 1200 4000 4800 4000 1000 1000]</p><p>the min-value of A=1000
The peak values of A= [8000 1800 5000],
But the problem here is if i use ordinary threshold limit& findpeak</p><pre class="language-matlab">findpeaks(A,'Threshold',1000)
it will only compare with the values near to it.
</pre><p>I want to find out the total number of peaks which obey my condition (i.e>1000) in detailed way</p><p>8000-1000 >1000 (true)
1800-1000<1000(false)
5000-1000>1000(True)</p><p>so the aswer i expect
peakswithcondition=2</p>navanhttp://www.mathworks.com/matlabcentral/profile/authors/6167894-navantag:www.mathworks.com,2005:Question/2214902015-05-30T10:17:47Z2015-05-30T10:25:59ZHow can i change the colours at the above code ?<p>Here at this code :</p><pre class="language-matlab">step = 0.05;
[X Y Z] = meshgrid(-3:step:3, -3:step:3, -3:step:3);
F=((-(X.^2).*(Z.^3)-(9/80).*(Y.^2).*(Z.^3))+((X.^2)+(9/4).*(Y.^2)+(Z.^2)-1).^3);
p = patch(isosurface(X,Y,Z,F,0));
set(p,'facecolor','w','EdgeColor','b');
daspect([1 1 1]), view(3), axis tight, axis equal
</pre><p>How to make this pink or red?</p>Altin Guberihttp://www.mathworks.com/matlabcentral/profile/authors/4839371-altin-guberitag:www.mathworks.com,2005:Question/2214562015-05-30T09:04:38Z2015-05-30T10:17:04Zplz give me a solution<p>Write
a
function
called
large_elements
that
takes
as
input
an
array
named X
that
is
a
matrix
or
a
vector.
The
function
identifies
those
elements
of
X
that
are
greater
than
the
sum
of
their
two
indexes.
For
example,
if
the
element
X(2,3)
is
6,
then
that
element
would
be
identified
because
6
is
greater
than
2
+
3.
The
output
of
the
function
gives
the
indexes
of
such
elements
found
in
row-‐
major
order.
It
is
a
matrix
with
exactly
two
columns.
The
first
column
contains
the
row
indexes,
while
the
second
column
contains
the
corresponding
column
indexes.
For
example,
the
statement
indexes = large_elements([1 4; 5 2; 6 0],
will
make
indexes
equal
to
[1 2;
2 1; 3 1].
If
no
such
element
exists,
the
function
returns
an
empty
array.</p><pre class="language-matlab">function found = large_elements(A)
[row col] = size(A);
found = [];
for ii = 1:row
for jj = 1:col
if A(ii,jj) > ii + jj
found = [found; ii jj];
else found = [];
end
end
end
end
</pre><p>Problem 4 (large_elements):
Feedback: Your function performed correctly for argument(s) 1</p><pre> Feedback: Your function performed correctly for argument(s) [1 2 3 4 5 6 7 8 9 10]</pre><pre> Feedback: Your function made an error for argument(s) [10 9 8 7 6 5 4 3 2 1]</pre><pre> Your solution is _not_ correct.</pre>Darshan Kanungohttp://www.mathworks.com/matlabcentral/profile/authors/6453515-darshan-kanungotag:www.mathworks.com,2005:Question/2213162015-05-30T06:14:18Z2015-05-30T10:14:13ZHow can I find these values using polyfit command?<p>Alright , so i have the values of t time respectively first colum and R radioactive decay which corresponds to second colum (look below ) . The formula of radioactive decay is R=R0 * e^(-λt). Now I wanted to know if there is any way to find the values of R0 and λ for each case by using command polyfit ?</p><p>Does anybody have an idea how can I do this?</p><p>Thank you & Have a great day.</p><pre class="language-matlab">Values : 10 312
11 328
12 311
13 290
14 283
15 285
16 255
17 291
18 271
19 272
20 253
21 255
22 263
23 246
24 264
25 213
26 261
27 241
28 228
29 242
30 215
31 192
32 206
33 182
34 188
35 197
36 195
37 180
38 210
39 176
40 183
41 199
42 159
43 171
44 166
45 145
46 181
47 177
48 137
49 149
50 185
51 148
52 149
53 142
54 150
55 140
56 149
57 123
58 112
59 118
60 145
61 146
62 118
63 113
64 120
65 126
66 120
67 125
68 114
69 114
70 117
71 103
72 102
73 96
74 97
75 102
76 117
77 114
78 88
79 94
80 101
81 93
82 113
83 74
84 78
85 81
86 102
87 94
88 93
89 81
90 64
91 88
92 81
93 96
94 72
95 82
96 81
97 71
98 71
</pre>Altin Guberihttp://www.mathworks.com/matlabcentral/profile/authors/4839371-altin-guberitag:www.mathworks.com,2005:Question/2214762015-05-30T10:04:52Z2015-05-30T10:12:38ZQuestion about LVQ training accuracy<p>Hello, I need help in answering this question. But first of all, sorry if my language is confusing, english is not my first language.</p><p>So I made a system that used LVQ as the method. The input for the system is an x-ray image, and the system will give diagnosis whether the patient's heart has an anomaly or not. I use 32 images as training data, and 45 images as testing data. The training accuracy is 87,5%, and the testing accuracy is 97,8%.</p><p>My question is, why is the training accuracy not 100%? While theoretically it should be, shouldn't it?.</p><p>I used 32 samples to do the training. Since the output of the system will be either YES (the patient's heart is abnormal) or NO (the heart is normal), so the there are two target classes, class 1 for normal and class 2 for abnormal. Each of those 32 samples are put into either class 1 or class 2. The system searches for the minimum distance between each of 32 samples and the initial weight based on the initial target classes. And it keeps processing the weight, until finally there is a final weight (w) which will be used in the testing phase.</p><p>What I don't understand is, because the final weight is produced from the training process using those 32 samples, so when I use the final weight to test each of those 32 samples, each of those images should have been put into the initialized target class (has 100% training accuracy). But when I used the final weight to test those 32 samples, only 28 gave the right answers. the other 4 images were put into classes which were different from the target classes. Why? I have looked up into several papers that use LVQ too as their method, and none of them has 100% training accuracy. But none explains why. I have also checked my code and I am quite sure there is nothing wrong with it. Can anyone help me answer this, please? Thank you</p>Haidarhttp://www.mathworks.com/matlabcentral/profile/authors/6252560-haidartag:www.mathworks.com,2005:Question/2214652015-05-30T09:18:42Z2015-05-30T10:03:34Zhow get this shape from series of pictures? <img src = "/matlabcentral/answers/uploaded_files/31746/5.png"><p>it doesnt have a same size in all slice and doent have a spesific color yet!</p><img src = "/matlabcentral/answers/uploaded_files/31747/5.png">tahoorasfhttp://www.mathworks.com/matlabcentral/profile/authors/3603699-tahoorasftag:www.mathworks.com,2005:Question/2214642015-05-30T09:15:22Z2015-05-30T10:02:02ZAre you convert matlab code to visual basic code form for me, please?<pre class="language-matlab">clc
clear
A=input( 'how many fixed suport?')
B=input( 'how many pinned support or roller supoport? ')
C=input( 'how many link support or elastic support? ')
for i=1:C
d=input( 'if link support is right enter(1)else enter(2)')
D(i)=d
end
E=input( 'how many are there discontinuity in member?')
R=2*A+B
for i=1:C
if D(i)==1
R=R+2
else
R=R+1
end
end
n=R-(2+E)
disp 'n';disp (n)
if n==0
disp 'structure is assignable'
end
if n>0
disp 'structure is unlimited'
end
if n<0
disp 'structure is unlimited and astatic'
end
</pre>saleh zareihttp://www.mathworks.com/matlabcentral/profile/authors/6575503-saleh-zareitag:www.mathworks.com,2005:Question/2204412015-05-28T17:35:00Z2015-05-30T09:45:32Zhow to share node table with neighbours node<p>hello friends i have multiple nodes on 2d graph and my question is how the nodes are share the table with neighbor node like AODV routing protocol.</p>singhhttp://www.mathworks.com/matlabcentral/profile/authors/6334127-singhtag:www.mathworks.com,2005:Question/2209262015-05-29T10:42:07Z2015-05-30T09:29:33ZHow to find quantize, flooring and mod 2 of an image<p>I have decomposed/ generated the coefficient matrices of the level-one approximation (LL) and horizontal (LH), vertical (HL) and diagonal features (HH) of an image with the following code line:</p><pre> figure
subplot (2,2,1);
imshow(LL,[]);
title('LL subband-Approximation');</pre><p>and similarly for LH, HL, HH band.</p><p>Now my problem is:</p><p>(i) separate LL out and quantify it to [0,255].
(ii) Then implement following term:</p><p>LL'(subscript i,j)= floor[LL (subscript i,j)/2^k] mod 2</p><p>where 0<=K<=7 and subscript i,j are 128*128.</p><p>How can this be implemented in MatLab. Please provide me the code.</p>Beginner inhttp://www.mathworks.com/matlabcentral/profile/authors/6460970-beginner-intag:www.mathworks.com,2005:Question/2209272015-05-29T10:44:28Z2015-05-30T09:26:06ZWhen you create an executable with the Matlab Compiler, are there any ITAR issues sending the Matlab SDK to international customers?<p>I would like to consider using the Matlab compiler to generate executables that can be installed on customer machines. Some of the customers we deal with are international and I need to understand if there is any ITAR issue with adding the SDK with the compiled code. Thanks!</p>Peter Vanderhamhttp://www.mathworks.com/matlabcentral/profile/authors/1282557-peter-vanderhamtag:www.mathworks.com,2005:Question/2214612015-05-30T09:10:15Z2015-05-30T09:12:18Zanyone has idea to create data to load into ANFIS editor??<p>I have written the rules into the ANFIS but getting error in loading the data.. so I think that there is a mistake in creating the data to be loaded....how will be the data created???</p><p>Thanks in advance....</p>sabitha royalhttp://www.mathworks.com/matlabcentral/profile/authors/6575482-sabitha-royal