https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-10-13T09:15:43Ztag:www.mathworks.com,2005:Question/2482992015-10-13T05:36:37Z2015-10-13T09:14:08ZSolving a system of differential equation numerically but with constants<p>Hello,</p><p>I am asking this question before I buy MATLAB to make sure that I can get a solution of a problem (so that I won't be wasting money). I have never used MATLAB before.</p><p>I am currently needing a numerical solution to a system of differential equation for a certain phenomenon I am currently working on. However, the problem is when I look through google, most question involves a system of differential equation with constants that are defined apriori (like 3*x^2 instead of a*x^2). I am using the system of differential equation to fit certain experimental data I have achieved so that I can figure out the constants that have important meaning to the phenomenon. Therefore, I have no idea what value the constants take.</p><p>The system of differential equation I have set up looks like this:</p><p>w(t) = a*exp(-t/b)</p><p>dx(t)/dt = c*w(t) + d*y(t) + e*z(t) - (1/f)*x(t)</p><p>dy(t)/dt = g*x(t) + h*y(t) + i*z(t) - (1/j)*y(t)</p><p>dz(t)/dt = k*x(t) + l*y(t) - (1/m)*z(t)</p><p>where x(0) = y(0) = z(0) = 0, dx(0)/dt = dy(0)/dt = dz(0)/dt = 0, and all the constants from a to m is above 0.</p><p>There are four differential equation and four yet-to-be-known equation, so I think this is theoretically solvable. However, each equations are recursive (am I using this term right?) and I cannot do this by hand and nor could a freeware software that tried to solve this analytically.</p><p>I am expecting a solution where each equation consists of variable (t) and constants combined in an arithmetic way.
Is this possible in MATLAB?</p><p>I really have no background in mathematics. Even worse, I learned almost everything in Japanese so I do not know the correct translation of tehcnical terms. Also, my English is mediocre at most. I apologize for my inability to effectively explain what I am trying to explain.</p><p>Thank you.</p>Hayaohttps://www.mathworks.com/matlabcentral/profile/authors/7105253-hayaotag:www.mathworks.com,2005:Question/2483242015-10-13T08:35:42Z2015-10-13T09:12:49ZConditional textscan - How to select certain lines from a file <p>Hi there, I would like to read information from a file into an array for later use. Only certain rows of that file are supposed to be read in, namely rows for which the second column starts with 'S1' and is followed by two random digits. I'm having trouble with this conditional textscan. Here is the code for reading in the file (note that it starts with 13 lines that are not in column format, hence the "headline" codes at the beginning). I basically want the varibales Postion, Length, Channel etc only to be read in for lines that meet the regex condition.</p><pre class="language-matlab">dataFileName=strcat('EEG_Anne_',int2str(pNumber),'.vmrk');
fid = fopen(dataFileName);
headline1=fgets(fid);
headline2=fgets(fid);
headline3=fgets(fid);
headline4=fgets(fid);
headline5=fgets(fid);
headline6=fgets(fid);
headline7=fgets(fid);
headline8=fgets(fid);
headline9=fgets(fid);
headline10=fgets(fid);
headline11=fgets(fid);
headline12=fgets(fid);
headline13=fgets(fid);
C = textscan(fid, '%s%s%d%d%d','Delimiter',',');
Stimulus=C{2};
if regexp(Stimulus{i},'S1\d*'),
Type=C{1};
Position=C{3};
Length=C{4};
Channel=C{5};
end
fclose(fid);
</pre>Anne Mickanhttps://www.mathworks.com/matlabcentral/profile/authors/7082710-anne-mickantag:www.mathworks.com,2005:Question/2480352015-10-11T17:25:06Z2015-10-13T09:09:44ZHow to find the "true" perimeter of objects in a binary image?<p>Say, there is an object consisting of 3 pixels next to each other (■■■). If I calculate the perimeter using</p><pre class="language-matlab">sum(sum(bwperim(image)))
</pre><p>I get 3. But the actual perimeter (considering all sides of the object) is 8. How do I find this?
Thanks.</p>Xenhttps://www.mathworks.com/matlabcentral/profile/authors/5358452-xentag:www.mathworks.com,2005:Question/2439352015-09-19T09:43:16Z2015-10-13T09:07:26ZCUDA and Matlab on mac: mex command not working<p>Hi,</p><p>I am interested to compile the program in <a href = "https://github.com/Ivanlh20/MULTEM">here</a> for GPU enabled computation on matlab. I have Matlab R2015a, Xcode7, and CUDA 7.0 already on OSX 10.11. However during the compiling, it complain about "mex" function.</p><pre> mex -silent -largeArrayDims -outdir ../mex_executables -I../src -I/Developer/NVIDIA/CUDA-7.0/include get_radial_distribution_2D.cpp -L../src -lfftw3f -L../src -lfftw3 -lfftw3f_threads -lfftw3_threads
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/maci64.html.
Error in MEX (line 31)
eval(textcommands);
Error in mex_radial_distribution_2D (line 3)
MEX('release', 'get_radial_distribution_2D.cpp', '../src');
Error in run (line 96)
evalin('caller', [script ';']);
Error in compile_mex_files (line 31)
run(['mex_files/', file{1}])</pre><p>Thus, I tried to test the example file at</p><pre> matlabroot/toolbox/distcomp/gpu/extern/src/mex/mexGPUExample.cu</pre><pre> >> mex -v mexGPUExample.cu
Verbose mode is on.
Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require the use of
-largeArrayDims and remove the -compatibleArrayDims option.
For more information:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
... Looking for compiler 'nvcc' ...
... Looking for environment variable 'MW_NVCC_PATH' ...No.
... Executing command 'which nvcc' ...No.
... Looking for file '/Developer/NVIDIA/CUDA-6.5/bin/nvcc' ...No.
... Looking for file '/usr/local/cuda/bin/nvcc' ...Yes.
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('7.0').
... Executing command '
agreed=7.0
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('7.0').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' ...No.
... Executing command 'find /Applications/Xcode.app/Contents/Developer -name MacOSX10.9.sdk' ...No.
Did not find installed compiler 'nvcc'.
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/maci64.html.</pre><p>Is it caused by cuda 7.0 not supporting xcode 7.0 yet? Thanks a lot for your help!</p>Jack Zhanghttps://www.mathworks.com/matlabcentral/profile/authors/6130960-jack-zhangtag:www.mathworks.com,2005:Question/2483292015-10-13T08:56:50Z2015-10-13T09:03:23ZHow can I speed up loadlirbrary for a C/C++ DLL?<p>Our company provides a C/C++ DLL (with a pure C interface) and a MATLAB wrapper to use the functionality in MATLAB. It works quite well exept for the loadlibrary part which is very slow (up to 15 seconds depending on the pc). A customer reported that a DLL from another company is loaded much faster (only a few seconds). Another aspect I came across is that using loadlibrary for our DLL in C++ is very fast (less than one second). Of couse, MATLAB will always need more time because its a different platform. But 15 seconds are too long. We use Windows but plan to use Linux in future, too.</p><p>So my question is: how can I speed up loadlibrary of our DLL?</p><ul><li>How can I modify the code of our C/C++ DLL to make MATLAB's loadlibrary faster?</li><li>Can I use MATLAB different to make loading my DLL faster?</li></ul><p>My current code where I load the DLL is:</p><pre class="language-matlab">if(~libisloaded(c.libalias))
try
[notfound,warnings] = loadlibrary (dllFullFileName,headerFileName,'alias',c.libalias);
catch ME
errorMessage = sprintf('...');
errorMessage = sprintf('%s\n%s', errorMessage, ME.message);
error(errorMessage)
end
end
</pre>Semjonhttps://www.mathworks.com/matlabcentral/profile/authors/5444480-semjontag:www.mathworks.com,2005:Question/2473022015-10-07T15:28:27Z2015-10-13T08:58:51Zimport data into matlab<p>I have imported data into uitable in gui, but data are large and appear statement: Matlab is not responding.</p><p>Is uitable appropriate for importing large files?</p>Radoslav Vandzurahttps://www.mathworks.com/matlabcentral/profile/authors/7028162-radoslav-vandzuratag:www.mathworks.com,2005:Question/2482852015-10-13T03:44:23Z2015-10-13T08:58:00Zhow to write code to ceate population of individuals that has three parameters namely location, type of equipment and it rating<p>how to write code to ceate population of individuals that has three parameters namely location, type of equipment and its rating , the single individulal is as follow for example</p><p>location = 12 3 7 number of locations is 200 site</p><p>type = 1 2 3 4 number of type of equipments to be placed in the above location is is 5</p><p>rating = 0.1 0.8 0.5 0.2 ( rating of equipment value between 0-1)</p>omer Elsiddighttps://www.mathworks.com/matlabcentral/profile/authors/2857247-omer-elsiddigtag:www.mathworks.com,2005:Question/2483302015-10-13T08:57:14Z2015-10-13T08:57:14Zputting a coordinate system on a video frame<p>I have a video converted into many frames in matlab. Now, I want to have each frame to have a coordinate system with domain: [0,150]x[0,150]. What additional line of codes should I write?</p><p>Thanks</p>cgohttps://www.mathworks.com/matlabcentral/profile/authors/5852688-cgotag:www.mathworks.com,2005:Question/2483212015-10-13T08:28:12Z2015-10-13T08:56:09ZCalculate midpoints between extrema in a picture<p>Hello, after calculating the maxima and minima in a picture i'd like to calculate the midpoints between them (and interpolate them later on). In a one dimensional singal it would be something like</p><pre class="language-matlab">if true
(E(i)+E(i+1))/2
end
</pre><p>where E(i) is the i-th Extrema. But in 2D it isn't that easy anymore, because in every direction there are points to calculate.
I don't really know how to approach this problem and maybe someone did something familiar?
I am thankful for any suggestion.</p>Simon Simsonhttps://www.mathworks.com/matlabcentral/profile/authors/7100651-simon-simsontag:www.mathworks.com,2005:Question/2482872015-10-13T03:54:44Z2015-10-13T08:55:14ZHow to save each iteration of a loop into the same sheet of an Excel spreadsheet? <p>Hello, I'm still relatively new to MATLAB.</p><p>I am trying to save data into an Excel Sheet, I have successfully managed to save single iteration of the loop in a given sheet. I have managed to save each iteration in a new sheet(as shown below in the code). However, I am interested in saving each iteration in the same sheet but within the following row of the Excel sheet. For example, heading save to row 1. Iteration 1 save to row 2, Iteration 2 save to row 3 and so on.</p><p>I understand I can specify the range ('Range','A1') for example to save to row 1. However, I do not know how to make the Range vary in relation to the length of START. What I mean is, if it is Iteration 2 how can I specify 'A3". The end purpose of the code is to generate large amounts of data.</p><pre> filename = 'Test.xlsx';
z = 1;
START = [0.2:0.1:0.9];</pre><pre> for i = 1:length(START);</pre><pre> start = START(i);
global start; </pre><pre> run 'Improved.' %m.file named 'Improved.m'
Table_1 = table(z,n,A,B,C,D); %variables "z,n,A,B,C,D" are generated within Improved.m</pre><pre> z = z+1;
sheet = z;
writetable(Table_1,filename,'Sheet',z,'Range','A1')</pre><pre> end </pre><p>Thank you</p>Alberto https://www.mathworks.com/matlabcentral/profile/authors/5715521-albertotag:www.mathworks.com,2005:Question/2483182015-10-13T08:12:30Z2015-10-13T09:15:43ZProblem in interpolation of data.<p>The following code is giving me the error that "The grid vectors do not define a grid of points that match the given values". I tried to use linear and other methods too, but nothing works. Need help.</p><pre> a=unique(Eo.signals.values(:,:));
b=unique(SOC.signals.values(:,:));
b1 = interp1(a,b,19,'spline','extrap')</pre>Daniyal Alihttps://www.mathworks.com/matlabcentral/profile/authors/7100212-daniyal-alitag:www.mathworks.com,2005:Question/2483282015-10-13T08:52:20Z2015-10-13T08:52:20ZHow can I convert a Matlab Code into a Simulink model for running on a Raspberry Pi?<p>With my Matlab Code I open and communicate via TCP/IP with a Lidar Sensor. Now I want to implement this code in an existing Simulink model as a new Simulink block. Further, I want to run the model on a Raspberry Pi independently.
I've tried 'MATLAB function block' but it doesn't really work.</p><p>Would be great if someone could help.</p>Sebastian Dietzhttps://www.mathworks.com/matlabcentral/profile/authors/6910817-sebastian-dietztag:www.mathworks.com,2005:Question/2483072015-10-13T07:05:40Z2015-10-13T08:50:20ZDiscretize a volume into smaller known volume sizes<p>Hello guys,</p><p>I have a simple shape at my disposal, and I would like to know how to discretize it. For example if I have a sphere of say 1m diameter, I would like to obtain n number of smaller spheres of a diameter of 10mm and know where they are located in space.</p><p>If my sphere is located at [0, 0, 0], then it will obviously extend to 0.5m in each direction. What I want to obtain is smaller spheres that will take up the space of the big one, and have coordinates for each of the smaller spheres.</p><p>I am using Simmechanics</p><p>Any help?</p>Matthttps://www.mathworks.com/matlabcentral/profile/authors/3451938-matttag:www.mathworks.com,2005:Question/2482892015-10-13T04:35:27Z2015-10-13T08:50:11ZHow to get leaf area( in cm^2) of a scanned color image<p>I want to automate the process of calculating color leaf area using matlab image processingcode/commands.Please provide the steps.</p>H. C. Vermahttps://www.mathworks.com/matlabcentral/profile/authors/6806300-h-c-vermatag:www.mathworks.com,2005:Question/2483102015-10-13T07:19:58Z2015-10-13T08:46:30ZRemove small background (black) regions within an image<p>Attached is the image. I was able to get rid of the background region across the boundary but the background region within the image is still persistent. Is there any method that can get rid of the small background regions within an image. Thank you.</p>Dimple Bhutahttps://www.mathworks.com/matlabcentral/profile/authors/7105662-dimple-bhutatag:www.mathworks.com,2005:Question/2483272015-10-13T08:45:28Z2015-10-13T09:06:04ZUse wildcards with excel<p>Hi. I am trying to read the first column of a sheet that contains a list of filepaths and look inside the folders for *.xlsx and open them. Unfortunately I get an error message. Do you have an idea how to solve this? Thank you very much in advance.</p><pre class="language-matlab">[~, entry] = xlsread(workbookFile,sheetName);
</pre><pre> for i=1
sourceDir = xlsread(entry{i,1}); %error message here
sourceFiles = dir(fullfile(sourceDir, '*.xlsx'));
data(:,1) = xlsread(sourceFiles, 1, [entry{i,3} ':' entry{i,3}]);
...</pre><p>Alternative Code:</p><pre> data(:,1) = xlsread(dir(fullfile(entry{i,1}, '*.xlsx')), 1, [entry{i,3} ':' entry{i,3}]);</pre><p>Error: File name must be a string</p>Kajoverhttps://www.mathworks.com/matlabcentral/profile/authors/7084272-kajovertag:www.mathworks.com,2005:Question/2483262015-10-13T08:43:22Z2015-10-13T08:44:10ZCheck if number in Row, if not delete the complete column<p>Hello,
this is the Data:</p><pre class="language-matlab">TestData = {'A','B','C','D';...
3,4,8,7;...
4,9,5,9;...
5,[],2,[];...
7,[],2,[];...
1,[],6,[]}
</pre><p>1. Check if in row 4 is a number</p><p>2. If not, delete the complete column where is not a number.</p><p>3. In this case this means: Delete column B and D.</p><p>The real data is very big, over 10000 rows...</p><p>How can I do this ?</p>Marvhttps://www.mathworks.com/matlabcentral/profile/authors/6104772-marvtag:www.mathworks.com,2005:Question/2483202015-10-13T08:21:23Z2015-10-13T08:41:43Zhi. i have two variables which are AREA and PERIMETER.<p>how to save both variables in a mat.file?
i only have coding for one variable only :</p><pre> _ _ _objArea = objMeasurements(k).Area; % Get area.
AREA=[objArea;AREA];
save('AREA.mat','AREA');</pre><pre class="language-matlab">objPerimeter= objMeasurements(k).Perimeter; % Get perimeter.
PERIMETER=[objPerimeter;PERIMETER];
save('PERIMETER.mat','PERIMETER');___
</pre>hudazinhttps://www.mathworks.com/matlabcentral/profile/authors/5843679-hudazintag:www.mathworks.com,2005:Question/2429012015-09-14T13:04:18Z2015-10-13T08:40:04ZNyquist plot and arrows<p>I'd like to draw Nyquist plot without arrows. I wonder if there is an option that makes it possible to choose whether I want the arrow on the plot. Alternatively, I'd like to remove the arrows after drawing the plot.</p>Annahttps://www.mathworks.com/matlabcentral/profile/authors/2249004-annatag:www.mathworks.com,2005:Question/2483252015-10-13T08:39:58Z2015-10-13T08:39:58ZR^2 for comparing the results of measured vs. predicted (non-linear model) values <p>I use the neural network toolbox for creating empirical relations between different parameters. The same relations are used to extrapolate the data for the remaining data set.
Since the neural network is a highly non-linear framework, can I use R^2 as the statistic measure to compare the predicted values and the measured values?</p>Ashishhttps://www.mathworks.com/matlabcentral/profile/authors/5032323-ashishtag:www.mathworks.com,2005:Question/2481322015-10-12T10:41:01Z2015-10-13T08:36:22ZSelecting rows from a file starting with a letter followed by 3 numbers<p>Hi there, I have a function that selects information from two files and combines this information into one new file. Importantly, I only want certain rows from file 2 to be included in the new document, namely rows for which the second column starts with 'S1' (followed by 2 other random numbers, eg: S124, S132, S112 etc.). Below is my code. I don't get an error message, however, it also does not give me the file I want. It prints only the header of the new file, but not the newly compiled lines. What am I doing wrong?</p><pre class="language-matlab">function []=CreateNewMarkersEEGlab(pNumber)
</pre><pre class="language-matlab">dataFileName=strcat(int2str(pNumber),'_logfile.txt');
fid = fopen(dataFileName);
C = textscan(fid, '%s%s%s%s%s%s%s%s%s%s%s%s%s%s', 'headerlines', 1);%14 columns
rScore=C{12};
sNumber=C{5};
cNumber=C{6};
subNumber=C{7};
tcode=C{10};
fclose(fid);
</pre><pre class="language-matlab">% compute the new marker
for i=1:156
if strcmp(rScore{i}, '1')
respMarker='corrresp';
else
respMarker='incorrresp';
end
if strcmp(tcode{i},'1')
corrMarker='corr';
else
corrMarker='incorr';
end
newMarker{i} = sprintf('S1_con%s_sub%s_%s_%s_Snr_%s',cNumber{i}, subNumber{i}, corrMarker, respMarker, sNumber{i});
end
</pre><pre class="language-matlab">% read the old marker file
dataFileName=strcat('EEG_Anne_',int2str(pNumber),'.vmrk');
fid = fopen(dataFileName);
headline1=fgets(fid);
headline2=fgets(fid);
headline3=fgets(fid);
headline4=fgets(fid);
headline5=fgets(fid);
headline6=fgets(fid);
headline7=fgets(fid);
headline8=fgets(fid);
headline9=fgets(fid);
headline10=fgets(fid);
headline11=fgets(fid);
headline12=fgets(fid);
headline13=fgets(fid);
C = textscan(fid, '%s%s%d%d%d','Delimiter',',');
Type=C{1};
Stimulus=C{2};
Position=C{3};
Length=C{4};
Channel=C{5};
fclose(fid);
</pre><pre class="language-matlab">% rewrite the new marker file
outFileName=strcat('EEG_Anne_',int2str(pNumber),'_new.vmrk');
fid = fopen(outFileName,'w+');
fprintf(fid,headline1);
fprintf(fid,headline2);
fprintf(fid,headline3);
fprintf(fid,headline4);
fprintf(fid,headline5);
fprintf(fid,headline6);
fprintf(fid,headline7);
fprintf(fid,headline8);
fprintf(fid,headline9);
fprintf(fid,headline10);
fprintf(fid,headline11);
fprintf(fid,headline12);
fprintf(fid,headline13);
for i=1:156
if strcmp(Stimulus,'S1\d*')
fprintf(fid, '%s,%s,%d,%d,%d\r\n', Type{i}, newMarker{i}, Position(i), Length(i), Channel(i));
end
end
fclose(fid);
</pre>Anne Mickanhttps://www.mathworks.com/matlabcentral/profile/authors/7082710-anne-mickantag:www.mathworks.com,2005:Question/2483232015-10-13T08:32:32Z2015-10-13T08:32:32ZWhat is the maximum FrameLength, which can be received using comm.SDRuReceiver from USRP N210?<p>I want to receive a subframe of 20 MHz LTE system but unable to receive a frame of length 61440 samples from USRP N210</p><p>The piece of code which has been executed is given below:</p><p>hSDRu_Receive = comm.SDRuReceiver('192.168.10.2', ...
'CenterFrequency', 748.5e6, ...
'Gain', 0, ...
'DecimationFactor', 10, ...
'EnableBurstMode', true, ...
'FrameLength', 61440,...
'OutputDataType', 'double');</p><p>Received_Waveform = step(hSDRu_Receive);</p><p>The error which I am getting is :
Assertion failed.</p><p>Error in mapiPrivate (line 159)</p><p>Error in openDataConnection (line 6)</p><p>Error in mapiPrivate (line 53)</p><p>Error in openDataConnection (line 6)</p><p>Error in SDRuReceiver/setupImplLocal (line 300)</p><p>Error in SDRuBase/setupImpl (line 366)</p><p>Error in DL_PBCH_decoding (line 14)
Received_Waveform = step(hSDRu_Receive);</p>Pushpalata Thttps://www.mathworks.com/matlabcentral/profile/authors/5337601-pushpalata-ttag:www.mathworks.com,2005:Question/2483222015-10-13T08:29:59Z2015-10-13T08:29:59ZArduino Due build error<p>Hello,</p><p>i have a problem to run a simulink model on an Arduino Due Board. As a first test, i only want a blinking led. I have installed the Arduino Hardware Support Package for Matlab and Simulink. But when i want to compile my model, i got the error message "Faild to generate all binary outputs". When i do the same for an Arduino Uno Board it runs fine.
Do i have to do some special configurations für the Arduino Due? The Board Type under Tools-->RunOnTargetHardware i have changed. I'm using Matlab 2015b</p><p>kind regards
Tobias</p>Tobiashttps://www.mathworks.com/matlabcentral/profile/authors/2383807-tobiastag:www.mathworks.com,2005:Question/2482942015-10-13T05:08:42Z2015-10-13T08:27:23ZMATLAB Compiler (R2010a) issue<p>Hi there,</p><p>I was trying mex program.cpp.</p><p>It showed an error
Error: Could not detect a compiler on local system
which can compile the specified input file(s)</p><p>Then I tried mex -setup</p><p>It did not list any compilers (Only none)</p><p>I did install Windows SDK 7.1 successfully (also has MS VC++ 2010 x64 redistributable)</p><p>I have lcc 32 bit in my system</p><p>Even then compiler list is shown [0] none</p><p>Any thoughts</p><p>I just wanted to run mex program.cpp</p>Madhu Kodappullyhttps://www.mathworks.com/matlabcentral/profile/authors/6788544-madhu-kodappullytag:www.mathworks.com,2005:Question/2483112015-10-13T07:45:26Z2015-10-13T08:27:19ZPlotting in for loop not working. Averaging matrix over ranges.<p>I thought i had a code that worked but i noticed a tiny error, and ive been banging my head on a brick wall sleeplessly trying to get it to work for days.</p><p>Heres my code, i hate it, it doesn't work, if you reckon you can fix it please tell me otherwise just skip this bit and as I've decide to start again.</p><pre class="language-matlab">function TempSalplot(datafile)
datafile=importdata(datafile);
A=datafile.data;
figure;
col = flipud(parula(round(max(datafile.data(:,28)))));
%depth,distance,salinity,temp are in column 28,2,14,11 of datafile respectively;
for d=[1:3:max(datafile.data(:,28))]; %max is around 16
for avd=[1:length(A(:,28))];
if A(avd,28)>d-0.5 & A(avd,28)<d+0.5;
B(avd,1)=A(avd,2);
B(avd,2)=A(avd,14);
B(avd,3)=A(avd,11);
B(all(B==0,2),:)=[];
end
[M,~,z] = unique(B(:,1),'stable');
M(:,2) = accumarray(z,B(:,2),[],@mean);
M(:,3) = accumarray(z,B(:,3),[],@mean);
plot(M(:,2),M(:,3),'o-','color',col(d,:));
hold on;
end
xlabel('Salinity (psu)');
ylabel('Tempurature (degC)');
h=colorbar('ticks',[1:3:round(max(datafile.data(:,28)))]);
h.Label.String=('Depth (m)');
caxis([1,max(d)]);
colormap(col);
end
</pre><p>Essentially i have 4 columns of interest say (a,b,c,d). I would like to average b and c over certain ranges of d. so I would only have as many b,c pairs for a certain d range as there are a values. Then I would like to plot that and redo it for another a range.</p><pre class="language-matlab">data=
0 15 33 0.5
0 15 32 0.8
0 16 32 1.3
0 13 34 1.6
10 13 34 0.6
10 14 35 1.0
10 16 36 1.5
10 12 33 1.9
25 13 34 0.6
25 12 33 0.9
25 12 34 1.6
25 12 36 1.9
</pre><p>What I think I need is a for loop.</p><p>1st iteration for 0<d=<1 (d=0.5).</p><pre class="language-matlab">M=
0 15 32.5 0.5
10 13.5 34.5 0.5
25 12.5 33.5 0.5
plot(M(:,2),M(:,3));
</pre><p>then repeat for d=1.5 (1<d=<2)
however some of the later iteration for example (10<d=<11) have no measurements for certain values of a so should be shorter than the earlier iterations and therefore plot fewer points.</p><p>Any help on this is really appreciated , this has been a nightmare for me, thinking I had it working so many times.</p>aaron Harveyhttps://www.mathworks.com/matlabcentral/profile/authors/7069146-aaron-harveytag:www.mathworks.com,2005:Question/2481662015-10-12T13:28:07Z2015-10-13T08:22:06ZSimhydraulics: Pressure distribution over the entire circuit<p>Hello,</p><p>How do I plot the distribution of pressure, or any parameter, over a section of the circuitry at an instant in time? For example, I would like to know the pressure distribution on the exhaust circuitry of a double acting cylinder 10 milliseconds after the piston has reached the end of its stroke.
Many thanks,</p><p>Paraic</p>Paraic OKellyhttps://www.mathworks.com/matlabcentral/profile/authors/6500372-paraic-okellytag:www.mathworks.com,2005:Question/2483162015-10-13T08:05:31Z2015-10-13T08:17:05ZSimple problem yet I cannot find the error<p>Here is my script:</p><pre class="language-matlab">haut=0.5
larg=0.5
long=2
A=linspace(1, larg*100, larg*100)'; % y
B=linspace(1, long*100, long*100)'; % x
C=linspace(1, haut*100, haut*100); % z
</pre><pre class="language-matlab">D=zeros(length(B),length(A));
</pre><pre class="language-matlab">for i=1:length(B)
for j=1:length(A)
D(i, j)=[B(i), A(j)]
end
end
</pre><p>But this doesn't work. Any suggestion?</p>Matthttps://www.mathworks.com/matlabcentral/profile/authors/3451938-matttag:www.mathworks.com,2005:Question/2483192015-10-13T08:12:34Z2015-10-13T08:12:34ZF5 and F9 key results difference<p>I was running a program1.m file</p><p>First I tried F9 and completed testing the code line by line and block by block (slect whatever line or block I needed then press F9)</p><p>After I found the entire code ready, I pressed F5. I have no idea, the result was not the same as it was with F9 execution</p><p>any thoughts</p>Madhu Kodappullyhttps://www.mathworks.com/matlabcentral/profile/authors/6788544-madhu-kodappullytag:www.mathworks.com,2005:Question/2483122015-10-13T07:46:26Z2015-10-13T08:12:31ZHow to run GUI in Matlab browser and script at the same time<p>I'm building a demonstrator for a project of mine. I have the background script working fine and the GUI also works by itself.</p><p>The problem I have is that the script needs to work constantly in the background to process data as it comes in, and the GUI should display the data in realtime. I build the GUI with html, so I have a few scripts for the GUI that write the data into the html files as needed.</p><p>The problem I found today is that I cannot execute the background script and the GUI at the same time in the client. I have been using global variables to shift data between various subscripts and the GUI scripts, which won't work if I run one or the other on a worker.</p><p>My question has two parts:
One, is it possible to run both scripts on the client, i.e. that the GUI can interrupt the background script for short periods (that is acceptable)?</p><p>Two, if that is not possible, how do I make the data accessible for the GUI? I thought about using files and such but the problem there is, what happens if the GUI script tries to read a file while the background script tries to write?</p><p>Thanks for the help.</p>Danielhttps://www.mathworks.com/matlabcentral/profile/authors/3145570-danieltag:www.mathworks.com,2005:Question/2483172015-10-13T08:06:52Z2015-10-13T08:09:29ZChange the content in an m-file based on check-box input from gui<p>Hi,</p><p>I have a checkbox in my gui based on which i want to make some changes in another m-file & later run it.</p><p>The format of other m-file is like this:-</p><pre class="language-matlab">tclstart = {...
'# ...there is further code above.. #',...
'# .......................... #',...
'set compile 1',...
'# .......................... #',...
'# there is further code below'
}
</pre><p>Based on check-box value</p><pre class="language-matlab">get(h.checkbox1, 'Value');
</pre><p><b>if it is 1,i want <i>set compile to be 1</i> in that m-file otherwise 0</b>
as an m-file is similar to txt file,i'm doing this-</p><pre class="language-matlab">content = fileread('tcl.m'); % name of that other m-file
index = regexp(content,'set compile')
</pre><p>Here i'm getting starting index of the matched sub-string,now how can i change the value from 1 to 0/vice-versa.</p>Luffyhttps://www.mathworks.com/matlabcentral/profile/authors/3528849-luffytag:www.mathworks.com,2005:Question/2483152015-10-13T08:04:08Z2015-10-13T08:04:08ZHow to update Axes LineStyle Order in Matlab Gui<p>Dear Community,</p><p>I want to change the Linestyle of a Matlab Figure in a Gui. I have a popupmenu with a switch case structure where I can set the property. However, no change occurs whatsoever. I tried whats in commentary with refresdata and so forth, but no change. Do I need to replot all the data with plot (yet I dont know at all times which data I have. Or is there another way for it to update the figure?</p><p>Thanks a lot, below the code
Ravi</p><pre class="language-matlab">switch get(hObject,'Value')
</pre><pre> case 1
set(handles.axes_eis,'LineStyleOrder', '-');
guidata(hObject, handles);
% refreshdata(handles.axes_eis)
% refreshdata(handles.axes_eis,'caller')
% draw now
case 2
set(handles.axes_eis,'LineStyleOrder', '.-');
guidata(hObject, handles);
end</pre><pre> guidata(hObject, handles);</pre>Ravi Goyalhttps://www.mathworks.com/matlabcentral/profile/authors/2587059-ravi-goyaltag:www.mathworks.com,2005:Question/2483082015-10-13T07:09:31Z2015-10-13T08:03:46ZI get an error for rxy[D]=0. I do not know why. Im doing a code for correlation.<pre class="language-matlab">double x[100];
double y[100];
double rxy[100];
</pre><pre class="language-matlab">for D = 0:1:100
rxy [D]= 0
for n=0:1:99
rxy [D] = rxy[D]+x[n]*y[n-D]
end
</pre>supasport13https://www.mathworks.com/matlabcentral/profile/authors/6863082-supasport13tag:www.mathworks.com,2005:Question/2481642015-10-12T13:18:59Z2015-10-13T08:00:29ZCreating a mouse down event specific to an axes1 component only<p>I am using the following to allow the user to use the mouse press to draw a marker on an image loaded to an axes component (axes1). There are other axes also on my GUI, and I want to be able to constrain this mouse action only if the mouse is over axes 1. Currently it also draws a marker when over other axes.</p><p>I put this in the opening function.</p><pre> set(gcf, 'WindowButtonDownFcn', @getMousePositionOnImage);</pre><p>And then use this function for the mouse click.</p><pre class="language-matlab">function getMousePositionOnImage(src, event)
</pre><pre class="language-matlab">handles = guidata(src);
cursorPoint = get(handles.axes1, 'CurrentPoint');
curX = cursorPoint(1,1);
curY = cursorPoint(1,2);
</pre><pre class="language-matlab">%check if mouse clicked outside of axes component
xLimits = get(handles.axes1, 'xlim');
yLimits = get(handles.axes1, 'ylim');
</pre><pre class="language-matlab">if (curX<min(xLimits)) (curX==min(xLimits))
end
if (curX>max(xLimits)) (curX==max(xLimits))
end
if (curY<min(yLimits)) (curY==min(yLimits))
end
if (curY>max(yLimits)) (curY==max(yLimits))
end
</pre><pre class="language-matlab">x=round(curX)
y=round(curY)
setappdata(0,'curX',x);
setappdata(0,'curY',y);
</pre><pre class="language-matlab">%Remove previous marker if present
delete( findobj(gca, 'type', 'line') );
hold on
plot(x,y,'ro','MarkerSize',10,'LineWidth',2)
hold off;
</pre><pre class="language-matlab">IMG = getimage(handles.axes1);
delta=50;
if (x<delta+1)|| (y<delta+1)
ROI = IMG(1:delta, 1:delta,:); % This is the ROI (indexing is (ymin:ymax, xmin:xmax)
else
ROI = IMG(y-delta:y+delta, x-delta:x+delta,:); % This is the ROI (indexing is (ymin:ymax, xmin:xmax)
end
</pre><pre class="language-matlab">%Now take a ROI around the marker position (i.e. where mouse is clicked)
%and draw in axes 3
axes(handles.axes3)
cla
[high,low]=Autoscaleimage(handles,ROI,3);
imshow(ROI,[low,high]);
hold on
plot(delta+1,delta+1,'ro','MarkerSize',10,'LineWidth',2);
hold off
</pre>Jasonhttps://www.mathworks.com/matlabcentral/profile/authors/1217570-jasontag:www.mathworks.com,2005:Question/2238442015-06-15T09:39:05Z2015-10-13T07:59:34ZHow to rename .m files<p>In my current directory bunch of <tt>XXX.mat</tt> files to be rename as <tt>XXXNewname.mat</tt> files using MATLAB command prompt .
Anyone knows ????</p>Harish Patilhttps://www.mathworks.com/matlabcentral/profile/authors/4218242-harish-patiltag:www.mathworks.com,2005:Question/953542009-06-27T01:11:00Z2015-10-13T07:53:37ZWhy do I receive an "LNK2019: unresolved external symbol _engOpen referenced in function" error when I compile my C++ code that calls the MATLAB engine API in Microsoft Visual Studio .NET?<p>I have created a C++ project in Microsoft Visual Studio .NET which uses the C MATLAB engine API's. I included the engine.h file that is located in the $MATLABROOT/extern/include (where $MATLABROOT is the MATLAB root directory on my machine, as returned by typing</p><pre class="language-matlab">matlabroot
</pre><p>at the MATLAB command prompt.)</p><p>When I build the project I get error messages of the form:</p><pre class="error"> </pre><pre> LNK2019: unresolved external symbol _engOpen referenced in function</pre><pre> LNK2019: unresolved external symbol _engClose referenced in function</pre>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/235422011-12-09T20:35:01Z2015-10-13T07:50:58ZHow to stream video into matlab from RTSP<p>I am working on a project where we need to process images in real time from an rtsp stream using mpeg4. Has anyone done this before or does anyone have any ideas as to how to make this work?</p>Jakehttps://www.mathworks.com/matlabcentral/profile/authors/511124-jaketag:www.mathworks.com,2005:Question/2477972015-10-10T03:42:35Z2015-10-13T07:38:56ZConnect oscilloscope via LAN, have installed Tekvisa4.0.4, but still "No Visa drivers detected"<p>I'd like to control oscillosope(TDS3054C) by MATLAB(R2010b) via LAN. So I installed Tekvisa4.0.4 as it required (it requires 3.3 version or above). But when I create instrument object, it still shows "no visa drivers detected". Is there any step I missed? like install Teckvisa into specific address or something? But the install address of Tekvisa is default.</p><p>picture Attached.</p><img src = "/matlabcentral/answers/uploaded_files/38223/VISAdriver.jpg"><p>..</p>Yuyao Zhouhttps://www.mathworks.com/matlabcentral/profile/authors/6987052-yuyao-zhoutag:www.mathworks.com,2005:Question/2472462015-10-07T09:30:18Z2015-10-13T07:26:05Zhow can i get a length of a barrel in an image using matlab <img src = "/matlabcentral/answers/uploaded_files/38067/1%5B1%5D.jpg">sree harihttps://www.mathworks.com/matlabcentral/profile/authors/7042579-sree-haritag:www.mathworks.com,2005:Question/1214432014-03-13T20:50:16Z2015-10-13T07:19:51ZError installing third party package Arduino software: Invalid zip file<p>I have the 2013a version of matlab and been trying to install the simulink support package for arduino hardware, but I keep getting the following error:</p><p>"Error installing third party package Arduino software: Invalid zip file "C:\MATLAB\SupportPackages\R2013a\downloads\arduino-1.0-windows.zip"."</p><p>and then the installation stops.</p><p>N.B.: I using windows 8.</p>Haninhttps://www.mathworks.com/matlabcentral/profile/authors/5142446-hanintag:www.mathworks.com,2005:Question/2483092015-10-13T07:14:58Z2015-10-13T07:14:58ZIs the Noise is considered in rayleighchan?<p>Hi everyone</p><p>I am trying to model a communication channel. The question is that, if I want to use one of the provided channel model like rayleighchan or ricianchan, is the Noise is considered also? OR I have to formulate the noise and then add it to the signal?</p><p>Regards,</p>Mahdiyarhttps://www.mathworks.com/matlabcentral/profile/authors/4242641-mahdiyartag:www.mathworks.com,2005:Question/2483062015-10-13T06:46:16Z2015-10-13T07:14:19Zhow to extract feature extraction in medical imaging<p>like MRI or any image , is Matlab is good for extracting features for medical application like MRI. tell me its urgent</p><pre class="language-matlab">i=imread('pic.jpg');
imshow(i);
%% gabor
phi = 6*pi/8;
theta = 2;
sigma = 0.65*theta;
filtersize = 5;
g = zeros(filtersize);
for i=(0:filtersize-1)/filtersize
for j=(0:filtersize-1)/filtersize
xprime= j*cos(phi);
yprime= i*sin(phi);
k = exp(2*pi*theta*sqrround((j+1)*filtersize))
??? = exp(-(i^2+j^2)/(sigma^2))*k;
end
end
%% convolve
j = conv2(ig);
figure
imshow(imag(j));
</pre>ajay sharmahttps://www.mathworks.com/matlabcentral/profile/authors/7085561-ajay-sharmatag:www.mathworks.com,2005:Question/2482862015-10-13T03:44:26Z2015-10-13T07:12:24ZHow do you assign a range of values (such as z = 0 to 100)and a specific values to the k value in a unity feedback system?<p>Can you please help me how to assign specific range values to K in Matlab. Please see my script for the way I did it which it doesn't give me the correct plot. I have attached the plots for both a and c parts alone with the problem text.</p><p>here is my script for the problem.
clear all; close all;
numG = [4]; denG = [1 4 7 0];
figure(1);
G = tf(numG,denG);
rlocus(G);
grid;
% Response to a unit step input 1/s for z=.6,2,and 4
figure(2)
z1=0.6; Gz1 = feedback(G*z1,1);
z2=2; Gz2 = feedback(G*z2,1);
z3=4; Gz3 = feedback(G*z3,1);
step(Gz1,Gz2,Gz3);</p>Ashkhen Aristakessianhttps://www.mathworks.com/matlabcentral/profile/authors/6900650-ashkhen-aristakessiantag:www.mathworks.com,2005:Question/2470392015-10-06T10:26:30Z2015-10-13T07:11:20ZHow to overlap two histograms , one generated from reference image other for noisy image ?<p>Actual Program which I tried is,</p><p>Prog 1:
A = imread('frame2.bmp');
I = rgb2gray(A);
J = imnoise(I,'salt & pepper',0.2);
figure;
imshow(I);title('original image');
figure;
imshow(J);title('image with salt&pepper noise=0.2');
figure;
imhist(I);title('histogram of refrece image');
figure;
imhist(J);title('histogram of salt&pepper noisy image');
figure;
K=imhist(I)+imhist(J);
hist(K);
But didn't get desired output.</p>Preethi H Lhttps://www.mathworks.com/matlabcentral/profile/authors/7060458-preethi-h-ltag:www.mathworks.com,2005:Question/2477102015-10-09T14:30:08Z2015-10-13T07:09:53Z'Typecasting' COM-objects in matlab?<p>Is it possible to typecast COM objects in matlab, as would be done in C# for instance?</p><p>I am using a COM dll (actxserver).</p><p>The code in C# of what I want to do is:</p><pre class="language-matlab">var m = tracker.Measurement.MeasureStationary() as StationaryMeasurement3D;
</pre><p>The object returned by 'tracker.Measurement.MeasureStationary()' is not of type 'StationaryMeasurement3D', but can be cast to it.</p><p>I've tried using the cast() function in matlab, but returns with the error 'Unsupported data type for conversion'.</p>Joris Janssenswillenhttps://www.mathworks.com/matlabcentral/profile/authors/5478308-joris-janssenswillentag:www.mathworks.com,2005:Question/2483052015-10-13T06:32:36Z2015-10-13T07:01:43ZHow to find optimum value to minimize error?<p>for e.g. How to find optimum value of m & c?
given, Ye=mx+c;
x=[0 1 2 3 4];
Ye=[3 5 7 9 11];
to minimize error</p>Ramnath shanbhaghttps://www.mathworks.com/matlabcentral/profile/authors/7105496-ramnath-shanbhagtag:www.mathworks.com,2005:Question/2482352015-10-12T21:28:08Z2015-10-13T06:59:39Zartificial neural network question<p>Hi all,</p><p>I have scaled the input and target data by using these commands
[pn,ps] = mapminmax(xt1');
[tn, ts] = mapminmax(yt1');
Should I scale the tested data as well? If yes should I use the same command?</p><p>Thanks
Aziz</p>Abdulaziz Abutunishttps://www.mathworks.com/matlabcentral/profile/authors/5634873-abdulaziz-abutunistag:www.mathworks.com,2005:Question/2429912015-09-15T04:55:13Z2015-10-13T06:34:52ZHow to adjust resolution in Hough transform?<p>I'm trying to interpret potential linear trends in a map op volcanic centers using the Hough transform. Attached is the image used with hough lines on it. As you can see, the lines are only very short. How do I change the sensitivity so that more points are considered in the transform?</p><p>Code used:</p><pre class="language-matlab">RGB = imread('NVP_WP_ONLY.tif');
I = rgb2gray(RGB);
BW = edge(I,'canny');
[H,T,R] = hough(BW);
subplot(2,1,1);
imshow(RGB);
title('Newer Volcanic Province Eruption Points');
subplot(2,1,2);
imshow(imadjust(mat2gray(H)), 'XData',T,'YData',R,'InitialMagnification','fit');
title('Hough transform eruption points all Default settings');
xlabel('\theta'),ylabel('\rho');
axis on, axis normal, hold on;
colormap(hot)
P = houghpeaks(H,100);
imshow(H,[], 'XData',T,'YData',R,'InitialMagnification','fit');
xlabel('\theta'),ylabel('\rho');
axis on, axis normal, hold on;
plot(T(P(:,2)),R(P(:,1)),'s','color','white');
lines = houghlines(BW,T,R,P);
figure, imshow(RGB), hold on; %expect a figure size warning
max_len = 0;
for k = 1:length(lines) xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
end
</pre>Korien Oostinghhttps://www.mathworks.com/matlabcentral/profile/authors/6894350-korien-oostinghtag:www.mathworks.com,2005:Question/2481532015-10-12T12:36:43Z2015-10-13T06:28:49ZHow to interpolate values of x-axis using y-axis values as reference?<p>I want to do interpolation. I am using the following code</p><pre> yreq = interp1(x,y,xreq)</pre><p>This code gives me the value of the parameter on y-axis when i give it the value of x-axis. What i want is to find the value of the x-axis while giving it the value of y-axis. Can it work? I tried switching the x and y axes but it didn't work. Any help will be appreciated. Thanks</p>Daniyal Alihttps://www.mathworks.com/matlabcentral/profile/authors/7100212-daniyal-alitag:www.mathworks.com,2005:Question/2483042015-10-13T06:12:51Z2015-10-13T06:12:51ZHow can I perform the joint process of weighting distribution and gamma correction on a histogram equalized image?<p>I enhanced the white balanced hsv image using histogram equalization. Now I want to perform a weighting distribution and a gamma correction on the histogram equalized image..</p>Vishnu Rhttps://www.mathworks.com/matlabcentral/profile/authors/7042485-vishnu-rtag:www.mathworks.com,2005:Question/2483012015-10-13T05:50:23Z2015-10-13T06:09:00Zsimulating probability density functions<p>Hey everyone,</p><p>I derived the probability density function and cumulative distribution function formulas for the random variable "R" .I need to simulate them and compare them with my theoretical results.Can you give any suggestions how to simulate them.Thanks for the help</p>Naga Ahttps://www.mathworks.com/matlabcentral/profile/authors/6882101-naga-a