https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-02-22T17:37:59Ztag:www.mathworks.com,2005:Question/3263962017-02-22T16:34:01Z2017-02-22T17:37:59ZHelp with the use of function <p>Hi,
I am trying to define my own function with really simple
syntax as following</p><pre class="language-matlab">function [rhs]=rk4_RDM(c_old,kon,dim,dt)
global DL koff dx
rhs=(circshift(c_old,-1,dim)+circshift(c_old,1,dim)-2*c_old)/(dx^2);
end
</pre><p>Calling this function always results in an error of matrix dimension mismatch. If I execute the same command</p><pre class="language-matlab">rhs=(circshift(c_old,-1,dim)+circshift(c_old,1,dim)-2*c_old)/(dx^2);
</pre><p>without calling the function, there is no such error.
So apparently there is some issue in calling the function.
The way I am doing it is simply</p><pre class="language-matlab">y=rk4_RDM(c_old,kon,dim,dt)
</pre><p>Could you please let me know if you find a mistake in this way of calling a function or what I might be doing wrong ?</p><p>Thanks</p>Pragya Srivastavahttps://www.mathworks.com/matlabcentral/profile/authors/7406143-pragya-srivastavatag:www.mathworks.com,2005:Question/3263622017-02-22T13:35:34Z2017-02-22T17:37:51Zcan I use multiple cores of my CPU?<p>I have an Apple Mac Pro with 6 cores. I've got a math-intensive application running. Can I launch another instance of Matlab or some other way run another copy of my code (with different parameters) do use multiple cores in parallel and get several (different) copies of my algorithm done in the same overall time frame? To be clear: my code is not parallel code - it's a simple looping computation, and I just want to run several different versions of it at the same time, using multiple CPUs in Apple OS X. Possible?</p>Michael Levinhttps://www.mathworks.com/matlabcentral/profile/authors/485014-michael-levintag:www.mathworks.com,2005:Question/3264092017-02-22T17:37:40Z2017-02-22T17:37:40ZApp designer to control several instruments<p>Hi MATLAB Community,</p><p>I use a "main" script to control and extract data from several instruments and plot their live data. The "main" script has become large and almost unreadable for the uninitiated junior grad students.</p><p>Each instrument's functions and properties are bundled into their own individual classes. These instrument classes are then created and manipulated within the "main" script.</p><p>I wish to use App Designer (or GUIDE) to perform the the task of the "main" script while piggy backing on the instrument classes already written.</p><p>Can anyone help me find some resources for this application? I wish to use MATLAB instead of LabView!</p><p>Sincerely,</p><p>Ward Newman</p>Wardohttps://www.mathworks.com/matlabcentral/profile/authors/2763530-wardotag:www.mathworks.com,2005:Question/3263972017-02-22T16:36:12Z2017-02-22T17:36:07ZCreate sub-tabs inside main tabs ('Parent' property problem)<p>I managed to create gui that has variable number of main tabs based on some extracted data from an XML file
using this code</p><pre class="language-matlab">if true
% code
Maintabgp = uitabgroup(gcf);
for x = 1: ActNo %create the number of tabs based on some calculations to find ActNo
MainTabs.(['MainTab' num2str(x)]) = uitab(Maintabgp,'Title',['Actuator' num2str(x)]);% For example, if ActNo = 4 then MainTabs: 1x4 cell = [1x1 Tab] [1x1 Tab] [1x1 Tab] [1x1 Tab]
end
</pre><p>And now I want to create 5 sub tabs inside each main tab but I can't assign the 'Parent' of the SubTabgp as illustrated below</p><pre class="language-matlab">if true
% code
Maintabgp = uitabgroup(gcf);
for x = 1: ActNo %create the number of tabs based on some calculations to find ActNo
MainTabs.(['MainTab' num2str(x)]) = uitab(Maintabgp,'Title',['Actuator' num2str(x)]);% For example, if ActNo = 4 then MainTabs: 1x4 cell = [1x1 Tab] [1x1 Tab] [1x1 Tab] [1x1 Tab]
Subtabgp = uitabgroup('Parent','???');
AppSubTab = uitab(Subtabgp,'Title','App','Parent','???');
SpecsSubTab = uitab(Subtabgp,'Title','Specs','Parent','???');
OpSubTab = uitab(Subtabgp,'Title','Op','Parent','???');
TrnsSubTab = uitab(Subtabgp,'Title','Trns','Parent','???');
ActEnrgySubTab = uitab(Subtabgp,'Title','ActEnrgy','Parent','???');
end
</pre><p>Also, the 'Parent' property must be assigned for each sub tab in order to be able to create ui components inside each sub tab, and properly provoke the callback functions.</p>Mus'ab Ahmadhttps://www.mathworks.com/matlabcentral/profile/authors/6439059-mus-ab-ahmadtag:www.mathworks.com,2005:Question/3264082017-02-22T17:35:41Z2017-02-22T17:35:41ZWhy can't Simulink real time find the FAT32 partition on my computer ?<p>Hello,</p><p>I am currently working on Matlab R2016b and Simulink Real-time 6.5. My target computer is a Dell Optiplex 780 with 3GB of RAM. I boot the target kernel with a CD, configured with no graphical mode and no secondary IDE.</p><p>I have just erased the Windows OS from my target computer to install Ubuntu. During the installation process, I have created a big FAT32 partition intented for Simulink Real-time. However, when I boot in the target kernel, I still have the message "Error: No accessible disk found: file system disabled". I could not find on the forum an answer for my problem. I read <a href = "https://ch.mathworks.com/matlabcentral/answers/160425-why-can-t-my-target-computer-find-any-accessbile-disk-drive">this post</a>, but I cannot apply the solution since I don't have a Windows OS on the computer anymore (and the solution did not work for the author anymway). Could somebody help me understand why my FAT partition is not detected and find a solution?</p><p>Thank you,</p><p>Guillaume</p>Guillaumehttps://www.mathworks.com/matlabcentral/profile/authors/9317478-guillaumetag:www.mathworks.com,2005:Question/3262112017-02-21T17:53:23Z2017-02-22T17:35:20ZOrganising/Sorting imported files into matlab<p>Hello,</p><p>I have a series of frames (files) that I would like to read into matlab with each file called Frame1.jpg, Frame2.jpg and so on. I was wondering if there is anyway to read these into matlab in order? Matlab organises them all to using the first integer to begin with, so it reads Frame1.jpg, Frame.10jpg and so on.</p><p>Any help would be much appreciated.</p><p>Kind regards</p><p>Liam</p>Liam Thurstonhttps://www.mathworks.com/matlabcentral/profile/authors/9680615-liam-thurstontag:www.mathworks.com,2005:Question/3264072017-02-22T17:33:22Z2017-02-22T17:33:22ZI want to subtract (or extract or crop?!!!) a certain part of image and display the result(mean original image minus the extracted part). In my program I2 is the extracted part and I is original image. I need I-I2? Thanks much<p>The goal is extracting the optic disc from retinal image:</p><p>I = imread('cameraman.tif');
[I2, rect] = imcrop(I);
figure, imshow(imcrop(I));</p>somayeh ghhttps://www.mathworks.com/matlabcentral/profile/authors/7859511-somayeh-ghtag:www.mathworks.com,2005:Question/3264062017-02-22T17:28:28Z2017-02-22T17:29:18ZNumerical Method Terminal Velocity<p>Parachutist of mass(m) = 68.1 kg
drag coefficient(c) = 12.5 kg/s
g= gravitational acceleration = 9.81
ti=0
vi=0
ti+1 - ti = 0.1
here is the eqn
v(ti+1)=v(ti)+(g-(c/m)*v(ti))*(ti+1 - ti)</p><p>I just want to plot within such a point that v(ti+1)-v(t)<0.001</p><p>thanks</p>Ali Enes Yildirimhttps://www.mathworks.com/matlabcentral/profile/authors/7728629-ali-enes-yildirimtag:www.mathworks.com,2005:Question/3249702017-02-14T15:52:11Z2017-02-22T17:25:56Zsave array data in a loop <p>Hi</p><p>in the following code I'm searching for a match of indexes between 2 files , if I found a match take -6,6 elements from the 1st file .</p><p>I need to save the found data as (1,13) . data array shows the elements but I can't save them because saves one over the other</p><pre class="language-matlab">earFilename = 'EAR_v1.txt';
stateFilename = 'output_close_tags_video_1.txt';
</pre><pre class="language-matlab">% read EAR values
earfile = fopen(earFilename,'r');
formatSpec = '%d %f %f';
sizeA = [3 Inf];
</pre><pre class="language-matlab">earVector = fscanf(earfile, formatSpec, sizeA);
earVector = earVector';
</pre><pre class="language-matlab">% read state file
statefile = fopen(stateFilename,'r');
formatSpec = '%d %*s';
sizeA = [1 Inf];
</pre><pre> stateVector = fscanf(statefile, formatSpec,sizeA);
stateVector = stateVector';</pre><pre class="language-matlab">% create a dataset containing framenumber, EAR, state
dataset = [earVector, -1*ones(size(earVector,1),1)];
</pre><pre class="language-matlab">% for each positive state, +-6 frame are marked as positive
data=[];
for i = stateVector'
rowNumber = find(dataset==i);
for j = -6:6
data=(rowNumber+j);
disp(data)
</pre>sarmad mhttps://www.mathworks.com/matlabcentral/profile/authors/6551379-sarmad-mtag:www.mathworks.com,2005:Question/944462013-03-05T20:45:00Z2017-02-22T17:25:04ZCan I send e-mail through MATLAB using Microsoft Outlook?<p>I want to send e-mail through MATLAB, but the SENDMAIL command does not save the outgoing message for future reference. I would like to send mail through MS Outlook so that I may reference it later.</p>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/3261922017-02-21T16:46:47Z2017-02-22T17:21:31Zgpu arrayfun matrix multipltication, but without using concatenation or varargin varargout<p>Hello,</p><p>I was wondering how i can apply the same matrix multiplication, as encountered in linear unmixing of data sets, upon the elements of multiple arrays, using gpu enabled arrayfun? the problem i am encountering is that only elementary operations are permitted, so i cannot concatenate the scalars that are passed to the function inside arrayfun to construct the vector to be multiplied by a matrix. Furthermore, i cannot use variable inputs/outputs to handle unknown number of datasets.</p><p>a working piece of code is as follows with 2 inputs/datasets {A,B} hard coded:</p><pre> A = rand(2048,2048,11);
B = rand(2048,2048,11);
K = rand(2,2);
invKmatrix = inv(K);</pre><pre> function [Aout,Bout] = gpuApplyInvKmatrix(invKmatrix,A,B)
%GPUAPPLYINVKMATRIX
function [output1,output2] = DoStuff(A,B)
output1 = invKmatrix(1)*A + invKmatrix(3)*B;
output2 = invKmatrix(2)*A + invKmatrix(4)*B;
end
[Aout,Bout] = arrayfun(@DoStuff,A,B);
end</pre><p>the above fulfills the gpu requirement of elementary operations only, but i don't know how to generalize to multiple datasets. for example if the user wants to input 5 datasets...so K matrix of rand(5,5); with dataset inputs of A,B,C,D,E... do i just hard code each case?</p><p><a href = "http://stackoverflow.com/questions/30339131/issues-concatenating-in-arrayfun-with-gpu-processing-matlab">stackoverflow question that is similar</a> suggested using a multiple right hand side call, but there seems to be a caveat that this approach allocates too much memory?</p>Frederick Changhttps://www.mathworks.com/matlabcentral/profile/authors/2465740-frederick-changtag:www.mathworks.com,2005:Question/1008162013-09-30T21:51:00Z2017-02-22T17:19:31ZHow do I locate the crash dump files generated by MATLAB?<p>MATLAB crashed and I would like to locate the crash log files on my computer.</p><p>Why do I get the error MATLAB has encountered an internal error and needs to close?</p>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/3264052017-02-22T17:17:49Z2017-02-22T17:17:49ZHow to reformat data from multiple files in a folder<p>I have written code to open a command window allowing the user to choose a folder. Then The files from this folder will be opened. I have this part of the code working. Now I need to include a code I had previously written to reformat the data in each file.</p><pre class="language-matlab">myFolder = uigetdir('C:\Users\c13459232\Documents\MATLAB');
if ~isdir(myFolder)
errorMessage = sprintf('Error: the following folder does not exist: \n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.asc');
Files = dir(filePattern);
for k = 1 : length(Files)
baseFileName = Files(k).name;
FileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', FileName);
</pre><p>This is the first section of the code I have written to open the files</p><pre class="language-matlab">Cell = textscan( FileName, '%d', 'delimiter', ';');
Data = cell2mat(Cell);
N = 1024;
Finish = reshape(Data, N, [])';
end
</pre><p>This code reformats the data the way I want it. I know I will need to write the code to create 50 new files (e.g. Finish_01, Finish_02, etc). I'm not sure how to compose this.
Any tips would be greatly appreciated.</p>Aaron Smithhttps://www.mathworks.com/matlabcentral/profile/authors/9670029-aaron-smithtag:www.mathworks.com,2005:Question/3264042017-02-22T17:16:25Z2017-02-22T17:16:25Zhow rectangular QAM demodulator computes LLR values using step function.<p>I am using comm.rectangular QAM demodulator with decision method EXACT llr.
I want to know ,how this object calculate LLR values.</p>Pushpender Mannhttps://www.mathworks.com/matlabcentral/profile/authors/8479338-pushpender-manntag:www.mathworks.com,2005:Question/3264032017-02-22T17:10:10Z2017-02-22T17:10:10Zpassing extra parameters in optimization<p>If my objective run simple operation and also call other sub-functions and each sub-function has own parameters and may be they can share some parameters the following example is a view to how look like my objective function :</p><pre> function y = MyObjFun(.)</pre><pre> some simple operation that need variables that do not change during the optimization.</pre><pre> a = x1+x2; </pre><pre> y1 = sub-function1(a,b,c);
y2 = sub-function2(b,d,e)
.
.
.
ym = sub-functionm(m,n)</pre><pre> y = y1+y2+y3ym;</pre><p>what is the best way to write my objective function and passe these parameters?</p>boureghda mohammedhttps://www.mathworks.com/matlabcentral/profile/authors/6256706-boureghda-mohammedtag:www.mathworks.com,2005:Question/3263792017-02-22T15:05:38Z2017-02-22T17:09:07ZMATLAB Check buttons to get graph to disappear when unchecked<p>Hi,</p><p>I am new to Matlab and I have created two check buttons linked to an axes within my GUI. When i check one button the axes is plotted but i need the graph to dissapear when unchecked. Additionally when one check button is clicked i need the other to not be able to be clicked on.
I have attached my code, any help will be much appreciated.</p>sufyan patelhttps://www.mathworks.com/matlabcentral/profile/authors/9170995-sufyan-pateltag:www.mathworks.com,2005:Question/3262352017-02-21T19:51:35Z2017-02-22T17:08:27ZGUI customized layout prompt<p>Hello, I'm writing because I have a question regarding the layout of the GUI. Here's my code:</p><pre class="language-matlab">clc
clear all
prompt={'one','two:';
'three' , 'four'};
% Create all your text fields with the questions specified by the variable prompt.
title='my title';
rowscols = 2
defaults = {' def1:','def2:';
'def3' ,'def4'};
</pre><pre class="language-matlab">cstr = inputdlg (prompt, title, rowscols, defaults)
</pre><p>However, it's not what I want. I would like to have two elements per row shown in the gui, and not a layout with four rows. How can I achieve that please?</p>aredhelhttps://www.mathworks.com/matlabcentral/profile/authors/4460818-aredheltag:www.mathworks.com,2005:Question/3263902017-02-22T16:06:14Z2017-02-22T17:07:30ZHow to find variance and std in matlab without using zeros in matrix?<img src = "/matlabcentral/answers/uploaded_files/70564/matlab1.jpg"><p>I have a matrix (pm2d), and i need to calculate the std and (population) variance in each column without using the zero values. I was wondering if i could use a for loop or an if statement?</p><p>For my variance i used:</p><p>var = sum(pm2d.^2)/(length(pm2d)-1) - (length(pm2d))*mean(pm2d).^2/(length(pm2d)-1)</p><p>But that took the zeros into account...</p><p>And for the standard deviation i used:</p><p>S = std(pm2d)</p><p>which definitely used the zeros.</p><p>Every code i try to write is not working. Any assistance would be appreciated! Thanks!</p>Leesyhttps://www.mathworks.com/matlabcentral/profile/authors/9636060-leesytag:www.mathworks.com,2005:Question/3263992017-02-22T16:46:09Z2017-02-22T17:02:31Zhow to do probability function ?<p>Hi, I have a data x=[0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20] and y=[0
0.495726496
0.299145299
0.102564103
0.068376068
0.017094017
0.017094017
0
0
0
0
0
0
0
0
0
0
0
0
0
0], how can I do probability function with my x and y(probability) with dfittool ?
Thanks</p>Salmanhttps://www.mathworks.com/matlabcentral/profile/authors/5330710-salmantag:www.mathworks.com,2005:Question/3263422017-02-22T11:00:11Z2017-02-22T17:01:12Zsubtracting a particular value until that the result becomes negative<p>Hi all,</p><p>how can I subtract elements of a column until the point that the result is negative?</p><p>example: A=[1 2 3 4 5 4 2 1 1 1 3]' , I have an external value let's say 6. I want to go to the 6th element lets say and do this:6-4. then take the result (in this case 2), and subtract it from the next element until the result to become negative. At this point I would like to stop the process. is there any way to do this?</p><p>Imagine that I have an array 48X365</p><p>thanks!</p>Nikolas Spiliopouloshttps://www.mathworks.com/matlabcentral/profile/authors/9122757-nikolas-spiliopoulostag:www.mathworks.com,2005:Question/3264022017-02-22T17:00:25Z2017-02-22T17:00:25ZI have some defect on product, How I get defect boundary and area? <img src = "/matlabcentral/answers/uploaded_files/70573/Sample.JPG">Taweesak Kuhamaneehttps://www.mathworks.com/matlabcentral/profile/authors/9269545-taweesak-kuhamaneetag:www.mathworks.com,2005:Question/928132013-05-06T20:03:00Z2017-02-22T16:58:04ZHow do I increase the heap space for the Java VM in MATLAB 6.0 (R12) and later versions?<p>I am using a MATLAB version that is newer than MATLAB 6.0 (R12).*</p><p>How do I increase Java VM heap space?</p><ul><li>Note that the information in this solution is applicable to recent releases such as MATLAB 7.14 (R2012a).</li></ul>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/3264012017-02-22T16:55:54Z2017-02-22T16:55:54ZOverlap two pcolor with different color and set up transparency<p>I have two figures like below.</p><img src = "/matlabcentral/answers/uploaded_files/70571/a.jpg"><img src = "/matlabcentral/answers/uploaded_files/70572/b.jpg"><p>What I want to do is 1) overlap them into one figure. 2) set transparency at the place where they meet each other. The colour can be changed, can be any color where an overlap will look nice.</p><p>Many thanks</p>Xinhttps://www.mathworks.com/matlabcentral/profile/authors/4475206-xintag:www.mathworks.com,2005:Question/3263832017-02-22T15:24:39Z2017-02-22T16:55:47ZFinding maximum overlaps in a matrix<p>Hi All,</p><p>I have an input matrix as shown. How do I calculate for which values the maximum overlap occurs? i.e, as you can see the maximum overlap is somewhere between 0.5 and 3e-5. How do I do this using MATLAB? I tried using regression function but it does not seem to work.</p><img src = "/matlabcentral/answers/uploaded_files/70556/query.png"><p>The x-axes represent current values and the y-axes represent the voltages. I need to to be able to say that in this case, for example, we have say an overlap of 11 or 12 inputs (y-values). So this is for what x-range?</p><p>Please assist. Thanks!</p>Kash022https://www.mathworks.com/matlabcentral/profile/authors/7862610-kash022tag:www.mathworks.com,2005:Question/3262162017-02-21T18:23:15Z2017-02-22T16:54:20Zi want to add rows and columns to a binary image <p>Hi, am working on words i want to add rows and columns to a binary image based on threshold values and also add nodes based on center of mass. please help me and i have attached an images for your refernces</p>Raghu Raohttps://www.mathworks.com/matlabcentral/profile/authors/9619059-raghu-raotag:www.mathworks.com,2005:Question/3263892017-02-22T16:05:11Z2017-02-22T16:54:20ZSimple operations with symbolic variables<p>Hello everybody,</p><p>I'm new to Matlab. I would like to ask if anyone knows what's the time complexity of the addition / subtraction operations with symbolic variables.</p><p>Example:</p><p>syms a b</p><p>A = a^2*b^2+a^3*b^3</p><p>B = a^2*b^2+a*b</p><p>I would like to know what's the time complexity of this simple operation:</p><p>A - B = a^3*b^3 - a*b</p><p>I'm not sure about how Matlab calculates it.</p><p>(note that each variable has no given value).</p><p>Thank you!</p>Ben Raduhttps://www.mathworks.com/matlabcentral/profile/authors/9780046-ben-radutag:www.mathworks.com,2005:Question/2363192015-08-25T15:11:56Z2017-02-22T16:51:48ZHow to specify Dimension of a Bus Object element?<p>How can I use a MATLAB Variable or Parameter to specify the Dimensions of a Bus Object bus element?</p><p>Everything is defined in the same Data Dictionary. When I type the name of my Variable or Parameter for into Dimension field of a bus element, the Bus Editor gives the error message: "Undefined function or variable."</p><p>Seems silly that I am reduced to using "magic numbers" to specify the dimensions of certain common bus elements.</p><p>Using 2015a. Thanks.</p>Jerry Girardhttps://www.mathworks.com/matlabcentral/profile/authors/4035798-jerry-girardtag:www.mathworks.com,2005:Question/2465072015-10-02T04:00:00Z2017-02-22T16:51:15ZWhy can't MEX find a supported compiler in MATLAB R2015b after I upgraded to Xcode 7.0?<p>I installed Xcode 7.0 on my Mac and tried to use MEX. I receive the following error at the MATLAB command prompt:</p><p> </p><pre class="error"> >> mex -setup
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/maci64.html</pre><p> </p><p>Why does MATLAB not recognize the Xcode 7.0 installation on my Mac?</p>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/3264002017-02-22T16:48:36Z2017-02-22T16:48:36ZUsing YALMIP with Gurobi Matlab Interface, to run gurobi_iis() command.How to do?<p>Basically, I have an optimization problem formulated using YALMIP, and I am using Gurobi to solve it, and both are working well. However, now for some reason, I am trying to change some parameters in my problem, and Gurobi gives me that it is infeasible. I knew that gurobi_iis() (<http://www.gurobi.com/documentation/7.0/refman/matlab_gurobi_iis.html>) should tell me which constraint(s) make(s) the problem infeasible. My question is: how to use this command with YALMIP? It looks that each need different way to define inputs. Gurobi needs the problem to be in matrix form, and YALMIP is using easier way to formulate the problem.</p><p>If it is not possible, or hard, is there any other solver which works with YALMIP, and has the same function (or command) that gives the constraints making the problem infeasible?</p>Mohamed AlAsheryhttps://www.mathworks.com/matlabcentral/profile/authors/6832474-mohamed-alasherytag:www.mathworks.com,2005:Question/3263922017-02-22T16:25:06Z2017-02-22T16:46:21ZHow do I present my solutions?<p>If for example I got a matrix of : A = [1;2;3;4] how do i get it into the form so that in the matlab console it displays for example</p><pre> x_answer = 1
y_answer = 2
z_answer = 3
p_answer = 4</pre>Aidan Shekhttps://www.mathworks.com/matlabcentral/profile/authors/9025546-aidan-shektag:www.mathworks.com,2005:Question/3262992017-02-22T06:39:02Z2017-02-22T16:46:17ZUsing looping and change in xlrange and xlsread<p>Hello everyone</p><p>I have a tricky question for you. I am having trouble using variables in xlrange while looping. I am trying to change the change the column every iteration by generating the corresponding column alphabet and read the entire column in excel. My code snippet is as follows :</p><pre> h = 0:5:300;
for k = 1:length(h)
x = 'xlsColNum2Str';
avg_rd = round(xlsread(filename,'sheet1', [x(k) ':' x(k)] ));</pre><pre> % i have some more numerical operations being performed on the column obtained from above variable "avg_rd"
end</pre><p>The function "xlsColNum2Str" is coming from the below url -</p><p><a href = "https://www.mathworks.com/matlabcentral/fileexchange/15748-excel-column-number-to-column-name/content/xlsColNum2Str.m">https://www.mathworks.com/matlabcentral/fileexchange/15748-excel-column-number-to-column-name/content/xlsColNum2Str.m</a></p><p>I would appreciate any help in solving this problem.</p><p>Thank you,</p>androidguyhttps://www.mathworks.com/matlabcentral/profile/authors/5530816-androidguytag:www.mathworks.com,2005:Question/3263332017-02-22T10:15:18Z2017-02-22T16:43:05ZHow can I filter an audio signal from another application?<p>Hi guys, hope you can help me.</p><p>I am trying to apply a filter to the audio signal that is sent from another application to the audio output device. In other words I am trying to intercept the signal from the other application.</p><p>The application creates a specific sound corresponding to real-time data it receives. The idea is to incorporate 3D audio by filtering the stereo audio signals by means of Head Related Transfer Functions (wiki on HRTF's for some basic info: <a href = "https://en.wikipedia.org/wiki/Head-related_transfer_function">HRTF</a>).</p><p>The application that plays the audio cannot be changed and sends its stereo signal to the audio output device.</p><p>I want to intercept the audio from the application and then filter it by the HRTFs but it seems I cannot read/record any internal audio signals with Matlab. All I found was how to read/record audio data from an external device (such as a microphone) through the line-in.</p><p>In short: is there any way to retrieve the signal that is sent to the audio output device with Matlab, in real-time preferably? (I think I could just wire the line-out directly to the line-in but I think you will all agree that this is not a nice solution)</p>Bas Holtenhttps://www.mathworks.com/matlabcentral/profile/authors/2504620-bas-holtentag:www.mathworks.com,2005:Question/3238192017-02-07T16:00:23Z2017-02-22T16:40:18ZI want to write the matlab code for Hierarchical Centroid Shape Descriptor method. The image contains the steps .Please help me to write the codes<p>Here by i attached the steps in the image.</p>sam CPhttps://www.mathworks.com/matlabcentral/profile/authors/8044262-sam-cptag:www.mathworks.com,2005:Question/3263982017-02-22T16:37:44Z2017-02-22T16:37:44ZDoes Matlab has Automotive Radar Simulation which gives us output at reflections level ?<p>I want to simulate automotive radar that gives me velocity and angle of extended target in form of multiple reflections. For example, A vehicle is moving at specific distance and at specific angle with respect to host vehicle. I want simulated radar model returns me the radial velocity and angle of vehicle from all reflections that is returning from vehicle.</p>Hafiz Muhammad Luqmanhttps://www.mathworks.com/matlabcentral/profile/authors/7261354-hafiz-muhammad-luqmantag:www.mathworks.com,2005:Question/3263952017-02-22T16:33:12Z2017-02-22T16:34:11ZQuadcopter Project Simulation Thrust vector problems<p>Hi guys,</p><p>at the moment I'm working on the quadcopter project you can open with 'asbQuadcopterStart'. It is important for my bachelorthesis and drives me crazy somehow.
What I want to do is to use this simulation, to simulate a software which I want to implement later on a real quadcopter. Therefore I have to unterstand the simulation. As there are no real manuals to read except the one for the basics by mathworks I hope someone is kind of a pro with the Quadcopter Project.
At first I just need to get control about the quadcopter. I changed the variants.command to 2 to use pre-saved data.</p><img src = "/matlabcentral/answers/uploaded_files/70567/Data2.jpg"><p>(Picture 1)</p><p>On the left site of Picture 1 you can see my code to give command to the quadcopter.</p><img src = "/matlabcentral/answers/uploaded_files/70568/Flight_Control_System_Controller.2jpg.jpg"><p>(Picture 2)</p><p>In picture 2 you can see that I changed the way of the throttle_cmd to give commands to the quadcopter and not to depend on the sensors.
As you can see in picture 1 I gave no command at all, but the motor torque and thrust still worked and the quadcopter went up. My question now is where does this vector comes from?</p><p>If I give in at first a positive value followed by a negative value it goes up and down, but as soon as the negative command stops, it goes right up again.</p><p>I hope someone had the same problem or works on the project at the moment and can help me.</p><p>Greetings Tristan</p>Tristan Struckmeierhttps://www.mathworks.com/matlabcentral/profile/authors/9483486-tristan-struckmeiertag:www.mathworks.com,2005:Question/3262262017-02-21T19:08:36Z2017-02-22T16:32:50ZLicense checkout as different user<p>Hello,</p><p>Is there a method of checking out a license from the license server using a different user account?</p><p>I have a computer which is not on a domain, so I login with a local account. But I need to checkout the license using a domain account.</p><p>I tried using runas.exe to launch MATLAB as the domain user, but it is failing for a reason I haven't been able to track down yet.</p><p>I'd like to find a solution I can implement in MATLAB as opposed to the OS.</p><p>Thank you,
Mike</p>Michael Kantorhttps://www.mathworks.com/matlabcentral/profile/authors/1272268-michael-kantortag:www.mathworks.com,2005:Question/603452013-01-30T09:54:34Z2017-02-22T16:32:09ZFilled contour plot problem: colors and contour lines mismatch<p>The aim is to create a filled contour plot with a matching colorbar.
I have done this very often, but now I have a matrix of ocean salinity which is not plotted correctly. I have reduced the skript to the following lines, after loading the matrix "isalt", which contains Nans at the borders and values in the range of "csal" in between.</p><pre class="language-matlab">csal=[34.76:0.02:34.98];
</pre><pre class="language-matlab">figure(1)
</pre><pre class="language-matlab">[C,h]=contourf([1:72],[1:20],isalt,csal);
colormap(jet(length(csal)-1));
caxis([csal(1) csal(end)]);
colorbar;
</pre><p>The plot looks fine until "caxis" is carried out.</p><p>I am new in this forum and cannot find a possibility to upload the .mat file containing the matrix and the resulting figure :-/</p><p>But maybe someone has an idea...</p>Kerstinhttps://www.mathworks.com/matlabcentral/profile/authors/4027118-kerstintag:www.mathworks.com,2005:Question/3255652017-02-17T12:44:40Z2017-02-22T16:30:07ZHow to get the order of Simulink blocks based on their pin connection <p>How to get the order of Simulink blocks based on their pin connection.</p><p>For Example: From attached Simulink model (This model has no meaning. created only to give idea about my problem ), I want to get the order of blocks based on pin connection instead of their alphabetic order.</p><p>The order should be like <b>(Expected Output)</b>:</p><p>1. Integrator,Second-Order Limited Block</p><p>2. Integrator or Rate Limiter Dynamic Block</p><p>3. Rate Limiter Dynamic or Integrator Block</p><p>4. Lookup table Dynamic Block</p><p>5. Data type Conversion block</p><p>6. n-DLookup Table Block</p><p>But Currently I am getting order based on Aplhabatic name of Blocks (Refer below image for the results uisng 'find_system' command.)</p><p><b>(Current Output):</b></p><img src = "/matlabcentral/answers/uploaded_files/70159/CurrentOrder.PNG">Ganesh Hegadehttps://www.mathworks.com/matlabcentral/profile/authors/8101030-ganesh-hegadetag:www.mathworks.com,2005:Question/1006032013-04-03T14:37:00Z2017-02-22T16:29:53ZHow can I compile a MATLAB Engine application using Microsoft Visual Studio 9.0 or 10.0 ?<p>I would like to call MATLAB from my C/C++ application using the Engine interface. However, I would like to compile my project in the Microsoft Visual Studio 9.0 (2008) or Visual Studio 10.0 (2010) environment, instead of compiling it in the MATLAB environment.</p>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/3263942017-02-22T16:29:30Z2017-02-22T17:11:17ZError in matlab code for best c and gamma using svmtrain()<p>Error in ==> svmtrain at 236
error('Bioinfo:svmtrain:UnknownParameterName',...</p><p>Error in ==> crossvalidation_w at 15
model = svmtrain(w(train),y(train,:),x(train,:),sprintf('-c %f -g %f -w-1 %d -w1 %d',
2^C(i), 2^gamma(i), 1, 9.16));</p><p>I am getting this error</p>JHANSI LAKSHMIhttps://www.mathworks.com/matlabcentral/profile/authors/9324124-jhansi-lakshmitag:www.mathworks.com,2005:Question/3263932017-02-22T16:27:12Z2017-02-22T17:37:05ZModifying GUIDE ListBox outside its Callback function<p>I have developed a GUI using GUIDE. It has several dropdown lists. I want to be able to reset/restore the state of the lists to some original/initial state when I press a push-button. The way I attempted to do it is by using the set command as follows:</p><pre class="language-matlab">set(handles.z_height, 'Value', z_index);
</pre><p>The above command is located within the callback of the reset button. However, when I run this code it returns the following error:</p><pre class="language-matlab">??? Error using ==> set
Invalid handle object.
</pre><pre class="language-matlab">Error in ==> GUI_LCL_LCL>reset_Callback at 906
set(handles.z_height, 'String', num2cell(z_height));
</pre><pre class="language-matlab">Error in ==> gui_mainfcn at 96
feval(varargin{:});
</pre><pre class="language-matlab">Error in ==> GUI_LCL_LCL at 42
gui_mainfcn(gui_State, varargin{:});
</pre><pre class="language-matlab">Error in ==> @(hObject,eventdata)GUI_LCL_LCL('reset_Callback',hObject,eventdata,guidata(hObject))
</pre><pre class="language-matlab">??? Error while evaluating uicontrol Callback
</pre><p>What I’m I missing?</p><p>Thanks in advance for any assistance.</p>Bryan Estebanhttps://www.mathworks.com/matlabcentral/profile/authors/3124156-bryan-estebantag:www.mathworks.com,2005:Question/2998462016-08-17T06:49:09Z2017-02-22T16:24:41ZHow can I convert a ROS Image topic into an matrix that I can process in Simulink?<p>I am trying to find a simple way of converting images received from ROS into matrix form that can then be processed in Simulink. On Matlab side there are the writeImage and readImage functions that can be used to convert ROS Image to matlab image but I am not sure what should be the correct way of doing this on Simulink side.</p><p>One option would be to get the raw data from Image topic and reorganize it into matrix form, but that processing is always dependent on the image size and format. Is there any simple way of doing this?</p>Anttihttps://www.mathworks.com/matlabcentral/profile/authors/1384538-anttitag:www.mathworks.com,2005:Question/3261372017-02-21T11:29:06Z2017-02-22T16:22:12ZHow to calculate velocity at each timestep for this problem? (Image Included)<p>I have a grid of x and z and a concentration front, c, that advances front z=0 with time and is c=1 at the start. I want to find the velocity at which this concentration front is moving, and so my idea was to find each point z at which c=0.001 (i.e. a very small number representing the concentration front). I also need to consider that the concentration front does not advance linearly so I think it would need to represent the average position?</p><p>i.e. <a href = "z">z</a>(t=0,c=0.001)=...</p><p><a href = "z">z</a>(t=dt,c=0.001)=...</p><p><a href = "V">V</a>=(z(t=0)-z(t=dt))/dt</p><p>Apologies if this doesn't make sense, maybe someone could help me with an idea of how to approach this problem?</p>George Kyriacouhttps://www.mathworks.com/matlabcentral/profile/authors/9693667-george-kyriacoutag:www.mathworks.com,2005:Question/3263912017-02-22T16:09:39Z2017-02-22T16:22:08Zfind foreground pixels in each segments in grid<p>i want to find the foreground pixels in each segments in grid after finding the foreground pixel i want to find center of mass in each segments and i want to add nodes based on center of mass.</p>Raghu Raohttps://www.mathworks.com/matlabcentral/profile/authors/9619059-raghu-raotag:www.mathworks.com,2005:Question/3262402017-02-21T20:38:37Z2017-02-22T16:21:40ZImage Analysis with flow and gray scale<p>Hello. I am trying to calculate the percentage of the white foam for this image. I am struggling because I can either do a 8 bit binary black and white but it takes out some of the foam that is less dense and not completely white. The color of the foam varies. The second way I approached it was using a RBG analysis. I basically just analyzed the closest ranges for gray to white and black as the background.</p><p>Do any of you know how to separate the foam from the background more accurately?</p><p>Thanks</p><pre> I = imread('test5.png') ;
figure;
imshow(I)
BW = im2bw(I,0.4);
figure; imshow(BW)
percentageBlack=(1-nnz(BW)/numel(BW))*100</pre><pre class="language-matlab">%%%%another method
</pre><pre class="language-matlab">clear all
clc
</pre><pre class="language-matlab">filename = 'test5.png';
RGB = imread(filename);
grayscale = rgb2gray(RGB);
</pre><pre class="language-matlab">numTotalPixel = size(grayscale,1) * size(grayscale, 2);
numBlackPixel = sum(grayscale(:)<= 80);
numWhitePixel = sum(grayscale(:)>140);
numGrayPixel = sum(grayscale(:)>80)-numWhitePixel;
</pre><pre class="language-matlab">percentBlackPixel = numBlackPixel / numTotalPixel * 100
percentWhitePixel = numWhitePixel / numTotalPixel * 100
percentGrayPixel = numGrayPixel / numTotalPixel *100
</pre>Christine Neehttps://www.mathworks.com/matlabcentral/profile/authors/3089154-christine-neetag:www.mathworks.com,2005:Question/3263772017-02-22T14:52:21Z2017-02-22T16:13:03ZHow to take average/median of table columns without the zeros?<img src = "/matlabcentral/answers/uploaded_files/70553/matlab1.jpg"><p>Hey there,
I have a big table (called pm2d), 12 columns by 31 rows, and i need to take the average and median of each column without the zeros being factored in. I know i can use for loop and if statement to check the number of valid data points and get a new array with only valid data points... But every code i try to write is not working. Any assistance would be appreciated! Thanks!</p>Leesyhttps://www.mathworks.com/matlabcentral/profile/authors/9636060-leesytag:www.mathworks.com,2005:Question/3254802017-02-16T23:14:40Z2017-02-22T16:00:38ZSimulink Desktop Real-Time Sync block (Matlab 2016b) seems to cause my PC to crash. Is this a reported problem? Any Fix?<p>This problem appears at random, but is has happened several times on both my laptop and PC (both running Windows 10). When running even simple models (i.e. Sine source to scope) with the real-time sync block, my PC will unexpectedly crash requiring a hard reset. Is this a problem with how the real-time kernel works with my PC clock? Is this a problem anyone else is experiencing, and is there a fix?</p>Jamesonhttps://www.mathworks.com/matlabcentral/profile/authors/3315243-jamesontag:www.mathworks.com,2005:Question/3263822017-02-22T15:16:11Z2017-02-22T15:59:01ZError that makes no sense at all<p>Suddenly the histogram function doesn't generate plots. I tested it with this:</p><pre class="language-matlab">>> x = randn(10000,1);
>> h = histogram(x)
Error using histogram
Too many input arguments.
</pre><p>What gives?</p>Stephen Thompsonhttps://www.mathworks.com/matlabcentral/profile/authors/5841753-stephen-thompsontag:www.mathworks.com,2005:Question/3260792017-02-21T05:37:43Z2017-02-22T15:58:54ZHow to perform Arthemtic Codding on Nested Cell Aray<p>I am having the following cell C, with the associated data</p><pre class="language-matlab">2x1 cell
[29;32]
[0;72]
</pre><pre class="language-matlab">2x1 cell
[]
[29;31;33;64]
</pre><pre class="language-matlab">6x1 cell
[]
[0;11;14;15;20;22;45;53]
[0;13;16;17;34;47]
[0;18;21;33]
[0;10;15;16;17]
[0;10;14;24;31]
</pre><pre class="language-matlab">18x1 cell
[]
[]
[]
[]
[]
11x1 int8
13x1 int8
[0;10;11;13;15;16;18;21;22;33]
16x1 int8
[0;10;11;13;15;20;23;24;26]
[0;10;11;13;14;16;18;25]
0
[0;14;15]
[0;11;13;14;16;20;21;23]
[0;11;13;15;21]
[0;10;11;12;14;17;19;20;23]
[0;10;11;12;13;15;16;18;20]
[0;10;11;12;14;15;19;20;25]
</pre><p>How can we apply Arithmetic coding of the above cell C. I tried to do Ac on each cell, but it is ending in error. How can we retrieve the unique symbols from all the cell and its count, so we can run the AC function, without effecting the cell structure. Also how can be do the decoding and retrieve the cell back?</p>GEEVARGHESE TITUShttps://www.mathworks.com/matlabcentral/profile/authors/7458829-geevarghese-titustag:www.mathworks.com,2005:Question/3263852017-02-22T15:37:51Z2017-02-22T15:58:08ZHow can I detect regions in image using x,y coordinates?<p>I am a newbie in Image Processing using Matlab. have been successful in doing Marked Circle recognition using Template Matching.This is the code I used:</p><pre class="language-matlab">function[res] = findtemplate(image, template, th, showtemp)
im = rgb2gray(imread(image));
temp = rgb2gray(imread(template));
close all
out = normxcorr2(temp, im);
[m, n] = size(temp);
out = out(m+1: end, n+1: end);
bw = out > th;
r = regionprops(bwlabel(bw));
</pre><pre> if nargin > 3
im(1:m, 1:n) = temp;
end</pre><pre> res = r;</pre><pre> clf
imshow(im, [])
hold on</pre><pre> for i=1:length(r)
rectangle('position', [r(i).Centroid(1), r(i).Centroid(2), m, n], 'EdgeColor','r','LineWidth',2);
end</pre><p>Output image looks like this:</p><img src = "/matlabcentral/answers/uploaded_files/70557/fgfgffgff.jpg"><p>And now I must detect that numbers using x,y coordinates.It would be helpful if someone explains it better since I am a newbie.Thanks in advance!</p>AminaOsmanovahttps://www.mathworks.com/matlabcentral/profile/authors/9604112-aminaosmanova