http://www.mathworks.de/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-04-24T22:17:22Ztag:www.mathworks.de,2005:Question/1270352014-04-24T17:45:59Z2014-04-24T22:17:22ZTextscan with very large .dat files, Matlab keeps crashing<p>Hey everyone,</p><p>I am using R2013b to read in some very large files, 35 of them but I am running into memory problems and matlab usually crashes before loading the files in. I am using textscan but I was hoping someone could help me edit the code so that it will load in the data a block at a time or at least make it less memory intensive. I need all the years in one large cell array.</p><p>Any ideas?</p><p>Many thanks!</p><pre class="language-matlab">tic;
HWFiles = {'midas_wind_197901-197912.txt','midas_wind_198001-198012.txt', ..........(up to 2013)};
HWData = cell(1,numel(HWFiles));
</pre><pre> for i=1:numel(HWFiles);
fid = fopen(HWFiles{i}, 'r');
tmp = textscan(fid,'%s %*s %*f %*f %s %*f %f %*f %f %f %f %f %f %*f %*f %*f %*f %*f %*s %*f %*f %*s %*f %*f', 'Delimiter',','); </pre><pre> HWData{i} = tmp ;
fclose(fid);
end
toc;</pre>Masao Ashtine/matlabcentral/answers/contributors/4739967-masao-ashtinetag:www.mathworks.de,2005:Question/1270732014-04-24T22:15:33Z2014-04-24T22:15:33ZTeeth Segmentation from a given X-ray image<p>from a given dental X-ray image, how to seperate the upper and lower jaws? Additionally, how to segment each tooth?</p>Prashit Mehta/matlabcentral/answers/contributors/5282338-prashit-mehtatag:www.mathworks.de,2005:Question/1270572014-04-24T20:34:10Z2014-04-24T22:06:05ZProblem saving vectors in a for loop<p>Hi all,</p><p>I am having trouble saving the vectors that I generate using a for loop. Running the code, that I have provided below, updates the 3D plot for each iteration. I would like to save each vector for each iteration and plot them all together. I believe the problem lies with the counter "xx" but I am unsure how to get around this since I want to save the vector "C" for each iteration which does not use "xx" as a counting variable. I have tried indexing "C" with "xx" to save the vector for each iteration Any help would be greatly appreciated.</p><pre class="language-matlab">for xx=0:5:350;
d2(1:71)=xx;
lambda=400:5:750;
</pre><pre class="language-matlab">d1=0.34;
</pre><pre class="language-matlab">% Define Refractive Indices for Materials:
</pre><pre class="language-matlab">% Air:
n_0=1;
</pre><pre class="language-matlab">% Graphene present & not present:
n_1=2.6-1.3i;
n_11=1;
</pre><pre class="language-matlab">% SiO2 (400-750nm):
n_2=[1.4701 1.4696 1.4691 1.4686 1.4681 1.4676 1.4672 1.4668 1.4663...
1.466 1.4656 1.4652 1.4648 1.4645 1.4641 1.4638 1.4635 1.4632 1.4629...
1.4626 1.4623 1.4621 1.4618 1.4615 1.4613 1.461 1.4608 1.4606 1.4603 1.4601...
1.4599 1.4597 1.4595 1.4593 1.4591 1.4589 1.4587 1.4586 1.4584 1.4582 1.458 1.4579...
1.4577 1.4576 1.4574 1.4572 1.4571 1.457 1.4568 1.4567 1.4565 1.4564 1.4563 1.4561 1.456...
1.4559 1.4558 1.4556 1.4555 1.4554 1.4553 1.4552 1.4551 1.455 1.4549 1.45475 1.4546 1.4545 1.4544 1.4543 1.4542];
</pre><pre class="language-matlab">% Silicon (400-750nm):
n_3=[5.554925088 5.422277418 5.302243523 5.193611448 5.095262656 5.006167192 4.925378971...
4.852031185 4.785331843 4.724559421 4.669058654 4.618236434 4.57155784 4.528542299 4.488759852...
4.451827565 4.417406046 4.3851961 4.354935495 4.326395864 4.299379722 4.273717609 4.249265359 4.225901491...
4.203524726 4.182051619 4.161414333 4.141558515 4.12244131 4.1040295 4.086297753 4.069227011 4.052802995 4.03701484...
4.021853804 4.00731224 3.9933825 3.980056106 3.967322993 3.955170878 3.943584754 3.932546514 3.922034693 3.912024332 3.902486974...
3.893390776 3.884700748 3.876379115 3.868385805 3.860679058 3.853216158 3.845954294 3.838851539 3.831867956 3.824966827 3.818116006 3.811289394...
3.804468544 3.797644378 3.790819041 3.784007871 3.777241493 3.770568042 3.7640555 3.75779417 3.751899264 3.746513614 3.741810515 3.737996688 3.735315359 3.734049478];
</pre><pre class="language-matlab">% Define r constants:
</pre><pre class="language-matlab">% For graphene on Si02:
r1=(n_0-n_1)./(n_0+n_1);
r2=(n_1-n_2)./(n_2+n_1);
r3=(n_2-n_3)./(n_2+n_3);
</pre><pre class="language-matlab">% Plain Si02 no graphene:
r11=(n_0-n_11)./(n_0+n_11);
r21=(n_11-n_2)./(n_2+n_11);
r31=(n_2-n_3)./(n_2+n_3);
</pre><pre class="language-matlab">% Define phase shifts:
psi1=(2*pi*n_1*d1)./lambda;
psi2=(2*pi*n_2.*d2)./lambda;
</pre><pre class="language-matlab">psi11=(2*pi*n_11*d1)./lambda;
psi21=(2*pi*n_2.*d2)./lambda;
</pre><pre class="language-matlab">% Intensity equation with graphene (I1) and without (I2):
I1=abs((r1.*exp(1i.*(psi1+psi2))+r2.*exp(-1i.*(psi1-psi2))+r3.*exp(-1i.*(psi1+psi2))...
+r1.*r2.*r3.*exp(1i.*(psi1-psi2))).*(exp(1i.*(psi1+psi2))+r1.*r2.*exp(-1i.*(psi1-psi2))+r1.*r3.*exp(-1i.*(psi1+psi2))+r2.*r3.*exp(1i.*(psi1-psi2))).^-1).^2;
</pre><pre class="language-matlab">I2=abs((r11.*exp(1i.*(psi11+psi21))+r21.*exp(-1i.*(psi11-psi21))+r31.*exp(-1i.*(psi11+psi21))...
+r11.*r21.*r31.*exp(1i.*(psi11-psi21))).*(exp(1i.*(psi11+psi21))+r11.*r21.*exp(-1i.*(psi11-psi21))...
+r11.*r31.*exp(-1i.*(psi11+psi21))+r21.*r31.*exp(1i.*(psi11-psi21))).^-1).^2;
</pre><pre class="language-matlab">% Contrast equation:
</pre><pre class="language-matlab">C=(I2-I1)./I2;
</pre><pre class="language-matlab">figure(1);plot3(lambda,d2,C);
figure(2);plot(lambda,C);
figure(3);plot(d2,C);
end
</pre>Travis/matlabcentral/answers/contributors/2222412-travistag:www.mathworks.de,2005:Question/1254182014-04-11T13:57:51Z2014-04-24T21:56:40Zextract matrix from matrix<p>sir i have image of size 256*256 and i want to extract 5*5 matrix from every 8*8 block of 256*256 image what is code for this...also i want to add zeros to all 5*5 blocks and make 5*5 to 8*8 matrix of the 256*256 image ..what is code for this</p>Jitesh Bhanushali/matlabcentral/answers/contributors/5171199-jitesh-bhanushalitag:www.mathworks.de,2005:Question/1270712014-04-24T21:54:48Z2014-04-24T21:54:48Zhow to find mse<p>sir how to find MSE of dft compressed image as idft is in complex form so we cant use</p><p>(original image)-(reconstructed image) as original image pixels are real..</p><p>can we use like (original image)-real(reconstructed image)</p>Jitesh Bhanushali/matlabcentral/answers/contributors/5171199-jitesh-bhanushalitag:www.mathworks.de,2005:Question/1270682014-04-24T21:42:37Z2014-04-24T21:54:20ZR2011B Command Window outputting every line that is executed in script<p>Hello recently MATLAB has been outputting every line that is executed in a script that i run. For example if I ran the script:</p><pre class="language-matlab">x = 1;
for i = 1:3
x = x+1;
if x == 4
x = 9;
end
end
</pre><p>I really want to eliminate this and go back to the default behavior
I would get the following lines in the command window</p><pre class="language-matlab">x = 1;
for i = 1:3
x = x+1;
if x == 4
x = x+1;
if x == 4
x = x+1;
if x == 4
x = 9;
end
end
</pre>Alexander/matlabcentral/answers/contributors/3520706-alexandertag:www.mathworks.de,2005:Question/1268662014-04-23T15:21:06Z2014-04-24T21:53:17ZHow to add text to a video in matlab?<p>hi, can someone help me on how to add text to a video that is running on matlab, my teacher told me its very simple and just 1 or 2 lines of code. i think you have to use the insertText function but im not sure how to do it. basically all i want to do is to write some text in certain frames of the video. it would be outputted in the subplot below. can someone please help me on this problem.</p><pre class="language-matlab">subplot(2, 2, 3);
imshow(Background);
title('Detecting Expression...', 'FontSize', fontSize)
</pre><p>thankyou</p>Anand/matlabcentral/answers/contributors/4730174-anandtag:www.mathworks.de,2005:Question/1270702014-04-24T21:51:28Z2014-04-24T21:51:28Zdwt based image compression<p>sir how we can do quantization in image compression using dwt??</p><p>how can we compress image using dwt?</p>Jitesh Bhanushali/matlabcentral/answers/contributors/5171199-jitesh-bhanushalitag:www.mathworks.de,2005:Question/1270662014-04-24T21:30:45Z2014-04-24T21:45:02ZHow to detected isolated/closed contours?<p>Hello. I'd like to know if there are any functions that I can use to detect detached and isolated closed contour lines. I've obtained the contour lines by using:</p><p>[C,h] = contourf(...)</p><p>But C gives location of points in contours of the same value, and I find it hard to sort out those which forms a close loop and those spread over the space domain. I wonder if there're any algorithms to detect closed contour / detached filament like those in the following image? (I use arrows to indicate some filaments of interest)</p><img src = "/matlabcentral/answers/uploaded_files/11828/Isolated_features.png"><p>Thanks for any kind help.</p>Upupaepops/matlabcentral/answers/contributors/2634145-upupaepopstag:www.mathworks.de,2005:Question/1270672014-04-24T21:31:48Z2014-04-24T21:31:48Zquantization in image compression using dft<p>sir which table is use for quantization in image compression using DFT??
as we use 8*8 jpeg quantization table to quantize.which is suitable for dft compression..</p><p>can we use Run Length Encoding in image compression using DFT?</p>Jitesh Bhanushali/matlabcentral/answers/contributors/5171199-jitesh-bhanushalitag:www.mathworks.de,2005:Question/1270652014-04-24T21:27:03Z2014-04-24T21:27:03Zis this code give me compression?<p>sir is this m file gives me compression??</p>Jitesh Bhanushali/matlabcentral/answers/contributors/5171199-jitesh-bhanushalitag:www.mathworks.de,2005:Question/1270642014-04-24T21:22:45Z2014-04-24T21:22:45Zget object rotation by matlab<p>hi every body
i'm working on a image processing project and in one of its part there are three object which must get their angle(rotation). i would be appreciate to help me.
thanks a lot.</p>sina dfhfdh/matlabcentral/answers/contributors/2867726-sina-dfhfdhtag:www.mathworks.de,2005:Question/1270622014-04-24T04:00:00Z2014-04-24T21:21:02ZDoes the Statistics Toolbox support hybrid kernels to train Support Vector Machines in MATLAB?<p>I see that the Statistics Toolbox R2014a provides a function called "svmtrain" to train an SVM. What kernels can I use to train it on my data? Can I use a hybrid kernel, i.e. a kernel made by mixing, for example, a linear kernel and a polynomial kernel?</p><p>Thanks!</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1270082014-04-24T14:52:05Z2014-04-24T21:19:34ZMahalanobis distance between a point and a line<p>hi all,</p><p>I am wondering if fellow reader can help me out to find a proper paper to calculate the Mahalanobis distance between a line and a point. I have found paper discussing "whitening transform" used to compute the Mahalanobis distance between a plane and a point, but could not find anything to for line/point.</p><p>mainly working in 3D.</p><p>thanks,</p>Elvis Chen/matlabcentral/answers/contributors/2513811-elvis-chentag:www.mathworks.de,2005:Question/1270602014-04-24T20:58:46Z2014-04-24T21:10:15ZMATLAB Coder and sparse matrix<p>Hi all,</p><p>I found MATLAB Coder to be fancy and can speedup the Matlab codes much in some cases by converting Matlab codes into C/C++/MEX. But it seems that it does not support sparse matrix, for example, the function sparse(). However, sparse matrix is used in my codes as the dimension of matrix can be huge and it is indeed sparse... Does anyone have idea about this problem and how can I overcome this? Many thanks!</p>ryan/matlabcentral/answers/contributors/4268812-ryantag:www.mathworks.de,2005:Question/1270612014-04-24T21:00:37Z2014-04-24T21:16:33ZLow performance of neural network using logsig for output layer<p>Hi.</p><p>I have a binary classification problem and using “newff” for it. There is a single output in my neural network structure. If this outputs is equal or greater than 0.5 it belongs to class 1 and if smaller than 0.5 it belongs to class 0. So my targets for every sample is 0 or 1. Besides it I am normalizing data with “Mapstd” or “mapmaxmin”.</p><p>When I use “tansig” transfer function for hidden layer(s) and “purelin” for output, classification accuracy of network is good but when I change “purelin” to “logsig” the classification accuracy is really bad (near 0.5) and the classification accuracy is 50% or 53~56%.
What is the problem? (I'm using "Trainlm" without any normalization for outputs)</p><p>PS.</p><p>When I checked outputs after training, many of them are greater than 0.5 .</p><p>Thanks.</p>Jack/matlabcentral/answers/contributors/5193869-jacktag:www.mathworks.de,2005:Question/1270382014-04-24T18:18:25Z2014-04-24T20:59:57ZHow to plot not only the result but also the derivatives using the ode45 function?<p>Hello there, I have already successfully run a code for the simulation of the deflection of beams under different loadings. I used the ode45 for Initial value Problems and bvp4c for Boundary conditions. So I generated graphics such as the one below:</p><img src = "/matlabcentral/answers/uploaded_files/11821/grafico.jpg"><p>I want now to plot not only the deflection y(x) but also dy/dx and d^2y/dx^2 on the same graphic and I am having difficulties to actually do it. Hope someone can give me a hint. All I want is to plot the function I inserted on the MyFunctionL and MyFunctionNL and it´s derivative together with the result. One of the codes I generated is below:</p><pre class="language-matlab">function def1= def1(F,L)
%--------------------------------------------------------------
% Deflection
% F [N] und L [mm]
% EI N*mm^2
% y[mm]
%--------------------------------------------------------------
global Fg Lg EI;
Fg = F;
Lg = L;
Em=200*10^9
</pre><p>%This part below is not relevant for the question</p><pre> for i=1:3
if i==1
b=0.055
h=0.1
Im=b*h^3/12
end
if i==2
Im=2.5175*10^(-6)
end
if i==3
re=0.065
ri=0.060
Im=pi/4*((re^4)-(ri^4))
end</pre><pre class="language-matlab">%As Im is in m^4 we are converting EI to N*mm^2 by multiplying it by (1000^2).
EI=(Em*Im)*(1000^2)
</pre><p>$Now this part below is.</p><pre class="language-matlab">%Start point
x0 = [0 0];
%Längenintervall
xspan = [0 L];
%Call Solver -> Linear
[x y] = ode45(@MyFunctionL,xspan, x0);
%Plot result
figure
plot(x,y(:,1));
if i==1 title('y(x) in a Retangular Profile')
end
if i==2 title('y(x) in a Iprofile(IPE 100)')
end
if i==3 title('y(x) in a Round hollow section')
end
set(gca,'ydir','reverse')
xlabel('[mm]');
ylabel('[mm]');
hold on;
%Call Solver -> NonLinear
[x z] = ode45(@MyFunction,xspan, x0);
%Plot result
plot(x,z(:,1),'-r');
set(gca,'ydir','reverse')
end
return
</pre><pre class="language-matlab">%---------------------------------------------------------------
function dy = MyFunctionL(x,y)
global Fg Lg EI;
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = (Fg/EI)*(Lg - x);
return
</pre><pre class="language-matlab">function dy = MyFunction(x,y)
global Fg Lg EI;
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = (Fg/EI)*(Lg - x)*(1+y(2)^2)^1.5;
return
</pre>Daniel Clemente/matlabcentral/answers/contributors/4812059-daniel-clementetag:www.mathworks.de,2005:Question/1270562014-04-24T20:27:42Z2014-04-24T20:58:02ZUnable to stop Arduino Bluetooth data pulling<p>Hi,
I would like to pull information from the arduino through bluetooth and be able to stop the data when a figure is closed. However, once I close the figure the code continues to run, I'm even unable to Ctrl+C in the command and the only way to stop the program is to close matlab.</p><p>Any ideas? Thank you</p><pre class="language-matlab">clear
clc
%fclose(instrfind)
</pre><pre class="language-matlab">%Open Serial COM Port
s = Bluetooth('RNBT-AD09',1);
fopen(s);
fid = fopen( 'Arduino.txt', 'w' );
</pre><pre class="language-matlab">g = figure;
</pre><pre class="language-matlab">pause(.5)
</pre><pre class="language-matlab">while ishandle(g) %Loop when Plot is Active
</pre><pre> dat = fscanf(s) </pre><pre> fprintf(fid, '%s\r\n', dat);</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">fclose(fid);
fclose(instrfind);
</pre>Vincent I/matlabcentral/answers/contributors/2916301-vincent-itag:www.mathworks.de,2005:Question/1270582014-04-24T20:40:17Z2014-04-24T20:55:35ZHow can I encrypt voice inside image?<p>How can I encrypt voice inside image using matlab?
plz help me
i want to encrypt a sound file inside image ?</p>Ali ali/matlabcentral/answers/contributors/4305185-ali-alitag:www.mathworks.de,2005:Question/1270042014-04-24T14:43:45Z2014-04-24T20:54:56ZReceived signal not on sampling time <p>Hello all,</p><p>I have a sequence d of length N samples each of duration Ts. The channel I have will scale the received samples by a factor (1+a), which means that the received samples will not be on multiples of Ts but on multiples of Ts*(1+a). How can I capture this effect in MATLAB?</p><p>Thanks in advance</p>S. David/matlabcentral/answers/contributors/2168282-s-davidtag:www.mathworks.de,2005:Question/1270592014-04-24T20:42:19Z2014-04-24T21:02:10Zhow to export large matlab toolbox output results to workspace for viewing <p>Please I need syntax on how I can export the results from a GA tool box that is too large to be displayed on it to workspace i.e using matlab prompt so that I can view all the results. I have it on my matlab prompt as: "The variable 'optimresults' has been created in the current workspace". But don't know how to get the results displayed for viewing.
Thanks</p>segun/matlabcentral/answers/contributors/3844616-seguntag:www.mathworks.de,2005:Question/1270542014-04-24T20:11:24Z2014-04-24T20:38:42ZHow can i cipher sound in image ?<p>How can i cipher sound in image using matlab ?
plz help</p>Ali ali/matlabcentral/answers/contributors/4305185-ali-alitag:www.mathworks.de,2005:Question/1270492014-04-24T19:46:32Z2014-04-24T20:36:35Zno error nor output<p>hello guys,
m working on image steganography my program is ready n also working..
but m getting some problems when i create a GUI for it...
at the instant there are no any error but no any output from it..
m not getting the solution..
help me to find the solution..
thanks a lot in advance</p>A160791/matlabcentral/answers/contributors/5220092-a160791tag:www.mathworks.de,2005:Question/1270512014-04-24T19:56:16Z2014-04-24T20:35:50ZFor Loop using two variables<p>I am new to MATLAB and I am trying to use a for loop using two variables. The question is:
Generate a MATLAB program to compute and plot the Fermi function, f(E), and 1- f(E)
versus ΔE = E-Ef for values of ΔE that is over the range of -0.5eV ≤ ΔE ≤ 0.5eV for
varying temperature settings where Temperature = 150, 250, 350, 450 and 550K.</p><p>The code I have written is:</p><pre class="language-matlab">k = 1.3806488*10^-23; %boltzman constant
format shortEng
for dE = linspace (-0.5, 0.5, 5), T1 = 150:100:550
fE = 1/(1+exp(dE/(k*T1))) %Fermi Function
fE2 = 1-fE
end
</pre><p>However, it its only displaying T1</p>Myles Wright-Walker/matlabcentral/answers/contributors/5076958-myles-wright-walkertag:www.mathworks.de,2005:Question/1269192014-04-23T23:03:31Z2014-04-24T20:34:04ZHelp with conditional statements<p>Dear all,</p><p>I am new to matlab and I am trying to solve the following question... I already tried the help function and google, but I am kind of stuck.
The question is: A student passes the exam if the grade on each of the four tests is greater or equal to 6. If this requirement is not met (that is, at least one of the four tests was graded with 5 or less), the student can pass the exam, performing an additional resit test, if the average score (on the four tests) is greater or equal to 6, otherwise the exam is failed.
This is as far as I got...
(The first column is the ID of the student, columns 2-4 are restults of individual tests)</p><p>Scores= [1 7 10 9 9;2 6 8 7 6;3 9 10 10 9;4 4 7 6 5;5 7 8 8 9; 6 8 10 9 10; 7 5 6 7 6; 8 8 9 7 6; 9 7 8 8 5; 10 8 10 8 10]</p><p>ScoresMean=Scores;
ScoresMean(:,1)=[];
mean(ScoresMean,2) % gives mean scores (per row)</p><p>ScoresNoID=Scores;
ScoresNoID(:,1)=[];
if ScoresNoID(1,:)>6
disp('pass')
elseif ScoresNoID(1,:)<6
disp('fail')
if ScoresNoID(1,:)<6 = mean(ScoresNoID,2)>6 % this might be wrong...
disp('resit')</p><p>as you can see, I am already stuck at the beginning. I would appreciate any help!</p>Marcel/matlabcentral/answers/contributors/5279293-marceltag:www.mathworks.de,2005:Question/1270532014-04-24T20:03:07Z2014-04-24T20:31:29ZMatrix manipulation depending on maximum and minimum values of existing matrix. <p>This first matrix table1 contains normalized values for 5 names.I need to perform some operations on this matrix and I have to obtain second matrix as shown in table2.</p><p>Diagonal elements of table2 should obtained by giving rank(ordinal value) to each value.That means highest element is given 5th rank and next 4th 3rd and so on.</p><p>Remaining elements of table obtained by giving rank to each value starting from 4 because only 4 elements remaining. Because already we are given rank to diagonal elements.Zero should be kept as it is.Suppose take table1 as A matrix and table2 as B matrix.</p><p>OPERATION1:For diagonal elements</p><pre> B(1,1)=5(first largest element)
B(2,2)=1(5th largest element)
B(3,3)=4(4th largest element)
B(4,4)=2(2nd largest element)
B(5,5)=3(3rd largest element)
OPERATION2:For remaining elements</pre><pre> B(1,2)=3(2nd largest element)
B(1,3)=4(1st largest element)
B(1,4)=1(4th largest element)
B(1,5)=2(3rd largest element)
And so on..</pre><pre> Table1:
BASAVARAJ MANOJ NATESH VIJAY GOWDA
BASAVARAJ 1.0000 0.2727 0.3182 0.0455 0.2727
MANOJ 0.2727 0.2727 0 0 0
NATESH 0.3182 0 0.4545 0.1818 0
VIJAY 0.0455 0 0.1818 0.2727 0.0909
GOWDA 0.2727 0 0 0.0909 0.3636
Table2:
BASAVARAJ MANOJ NATESH VIJAY GOWDA
BASAVARAJ 5 3 4 1 2
MANOJ 4 1 0 0 0
NATESH 4 0 4 3 0
VIJAY 2 0 4 2 3
GOWDA 4 0 0 3 3
</pre>prashanth/matlabcentral/answers/contributors/4938605-prashanthtag:www.mathworks.de,2005:Question/1269162014-04-23T22:41:51Z2014-04-24T20:26:37ZCan movegui in openfig be disabled?<p>I have a dual-monitor setup with my left (primary) monitor rotated into a portrait orientation, so that the monitor width is only 1024 pixels. I'm trying to run a program that loads a GUI figure that is 1300 pixels wide. When I run the program, the figure gets resized to be only 1014 pixels wide. The culprit appears to be a call to <tt>movegui(fig(n),'onscreen')</tt> in <tt>openfig</tt> , which gets called to open the .FIG file. I don't want the figure to be resized; in my extended desktop, the figure would be just fine spilling into the other monitor. Plus, the figure's children's units are <i>not</i> normalized, so important controls are being chopped off the right side of the figure.</p><p>For now, I've commented-out the call to <tt>movegui</tt> on line 109 of <tt>openfig</tt> . I'm always reluctant to modify Mathworks-supplied files, so I was looking for an alternate method of keeping MATLAB from resizing the figure.</p>Johnny B/matlabcentral/answers/contributors/58986-johnny-btag:www.mathworks.de,2005:Question/1269842014-04-24T12:16:35Z2014-04-24T20:26:33ZGiven a colour image containing a variety of shapes your MATLAB-based system /algorithm should be able to detect and classify/identify the distinct shapes. 1. Circle2. Square3. Triangle4. Rectangle5. Pentagon6. Hexagon7. Ellipse8. Octagon<pre class="language-matlab">A binary (black and white) image with all the shapes in white and background in black. In addition, a number, indicating the classification according to the above numbered descriptors, must be inserted in the centre of each shape. A value of zero (0) should be placed in the centre of the shape that does not fall into one of the above classifications.
2. A colour image with each shape displayed in a pre-assigned colour i.e. instead of inserting a number into each shape they can be displayed in different colours e.g. blue for all circles and yellow for all hexagons. The colour black must be assigned to all unclassified shapes. The background of this image must be white.
3. A binary (black and white) image with all the shapes in white and background in black. In addition, a number, indicating the area (in m2 and 3 decimal places), must be inserted in the centre of each shape in the image. A text value of "N/A" should be placed in the centre of the shape that does not fall into one of the above classifications. Assume each pixel represents a distance of 1 mm.
</pre>keagan/matlabcentral/answers/contributors/5261051-keagantag:www.mathworks.de,2005:Question/1270412014-04-24T18:31:50Z2014-04-24T20:20:58Zdaq interface to mcc device<p>I bought a 16-channel USB-3105 D/A from Measurement Computing Corp. I installed the MCC software, plugged in the USB-3105, ran Instacal (MCC device conficuration/registration), and (since mcc is only accessible through the legacy interface)installed 32-bit Matlab (R2013a) in addition to 64-bit R2013b that I already had installed.</p><p>I'm on a Dell T5500 running 64-bit Win 7 Pro. SP1.</p><p>Matlab command daqhwinfo does not find any 'mcc' devices. Any suggestions?</p>Alan Finn/matlabcentral/answers/contributors/5281935-alan-finntag:www.mathworks.de,2005:Question/1270132014-04-24T15:30:55Z2014-04-24T20:15:30ZHow can I eliminate unwanted zeros from a matrix?<p>e.g I want to make this:</p><p>1,1,1,1,0,0</p><p>1,1,0,0,0,0</p><p>1,0,0,0,0,0</p><p>1,1,1,1,1,0</p><p>into this:</p><p>1,1,1,1</p><p>1,1</p><p>1</p><p>1,1,1,1,1
...</p><p>Thanks</p>Mark/matlabcentral/answers/contributors/4647592-marktag:www.mathworks.de,2005:Question/1270522014-04-24T20:01:00Z2014-04-24T20:01:00Zneed help for developing a signal<p>As a part of that, an arbitrary</p><p>speech signal has been chosen which is 16 kHz sampled and 16 bits quantized for each sample.
Adaptive CS and CS sampling and reconstruction are performed frame by frame, with a frame
length of N=320 samples</p><p>please find my files attached. Not getting the desired output. Can anyone please help.</p>Manipal Reddy Kuchakuntla/matlabcentral/answers/contributors/4738954-manipal-reddy-kuchakuntlatag:www.mathworks.de,2005:Question/1269222014-04-23T23:57:28Z2014-04-24T20:00:20ZOpen multiple .WTD files and create a matrix to perform calculation <p>Hi,</p><p>I have 39 .wtd files (see a sample of attached file) and need to read the 1st and 4th columns. Then I need to create a data matrix [0001(:,4) 0002(:,4)...0039(:,4)]. Please help me to create this.</p><p>See the 0001.wtd attached.</p><p>Thanks for any help in advance.</p>Damith/matlabcentral/answers/contributors/5131512-damithtag:www.mathworks.de,2005:Question/768552013-05-24T07:53:10Z2014-04-24T19:58:52ZConvergence failure for consistent initial conditions using 'decic' function<p>I have a set of highly non-linear, implicit ODEs and I need to use an implicit solver such as ode15i to integrate the equations. In order to use ode15i, you must acquire consistent initial conditions for the derivatives and dependent variables. MATLAB has a built in function, 'decic', that can calculate the consistent ICs, however, when I execute the function, I get the following error:</p><p>"Convergence failure in DECIC."</p><p>Now, generally, if your equations are inconsistent, 'decic' will give you a warning asking you to free up some of the variables of Y0. But in my case, I don't think I have inconsistent equations, but I'm not really sure why the convergence failure error is showing up and how to fix it. There isn't a whole lot of documentation online about it. I'm including a self-contained code below with all the necessary values to run it. Since this is a very specific issue, I can't really shorten the code or give a simplified example. Any suggestions/help is appreciated.</p><pre> function [Y0,YP0] = droplet_momentum_IC(theta,K,G,P,Z0,Y0)</pre><pre> YP0 = [0;0;0;0];
[Y0,YP0] = decic(@momentum,Z0,Y0,[1;1;1;1],YP0,[0;0;0;0]);</pre><pre> function RES = momentum(z,y,yp)</pre><pre> RES = zeros(4,1);</pre><pre> %Entrained Total Velocity
Ve = sin(theta)*(0.5*z*yp(4) + y(4));</pre><pre> %Total Relative Velocity
Urs = sqrt((y(1) - y(4))^2 + (y(2) - Ve*cos(theta))^2 + (y(3))^2);</pre><pre> %Coefficients
PSI = K*Urs/y(1);
PHI = P*Urs/y(1);</pre><pre> %Liquid Axial Velocity
RES(1) = yp(1) - PSI*sign(y(1) - y(4))*(1 + (1/6)*(abs(y(1) - y(4))*G)^(2/3));</pre><pre> %Liquid Radial Velocity
RES(2) = yp(2) - PSI*sign(y(2) - Ve*cos(theta))*(1 + (1/6)*(abs(y(2) - ...
Ve*cos(theta))*G)^(2/3));</pre><pre> %Liquid Tangential Velocity
RES(3) = yp(3) - PSI*sign(y(3))*(1 + (1/6)*(abs(y(3))*G)^(2/3));</pre><pre> %Gaseous Axial Velocity
RES(4) = yp(4) - (1/z/y(4))*((PHI/z)*sign(y(1) - y(4))*(1 + ...
(1/6)*(abs(y(1) - y(4))*G)^(2/3)) + Ve*Ve - y(4)*y(4));</pre><pre> end</pre><pre> end</pre><p>Where the above function can be called with the following commands:</p><pre> theta = 0.48;
K = -8.99*10^(-4);
G = 251.6818;
P = 0.1780;
Y0 = [0.7884;0.6145;0.0272;0.0079];
Z0 = 10.4105;
[Y0,YP0] = droplet_momentum_IC(theta,K,G,P,Z0,Y0);</pre><p>I should note that even if you allow 'decic' to change alter both Y0 and YP0 (essentially giving it free reign to choose arbitrary values that satisfy those equations, you still get the same convergence error).</p>Ali/matlabcentral/answers/contributors/4312327-alitag:www.mathworks.de,2005:Question/1270442014-04-24T18:54:46Z2014-04-24T19:55:22ZHow to print ( ) in mathlab<p>Hello,</p><p>I am running a matlab code which writes output to an excel file.</p><p>I would like to write * <i>each output value inside a parenthesis</i> * . Is there an easy way to do this?</p><p>Code I use:</p><pre class="language-matlab">results = zeros(5,10);
</pre><pre class="language-matlab">for i = 1:10
results(1,i)= avxt(i);
results(2,i)= stdxt(i);
results(3,i)= avxtl(i);
results(4,i)= stdxtl(i);
results(5,i)= afxtPI(i);
end
</pre><pre class="language-matlab">xlswrite('output.xlxs', results, 'sheet1', 'A1:H5'
</pre><p>Thanks.</p>dav/matlabcentral/answers/contributors/3693465-davtag:www.mathworks.de,2005:Question/1270452014-04-24T19:02:12Z2014-04-24T19:55:19ZHow to mod the coding to get Crout LU Decomposition with 8x8 matrix .<p>Hi , I have tried modifying the coding below to suite my problem which is Crout LU Decomposition with 8x8 matrix .</p><p>code :</p><pre class="language-matlab">function [L, U]=LUdecompCrout(A)
</pre><pre> [R, C]= size(A);
for i=1:R
L(i,1)=A(i,1);
U(i,i)=1;
end
for j=2:R
U(1,j)=A(1,j)/L(1,1);
end
for i=2:R
for j=2:i
L(i,j)=A(i,j)-L(i,1:j-1)*U(1:j-1,j);
end</pre><pre> for j=i+1:R
U(i,j)=(A(i,j)-L(i,1:i-1)*U(1:i-1,j))/L(i,i);
end
end</pre><p>Thanks in advance</p>narutorao/matlabcentral/answers/contributors/5282007-narutoraotag:www.mathworks.de,2005:Question/1259132014-04-16T01:11:15Z2014-04-24T19:55:07ZInquiry on Johansen method (jcitest function)<p>Dear all,</p><p>I've got a quick question with regard to the code segment in</p><p><a href = "http://www.mathworks.co.kr/kr/help/econ/identify-cointegration.html#btdp660">http://www.mathworks.co.kr/kr/help/econ/identify-cointegration.html#btdp660</a></p><p>>></p><p>load Data_Canada
Y = Data(:,3:end); % Interest rate data
[~,~,~,~,reg] = egcitest(Y,'test','t2');
c0 = reg.coeff(1);
b = reg.coeff(2:3);
beta = [1; -b];</p><p>[~,~,~,~,mles] = jcitest(Y,'model','H1*');
BJ2 = mles.r2.paramVals.B;
c0J2 = mles.r2.paramVals.c0;</p><p>% Normalize the 2nd cointegrating relation with respect to
% the 1st variable, to make it comparable to Engle-Granger:
BJ2n = BJ2(:,2)/BJ2(1,2);
c0J2n = c0J2(2)/BJ2(1,2);</p><p>% Plot the normalized Johansen cointegrating relation together
% with the original Engle-Granger cointegrating relation:</p><p>COrd = get(gca,'ColorOrder');</p><p>plot(dates,Y*beta-c0,'LineWidth',2,'Color',COrd(4,:))
hold on
plot(dates,Y*BJ2n+c0J2n,'--','LineWidth',2,'Color',COrd(5,:))
legend('Engle-Granger OLS','Johansen MLE','Location','NW')
title('{\bf Cointegrating Relation}')
axis tight
grid on
hold off</p><p>>></p><p><b>**********************</b>
Results Summary (Test 1)</p><p>Data: Y
Effective sample size: 40
Model: H1*
Lags: 0
Statistic: trace
Significance level: 0.05</p><p>r h stat cValue pValue eigVal
----------------------------------------
0 1 38.8360 35.1929 0.0194 0.4159
1 0 17.3256 20.2619 0.1211 0.2881
2 0 3.7325 9.1644 0.5229 0.0891</p><p>>></p><p>According to the test result, it implies that there is only one cointegrating relation. Yet there exist two columns in BJ2 which means that only one column of two is a candidate for the single cointegrating relation.</p><p>At this point, the code simply assumes that it is the second column for the relation, which justifies the following part.</p><p>>></p><p>% Normalize the 2nd cointegrating relation with respect to
% the 1st variable, to make it comparable to Engle-Granger:
BJ2n = BJ2(:,2)/BJ2(1,2);
c0J2n = c0J2(2)/BJ2(1,2);</p><p>>></p><p>Now my question is how do you know the cointegrating relation is the second column, not the first one?</p><p>Please let me know.</p><p>Thanks in advance!</p>Hyungseok Hahm/matlabcentral/answers/contributors/2095387-hyungseok-hahmtag:www.mathworks.de,2005:Question/1270502014-04-01T04:00:00Z2014-04-24T19:49:07ZWhat are the system requirements for MATLAB Online?<p>What are the system requirements for MATLAB Online?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1269912014-04-24T13:19:55Z2014-04-24T19:39:52ZRunning Simulink in Parellel<p>I have a question regarding running Simulink in a parfor loop on a single (local) machine. Right now the program runs fine in a regular for loop, but in converting it over for parellel processing, I am running into a problem of transparency on a m-file inside the loop. Unfortunately, switching this non-function m-file to a function would be extremely cumbersome, as there are hundreds of variables defined in this file that need to be passed in and out of any setup function, since the Simulink model needs to see all the variable names as they currently are. This also makes converting these variables into a data structure also off the table, as I would just have to unpackage the structure back into its original variable names in the parfor loop.</p><p>Thus, my question is, is there a more efficient way of writing this script short of just pasting all the individual code into the text of the loop? I can do this, but that adds hundreds if not thousands of lines of code to the file. For the most part, the scripts to be run either set variables or else load mat files (which I know need to be handled differently in parfor loops). Otherwise, they are all completely ready to be run in parallel.</p><p>Additionally, I seem to be running into the problem that the variables I define in the parfor loop are not being seen by the simulink model. The variables are defined in both the loop and outside it, so I'm not sure why this is a problem (I tried defining them just outside the loop, and that did not work). Some of the varibles are modified by the simulation, and some are not. Any help on this would also be appreciated.</p>Matthew/matlabcentral/answers/contributors/4014153-matthewtag:www.mathworks.de,2005:Question/1270362014-04-24T17:58:19Z2014-04-24T19:29:18Zhow can I access internal signals from one model?<p>how can I access internal signals from one model? i have to read some internal signals from one model. is it possible this?</p><p>thank you</p>Gabriela/matlabcentral/answers/contributors/4511954-gabrielatag:www.mathworks.de,2005:Question/1269402014-04-24T06:52:36Z2014-04-24T19:20:25Z[MATLAB GUI] How can I add a string to the last line in multiline EditText?<ul><li>Hi all,</li><li>I often use this way to add a string to the last line in multiline editText:</li><li>Example: The before editText: (handles.txtLine)</li><li>"line 1</li><li>line 2</li><li>line 3"</li><li>and i want to add string "line 4" to it. So i do:</li><li>msg = get(handles.txtLine,'string');</li><li>msg_i = sprintf('\nline 4');</li><li>msg = [msg msg_i];</li><li>set(handles.txtLine,'string',msg)</li><li>--> Result: " line 1</li><li>line 2</li><li>line 3</li><li>line 4"</li><li>I want to ask: "Are there other methods to do the same function?"</li><li>Thanks advance!</li><li></li></ul>Luong Son/matlabcentral/answers/contributors/4828893-luong-sontag:www.mathworks.de,2005:Question/1269992014-04-24T14:14:52Z2014-04-24T19:17:45ZCreating and exporting a 3D plane from already known x,y,z values <p>Hey all,</p><p>I'm getting rather stressed here! I'm new to Matlab but have been told to use it for my thesis.
I need to create a 3D plane from x,y and z values I already have stored in excel. I can create a plot fine with cftool but I am finding it hard to export this plane into Arcgis.</p><p>So, can anybody help with this? Either with exporting the plane in cftool or does anyone have any other methods by which I can create and export a plane?</p><p>I am using Matlab R2012a and Arcmap10.</p><p>Thanks</p>Katie/matlabcentral/answers/contributors/5227064-katietag:www.mathworks.de,2005:Question/1253282014-04-10T19:59:35Z2014-04-24T19:14:17ZEstimate state-space model parameters using Parameter Mapping function<p>Hi everyone,</p><p>I am currently having a set of differential equations, namely</p><p>dB = - mu*S,</p><p>dS = mu*S - beta*S*I + gamma*I - nu_s*S,</p><p>dI = beta*S*I - gamma*I - alpha*I - nu_i*I,</p><p>dP = nu_s*S + nu_i*I, and</p><p>dD = alpha*I,</p><p>as well as a dataset, containing observations of the states of B, S, I, P, and D.</p><p>I am trying to estimate the parameter [mu, beta, gamma, alpha, nu_s, nu_i], using the econometrics toolbox approach to estimate state space models with unknown parameters.</p><p>The state transition matrix A, with unknown parameter denoted as NaN is</p><pre> A = [0 NaN 0 0 0;...
0 NaN NaN 0 0;...
0 NaN NaN 0 0;...
0 NaN NaN 0 0;...
0 0 NaN 0 0]</pre><p>In accordance with the documentation, I formulated the parameter mapping function:</p><pre class="language-matlab">function [A,B,C,D,Mean0,Cov0,StateType] = timeInvariantParamMap(params)
A = [0 -params(1) 0 0 0;...
0 params(1)-params(3) params(4)-params(2) 0 0;...
0 0 params(2)-params(4)-params(5)-params(6) 0 0;...
0 params(3) params(6) 0 0; 0 0 params(5) 0 0];
B = [params(7) 0 0 0 0;...
0 params(8) 0 0 0;...
0 0 params(9) 0 0;...
0 0 0 params(10) 0;...
0 0 0 0 params(11)];
C = eye(5);
D = zeros(5,1);
Mean0 = [30161, 3, 0, 0, 0]; % First observed values
Cov0 = [];
StateType = [0, 0, 0, 0, 0];
end
</pre><p>But I don't know, how to incorporate the term beta*S*I, so a state variable in the transition matrix. The current approach just ignores that fact</p><p>Since the econometrics toolbox is a quite new tool, I was not able to find any related Q&As.</p><p>I would really appreciate any hint on my problem, as well as additional information.</p><p>Best regards,</p><p>David</p>David/matlabcentral/answers/contributors/3123854-davidtag:www.mathworks.de,2005:Question/1270462014-04-01T04:00:00Z2014-04-24T19:09:07ZWhy do I get a license manager error -194 when I start MATLAB?<p>Why do I get a license manager error -194: INVALID error code when I start MATLAB?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1266672014-04-22T12:34:43Z2014-04-24T19:09:01Zfrom workspace to scope plot<pre> Hi all </pre><p>I want to show matlab graph in scope how can i do this ?</p><p>please give me answer</p>mutah/matlabcentral/answers/contributors/3452108-mutahtag:www.mathworks.de,2005:Question/1270472014-04-24T19:06:47Z2014-04-24T19:08:52ZReturn the cursor to the command window after dbstop?<p>Is there a way to return the cursor to the command window after dbstop by default? I am aware that I can toggle between the editor and the command window with keyboard shortcuts, but in the interest of prevent preventing stray keystrokes, I would prefer to change the default cursor location. Thank you.</p>Burke/matlabcentral/answers/contributors/2004536-burketag:www.mathworks.de,2005:Question/1270392014-04-24T18:18:57Z2014-04-24T18:58:40ZForced vibration response Ode45 <p>I am suck on a question for an assignment. I can not get matlab to work the following function I keep getting error messages.</p><p>function f=t</p><p>F=940*sin(10*pi*t);</p><p>k=50000;</p><p>damping=0.05;</p><p>r=3.224;</p><p>x(1+t)=(F/k)/sqrt((1-R^2)^2+4*(damping^2)*r^2);</p><p>t=1/(10*pi);</p><p>[x,t]=ode45('f',[T,T*50],0);</p><p>plot(x)</p>Ryan/matlabcentral/answers/contributors/5271401-ryantag:www.mathworks.de,2005:Question/1267722014-04-23T04:23:58Z2014-04-24T18:58:13Z- swapping a matrix <p>a =</p><pre> 1 3 5 6 7
2 3 2 3 2
5 6 7 8 7</pre><p>b=</p><pre> 5 2 1 3 7
6 8 2 3 1
5 7 8 6 3</pre><p>how to swap b to a.</p><p>ans=</p><pre> 1 3 5 6 7
2 3 2 3 2
5 6 7 8 7</pre>Anusha/matlabcentral/answers/contributors/4711752-anushatag:www.mathworks.de,2005:Question/1269932014-04-24T13:21:13Z2014-04-24T18:40:39ZIs there an "isdeploy" function for matlab coder?<p>my script is a little diffrent for c++ and matlab..
I need to know who is calling the lib for that.</p><p>I know that exe files that was made by matlab compiler has the isdeploy function, but it doesnt work for dll generated from MATLAB coder..
Is there something else for that?</p>ayana/matlabcentral/answers/contributors/4401059-ayanatag:www.mathworks.de,2005:Question/1270422014-03-25T04:00:00Z2014-04-24T18:34:07ZWhy do I see an error stating: "Could not create "." - unzip operation cancelled." when starting the MATLAB R2014a installer on Windows?<p>When launching the MATLAB R2014a installer on Windows, the Windows Self-Extractor fails with an error stating "Could not create "." - unzip operation cancelled." How can I resolve this issue?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1270402014-04-24T18:24:20Z2014-04-24T18:24:20ZSaving error when installing MLE+<p>Hi,</p><p>I am trying to install MLE+, however after I select EnergyPlus and Java folders I am getting the following errors in the MATLAB command window (BTW my operating system is Windows 8.1):</p><p><b>Error using save
Unable to write file gui\eplusPath.mat: permission denied.</b></p><p><b>Error while evaluating uicontrol Callback*</b></p><p>I contacted MLE+ developers and they told me that I have permission issues in Matlab, and therefore I cannot save my project settings.</p><p>Please could you help me solve this?</p><p>Many thanks!</p>Miroslava Kavgic/matlabcentral/answers/contributors/3858515-miroslava-kavgic