https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-03-05T06:51:16Ztag:www.mathworks.com,2005:Question/1810952015-03-02T15:56:59Z2015-03-05T06:51:16ZExport model configuration parameters.<p>Hello! How to export all model configuration parameters and import it to other model? Thanks for answers.</p>vvd03https://www.mathworks.com/matlabcentral/profile/authors/5918589-vvd03tag:www.mathworks.com,2005:Question/1814602015-03-04T07:27:10Z2015-03-05T06:45:05Zhow to convert an image in to binary bits sequence ??????<pre> a=imread('cameramen.jpg');
b= round(a./256);
but i got binary bits like this
1 0 1 0 0 1 0 0 0 0
0 0 0 1 0 1 0 1 0 0
.
.
. </pre><pre> 1 0 0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1 0 0
.
.</pre><pre> 1 0 1 0 1 0
0 0 0 0 0 0 </pre><pre class="language-matlab">but what i want is: b = (1 0 1 0 1 0 0 0 .....n)
</pre>Anamika jainhttps://www.mathworks.com/matlabcentral/profile/authors/6050319-anamika-jaintag:www.mathworks.com,2005:Question/1816162015-03-05T06:36:43Z2015-03-05T06:36:43ZIs it possible to do fruit classification using neural based on shape,size feature extraction and using xilinx system generator blocks<p>Is it possible to do fruit classification using neural based on shape,size feature extraction and using xilinx system generator blocks so that I can dump that into a FPGA</p>shalini chttps://www.mathworks.com/matlabcentral/profile/authors/6233013-shalini-ctag:www.mathworks.com,2005:Question/1815852015-03-04T21:14:39Z2015-03-05T06:29:16Zneural network model meaning???<p>Sir,I have one small query kindly help me with this.. if i am asked to make a neural network model..then what am i suppose to do...should i make a neural network code and then put the input values and train it or i should just take the use of the toolboxes and the input values and train it directly</p>VIKRAMhttps://www.mathworks.com/matlabcentral/profile/authors/5956666-vikramtag:www.mathworks.com,2005:Question/1816002015-03-05T01:48:59Z2015-03-05T06:21:49Zwhere can I upload my model which I have created<p>where can I upload my model which I have created</p>shalini chttps://www.mathworks.com/matlabcentral/profile/authors/6233013-shalini-ctag:www.mathworks.com,2005:Question/375092012-05-05T13:18:16Z2015-03-05T06:18:44ZHelp needed: Fingerprint Verification system<p>I am using this code to use in my project. Fingerprint Verification <a href="http://www.comp.hkbu.edu.hk/~vincent/resTool.htm">http://www.comp.hkbu.edu.hk/~vincent/resTool.htm</a></p><p>But I have to modify it as I don;t have to use the user interface in my system. I have just to extract Minutiae by executing single .m file. I have tried to sum up it in one file but the Minutiae extraction file of this project makes the problem as I am unable to pass it the desired argument.</p><pre class="language-matlab">[end_list1,branch_list1,ridgeMap1,edgeWidth]=mark_minutia(o1,o1Bound,o1Area,w);
//oBound1 and o1Area are undeclared as it is getting it from the interface but I don’t have to use any interface.My effort code is
%main file
image1=readimage('101_1.tif');
figure,imshow(image1),title('Original image');
%image1=loadimage;
direction(image1,16);
%drawROI(image1,o1Bound,o1Area);
image1=histeq(uint8(image1));
figure,imshow(image1,[]),title('histogram');
image1=adaptiveThres(double(image1),32);
figure,imshow(image1,[]),title('adaptive thershold');
W=str2double(char(0.45));
image1=fftenhance(image1,W);
figure,imshow(image1,[]),title('fftehancement');
%[end_list1,branch_list1,ridgeMap1,edgeWidth]=mark_minutia(o1,o1Bound,o1Area,w);
%show_minutia(o1,end_list1,branch_list1);
%[pathMap1,real_end1,real_branch1]=remove_spurious_Minutia(o1,end_list1,branch_list1,o1Area,ridgeMap1,edgeWidth);
%show_minutia(o1,real_end1,real_branch1);
%W=inputdlg('file name');
%W=char(W);
%save(W,'real_end1','pathMap1','-ASCII');
</pre><p>And this code is the replacement of file start_gui_interface.m of this project</p>Shizahttps://www.mathworks.com/matlabcentral/profile/authors/3456332-shizatag:www.mathworks.com,2005:Question/1816152015-03-05T06:17:49Z2015-03-05T06:17:49ZGetting error in audioplayer/Initialize..<p>Hi</p><p>I am using matlab2013b. in my application i used 'audioplayer' to play a sound from a data which is available with me. when i try to run the code i am getting an error</p><p>error using audioplayer/initialize
Too many input arguements
error in audioplayer
Object.Initialize</p><p>how to resolve this please give me suggestion or sollution
Thanks in advance</p>Dumpalahttps://www.mathworks.com/matlabcentral/profile/authors/2958743-dumpalatag:www.mathworks.com,2005:Question/1816132015-03-05T05:58:27Z2015-03-05T06:10:59ZHow can I count the number of elements of a given value in a matrix?<p>I have a matrix such as.</p><p>44.147231 ; 24.358619</p><p>44.461415 ; 24.118248</p><p>44.258173 ; 23.185014</p><p>43.166729 ; 24.100443</p><p>43.159002 ; 26.708013</p><p>42.954059 ; 27.338612</p><p>44.139759 ; 23.927882</p><p>44.424679 ; 25.301393</p><p>42.957588 ; 25.530434</p><p>44.615223 ; 24.200719</p><p>44.384409 ; 25.486735</p><p>43.965701 ; 28.454219</p><p>43.400971 ; 21.492123</p><p>42.068687 ; 22.303336</p><p>43.245372 ; 28.932286</p><p>44.593751 ; 23.635179</p><p>The first column is longitude , the second column is latitude.</p><p>So, I want to count the number of region.</p><p>In the above matrix,</p><img src = "/matlabcentral/answers/uploaded_files/26570/%EC%BA%A1%EC%B2%98.JPG"><p>But I don't know how make the code.</p><p>Please help me...</p>MIHYUNhttps://www.mathworks.com/matlabcentral/profile/authors/4940188-mihyuntag:www.mathworks.com,2005:Question/1816142015-03-05T06:08:36Z2015-03-05T06:08:36Zhow to connect solar cell to simpowersystem elements<p>foe example take this model... there is a solar cell and a load from sim power system .. how can i connect this... basically i want to desing an solar pv system interconnected to a grid using DC-DC converter...so apart from solar panel rest will from simpowersystem library which i am unable to directly connect to the cell....kindly suggest me the solution</p>puneet joshihttps://www.mathworks.com/matlabcentral/profile/authors/6247582-puneet-joshitag:www.mathworks.com,2005:Question/1259222014-04-16T05:06:43Z2015-03-05T05:54:53Zi wanted to convert image encryption and decryption to video encryption and decryption for the following code is given below...please help me to convert the code to video ....<pre class="language-matlab">if true
clc;
clear all;
close all;
nMod = 7 ;
%% cover image
[FileName,PathName] = uigetfile('*.jpg','Select the Cover Image');
file = fullfile(PathName,FileName);
disp(['User selected : ', file]);
cover = imresize(imread(file),[128 128]);
cover = double(cover);
if ndims(cover) ~= 3
msgbox('The cover image must be colour');
break;
end
figure;
subplot(1,2,1);
imshow(uint8(cover),[]);
title('Cover image');
%% secret image
[FileName,PathName] = uigetfile('*.jpg','Select the Secret Image');
file = fullfile(PathName,FileName);
disp(['User selected : ', file]);
secret = imresize(imread(file),[128 128]);
if ndims(secret) ~= 3
msgbox('The cover image must be colour');
break;
end
subplot(1,2,2);
imshow(uint8(secret),[]);
title('Secret Image');
%% Stegnography
% Quantification of secret image by a factor 45
[nRow, nColumn] = size(cover);
secret = double(secret)/45;
stegImg1 = zeros(size(cover));
stegImg2 = zeros(size(cover));
stegImg3 = zeros(size(cover));
shadowImg1 = zeros(size(cover));
shadowImg2 = zeros(size(cover));
shadowImg3 = zeros(size(cover));
encrykey = input('Please Enter an Encryption Key Between 0 - 255:\n');
if encrykey < 0 || encrykey > 255
error('Invalid Key enter');
end
encrykey = uint8(encrykey);
for k=1:3
m = mod(cover(:,:,k), nMod);
quantification = floor(cover(:,:,k)/nMod)*nMod;
[R C] = size(cover(:,:,k));
for i = 1:R
for j = 1:C
shadowImg1(i,j,k) = mod(m(i,j)*1,nMod);
shadowImg2(i,j,k) = mod(m(i,j)*2,nMod);
shadowImg3(i,j,k) = mod(m(i,j)*3,nMod);
stegImg1(i,j,k) = quantification(i,j)+ mod(m(i,j)*1 + secret(i,j,k),nMod);
stegImg2(i,j,k) = quantification(i,j)+mod(m(i,j)*2+ secret(i,j,k),nMod);
stegImg3(i,j,k) = quantification(i,j)+mod(m(i,j)*3+ secret(i,j,k),nMod);
end
end
end
figure;
subplot(1,3,1)
imshow(uint8(shadowImg1),[]);
title('Shadow Image 1');
subplot(1,3,2);
imshow(uint8(shadowImg2),[]);
title('Shadow Image 2');
subplot(1,3,3);
imshow(uint8(shadowImg3),[]);
title('Shadow Image 3');
figure;
subplot(1,3,1)
imshow(uint8(stegImg1),[]);
title('Stegno Image 1');
subplot(1,3,2);
imshow(uint8(stegImg2),[]);
title('Stegno Image 2');
subplot(1,3,3);
imshow(uint8(stegImg3),[]);
title('Stegno Image 3');
%%
decrykey = input('Please Enter an Decryption Key:\n');
if encrykey == decrykey
% Reverse secret image
revsecret = zeros(size(secret));
for k=1:3
mod1 = mod(stegImg1(:,:,k), nMod);
mod2 = mod(stegImg2(:,:,k), nMod);
mod3 = mod(stegImg3(:,:,k), nMod);
for e = 1:R
for f = 1:C
if mod2(e, f) < mod1(e, f) || mod2(e, f) == 0
mod2(e, f) = mod2(e, f)+nMod;
end
end
end
a1 = mod2 - mod1;
temp = mod1 - a1;
for e = 1:R
for f = 1:C
if temp(e,f) < 0
temp(e,f) = temp(e,f) + nMod;
end
end
end
revsecret(:,:,k) = temp*45 ; % dequantification
end
figure;
subplot(1,2,1);
imshow(uint8(revsecret),[]);
title('Reconstructed Secret Image');
%% Cover image reconstruction
dequantification = zeros(size(cover));
for k=1:3
dequantification1 = floor(stegImg1(:,:,k)/nMod)*nMod;
dequantification2 = floor(stegImg2(:,:,k)/nMod)*nMod;
dequantification3 = floor(stegImg3(:,:,k)/nMod)*nMod;
dequantification(:,:,k) = floor((dequantification1+dequantification2+dequantification3)/3);
end
subplot(1,2,2);
imshow(uint8(dequantification),[]);
title('Reconstructed Cover Image');
%% PSNR FOR STEGNO IMAGE
Q = 255;
MSE = sum(sum((stegImg1-cover).^2))/nRow / nColumn ;
PSNR=10*log10(Q*Q/MSE);
fprintf('The stegImg1PSNR performance is %.2f dB\n',sum(PSNR)/3);
MSE = sum(sum((stegImg2-cover).^2))/nRow / nColumn ;
PSNR=10*log10(Q*Q/MSE);
fprintf('The stegImg2PSNR performance is %.2f dB\n',sum(PSNR)/3);
MSE = sum(sum((stegImg3-cover).^2))/nRow / nColumn ;
PSNR=10*log10(Q*Q/MSE);
fprintf('The stegImg3PSNR performance is %.2f dB\n',sum(PSNR)/3);
else
msgbox('You have enter the invalid key');
end
end
</pre>Rohithttps://www.mathworks.com/matlabcentral/profile/authors/5256918-rohittag:www.mathworks.com,2005:Question/1816122015-03-05T05:45:14Z2015-03-05T05:45:14ZHow to find circular Histogram of Oriented Rectangles(CHOR)<p>Hi everyone,
I am just trying to find out circular histogram of oriented rectangles as shown in figure.
kindly help me.</p><img src = "/matlabcentral/answers/uploaded_files/26569/Untitled.jpg">amruta hosurhttps://www.mathworks.com/matlabcentral/profile/authors/6247458-amruta-hosurtag:www.mathworks.com,2005:Question/1816112015-03-05T05:29:53Z2015-03-05T05:29:53Zhow to remove stopfcn error? i am not getting BER results for any of my simulink models because of that<p>please help me</p>yogesh Rhttps://www.mathworks.com/matlabcentral/profile/authors/6230263-yogesh-rtag:www.mathworks.com,2005:Question/1816102015-03-05T05:29:00Z2015-03-05T05:29:00ZI want to detect pupil from the image obtained from webcam and it's center also in matlab. What should i do?? Anyone help me with the code please<p>I am using matlab for eye pupil detection and moving the cursor according to the eye movements by real time webcam access. I want help in coding for the same..I got stuck at detecting the pupil. so help me out please</p>Bhushan Bhandarkarhttps://www.mathworks.com/matlabcentral/profile/authors/5985866-bhushan-bhandarkartag:www.mathworks.com,2005:Question/1812082015-03-03T06:23:40Z2015-03-05T05:26:35Zcan i use more than one hold on function in same code?<p>I am dividing an image in four quadrants recursively if they satisfy the condition. For that I am using following code:</p><pre class="language-matlab">figure;
imshow(lf);
div_rec_A(lf,rf,r,c,g1_squ,g2_squ);
</pre><pre class="language-matlab">function div_rec_A( lf,rf,r,c,g1_squ,g2_squ )
hold on;
xv1=[c/2,c/2];
yv1=[1,r];
line(xv1,yv1,'Color','r','LineWidth',1);
xh1=[1,c];
yh1=[c/2,c/2];
line(xh1,yh1,'Color','r','LineWidth',1);
if condition
%copy the part in another image
else
lf = AL;
rf = AR;
[r c] = size(lf);
g1_squ = AFL;
g2_squ = AFR;
</pre><pre> div_rec_A(lf,rf,r,c,g1_squ,g2_squ);</pre><p>here lf and rf are two images, r and c are dimension of the image and g1_squ and g2_squ are gradient of the lf and rf respectively. AL and RL is image portion of first quadrant of lf and rf images respectively. And AFL and AFR is image portion of first quadrant of g1_squ and g2_squ images respectively.</p><p>The above code works well and divides the first quadrant of the image but now I want to divide image of all four quadrants. So I made other three same functions namely div_rec_B(lf,rf,r,c,g1_squ,g2_squ), div_rec_C(lf,rf,r,c,g1_squ,g2_squ), div_rec_D(lf,rf,r,c,g1_squ,g2_squ) because the conditions are different for each quadrant. And all four functions are called in main function sequentially.</p><p>The problem is, the division of only first function is displayed. I tried adding</p><pre class="language-matlab">figure;
imshow(lf);
</pre><p>in each function at starting. It shows the result but I want all the divisions to be done on single image. So I guess the hold on function is not holding the image after first function. I didn’t write hold off in any of the function.</p><p>I hope the problem is clear. Plz HELP. Thanks in advance.</p>Dishahttps://www.mathworks.com/matlabcentral/profile/authors/3985038-dishatag:www.mathworks.com,2005:Question/1816092015-03-05T05:14:50Z2015-03-05T05:14:50ZHow do I get intensity of each pixel for gray-colored images?<p>I wanna get the intensity of each pixel (ex, 0~255) from gray-colored images.
But I don't know the code.
plz teach me.</p>Joo Yong Moonhttps://www.mathworks.com/matlabcentral/profile/authors/4001859-joo-yong-moontag:www.mathworks.com,2005:Question/47652011-04-05T00:34:09Z2015-03-05T04:59:15ZRMSE<p>Hi,</p>
<p>Does anybody know if there is any command in matlab, to calculate the RMSE (Root Mean Square Error) in a curve fitting problem?</p>
<p>Thanks</p>johnhttps://www.mathworks.com/matlabcentral/profile/authors/2758880-johntag:www.mathworks.com,2005:Question/1816082015-03-05T04:46:03Z2015-03-05T04:46:45ZNeed a example of c.steger's curvilinear structure extraction code,is problem in image processing, can anyone help?<p>curvilinear structure extraction code,</p>Sri Vidhyahttps://www.mathworks.com/matlabcentral/profile/authors/6158420-sri-vidhyatag:www.mathworks.com,2005:Question/1816072015-03-05T04:30:24Z2015-03-05T04:39:55ZHow to find which element is the lowest first or second or third or ....<p>There is a 1X1 matrix.</p><p>I wanna find which element is the MINIMUM not the minimum value but the number of the particular element.</p><p>If this is the matrix,</p><p>y = [682.8333 399.8160 34.2270 46.1800 107.7035 ];</p><p>I know the minimum value is 34.2270 to get that we can use</p><p>mini= min(y);</p><p>but what i want is how to get the number of the minimum element</p><p>in here it's the 3rd element.</p><p>Thank you.</p>Chamira Wickramasinghehttps://www.mathworks.com/matlabcentral/profile/authors/6020974-chamira-wickramasinghetag:www.mathworks.com,2005:Question/1815892015-03-04T21:44:47Z2015-03-05T04:38:44Zinput arguments must be scalar matlab error<p>I have written a code in it is telling above error in part mentioned below</p><pre class="language-matlab">NB=max(size(Y));
H=zeros(2:NB,2:NB);
N=zeros(NG+1:NB,NG+1:NB);
L=zeros(2:NB,NG+1:NB);
M=zeros(NG+1:NB,2:NB);
</pre><p>Plz. reply fast</p>SAURABH KUMARhttps://www.mathworks.com/matlabcentral/profile/authors/5049742-saurabh-kumartag:www.mathworks.com,2005:Question/1810822015-03-02T13:34:37Z2015-03-05T04:29:14ZHo w to find the first minimum element in a row<p>Here i have a 1X6 matrix</p><p>y =</p><pre class="language-matlab">682.8333 399.8160 34.2270 46.1800 107.7035 21.5367
</pre><p>what i wanna do is to find the FIRST minimum element</p><p>which means if i plot "y" i wanna find first minimum turning point</p><p>for this example it must be 34.2270</p><p>Thank you.</p>Chamira Wickramasinghehttps://www.mathworks.com/matlabcentral/profile/authors/6020974-chamira-wickramasinghetag:www.mathworks.com,2005:Question/665902013-03-10T14:35:03Z2015-03-05T04:25:49ZHow can I keep automatical adjustment of y-axis limits when manually zooming/using pan tool?<p>Hello,</p><p>Is there a possibility to keep the <b>'ylimmode'</b> axes property set to <b>'auto'</b> when manually zooming in/out or moving the graph in x-direction with the pan tool?</p><p>I defined a plot with specified limits of the x-axis and the 'ylimmode' property set to 'auto' (which is set by default anyway). E.g. like:</p><pre class="language-matlab">F = figure;
x = linspace(0,10*pi,1000);
signal = sin(t) + 0.07*randn(size(x));
h = plot(x,signal,'-x');
set(gca,'xlim', [2 3],'ylimmode','auto')
</pre><p>Whenever I scroll through the plot in x-direction using the pan tool in the property editor, 'ylimmode' property is set to 'manual' automatically. However, I want the limits of the y-axis to adjust automatically to the data when moving the graph from left to right. Is there a way to keep the 'ylimmode' property set to 'auto'?</p><p>Am looking forward for any comments.
Thanks,
Alex</p>Alexanderhttps://www.mathworks.com/matlabcentral/profile/authors/1193230-alexandertag:www.mathworks.com,2005:Question/1816062015-03-05T04:04:35Z2015-03-05T04:04:35ZHi I donot know mat lab code for the convergence rate of upwind finite difference method when exact solution is not known.<p>Hi I donot know mat lab code for the convergence rate of upwind finite difference method when exact solution is not known.</p>sam samyhttps://www.mathworks.com/matlabcentral/profile/authors/6245682-sam-samytag:www.mathworks.com,2005:Question/1816052015-03-05T03:17:02Z2015-03-05T03:58:19Zhow can k set the initial variable of my vector<p>Hello;
l set an initial value of a vector to [] neighbour_n= [];but once inside the loop neighbour_n(k)= [neighbour_n(k) j] doesnt work it returns me this message <b>the variable n(i) appears to change size in every loop iteration within the script consider prellocating for speed</b>
My target is to get a vector of indices [1 3 5 6 ..]
returned error :
%</p><pre class="language-matlab">??? Attempted to access neighbour_n(1); index out of bounds because numel(neighbour_n)=0.
</pre><pre class="language-matlab">Error in ==> agawa at 52
neighbour_n(k)= [neighbour_n(k) j];
%
</pre><p>my code:
%</p><pre class="language-matlab">N=200;
*neighbour_n(k)= [];*
m=0;
</pre><pre class="language-matlab">for k=1:N;
</pre><pre> for j= k+1 : N;</pre><pre> d =((nodesX(k)-nodesX(j))^2+(nodesY(k)-nodesY(j))^2)^0.5;</pre><pre> if d<=200;
m=m+1; % number of created links
line([nodesX(k),nodesX(j)],[nodesY(k),nodesY(j)]);
A(k, j)=1; </pre><pre> neighbour_n(k)= [neighbour_n(k) j];
else
A(k, j)=0;
end;</pre><pre> end;
display(A(k, j));
end;
%</pre>mazari ahmedhttps://www.mathworks.com/matlabcentral/profile/authors/6157243-mazari-ahmedtag:www.mathworks.com,2005:Question/1816032015-03-05T02:36:26Z2015-03-05T03:25:29ZHow to extract p-value from regress and corrcoef ?<p>Hello everyone,</p><p>I was able to write the code to run regress and corrcoef but didn't know how to get the <b>p value.</b></p><p>What exactly do i need to write before = in order to get these values?
[ ?? ]= regress(speed',weight)</p><p>Any idea how to get these out of regress and corcoeff?</p>Belal Abboushihttps://www.mathworks.com/matlabcentral/profile/authors/5985841-belal-abboushitag:www.mathworks.com,2005:Question/1816042015-03-05T02:48:22Z2015-03-05T03:08:01ZHow does one put an accent on a symbol in plots?<p>Hi,</p><p>I'd like to insert symbols like 'hat', 'dot', 'bar', 'arrow', etc over text symbols in plots. Could someone let me know how this is done in Matlab 2014b in the figure window?</p><p>Thanks.</p>Sai Prakashhttps://www.mathworks.com/matlabcentral/profile/authors/2401937-sai-prakashtag:www.mathworks.com,2005:Question/1815992015-03-05T01:24:03Z2015-03-05T02:34:24ZConvert .csv file(s) to netCDF file<p>Hi,</p><p>I need to convert the attached .csv file to netCDF file.(I have hundreds of similar .csv files) Is there a way to do in MATLAB?</p><p>Thanks in advance.</p>Damithhttps://www.mathworks.com/matlabcentral/profile/authors/5131512-damithtag:www.mathworks.com,2005:Question/1816022015-03-05T02:09:11Z2015-03-05T02:14:35ZI need code for packet transmission between two nodes in matlab. please help me<p>matlab code</p>dipali patelhttps://www.mathworks.com/matlabcentral/profile/authors/6221017-dipali-pateltag:www.mathworks.com,2005:Question/1815942015-03-04T23:11:24Z2015-03-05T02:13:16ZI am having trouble smoothing my data.<p>I have some data I need to do a bit of analysis on but I am having trouble getting it in the correct form. I have attached a fig for your viewing pleasure.</p><img src = "/matlabcentral/answers/uploaded_files/26558/weird.png"><p>As you can see I have two set of data, one is beautiful (relatively smooth and continuous in red) the other is all over the place. The spikes you see are do to gap fills and I am not sure why it behaves this way but it seems that these "gap-fills" are interpolated data but scaled up. I need to connect the higher "gap-fills" with the lower values but I am not sure how to go about it. I have tried a few things but nothing is working as well as I'd like. First I got rid of the spikes and replaced them with NaN's then interpolated those gaps but it was not what I needed. Any help is appreciated! Thanks!</p>danielhttps://www.mathworks.com/matlabcentral/profile/authors/5402792-danieltag:www.mathworks.com,2005:Question/1811302015-03-02T18:36:09Z2015-03-05T02:01:37ZHow can I find the length of a particular part of a image after defining the region of interest from the complete image?<p>I need a code to find the length of a particular portion of a MRI scan image after defining the area of interest from the full image.</p>Naveen Sundaramhttps://www.mathworks.com/matlabcentral/profile/authors/6235824-naveen-sundaramtag:www.mathworks.com,2005:Question/1816012015-03-05T01:56:39Z2015-03-05T01:56:39ZMatlab generated code. Embedded implementation<p>Hello. I try to realize Cheby1 filter in embedded system ( stm32 based ).
For this i get logs from microcontroller - there is blue line in graph. So there is noised raw data. Then i realize Cheby1 filter in Matlab and it work good - green line in graph. After that i generate C code using Matlab coder and move it in firmware for microcontroller as is. And there is result - red line in graph - it is gain cutted! What is the reason of it? Where am i mistaken?</p>almaz hamhttps://www.mathworks.com/matlabcentral/profile/authors/6161433-almaz-hamtag:www.mathworks.com,2005:Question/1815782015-03-04T19:59:16Z2015-03-05T01:01:50Zhelp with syntax of textread<p>hello,</p><p>I am new to MATLAB.</p><p>I need to import a text file with text and numbers.
Four delimiters: forward slash, space, colon, comma. (or I suppose you could view that as just 1 delimiter, the comma, and then I could break apart the date and time later. But I would prefer doing that all in one step.)</p><p>I do not particularly want the headings, which appear in the first row.
The data in the subsequent rows currently appears as Date Time,Data. e.g.</p><pre class="language-matlab">row 2: 3/2/2014 10:28:00 AM,4,1944,136,24.41,354066,24.61,24.64,24.53,24.29
</pre><p>I would like each value in each row to occupy its own column:</p><pre class="language-matlab">row 2: 3 2 2014 10 28 00 AM 4 1944 136 24.41 354066 24.61 24.64 24.53 24.29
</pre><p>thanks for your help!</p>Brittahttps://www.mathworks.com/matlabcentral/profile/authors/6160813-brittatag:www.mathworks.com,2005:Question/1815982015-03-05T00:59:16Z2015-03-05T00:59:16ZSTL to point clouds<p>Hi all,</p><p>Currently, I am able to read a STL using matlab which return me 1 faces matrix and 1 vertices matrix.</p><p>stlread(file) <a href = "http://www.mathworks.com/matlabcentral/fileexchange/22409-stl-file-reader/content/STLRead/stlread.m">http://www.mathworks.com/matlabcentral/fileexchange/22409-stl-file-reader/content/STLRead/stlread.m</a></p><p>However, now I would like to convert the geometry into point cloud data (matrix form) for registration purpose.Is there any programs I can run to convert the vertices and faces into point cloud?</p><p>Thanks.
Yang Jun</p>yang jun yoonghttps://www.mathworks.com/matlabcentral/profile/authors/5726170-yang-jun-yoongtag:www.mathworks.com,2005:Question/1815972015-03-05T00:54:46Z2015-03-05T00:54:46ZHow do I Reconstruct an image using Tomographic data?<p>The idea of my problem is to construct a 32x32 image using only square pixels, which can only be completely white or completely black. I have data of absorption by 32 evenly spaced parallel beams at various angles, i.e. 32 data points per angle. I'm not entirely sure how to construct the image using data, as opposed to using Shepp-Logan head phantom image. I'm almost certain I need to use radon and/or iradon functions, I'm just not sure how the data fits into those. Any help would be greatly appreciated!</p>Benjamin Freundhttps://www.mathworks.com/matlabcentral/profile/authors/4285561-benjamin-freundtag:www.mathworks.com,2005:Question/1815962015-03-05T00:53:35Z2015-03-05T01:06:32ZFinding the approximate length with for loop?<p>mylength(f,g,a,b,n) which takes five inputs:
f: A function handle.
g: A function handle.
a: A real number.
b: A real number.
n: A positive integer.
Note: You may assume that that a < b.
Question: The functions f(t) and g(t) determine the location of an object at any time t by (f(t), g(t)).
Approximate the distance traveled by the object between t = a and t = b by dividing [a, b] into n equal
subintervals, determining the location of the object at each of those t-values and then by finding the
straight-line distance between those locations and adding them.</p><p>Code:</p><pre> function results = mylength(f,g,a,b,n);
totalLength = 0;
interval = sqrt((f-a)^2+(g-b)^2);
for x = [a:interval:b]
if x<b
totalLength = totalLength + x + interval;
end
end
results = totalLength;
end</pre><p>Error: I am getting an error at the start of the for loop. I know I am getting that error because in interval I am using 4 variables and not just 2 variables. Also an error with how I am calculating interval. Can someone help/tell me how I would adjust the code to solve for this problem.</p>Bradley Sanchezhttps://www.mathworks.com/matlabcentral/profile/authors/6106580-bradley-sancheztag:www.mathworks.com,2005:Question/1815222015-03-04T15:08:02Z2015-03-05T00:28:07ZIssues when multipling and summing very small values in a matrix<p>Hi,</p><p>So I am performing a fairly simple task, where it basically multiplies all values in a matrix by a value, then summing the matrix.
The issue I am having is that when these values of the matrix becomes quite low, it just sums /rounds to 0 or something.</p><pre class="language-matlab">for count1 = 1:len1
constant = 2*pi*count1*0.0100;
datamatrix = massplume_area(:, count1).*constant;
end
totalmassplume = sum(datamatrix(:));
</pre><p>It seems to be if the values are very small, or if there a quite a few zero values in the matrix 'massplume_area', then the act of multiplying it by the value 'constant' causes the output to be 0.
If there are plenty of large values/ not many 0 values in massplume_area, then there is no issue.</p><p>Any advise?</p>Davidhttps://www.mathworks.com/matlabcentral/profile/authors/5502517-davidtag:www.mathworks.com,2005:Question/1815662015-03-04T18:47:09Z2015-03-05T00:17:59ZWhere can I find the signal processing workshop example: specgramdemo<p>Hi, I have attended a signal processing workshop from Matlab. I would revisit to see the demo example called 'specgramdemo', but I couldn't find it anywhere, can you let me know where can I find the example file?</p>Yen Matsutomihttps://www.mathworks.com/matlabcentral/profile/authors/2404680-yen-matsutomitag:www.mathworks.com,2005:Question/1813042015-03-03T14:23:22Z2015-03-05T00:13:51ZError Starting Matlab, how do I permanently fix this issue without using "restoredefaultpath;matlabrc" everytime I open MatLab<p>Everytime I start up Matlab I get the following message:</p><p>"C:\Program Files\MATLAB\R2014a\toolbox\local\pathdef.m: Cannot open file: permission denied.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this warning the next time you start MATLAB, type "docsearch problem path" after recovering for this session.
Warning: Duplicate directory name: C:\Program Files\MATLAB\R2014a\toolbox\local
Warning: Initializing Handle Graphics failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:undefinedVarOrClass
Undefined variable "graphics" or class "graphics.internal.initializeMATLABRoot".
Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:UndefinedFunction
Undefined function 'usejava' for input arguments of type 'char'.
> In matlabrc at 110
Warning: Failed to add default profiler filters.
> In matlabrc at 149
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.mathworks.mlwidgets.graphics.ModelStateFactory.createNoSelectionModelState(ModelStateFactory.java:242)
at com.mathworks.mlwidgets.graphics.PlotToolSetFactory$3.parseComplete(PlotToolSetFactory.java:128)
at com.mathworks.mlwidgets.graphics.ModelStateFactory$ProductInfoListener$1$1.run(ModelStateFactory.java:1023)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)"</p><p>Recovering the session using "restoredefaultpath;matlabrc" does work, but I cannot figure out how to fix the problem so this message does not pop up every single time I start MatLab.</p>Jaxonhttps://www.mathworks.com/matlabcentral/profile/authors/6109611-jaxontag:www.mathworks.com,2005:Question/1815492015-03-04T17:27:40Z2015-03-05T00:06:12ZProblem with pop-up menu in gui<p>Hello world,
I've been using GUIDE for making guis for a short time. I have a major problem when I delete elements from a pop-up menu, as it disappears for absolutely no reason, although the cell that is being used for pop-up menu population, still has one last element. I've read about pop-up menus and their problem with empty Values, however that's not the case, because the there is still one string element. Any ideas please??
I have attached the file, so anyone can see.
Thank you all!</p>Andreashttps://www.mathworks.com/matlabcentral/profile/authors/4202492-andreastag:www.mathworks.com,2005:Question/1537092014-09-06T15:02:16Z2015-03-04T23:59:30Zimplement for loop in simulink with function block<p>hi,</p><p>i have a source in simulink x = rand which outputs single random value and other function blocks acts on this.</p><p>i wanted to generate k values source data and each function block should acts on each x(k) input
eg in script we use for loop to generate x values and we can manipulate the different x values,
how to implement this in simulink with function blocks
if true
for k = 1:10;
x(k) = rand is a source</p><p>and function block should act on each x(k),</p><p>y(k) = some_function(x(k))
end</p><p>How to implement this in simulink?</p><p>thanks</p>Sumahttps://www.mathworks.com/matlabcentral/profile/authors/4783692-sumatag:www.mathworks.com,2005:Question/1815922015-03-04T22:50:43Z2015-03-04T23:58:17Zreshape error in an .stl writer?<p>So i've used an function, stlread, to import an .stl files information (faces, vertices, and normals) into matlab and am now trying to export them as an .stl. The problem is that the function I'm using to take the faces and vertices and write them to an stl file has this line of code:
facets = reshape(facets(:,ceil(faces)'), 3, 3, []);
which doesn't like that faces is an array of non integers. However, that's the array that the .stl reader outputs.
Here's the stl reader: <a href = "http://www.mathworks.com/matlabcentral/fileexchange/6678-stlread">http://www.mathworks.com/matlabcentral/fileexchange/6678-stlread</a>
and here's the .stl writer: <a href = "http://www.mathworks.com/matlabcentral/fileexchange/20922-stlwrite-write-binary-or-ascii-stl-file">http://www.mathworks.com/matlabcentral/fileexchange/20922-stlwrite-write-binary-or-ascii-stl-file</a>
and help is greatly appreciated! Thank you very much!</p>Nicholas Lopezhttps://www.mathworks.com/matlabcentral/profile/authors/6246484-nicholas-lopeztag:www.mathworks.com,2005:Question/907942013-10-20T03:44:08Z2015-03-04T23:55:18ZFinding Max Distance between coordinates<p>Hi guys,
Urgently need some help on this.
I have made a code that analyses any given image and outputs the coordinates of the boundary points into 2 separate arrays, x and y.
I want to find the distance between all the coordinates with each other. And then identify the coordinates that give the longest distance.</p><p>Thanks</p>Prabshttps://www.mathworks.com/matlabcentral/profile/authors/4721284-prabstag:www.mathworks.com,2005:Question/1462792014-08-05T00:33:26Z2015-03-04T23:53:33ZFinding the distance between objects<img src = "/matlabcentral/answers/uploaded_files/16321/Untitled.png"><p>I have the above image which I have already labeled using bwlabel(). Now what I want to do is something similar to what was posted in: <a href = "http://www.mathworks.com/matlabcentral/answers/91046-how-to-find-distance-in-binary-image">http://www.mathworks.com/matlabcentral/answers/91046-how-to-find-distance-in-binary-image</a></p><p>For this case I want to calculate the smallest distance between object 1&2, 1&3 and 2&3. But in general I want to make it flexible so I could input any image with any amounts of objects and be able to calculate the distances.</p><p>This is my code so far:</p><pre class="language-matlab">Timg = zeros(size(Limg));
Timg(Limg == i)=1 ;
Dist = bwdist(Timg, 'euclidean');
for j~=i
DistanceValues = Dist(lableledImage == j));
min(DistanceValues);
end
</pre><p>It doesn't work as I expected it to. Any help in editing this code or completely changing the concept would be appreciated.</p><p>Thanks</p>Duncanhttps://www.mathworks.com/matlabcentral/profile/authors/5351214-duncantag:www.mathworks.com,2005:Question/1812832015-03-03T12:42:56Z2015-03-04T23:36:23ZSpatial subset of geotiff through masking by shapefile?<p>I would like to create a mask (using poly2mask) to apply to a geotiff image, based on a single polygon in shapefile .shp format.</p><p>I have put together simple code below but evidently I have something wrong with syntax (maybe even just totally improper usage) of the worldtoIntrinsic part.</p><p>I have searched help avenues, but haven't cracked it.</p><p>Error message: (An issue with the structure of R, that I am returning by geotiffread?)</p><p>Undefined function 'worldToIntrinsic' for input arguments of type
'map.rasterref.GeographicPostingsReference'.
Error in polygon_shapefileread_example (line 15)
[ix, iy] = worldToIntrinsic(R,rx,ry);</p><p>Attached are the small geotiff and shapefile.</p><p>Many thanks for any help,
Matt</p><pre> %Read in GeoTIFF
[I R] = geotiffread('geotiff_example.tif');
% Read Region of Interest shapefile
roi = shaperead('shapefile_example.shp');
% Remove trailing nan from shapefile
rx = roi.X(1:end-1);
ry = roi.Y(1:end-1);</pre><pre> % convert to image coordinates
[ix, iy] = worldToIntrinsic(R,rx,ry);
%Make the mask
mask = poly2mask(ix,iy,R.RasterSize(1),R.RasterSize(2));
%Following line checks some 1's are generated in mask
maskcheck=sum(sum(mask));</pre>mcb001https://www.mathworks.com/matlabcentral/profile/authors/6239225-mcb001tag:www.mathworks.com,2005:Question/1815932015-03-04T23:06:22Z2015-03-04T23:33:23ZObject segmentation: defining the object of interest<p>This question might be a bit more broad.</p><p>In case of object segmentation, for instance my object of interest is a person in the image, so before performing the segmentation on the person, how can I identify that person as the object of interest? What I mean to say is, I don't want to segment any other object in the image except the person. How can I do that? I know there's template based approach, however, I was wondering if this can be done using predefined thresholds that defines the sizes of different parts of the body and processes only those parts further?</p>monahttps://www.mathworks.com/matlabcentral/profile/authors/2928707-monatag:www.mathworks.com,2005:Question/1815872015-03-04T21:44:12Z2015-03-04T23:28:06Zgraphing -- make figure window larger<p>I'm plotting a bunch of points, but I want the figure window to appear larger when I run the code. I need this to be some command that I can include in the code. thanks</p>Lisahttps://www.mathworks.com/matlabcentral/profile/authors/6067463-lisatag:www.mathworks.com,2005:Question/1771482015-02-11T01:37:29Z2015-03-04T23:15:18Zwrite a matlab code to compute golomb sequence<p>Is there any function for golomb sequence in matlab?. write the code to display the golomb sequence [the numbers ].</p>Olumide David Awehttps://www.mathworks.com/matlabcentral/profile/authors/6166205-olumide-david-awetag:www.mathworks.com,2005:Question/1815912015-03-04T22:47:34Z2015-03-04T23:14:42ZCode to solve kdv ecuation with an animation of 2 solitions<p>I need some help to understand the math behind this code to solve kdv ecuation. I need an explanation step by step. Thanks</p><pre class="language-matlab">% kdv.m - Solve KdV equation by Fourier spectral/ETDRK4 scheme
% A.-K. Kassam and L. N. Trefethen 4/03
%
% This code solves the Korteweg-de Vries eq. u_t+uu_x+u_xxx=0
% with periodic BCs on [-pi,pi] and initial condition given by
% a pair of solitons. The curve evolves up to t=0.005 and at
% the end u(x=0) is printed to 6-digit accuracy. Changing N
% to 384 and h to 2.5e-7 improves this to 10 digits but takes
% four times longer.
</pre><pre> clear
clc
% Set up grid and two-soliton initial data:
N = 512;
x = (2*pi/N)*(-N/2:N/2-1)';
A = 25; B = 16;
u = 3*A^2*sech(.5*(A*(x+2))).^2+3*B^2*sech(.5*(B*(x+1))).^2;
p = plot(x,u,'linewidth',3);
axis([-pi pi -200 2200]), grid on</pre><pre class="language-matlab">% Precompute ETDRK4 scalar quantities (Kassam-Trefethen):
h = 1e-6; % time step
</pre><pre> k = [0:N/2-1 0 -N/2+1:-1]'; % wave numbers
L = 1i*k.^3; % Fourier multipliers
E = exp(h*L); E2 = exp(h*L/2);
M = 64; % no. pts for complex means
r = exp(2i*pi*((1:M)-0.5)/M); % roots of unity
LR = h*L(:,ones(M,1))+r(ones(N,1),:);
Q = h*mean( (exp(LR/2)-1)./LR ,2);
f1 = h*mean((-4-LR+exp(LR).*(4-3*LR+LR.^2))./LR.^3,2);
f2 = h*mean( (4+2*LR+exp(LR).*(-4+2*LR))./LR.^3,2);
f3 = h*mean((-4-3*LR-LR.^2+exp(LR).*(4-LR))./LR.^3,2);
g = -.5i*k;</pre><pre class="language-matlab">% Time-stepping by ETDRK4 formula (Cox-Matthews):
</pre><pre> set(gcf,'doublebuffer','on')
disp('press <return> to begin'), pause % wait for user input
t = 0; step = 0; v = fft(u);
while t+h/2 < 0.006
step = step+1;
t = t+h;
Nv = g.*fft(real(ifft(v)).^2);</pre><pre> a = E2.*v+Q.*Nv; Na = g.*fft(real(ifft(a)).^2);
b = E2.*v+Q.*Na; Nb = g.*fft(real(ifft(b)).^2);
c = E2.*a+Q.*(2*Nb-Nv); Nc = g.*fft(real(ifft(c)).^2);
v = E.*v+(Nv.*f1+(Na+Nb).*f2+Nc.*f3);
if mod(step,25)==0
u = real(ifft(v)); set(p,'ydata',u)
title(sprintf('t = %7.5f',t),'fontsize',18), drawnow
end
end
text(-2.4,900,sprintf('u(0) = %11.7f',u(N/2+1)),...
'fontsize',18,'color','r')</pre>Alex Alfiohttps://www.mathworks.com/matlabcentral/profile/authors/6246463-alex-alfiotag:www.mathworks.com,2005:Question/1815792015-03-04T20:07:22Z2015-03-04T23:14:40ZImage denoising and contrast enhance!<img src = "/matlabcentral/answers/uploaded_files/26554/Image01.jpg"><p>Hey,</p><p>Does anybody has an idea how to denoising this image and enhance the contrast? The random distribution stripes and the low contrast really a pain.</p><p>I knew there is a way to filtering in the frequency domain, could anyone help me out here?
Thanks very much</p><p>Joanna</p>xsfenghttps://www.mathworks.com/matlabcentral/profile/authors/3344109-xsfengtag:www.mathworks.com,2005:Question/1815952015-03-04T23:14:07Z2015-03-04T23:14:07ZStereo Calibration and Image Rectification<p>I'm trying to use the stereo camera calibrator to rectify a pair of stereo images. However, while the reprojection errors, extrinsic view, and reprojected points all look reasonable, the "show rectified" button just returns horizontal lines of various colors.</p><img src = "/matlabcentral/answers/uploaded_files/26557/screenshot.png"><p>Similarly, attempting to use</p><pre class="language-matlab">[J1, J2] = rectifyStereoImages(I1, I2, stereoParams);
</pre><p>to rectify the stereo images returns a blank image:</p><img src = "/matlabcentral/answers/uploaded_files/26559/screenshot.png"><p>Turning on 'OutputView' ,'full' :</p><pre class="language-matlab">% Rectify the images.
[J1, J2] = rectifyStereoImages(I1, I2, stereoParams, 'OutputView' ,'full');
</pre><p>shows the rectification is inverted:</p><img src = "/matlabcentral/answers/uploaded_files/26560/screenshot.png"><p>I've attached my calibration images if they are of use.
Thanks in advance for any help!</p>John Boylehttps://www.mathworks.com/matlabcentral/profile/authors/3145911-john-boyletag:www.mathworks.com,2005:Question/1815882015-03-04T21:44:25Z2015-03-04T23:03:56ZHow can I calculate the thickness for the attached images?<p>How can I calculate the thickness for the attached image??</p><p>I did segmentation for all the nerves in the image and I labelled each object in the image. What I want is how can I calculate the thickness of each nerve? And how can I highlight a specific part of the nerve if there is an inflation in any nerve?</p><p>Your help in this regard is highly appreciated, thank you in advance</p>Alaahttps://www.mathworks.com/matlabcentral/profile/authors/5708381-alaa