http://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2016-06-29T22:42:54Ztag:www.mathworks.com,2005:Question/2930022016-06-29T14:27:21Z2016-06-29T22:42:54ZAbout "graycomatrix".<p>Hi,</p><p>I am relatively a new user of Matlab. And I have a small question, maybe because of my low level of Matlab knowledge.
When I run the graycomatrix func over the array shown in thw documented help manual of the "graycomatrix" func, I do not get an 8-by-8 matrix as shown in the documented help.</p><pre class="language-matlab">I = [1 1 5 6 8;2 3 5 7 1;4 5 7 1 2;8 5 1 2 5]
glcm = graycomatrix(I); %Fn#1
</pre><p>What we get is an 8-by-8 matrix of all zeros except the bottom right element as 16. Now, if we go by the documented help the resultant matrix should be
[1 2 0 0 1 0 0 0;0 0 1 0 1 0 0 0;...] This matrix is alright. I can understand how it came.</p><p>But my confusion is why we get a diff matrix when we use graycomatrix func (noted as Fn#1 above)?</p><p>Any help will be much appreciated.</p>kamal rajhttp://www.mathworks.com/matlabcentral/profile/authors/8383410-kamal-rajtag:www.mathworks.com,2005:Question/2930052016-06-29T14:49:47Z2016-06-29T22:37:47ZHow can i import jpeg file in my app designer gui ?<p>Hello,</p><p>How can i import jpeg file in my app designer gui ?</p><p>With the previous version of Matlab GUI (GUIDE), i could import jpeg file into an Axes to see it but i don't find how to do this with app designer. Somebody can help me ? Please. Thank you</p>Maxime LEGUILLONhttp://www.mathworks.com/matlabcentral/profile/authors/3428836-maxime-leguillontag:www.mathworks.com,2005:Question/2930082016-06-29T15:06:29Z2016-06-29T22:36:33Zsend 1-bit from node to other?<p>Hello guys,
How can I send data (1-bit) from node to other??
help me please</p>skysky2000http://www.mathworks.com/matlabcentral/profile/authors/8108639-skysky2000tag:www.mathworks.com,2005:Question/2930382016-06-29T18:20:19Z2016-06-29T22:31:29Zproblem in imfinfo give me the following error<p>I have done the following code</p><pre class="language-matlab">clear all,close all,clc;
originalImage = imread('101_1.tif');
testImage = imread('101_1.tif');
originalInfo = imfinfo(originalImage)
fakelInfo = imfinfo(testImage);
if(getfield(originalInfo,'ColorType')=='truecolor')
originalImage=rgb2gray(imread('101_1.tif'));
else if(getfield(originalInfo,'ColorType')=='grayscale')
</pre><pre> originalImage=imread('101_1.tif');</pre><pre> else
error('The Color Type of Left Image is not acceptable. Acceptable color types are truecolor or grayscale.');
end
end</pre><pre> if(getfield(fakelInfo,'ColorType')=='truecolor')</pre><pre> testImage=rgb2gray(imread('101_1.tif'));
else if(getfield(fakelInfo,'ColorType')=='grayscale')</pre><pre> fakelInfo=imread('101_1.tif');</pre><pre> else
error('The Color Type of Left Image is not acceptable. Acceptable color types are truecolor or grayscale.');
end
end</pre><p>But when I run this code it shows me the following error:</p><pre class="language-matlab">Error using imfinfo (line 80)
Expected FILENAME to be one of these types:
</pre><pre class="language-matlab">char
</pre><pre class="language-matlab">Instead its type was uint8.
Error in teste (line 20)
originalInfo = imfinfo(originalImage)
</pre><p>how can I solve this.</p>Biza Ferreirahttp://www.mathworks.com/matlabcentral/profile/authors/3743527-biza-ferreiratag:www.mathworks.com,2005:Question/2922622016-06-25T08:22:24Z2016-06-29T22:29:29Zhow to make a slice of multiple images in 3d<p>I have these three images meterology. First image is weather chat of 100m, second is of 200m, thrid is of 300m.</p><img src = "/matlabcentral/answers/uploaded_files/54960/100.jpg"><img src = "/matlabcentral/answers/uploaded_files/54963/200.jpg"><img src = "/matlabcentral/answers/uploaded_files/54964/300.jpg"><p>I have these three images meteorology. First image is weather chat of 100m, second is of 200m, third is of 300m</p><p>This is roughly prototype of my idea what i want</p><img src = "/matlabcentral/answers/uploaded_files/54965/0t4Sn.png"><p>Both longitude and latitude are same in three images, I want to just makes longitude as x - axis, latitude as y axis and 100m image at 100, 200m image at 200 ....</p><pre> i able to producce this code, </pre><pre class="language-matlab">a=imread('100.jpg');
b=imread('200.jpg');
c=imread('300.jpg');
I = cat(4,a,b,c);
data = importdata('gpheight300.txt') ;
x = data(:,1) ; x = unique(x) ;
y = data(:,2) ; y = unique(y) ;
%# coordinates
[X,Y] = meshgrid(1:size(I,2), 1:size(I,1));
%[X,Y]=meshgrid(x,y);
Z = ones(size(I,1),size(I,2));
kin=[100 200 300];
</pre><pre class="language-matlab">for k=1:length(kin)
surface('XData',X, 'YData',Y, 'ZData',Z.*kin(k), ...
'CData',I(:,:,k), 'CDataMapping','direct', ...
'EdgeColor','none', 'FaceColor', 'texturemap')
% patch('XData',X, 'YData',Y, 'ZData',Z.*kin(k),'CData',I(:,:,k))
end
%colormap(cmap)
view(3), box on, %axis tight square
%set(gca, 'YDir','reverse', 'ZLim',[0 size(I,3)+1])
saveas(gcf,'3d','jpg');
</pre><p>This code producing surface in which all three images becomes brown color,(wrapped) when i save them just is this blank 3d block save appear.</p><img src = "/matlabcentral/answers/uploaded_files/54966/3d.jpg"><p>Can some one tell me how i can do this 3d slicing of images?</p>Muhammad Usman Saleemhttp://www.mathworks.com/matlabcentral/profile/authors/6394611-muhammad-usman-saleemtag:www.mathworks.com,2005:Question/2930162016-06-29T15:47:03Z2016-06-29T22:28:36ZReduce Horizontal Spacing Between Subplots (Trouble With Subaxis)<p>I'm trying to make generic m x n subplots as an output for a larger function, and I'd like to decrease the horizontal spacing between axes. I'm using subaxis successfully to adjust vertical spacing, but for some reason the horizontal spacing remains unchanged. Ultimately, I'd like to set a constant horizontal spacing parameter independent of the number of columns in the figure.</p><p>I've seen multiple posts about this issue but haven't been able to find an answer. Any suggestions?</p>amen45http://www.mathworks.com/matlabcentral/profile/authors/6134492-amen45tag:www.mathworks.com,2005:Question/2929852016-06-29T13:12:44Z2016-06-29T22:26:23ZHow multiple Linux users can use a "designated computer" license on linux<p>I have successfully installed Matlab for Linux. The license is a "designated computer" license which allows any user on the computer to use the license. However, when a user other than the one who installed the license tries to launch Matlab the license manager says the license is unavailable and Matlab never launches.</p><p>What do I need to allow all users on the machine to be able to successfully launch Matlab?</p><p>Thanks.</p>Joehttp://www.mathworks.com/matlabcentral/profile/authors/3295379-joetag:www.mathworks.com,2005:Question/422392012-06-28T08:00:56Z2016-06-29T22:21:45Zxlsread: Not enough storage is available to complete this operation<p>Hi all</p><p>I am attempting to import a spreadsheet into MATLAB which is apporximately 200MB in size. When I use xlsread I get the following message:</p><p>Invoke Error, Dispatch Exception: Not enough storage is available to complete this operation.</p><pre class="language-matlab">Error in xlsreadCOM (line 64)
rawData = DataRange.Value;
</pre><pre class="language-matlab">Error in xlsread (line 230)
[numericData, textData, rawData, customOutput] = xlsreadCOM(file, sheet, range, Excel,
customFun);
</pre><p>Is this a limitation on the size of file which MATLAB can read or is it a hardware limitation?</p><p>Thanks</p><p>Peter</p>Peterhttp://www.mathworks.com/matlabcentral/profile/authors/3522952-petertag:www.mathworks.com,2005:Question/2930312016-06-29T17:32:04Z2016-06-29T22:20:12ZGenetic Algorithm Optimization - No Toolbox<p>Hello there,</p><p>I'm doing some research that involves the use of a genetic algorithm - -
I was wondering if anyone had any advice as to how to optimize a genetic algorithm.
Is there a particular method for the mutation/fitness/mating functions that gets to the goal fast?
Or types of parameters that does so as well..</p><p>Thank you.</p>Tara Penahttp://www.mathworks.com/matlabcentral/profile/authors/6971997-tara-penatag:www.mathworks.com,2005:Question/2930372016-06-29T18:19:43Z2016-06-29T22:18:09ZIs there any one that has a matlab code for Digital breast tomosynthesis reconstruction ?<p>I am a beginner in the Tomosynthesis reconstruction field.
To start up my research, I am looking for a simple matlab code than can help me build and adapt different reconstruction methods.</p>Fatmahttp://www.mathworks.com/matlabcentral/profile/authors/4884005-fatmatag:www.mathworks.com,2005:Question/2927622016-06-28T16:56:22Z2016-06-29T22:17:56ZHow can I made a correlation between two images of the same size?<p>Hello,
I have a small problem I wanted to build a table with the correlation of 10 images values all with the same size.</p>Biza Ferreirahttp://www.mathworks.com/matlabcentral/profile/authors/3743527-biza-ferreiratag:www.mathworks.com,2005:Question/2930402016-06-29T18:44:59Z2016-06-29T22:11:38ZCannot print a figure using print()<p>Currently using the lines</p><pre class="language-matlab">set(fig,'paperpositionmode','manual');
set(fig,'paperorientation','landscape');
set(fig,'paperunits','normalized');
set(fig,'paperposition',[0 0 1 1]);
print(fig,filename,'-dpdf','-fillpage');
</pre><p>to print a figure. Receiving error:</p><pre class="language-matlab">Error using checkArgsForHandleToPrint>LocalString2Handle (line 170)
Problem reading figure handle in -f switch: '-fillpage'.
</pre><pre class="language-matlab">Error in checkArgsForHandleToPrint (line 43)
</pre><pre class="language-matlab">Error in print>LocalCreatePrintJob (line 336)
handles = checkArgsForHandleToPrint(0, varargin{:});
</pre><pre class="language-matlab">Error in print (line 153)
[pj, inputargs] = LocalCreatePrintJob(varargin{:});
</pre><pre class="language-matlab">Error in dispPressures>savePlots (line 1088)
print(fig,filename,'-dpdf','-fillpage');
</pre><pre class="language-matlab">Error while evaluating UIControl Callback
</pre><p>I'm trying to print out a figure with two axes onto a PDF in landscape format and with the printout filling the entire page. I would prefer to use '-bestfit', but that gives me an illegal option error. Running 2015a.</p>TastyPastryhttp://www.mathworks.com/matlabcentral/profile/authors/6782881-tastypastrytag:www.mathworks.com,2005:Question/2930552016-06-29T22:10:34Z2016-06-29T22:11:33ZWhy isn't uigetfile working in my compiled standalone application? <p>I created a standalone application that plots data, in order to select the files with the data I use uigetfile. When I compile this on a mac and run the stand alone program on a mac it works. When i compile this on windows and try to run it on windows it does not work. When the file selection window is supposed to open, it never does.
Here is a snippet of my code from my guide:</p><pre class="language-matlab">global var
if isnan(var)
h=msgbox('Please input a number in the box');
else
[DRIfilename,pathNameDRI]=uigetfile('../*.xlsx');
allDRI=fullfile(pathNameDRI,DRIfilename);
if isequal(DRIfilename,0)
buttonDRI=questdlg('Do you wish to quit this program?','No selection','Continue','Quit','Continue');
if isequal(buttonDRI,'Quit')
return
else
[DRIfilename,pathNameDRI]=uigetfile('../*.xlsx');
allDRI=fullfile(pathNameDRI,DRIfilename);
end
end
plotter(var,allDRI);
end
</pre>Rachel Rexhttp://www.mathworks.com/matlabcentral/profile/authors/6576849-rachel-rextag:www.mathworks.com,2005:Question/2930492016-06-29T20:32:36Z2016-06-29T22:04:38Zhow i can use Particle swarm optimizaton with load flow ?????<p>how i can use Particle swarm optimizaton with load flow ?????</p>doaa mahmoudhttp://www.mathworks.com/matlabcentral/profile/authors/7830874-doaa-mahmoudtag:www.mathworks.com,2005:Question/2906662016-06-18T14:41:31Z2016-06-29T21:59:23ZHow to limits a photo in GUI<p>I'm trying to control an uploaded photo position and size in GUI.
I'm using GUI to run the m file, which uploads the photo.</p>Guyhttp://www.mathworks.com/matlabcentral/profile/authors/8328023-guytag:www.mathworks.com,2005:Question/999552011-11-21T21:11:00Z2016-06-29T21:51:26ZHow do I compute the mean and median frequency of a power spectrum using the Signal Processing Toolbox?<p>I would like to compute the following:</p><p>1. The mean frequency of a power spectrum, defined as the normalized,</p><p>one-sided, first order spectral moment.</p><p>2. The median frequency defined as the particular frequency that would divide the</p><p>power spectrum into two parts of equal area.</p>MathWorks Support Teamhttp://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/1310872014-05-25T18:36:50Z2016-06-29T21:49:18ZHow to display and save rise time, maximum overshoot and settling time <p>I doing large iteration to choose the best gains for different flight conditions, how may I calculate the rise time, maximum overshoot and settling time for every iterations and save it in a file so that I can use that file to train my ANN</p><p>Tq</p>Arjunhttp://www.mathworks.com/matlabcentral/profile/authors/5314938-arjuntag:www.mathworks.com,2005:Question/60692011-04-23T04:08:03Z2016-06-29T21:46:25ZDTW(Dynamic Time Warping Algorithm)<p>I need a matlab code for a fast unconstrained DTW to add it to my speech recognition project .
Thanks a lot
Nada Gamal</p>Nada Gamalhttp://www.mathworks.com/matlabcentral/profile/authors/2655383-nada-gamaltag:www.mathworks.com,2005:Question/2930412016-06-29T18:50:39Z2016-06-29T21:39:30ZProblem with multi-line in TextEdit box<p>Hi,
I cannot find a way to display the text in multiple lines in text edit box. I read that I all I need is to set property Max to be larger than Min (e.g. Max = 2), but this does not do the trick.
For test purpose I have simple GUI, with only one text edit box and one button. "Pushbutton1_Callback" function executes the following code:</p><pre> for i =1 :100
set(handles.edit1,'String', [num2str(i), ' test'] );
pause(0.1);
end</pre><p>However, all i get on the box is single line. How can I fix this to obtain multiple lines like this:</p><p>1 test</p><p>2 test</p><p>3 test
....</p><p>Thank you!</p>stani7062http://www.mathworks.com/matlabcentral/profile/authors/8384286-stani7062tag:www.mathworks.com,2005:Question/2930322016-06-29T17:35:45Z2016-06-29T21:38:29Zhi,I wanted to know,if it is possible to plot some data in the same graph from two different M files?<p>I want to plot figures in the same graph from two different M-files? Is it possible?</p>nafila aytijahttp://www.mathworks.com/matlabcentral/profile/authors/2894215-nafila-aytijatag:www.mathworks.com,2005:Question/2738822016-03-16T04:00:00Z2016-06-29T21:36:15ZWhy does MATLAB crash on startup after recent (Feb 2016) Windows Updates?<p>Why does MATLAB crash upon startup after having updated my Windows operating system?</p>MathWorks Support Teamhttp://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/2929622016-06-29T11:06:39Z2016-06-29T21:35:15ZI need to input varying frequency in sine wave how can i do that?<p>Actually i have a varying frequency output which i should input into sine. I m having problems please help me...</p>Abhishek Sarakanamhttp://www.mathworks.com/matlabcentral/profile/authors/8382790-abhishek-sarakanamtag:www.mathworks.com,2005:Question/2930452016-06-29T19:14:36Z2016-06-29T21:31:17Zconvert matrix to jet colormap image and save as tiff<p>I'm working with hundreds of images that I need to convert to images using the jet colormap.</p><p>I work with tiff files.</p><p>I can import these in as matrices, but I can't seem to find a way to convert them to jet colormap images.</p><p>I wish to be able to convert them to jet colormap images and export them as a tiff file.</p>Hosup Songhttp://www.mathworks.com/matlabcentral/profile/authors/6111579-hosup-songtag:www.mathworks.com,2005:Question/2929022016-06-29T08:12:25Z2016-06-29T21:30:01ZHow to shift curves and select appropriate peak y-axis values<p>I have curves of experimental data (imported from spreadsheets) for which I have to compute the max y-axis values and the delta time on the x-axis.
For each test condition I have perfomed at least 3 experiments.</p><p>1) The first problem is that while the peak values and the delta times are similar, the curves have a time shift (i.e. the Y-axis peak is occurring earlier or later), so I cannot simply compute the average in Excel, since this time-shift would affect the mean values and delta time computation (e.g. the curves would look "wider").</p><p>I know how to import the spreadsheets data, but how can organize the data in Matlab in order to avoid the effect of the time shift?</p><p>2) Then the second problem is due to the fact that the Y-axis peak is not always on the one that I am looking for, but sometimes it just occurs at the beginning of the experiment, while I am looking at a later time peak value. How can I select it?
Note that the starting Y-values are sometimes smaller than zero.</p><p>I am attaching a sample Excel file with numerical test results.</p><p>And here I am also attaching a figure for one single test result to be more clear.</p><img src = "/matlabcentral/answers/uploaded_files/55219/Capture3.PNG">Quong Axxonghttp://www.mathworks.com/matlabcentral/profile/authors/8368480-quong-axxongtag:www.mathworks.com,2005:Question/2930512016-06-29T20:40:01Z2016-06-29T21:27:20ZNew article on image retrieval based on triangular histograms or histograms of triangles<p>New article on image retrieval based on triangular histograms <a href = "http://www.sciencedirect.com/science/article/pii/S0045790616300726">http://www.sciencedirect.com/science/article/pii/S0045790616300726</a></p>Nomi khanhttp://www.mathworks.com/matlabcentral/profile/authors/4965748-nomi-khantag:www.mathworks.com,2005:Question/2930362016-06-29T18:10:44Z2016-06-29T21:26:21ZI have this code d is matrix. I cant find x and z from d. how can I do that?<p>MATLAB code</p><pre class="language-matlab">function pimage(x,z,d);\\
%PIMAGE: High quality image for ppt presentations etc etc.
% Go to "file" "export setup" to export with proper labels,
% line width, size and other attributes.
%
% I *N x: x-axis, x(nx)
% z: z-axis, z(nz)
% d: data, d(nz,nx)*
%
%
% Copyright (C) 2008, Signal Analysis and Imaging Group
% For more information: http://www-geo.phys.ualberta.ca/saig/SeismicLab
% Author: U. Theune and M.D.Sacchi
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation, either version 3 of the License, or
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details: http://www.gnu.org/licenses/
function pimage(x,z,d);
%PIMAGE: High quality image for ppt presentations etc etc.
% Go to "file" "export setup" to export with proper labels,
% line width, size and other attributes.
%
% IN x: x-axis, x(nx)
% z: z-axis, z(nz)
% d: data, d(nz,nx)
%
%
% Copyright (C) 2008, Signal Analysis and Imaging Group
% For more information: http://www-geo.phys.ualberta.ca/saig/SeismicLab
% Author: U. Theune and M.D.Sacchi
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation, either version 3 of the License, or
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details: http://www.gnu.org/licenses/
%
</pre><pre> pcolor(x,z,d);
shading interp;
axis ij; </pre><pre> set(gca,'ydir','reverse','xaxislocation','top','yaxislocation','left','layer','top','linewidth',2,'tickDir','out','box','on')</pre><pre> % Move the plot down to make space at the top</pre><pre> pos=get(gca,'position');
set(gca,'position',[pos(1) 0.05 pos(3) pos(4)])</pre><pre> colormap(seismic(1));</pre><pre> return;</pre>Hugo Ochoahttp://www.mathworks.com/matlabcentral/profile/authors/8345127-hugo-ochoatag:www.mathworks.com,2005:Question/2930542016-06-29T21:11:00Z2016-06-29T21:20:59ZHow can I be associated with a license to download products and updates? How can I get my serial number?<p>I have my account but I can not download the product without an unique serial number. How can I free get it?</p>Ordinary Manhttp://www.mathworks.com/matlabcentral/profile/authors/8384112-ordinary-mantag:www.mathworks.com,2005:Question/2929472016-06-29T09:58:54Z2016-06-29T21:15:59ZFast access to matfile in GUI<p>I have a large array of structures stored in a matfile and I need these values to plot in a GUI. But the conventional loading of the entire matfile takes a minute or more and this is not good for a GUI. Is there anyway I can access these values faster?</p>Amulya NVhttp://www.mathworks.com/matlabcentral/profile/authors/6354570-amulya-nvtag:www.mathworks.com,2005:Question/2929202016-06-29T09:13:39Z2016-06-29T21:14:01Zsolution of one variable is non-zero but associated parameters are zero<p>I want to solve a system with a non-zero initial condition, if I set up some parameters to zero, I end up with a non-zero solution, which is weird as I should end up with a zero solution (except of the inits value).</p><p>This is an example:</p><pre class="language-matlab">function dydt = odefcn(t,y,A,B)
dydt = zeros(2,1);
dydt(1) = y(2);
dydt(2) = (A/B)*y(1);
</pre><p>If I run:</p><pre class="language-matlab">A = 0;
B = 2;
tspan = [0 5];
y0 = [10 0.01];
[t,y] = ode113(@(t,y) odefcn(t,y,A,B), tspan, y0);
</pre><p>i. e. both initial conditions non-zero, I end up with the following solution</p><pre class="language-matlab">10 0.0100000000000000
10.0050000000000 0.0100000000000000
...
</pre><p>which i believe is incorrect as already the second entry of the second variable should be zero!</p>Judith Cerithttp://www.mathworks.com/matlabcentral/profile/authors/7989381-judith-cerittag:www.mathworks.com,2005:Question/2929272016-06-29T09:22:12Z2016-06-29T21:12:02ZSubscript indices must either be real positive integers or logicals. why does this come up?<pre class="language-matlab">Trial>> AusProfInt(2, 1, 1.5, 3, 100, 0.7)
Subscript indices must either be real positive integers or logicals.
</pre><pre class="language-matlab">Error in AusProfInt (line 8)
Ausdemand1= -(A*2^2)/2 + (A*((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*(1 +
((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa*(-1 + sigma))*2^3)/ (pa*(-3 + sigma)*(2 -
3*sigma + sigma^2)* (((1 + ((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa)*sigma*2)/(-1 +
sigma))^sigma) + (A*(pa + 2)^2*(pa*(-2 + sigma) + 2))/ (pa^2*(-3 + sigma)*(2 - 3*sigma
+ sigma^2)* ((sigma*(pa + 2))/(-1 + sigma))^sigma)+ (A*1^2)/2 +
(A*((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*(1 +
((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa*(-1 + sigma))*1^3)/ (pa*(-3 + sigma)*(2 -
3*sigma + sigma^2)* (((1 + ((x^1/1-sigma)-1/pa-pc(x)^1/1-sigma)*pa)*sigma*1)/(-1 +
sigma))^sigma)+(A*(pa + 1)^2*(pa*(-2 + sigma) + 1))/ (pa^2*(-3 + sigma)*(2 - 3*sigma +
sigma^2)* ((sigma*(pa + 1))/(-1 + sigma))^sigma);
</pre>Darcy Lovehttp://www.mathworks.com/matlabcentral/profile/authors/8349186-darcy-lovetag:www.mathworks.com,2005:Question/2930522016-06-29T20:49:34Z2016-06-29T21:11:38ZHow can I link arrays (different arrays with different information about the same stock -maybe like excel-vlookup?!)<p>I am working with stock data. For this I habe several tables (i.e. price, market value, dividend yield). After xlsread I have matrices where the columns are one company each and the rows are the daily prices/market values/dividend.
Unfortunately, the columns have no names - is it possible to give them names in order to link the different matrices together? (Like excel vlookup). Or is there another solution that helps me calculate the market values, sort them ascending and using this order to look at the stock prices half a year after? (For example to calculate size investing-portfolios)
I would be glad for your help!
Hans</p>HansDMhttp://www.mathworks.com/matlabcentral/profile/authors/8384657-hansdmtag:www.mathworks.com,2005:Question/2929352016-06-29T09:47:51Z2016-06-29T21:04:43ZAddlistener error: Undefined function for input arguments of type 'matlab.ui.Figure'.<p>I am using addlistener in my openingFcn like this</p><pre> handles.viewCAM_handles.listener = addlistener(viewCAM_handles.slider_master,'Value', 'PostSet',@(eventdata,viewCAM_handles)slider_master_continuousCallback(hObject,eventdata,handles));</pre><p>But i get the error: Undefined function 'slider_master_continuousCallback' for input arguments of type 'matlab.ui.Figure'.
Why can't I use a figure as input argument for my callback? What should I use instead, I tried with hObject but it gave me the same error.</p>Joakim Magnussonhttp://www.mathworks.com/matlabcentral/profile/authors/4190725-joakim-magnussontag:www.mathworks.com,2005:Question/2929712016-06-29T11:58:57Z2016-06-29T21:02:21ZRetrieve Both Besides String of Center String<p>Hi, i want to retrieve both string of center string. In example, i have below data :</p><pre class="language-matlab">data = {'a', 'b', 'c', 'o', 'm'}
center_string = {'c'}
</pre><p>Output</p><pre class="language-matlab">'b' 'o'
</pre><p>or</p><pre class="language-matlab">'b' 'c' 'o'
</pre><p>Thanks in advance.</p>Angga Lisdiyantohttp://www.mathworks.com/matlabcentral/profile/authors/6804712-angga-lisdiyantotag:www.mathworks.com,2005:Question/2927712016-06-28T18:04:10Z2016-06-29T21:02:11ZGUI screen resolution auto-resize<p>Is there a way to have a GUI in guide auto-adjust to fit current screen resolution, and/or can I hard-set the resolution of the interface at a specific value?</p>Eric Gilkeyhttp://www.mathworks.com/matlabcentral/profile/authors/7371239-eric-gilkeytag:www.mathworks.com,2005:Question/2930462016-06-29T19:25:13Z2016-06-29T21:01:24ZExtract rainfall values and the corresponding date from a time series when it satisfies certain condition<p>I have a daily time series data of one rain gauge station for 113 years. I want to extract those rainfall values and the corresponding dates only for those rainfalls which have a value greater than 2.5 mm and count the number of days with rainfall values greater than 2.5 mm for each year. The data is in .xlsx format and sample data is attached here.</p><p>Any help will be highly appreciated.</p>martin atamhttp://www.mathworks.com/matlabcentral/profile/authors/8380906-martin-atamtag:www.mathworks.com,2005:Question/2930102016-06-29T15:13:59Z2016-06-29T20:59:32ZHow to build a mex return structure?<p>I am unable to figure out how to build and attach matrices to the structure I have being returned</p><pre> mwSize dims[2] = {1,NumChans};
plhs[0] = mxCreateStructArray(2, dims, NUMBER_OF_FIELDS, field_names);</pre><p>I want to place matrices in one of the fields where I'll have a different one for each structure element. I can't seem to find any examples how best to do this, would there possibly be such an example?</p><p>Thanks</p>Jeffhttp://www.mathworks.com/matlabcentral/profile/authors/288206-jefftag:www.mathworks.com,2005:Question/2920002016-06-24T04:16:39Z2016-06-29T20:50:59ZSorting arrays of objects by dynamic property value<p>I have an number of face images that I have loaded into an object array for presentation using Matlab. Dynamic properties for the faces are added from a spreadsheet. All objects have the same properties, but there are a lot of them.</p><p>I have found that the normal manner of searching such an array (for instance by rated Anger) does not work with the dynamic properties.</p><pre class="language-matlab">[~,idx]=sort([faceArray.Anger]);
</pre><p>and</p><pre class="language-matlab">[~,idx]=sort([faceArray.('Anger')]);
</pre><p>both return the error:</p><pre class="language-matlab">No appropriate method, property, or field 'Anger' for class 'FaceStimulus'.
</pre><p>I can see the field in the variable viewer, and can sort by static properties using this method. Is there something that I'm missing?</p>Matt Moorehttp://www.mathworks.com/matlabcentral/profile/authors/6569499-matt-mooretag:www.mathworks.com,2005:Question/2930532016-06-29T20:50:35Z2016-06-29T20:50:35ZCombining merges in top and sub system: error<p>I'm trying to understand some of the details of the merge block, and it appears there are inconsistent results between using it on the top level and using it in a subsystem. The following diagram has no function other than to help in communication, though its design is similar to something I'm working on.</p><p>Running this subsystem as an individual model, I was able to get a valid output even for a condition that did not execute the cases connected to the merge as shown.</p><img src = "/matlabcentral/answers/uploaded_files/55284/SubSystem.PNG"><p>But when I insert it as a subsystem and run the same condition as shown</p><img src = "/matlabcentral/answers/uploaded_files/55285/TopLevel.PNG"><p>I get the following error:</p><img src = "/matlabcentral/answers/uploaded_files/55286/Error.PNG"><img src = "/matlabcentral/answers/uploaded_files/55287/Sub2wErr.PNG"><p>Based on the error message, I would think that even in the subsystem as an individual system I would get that message as none of the inputs are active. Rather it outputted zero, yet that zero is not passed through to the top system when it is run as a subsystem.</p><p>Can anyone explain why this happens? And/or suggest a different way to handle conditional cases that effect various outputs?</p><p>Thanks in advance</p>Julia Beverhttp://www.mathworks.com/matlabcentral/profile/authors/4954214-julia-bevertag:www.mathworks.com,2005:Question/2930062016-06-29T14:55:05Z2016-06-29T21:25:04Zhow to use dir in subfolders?<p>I am trying to search for all the xlsx files inside a folder that have many subfolders to search from. I realize matlab does not search inside subfolders. So I tried this:</p><pre class="language-matlab">>> addpath(genpath('D:/'))
>> savepath
>> dir *.xlsx
</pre><p>but it is not working, please advice on what I can do. I want to make a code that works for any folder that I put inside genpath(' '). Thanks!</p>chlor askhttp://www.mathworks.com/matlabcentral/profile/authors/8383523-chlor-asktag:www.mathworks.com,2005:Question/2930442016-06-29T19:11:09Z2016-06-29T20:39:16ZHow to count up matrix values for specific number of positions specified by other matrix?<p>Hi there,</p><p>I am trying to solve this task, I have matrix with Experimental Conditions eg:</p><p>A =</p><pre> 10 12 13 13 13</pre><pre> 13 10 14 16 14</pre><pre> 10 11 12 12 14</pre><pre> 9 14 10 16 14</pre><pre> 10 9 15 14 12</pre><pre> 12 13 9 15 10</pre><p>and corresponding accuracy matrix with logical values 1 (for the correct responses) and 0 (for incorrect responses), eg:</p><p>B =</p><pre> 1 1 0 0 0
1 1 1 0 1
1 0 0 1 1
1 1 1 0 1
0 0 1 1 1
1 0 0 1 1</pre><p>What I need to do, is to count up correct trials for eg. first five trials within experimental condition "10" (ordered in columns, so first count 1st column then 2nd etc..) so in this case the 5th experimental condition "10" is located in A(4,3) and so the result would be 4.</p><p>Thank you very much in advance.</p><p>Rene</p>Rene Sebenahttp://www.mathworks.com/matlabcentral/profile/authors/8193555-rene-sebenatag:www.mathworks.com,2005:Question/2930502016-06-29T20:34:17Z2016-06-29T20:34:17ZMy .Net application with matlab compiler works insite IDE (Visual Studio 2012), but not any way different.<p>My .Net application with matlab compiler works insite IDE (Visual Studio 2012), but not any way different.</p><p>I was trying to run it under bin/Debug folder or bin/Release. I've tried to create an installer. nothing helps.</p><p>What should i do to distribute an application.</p>Kateryna Sayenkohttp://www.mathworks.com/matlabcentral/profile/authors/3585429-kateryna-sayenkotag:www.mathworks.com,2005:Question/656032013-03-02T19:11:26Z2016-06-29T20:33:57ZDivide an image in half<p>Hey guys, I want to divide a black and white image 320px by 240px vertically and then count up the black pixels where the output is the % of black pixels in each of the 2 image segments. So far I have this</p><p>[filename pathname] = uigetfile('*.jpg', 'Choose Image');</p><p>imageLocation = strcat(pathname, filename);</p><p>blackWhiteImage = im2bw(imread(imageLocation), 0.5);</p><p>splitImage = imdivide(blackWhiteImage,2);</p><p>totalNumberOfPixels = 120*160;</p><p>numberOfBlackPixelsLeft = sum(sum(splitImage == 0));</p><p>set(handles.console, 'string', percentBlackPixelsLeft);</p><p>I am new to matlab and I need some help with that, any help would be greatley appriciated :)))</p>Stefanhttp://www.mathworks.com/matlabcentral/profile/authors/4058267-stefantag:www.mathworks.com,2005:Question/2305872015-07-21T09:46:53Z2016-06-29T20:32:07Zhow to read information from RTPlan image dicom matlab<p>Hi,
I want extarct information from image RTplan dicom like position of jaw , DSD : distance source detector.
I have program that work well for RT image not for RTPlan.
Any help will be very appreciate</p>addou abdeljalilhttp://www.mathworks.com/matlabcentral/profile/authors/3876936-addou-abdeljaliltag:www.mathworks.com,2005:Question/2840982016-05-13T14:42:54Z2016-06-29T20:25:29ZHELP:) Electric Field lines on MatLab (solving fields given coordinate points)<p>Currently I have used and edited a code that I have found on creating electric field lines on MatLab, I have use two test points at set coordinates with set charges [1 -1], yet the field lines that I get on my solution is incorrect. The direction of the lines should be all <b>away from positive</b> and <b>towards the negative</b> charges. Please help me fix this code!</p><pre class="language-matlab">x=[3 8];
y=[5 5];
q=[-1 1];
</pre><pre class="language-matlab">% Coulumb's number
ke = 8.9875517873681764e9;
</pre><pre class="language-matlab">xi=linspace(0,10,33);
yi=linspace(0,10,33);
[XI YI] = meshgrid(xi,yi);
</pre><pre class="language-matlab">zi = complex(XI,YI);
z = complex(x,y);
[ZI Z]=ndgrid(zi(:),z(:));
</pre><pre class="language-matlab">dZ = ZI-Z;
Zn = abs(dZ);
</pre><pre class="language-matlab">E = (dZ./Zn.^3)*(q(:)*ke);
E = reshape(E,size(XI));
</pre><pre class="language-matlab">En = abs(E);
Ex = real(E);
Ey = imag(E);
</pre><pre class="language-matlab">figure;
quiver(XI,YI,Ex./E,Ey./E);
</pre><pre class="language-matlab">hold on;
plot(x,y,'or');
axis equal;
</pre><p>Thank you,</p>Claire Parkhttp://www.mathworks.com/matlabcentral/profile/authors/8183787-claire-parktag:www.mathworks.com,2005:Question/2929782016-06-29T12:38:53Z2016-06-29T21:31:32ZError linking Matlab generated C-code: start.S:114: undefined reference to `main' collect2<p>When using Matlab Code Generator to generate an executable, I get the following error (see below) at the linking stage. Is this due to having a too new glibc version 5.2.x (because I use Ubuntu 15.10 rather than 14.x) and is there any solution other than to reinstall my complete system with Ubuntu 14.10 and glibc 4.7.x ??</p><p>Please advice where this error comes from and if it can somehow be resolved.</p><p>Thanks, Mark.</p><pre class="language-matlab">---------- gcc error:
</pre><pre class="language-matlab">gcc -Wl,-rpath,"/usr/local/MATLAB/R2016a/bin/glnxa64",-L"/usr/local/MATLAB/R2016a/bin/glnxa64" -L/usr/local/MATLAB/R2016a/sys/os/glnxa64 -fopenmp -liomp5 -o /home/mscheffer/Desktop/kstar/rtda/matlab/mse_rtda mse_rtda_rtwutil.o mse_rtda_data.o mse_rtda_initialize.o mse_rtda_terminate.o mse_rtda.o cos.o sin.o besselj.o cbesj.o abs.o sqrt.o cbinu.o gammaln.o cuchk.o cmlri.o casyi.o cuoik.o cunhj.o cunik.o extract_cosine.o interp1.o mean.o bsxfun.o correctphase.o sum.o norm.o std.o permute.o any.o getstokes.o mse_rtda_emxutil.o rt_nonfinite.o rtGetNaN.o rtGetInf.o -lm
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
/build/glibc-qbmteM/glibc-2.21/csu/../sysdeps/x86_64/start.S:114: undefined reference to `main'
collect2: error: ld returned 1 exit status
</pre>Mark Schefferhttp://www.mathworks.com/matlabcentral/profile/authors/2302981-mark-scheffertag:www.mathworks.com,2005:Question/2930482016-06-29T19:53:40Z2016-06-29T20:01:47ZClock is constant rather square wave in StateFlow<p>I created this state machine chart in Simulink using the StateFlow :</p><p>There are two states (S1,S2), one of which (S1) has 3 nested parallel FSM , each one has 4 states (SS1, SS2, SS2, SS4) , I put a default state in all of the 3 FSMs (SS1), and in the main two states (default S2).</p><p>To test the main FSM (S1,S2) , I used signal builder for all my inputs/events. One of the inputs is a square wave which is a clock event for my main FSM (1 Hz) and the duration of the simulation is 50 sec.</p><p>The problem i have is that i can see in the signal builder that i have a square wave, however when i put scope to that clock i see one square wave (extending from 0 to 49.5 second then drops to 0) .</p><p>Where is my clock ? what isn't it feeding my FSM properly ?</p><p>Thanks</p>Sam Chakhttp://www.mathworks.com/matlabcentral/profile/authors/8384503-sam-chaktag:www.mathworks.com,2005:Question/2909672016-06-20T07:56:17Z2016-06-29T19:45:56Zangle and edge pixel matrix in which according to angle i need to compute pixel difference based upon threshold value please anyone suggest<p>for i=1:256;
for j=1:256;
if angle(i,j)==0;
t=1;k=256;
for r=1:k;
xm=e(i,j-r);
xo=e(i,j);
xn=e(i,j+r);
if abs(xm-xo)<=t && abs(xn-xo)<=t;
xm1=e(i,j-r);
xn1=e(i,j+r);
end
end</p>Ramhttp://www.mathworks.com/matlabcentral/profile/authors/7249648-ramtag:www.mathworks.com,2005:Question/2907812016-06-19T12:25:41Z2016-06-29T19:43:16ZWhy is matlab always stuck in busy state?<p>Recently i have a problem with matlab that whenever my code contains of even simple loops then it is stuck during execution in busy state so i can not go any further. I use matlab 2015a on Dell XPS with ubuntu 16.04 Lts. I am also a beginner to matlab but i have never had that kind of problem before even with looping over large matrices. Any help would be appreciated.</p>Ece Balkanhttp://www.mathworks.com/matlabcentral/profile/authors/5994377-ece-balkantag:www.mathworks.com,2005:Question/2929722016-06-29T12:00:10Z2016-06-29T19:34:19Zhow do I find where a function is being invoked?<p>How do I find where, i.e., in what other defined functions, a function is being invoked? My codebase is getting pretty large, and sometimes I'm not sure where I've used a particular function. Any help for that?</p>Jim Antonissehttp://www.mathworks.com/matlabcentral/profile/authors/5535855-jim-antonissetag:www.mathworks.com,2005:Question/2930472016-06-29T19:30:15Z2016-06-29T19:30:15ZHow to use intlingprog algorithm for branch and bound method?<p>I want to know if this algorithm can solve an integer programming model by branch and bound method?</p><p>I have a long mathematical model illustrated below. Zim variables are binary. Xm variables are continuous and 0<Xm<1. Wim variables (Wim=ZimXm) are continuous. Wim is used to linearize the multiplication of Zim and Xm variables.</p><p>All other notations such as Ci, Ri, Li, Pi, Ui, q, ei, d are parameters. So, is branch and bound method for this integer programming problem applicable by intlinprog algorithm?</p><p>i= counter for number of employees
m= counter for number of performance categories</p><p>I know linprog may be more applicable and easier way to solve this problem. Furthermore, the software LINDO can be even more convenient to solve the problem, since it is a simple integer linear programming problem once parameters are placed. However, I am required to solve this problem by using Branch and Bound for Integer Programming Method.</p><p>I would highly appreciate for any comments.</p><img src = "/matlabcentral/answers/uploaded_files/55281/Model1.png">Taner Cokyasarhttp://www.mathworks.com/matlabcentral/profile/authors/7483716-taner-cokyasar