http://mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-10-21T19:53:14Ztag:mathworks.com,2005:Question/1594882014-10-21T11:01:21Z2014-10-21T19:53:14Zproblem with cellular automata code?<p>i found this code here, and i try to initialize it with [1 0 1 1 0 1 1] but it didn't work.</p><p><a href = "http://www.mathworks.com/matlabcentral/fileexchange/39492-ca-code-for-matlab/content/wolfram.m">http://www.mathworks.com/matlabcentral/fileexchange/39492-ca-code-for-matlab/content/wolfram.m</a></p><p>the code is long to paste it here.
and how to locate the image?</p>sara/matlabcentral/answers/contributors/5790085-saratag:mathworks.com,2005:Question/1049732013-11-05T14:15:46Z2014-10-21T19:52:31Zhelp ! Some questions about wcoher.m<p>In the function wcoher.m can get the wavelet coherence.This function handles two sequence to obtain the wavelet coherence. But it is the result of a numerical value, not unique and determine one. What is this string value represents ? And can this function get the unique and determined value?</p>Lisa TOP/matlabcentral/answers/contributors/4771213-lisa-toptag:mathworks.com,2005:Question/1595522014-10-21T17:44:34Z2014-10-21T19:52:20ZConvergence problem for several variables<p>Dear all,</p><p>I attempt to solve a convergence problem for nine variables that are subject to optimisation and nine equations. Each equation depends on at least 3 other variables that need to be optimised
My idea is to use nine nested while loops.
As the problem covers some space, the following is a simplified example which, hopefully, clearifies the issue. (Explanation see below)</p><pre class="language-matlab">clc
clear ap ap_plus aopt counta bp bp_plus bopt countb
clear coll_counta coll_countb counta_coll countb_coll
</pre><pre class="language-matlab">ap=1; %lower boundary, value a
ap_plus=100; %upper boundary, value a
aopt=0.1; %starting value
counta=0; % count iteration steps for value a
</pre><pre class="language-matlab">bp=1; %lower boundary, value b
bp_plus=100; %upper boundary, value b
bopt=0.1; %starting value
countb=0; % count iteration steps for value b
</pre><pre class="language-matlab">while abs(ap-ap_plus)>0.00001 %I need the value aopt where ap-ap_plus is close to zero, so I %can't use aopt in the condition
</pre><pre> ap=ap_plus;</pre><pre> ap_plus=-tanh(aopt)+coth(bopt);%-tanh(aopt)--> -1, coth(bopt)-->1 </pre><pre> while abs(bp-bp_plus)>0.00001</pre><pre> bp=bp_plus;</pre><pre> bp_plus=1+tanh(-bopt)+1/aopt+acoth(aopt*bopt); %tanh(-bopt)-->-1 acoth(aopt*bopt)-->0</pre><pre> bopt=bopt+0.1 %After each iteration the new estimate of bopt is increased +0.1, %assumes that the initial bopt is the lowest boundary
countb=countb+1; %count iteration
coll_countb(countb)=abs(bp_plus-bp); %collect differences</pre><pre> end</pre><pre> aopt=aopt+0.1 %see above
counta=counta+1;
coll_counta(counta)=abs(ap_plus-ap);</pre><pre class="language-matlab">end
</pre><pre> counta_coll=[1:counta]; %array of iteration steps
countb_coll=[1:countb]; </pre><pre> plot(counta_coll, coll_counta, 'pk', countb_coll,coll_countb,'or')
legend('convergence of a', 'convergence of b') </pre><p>The convergence is quite good, of course, due to the functions chosen...</p><p>The problem:
However, after the inner loop is solved and an optimised value bopt is determined, this value is taken to the next equation, and so forth until the outer while loop is reached. So, as the functions ap_plus and bp_plus share the same variables, I'd like the inner while loop to be run again or as to say, ap_plus and bp_plus need to be solved simultaniously. How to do? Are there any other Matlab-embedded alternatives?
I tried quite some combinations of the location of the variable definition or adding the same witing something like while abs(ap-ap_plus)>0.00001 && while abs(bp-bp_plus)>0.00001 but neither works. I also thought about 'parfor' but as the functions are dependend on each other, apparently it can't be applied (according to mathworks).</p><p>The real problem is a bunch of equations that need to be solved numerically (e.g. due to integrals that can't be solved analytically), so I have to go for iteration solutions and can't use 'solve' or the like.</p><p>Kind regards and thanks!</p>Magnus/matlabcentral/answers/contributors/5582735-magnustag:mathworks.com,2005:Question/1595682014-10-21T19:38:51Z2014-10-21T19:50:56ZParfor and cell array<pre class="language-matlab">Suppose I have the following code
p = cell(1,3);
w = zeros(5,3);
p{1} = X; 2 by 2 matrix
p{2} = Y; 2 by 2 matrix
p{3} = Z; 2 by 2 matrix
</pre><pre> parfor k=1:3
for i=1:5
w(i,k) = somefunction(variable1, variable2,p{k})
end
end</pre><p>If I remove the parfor, the code runs fine, but if I use the parfor I get the error: Output argument "XXXX" from some other function that is used in "somefunction" was not assigned during call.</p><p>Sorry for being very schematic but the actual code is very long has and uses numerous functions.</p>Michael/matlabcentral/answers/contributors/27622-michaeltag:mathworks.com,2005:Question/690042013-03-28T17:51:40Z2014-10-21T19:50:03ZHow to choose scales and input for code below using wavelets done by FFT? <p>If anyone understands how to pick scales for cwt using FFT I would so appreciate the advice. I am using Torrence and Compo's code that has been adapted (below). However, all I know is how to find out using scal2frq the scale/frequency relationship. Here they are talking about fourier periods and talking about picking scales based on milliseconds which I am finding very confusing. I have EEG data, sampled at 256 Hz, length(n)=315 and I am interested in looking at the cross coherence between 4 and 15 hz. Thank you to anyone who can shed light on this!!
Kim</p><p>Wavelet coherence
%
% USAGE: [Rsq,period,scale,coi,sig95]=wtc(x,y,[,settings])
%
%
% Settings: Pad: pad the time series with zeros?
% . Dj: Octaves per scale (default: '1/12')
% . S0: Minimum scale
% . J1: Total number of scales
% . Mother: Mother wavelet (default 'morlet')
% . MaxScale: An easier way of specifying J1
% . MakeFigure: Make a figure or simply return the output.
% . BlackandWhite: Create black and white figures
% . AR1: the ar1 coefficients of the series
% . (default='auto' using a naive ar1 estimator. See ar1nv.m)
% . MonteCarloCount: Number of surrogate data sets in the significance calculation. (default=300)
% . ArrowDensity (default: [30 30])
% . ArrowSize (default: 1)
% . ArrowHeadSize (default: 1)
%
% Settings can also be specified using abbreviations. e.g. ms=MaxScale.
% For detailed help on some parameters type help wavelet.
%
% Example:
% t=1:200;
% wtc(sin(t),sin(t.*cos(t*.01)),'ms',16)
%
% Phase arrows indicate the relative phase relationship between the series
% (pointing right: in-phase; left: anti-phase; down: series1 leading
% series2 by 90°)
%
% Please acknowledge the use of this software in any publications:
% "Crosswavelet and wavelet coherence software were provided by
% A. Grinsted."
%</p>Kim/matlabcentral/answers/contributors/651916-kimtag:mathworks.com,2005:Question/1254362014-04-11T04:00:00Z2014-10-21T19:42:19ZWhy will warning/error messages not show up in a pop-up window when I hover over the text in the MATLAB Editor with Gnome 3.10?<p>I use MATLAB R2014a on Linux. When there is an error or a warning in my code (like forgetting a semi-colon), the text is underlined in red or in yellow. With OpenSUSE 12.3, when I hover the mouse over the text, a pop-up appears with an explanation for the error or the warning and some suggestions to fix it. I just upgraded to OpenSUSE 13.1 and now the pop-up messages are not displayed anymore.</p><p>In addition, when I rename a variable, the pop-up that suggests to press Shift+Enter to rename all the occurrences does appear but it grabs focus and prevent me from typing until I click somewhere else.</p><p>Is that a bug? I use OpenSUSE 13.1 and Gnome 3.10.2.</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:mathworks.com,2005:Question/1595562014-10-21T18:04:32Z2014-10-21T19:41:05ZCant get headerlines to work <p>Hi guys,
I've recently bought Matlab and i dont know a great deal so bear with me.
So i want to input data into matlab from</p><p>'http://jsoc.stanford.edu/SUM20/D358012442/S00000/Uy/1909:105.0_00.0W00.0N.Uy'</p><p>i use</p><p>urlread('http://jsoc.stanford.edu/SUM20/D358012442/S00000/Uy/1909:105.0_00.0W00.0N.Uy')</p><p>which gives me the data i need but i cant get it to ignore the first 7 lines of text.</p><p>I have been trying by textread('ans','headerlines', 7) which doesnt work.</p><p>If i select the data manually after putting in the urlread, and putting [..] around the data i want, it does give me what i want which comes up as '31x9 double' in workspace, instead of '1x2881 char'.</p><p>Can i get the data to be plotted in '31x9 double' directly from the website without me copy and pasting it, theres a lot of data so im looking for the shortest way.
My explanation is terrible, i hope someone gets it, Any help is appreciated. Thanks in advance.</p>Cio/matlabcentral/answers/contributors/5772400-ciotag:mathworks.com,2005:Question/1594012014-10-20T17:31:45Z2014-10-21T19:38:57ZHow to loop through a function twice?<p>I have a function that now works for individual values. I am trying (and so far, failing) to run the function for several values for each of two parameters: K and Smax.</p><p>Any help would be very appreciated. This is my first time using MatLab.</p><p>Here is the functional, version I'm using for individual trials:</p><pre class="language-matlab">%%
% No Spill Scenario
% Storage where k=0.3; Smax=100
%
SynthK=0.3;
SynthSmax=100;
Storage = [Precipmmday(1) 0];
Baseflow = [Precipmmday(1) 0];
for k1 = 2:length(Precipmmday)
Baseflow (k1,:) = [(Storage(k1-1,2)+Precipmmday(k1-1))*SynthK];
Storage(k1,:) = [(Storage(k1-1,2)+Precipmmday(k1-1))*(1-SynthK)];
end
SynthStorage = Storage;
SynthStorage (:,1) =[];
</pre><pre class="language-matlab">SynthSpill=SynthStorage - SynthSmax;
SynthSpill(SynthSpill<0)=0;
</pre><pre class="language-matlab">SynthStorage(SynthStorage>SynthSmax)=SynthSmax;
</pre><pre class="language-matlab">SynthBaseflow = Baseflow;
SynthBaseflow (:,1) = [];
</pre><pre class="language-matlab">SynthOutflow = SynthBaseflow + SynthSpill;
</pre><p>And here is what I'm working on to run through many values for the two parameters:</p><pre class="language-matlab">%%
% Run Model
Storage = [Precipmmday(1) 0];
Baseflow = [Precipmmday(1) 0];
for Smax = linspace(10,500,10);
Smax = repmat(Smax,10,1);
for K = linspace(0.01,1,10);
K = repmat(K,10,1);
for k1 = 2:length(Precipmmday)
Baseflow(k1,:) = [(Storage(k1-1,2)+Precipmmday(k1-1))*K];
Storage(k1,:) = [(Storage(k1-1,2)+Precipmmday(k1-1))*(1-K)];
end
ModelStorage = Storage;
</pre><pre> ModelSpill=ModelStorage - Smax;
ModelSpill(ModelSpill<0)=0;</pre><pre> ModelStorage(ModelStorage>Smax)=Smax;</pre><pre> ModelBaseflow = Baseflow;</pre><pre> ModelOutflow = ModelBaseflow + ModelSpill;
end
end</pre><p>I can see where some of the errors are but don't know how to fix them. I think the way I'm defining Storage and Baseflow is an issue. Also, I keep getting the "Subscripted assignment dimension mismatch." or "Attempted to access Storage(2,2); index out of bounds becausesize(Storage)=[10,1]." error messages.</p><p>Thank you for any suggestions you have.</p><p>ETA: Data file is attached</p>Vert/matlabcentral/answers/contributors/5756569-verttag:mathworks.com,2005:Question/1595462014-10-21T17:20:38Z2014-10-21T19:36:42ZPlease Please help with centering and overlaying an image<p>I know this should be simple but I really cannot figure it out. How do I take two images and then have them display overlap each other at the central point (I have included a figure below)?
These pictures are of different sizes.
And I would like to do this without "hard-coding"</p><p>I have A = imread('A.png');
A = imread('B.png');
imshow (A)
hold on;
imshow (B)</p><p>But after this I have no idea how to center these :(</p><img src = "/matlabcentral/answers/uploaded_files/19791/Screen%20Shot%202014-10-21%20at%2010.19.29%20AM.png">MLnoob5340/matlabcentral/answers/contributors/5678449-mlnoob5340tag:mathworks.com,2005:Question/1595572014-10-21T18:07:15Z2014-10-21T19:36:08Zhelp me to reduce my function time runing<p>Hi every body</p><p>This is my code</p><pre class="language-matlab">if true
for r = 1:100
U = 1 * (r-1);
for c = 1:100
V = 2 * (c-1);
F(r,c) = 10 * sin(U + V);
end
end
imagesc(F);
colormap(gray);
</pre><pre class="language-matlab">end
</pre><p>Its generate a replicate pattern which I upload it here. Is there any suggestion to reduce the running time for this code?</p><p>Thanks</p><img src = "/matlabcentral/answers/uploaded_files/19797/4.1.jpg">mostafa/matlabcentral/answers/contributors/5254145-mostafatag:mathworks.com,2005:Question/1595672014-10-21T19:32:50Z2014-10-21T19:34:15ZUnable to meet integration tolerance<p>Hi! I'm trying to design an steady-state packed bed reactor, with a nonlinear second-order differential equation, but i'm getting this <i>"Warning: Failure at t=2.455844e-06. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (6.776264e-21) at time t."</i></p><p>I would really appreciate your time and help, thanks.</p><p>The script is:</p><pre class="language-matlab">clear all; clc
global U Deff ro_b k
</pre><pre class="language-matlab">%butanotiol+heptano
%T=25ºC
</pre><pre class="language-matlab">Deff=0.046E-8 %m2/s
ro_b=167.9400;
L=4.27;
U=0.0024;
k=4.68E-2
</pre><pre class="language-matlab">Ca0=6.05;
%ODE
z=0:0.1:L;
z1=z';
y0=[Ca0; 0]
</pre><pre class="language-matlab">[z,y]=ode15s(@react,z1,y0)
plot(z,y(:,1))
ylabel('Concentración Ca [mol/m3]')
xlabel('z [m]')
</pre><p>and the function is:</p><pre class="language-matlab">function F=react(z,y)
global U Deff ro_b k
A=y(2);
B=(U./Deff).*y(2)-k.*ro_b.*(y(1).^2)./Deff;
F=[A; B];
end
</pre>Carlos/matlabcentral/answers/contributors/5802066-carlostag:mathworks.com,2005:Question/1595662014-10-21T19:30:05Z2014-10-21T19:30:05ZPulling data from text file and the results are being shown as NaN<ol><li>I am loading a text file but some of my results are being shown as NaN. This is my code:</li><li></li><li>clear all;</li><li>close all;</li><li>test=0.001;</li><li>imax=13;</li><li>kmax=4;</li><li></li><li>load('hcrdat.txt');</li><li>q=hcrdat(:,1);</li><li>d=hcrdat(:,2);</li><li>r=hcrdat(:,3);</li><li></li><li>%q=[250 250 100 50 100 25 25 25 45 70 80 30 20];</li><li>%d=[.4,.4,.3,.3,.3,.2,.2,.2,.3,.3,.3,.2,.2];</li><li>%r=[96.8,96.8,306,306,306,3098,3098,3098,306,312,306,9295,3098];</li><li></li><li>m=zeros(kmax,imax);</li><li></li><li>iter=0;</li><li>for n=1:500</li><li>iter=iter+1;</li><li>difmax=0;</li><li>%DISCHARGE CORRECTIONS IN EACH LOOP</li><li>for k=1:kmax</li><li>sum1=0;</li><li>sum2=0;</li><li>for i=1:imax</li><li>t=m(k,i);</li><li>sum1=sum1+t*r(i)*q(i)^2;</li><li>sum2=sum2+2*abs(t)*q(i)*r(i);</li><li>end</li><li>dq=-sum1/sum2;</li><li>if abs(dq)>difmax</li><li>difmax=abs(dq);</li><li>end</li><li>for i=1:imax</li><li>q(i)=q(i)+m(k,i)*dq;</li><li>%CHANGE OF ASSUMED DISCHARGE DIRECTION AND PROPER CORRECTIONS</li><li>if q(i)<0</li><li>q(i)=-q(i);</li><li>end</li><li>for kk=1:kmax</li><li>m(kk,i)=-m(kk,i);</li><li>end</li><li>end</li><li>end</li><li>it=n;</li><li>diff(it)=difmax;</li><li>%CHECK FOR CONVERGENCE TO FINAL DISCHARGE VALUES</li><li>if difmax<test</li><li>break</li><li>end</li><li>end</li><li>for i=1:imax</li><li>% FLOW VELOCITIES IN THE VARIOUS BRANCHES</li><li>u(i)=q(i)/1000*1.273/d(i)^2;</li><li>% HEAD LOSSES IN EACH BRANCH</li><li>dh(i)=r(i)*q(i)^2/1000000;</li><li>end</li><li></li><li>= = = = = = = = = = = = = = = = = = =</li><li></li><li>The data in the text file is:</li><li></li><li>250, .4, 96.8</li><li>250, .4, 96.8</li><li>100, .3, 306</li><li>50, .3, 306</li><li>100, .3, 306</li><li>25, .2, 3098</li><li>25, .2, 3098</li><li>25, .2, 3098</li><li>45, .3, 306</li><li>70, .3, 612</li><li>80, .3, 306</li><li>30, .2, 9295</li><li>20, .2, 3098</li><li></li><li>= = = = = = = = = = = = = = = = = = =</li><li></li><li>My results for sum1, sum2 and dq are NaN and the problem is because q is being loaded as NaN.</li></ol>Gino/matlabcentral/answers/contributors/5802152-ginotag:mathworks.com,2005:Question/1595642014-10-21T19:07:23Z2014-10-21T19:28:51ZHow to properly pass handles into TimerFcn? Handles is currently showing up as emtpy<p>Hi everyone,</p><p>This question is sort-of a follow-up to a previous question.</p><p><a href = "http://www.mathworks.com/matlabcentral/newsreader/view_thread/158550">http://www.mathworks.com/matlabcentral/newsreader/view_thread/158550</a></p><p>The problem is that I followed all the suggested steps and I have encountered a new problem. Here is a brief overview of what I am trying to do. I have a program that is reading data from 1 to 10 RFID readers simultaneously via bluetooth. I know that I cannot use simultaneous while loops so I am trying to use separate timers to start and stop data collection from each reader.</p><p>I create the timer object in the opening function:</p><pre class="language-matlab">handles.TimerA = timer('ExecutionMode','fixedrate','Period',1,...
'TimerFcn',{@StartReaderA,varargin});
</pre><p>After the GUI opens, a bluetooth connection is initiated with each reader and the user inputs a filename for saving the data. Once the filename is valid, the user can press the Start/Stop toggle button to begin reading/saving from the RFID reader. When the start button is pressed (i.e., when the toggle is down) I execute</p><pre class="language-matlab">start(handles.TimerA);
</pre><p>This begins executing the reading process within the reader function</p><pre class="language-matlab">function StartReaderA(obj,event,handles)
</pre><p>Unfortunately, handles is somehow being lost between the start command and when the function is entered. Obj and event are the timer's information, but handles is appearing as a 0x0 cell. I need information within handles to properly execute StartReaderA.</p><p>How do I correctly pass handles to StartReaderA so that I can use the information?</p><p>Thank you for your help.</p><p>Justin</p>Justin/matlabcentral/answers/contributors/2900979-justintag:mathworks.com,2005:Question/1595352014-10-21T15:16:58Z2014-10-21T19:23:55ZSimulink filter using frequency response transfer function<p>Hi,</p><p>My main problem is this: I'm building a fiber optical communication system using simulink.</p><p>As a source, I use a bernoulli generator, then this signal runs to a low pass filter and the exit is the signal equivalent to a signal that comes off a led, so the emission part is done.</p><p>The problems begins at the transmission channel. I want to do a filter that simulates the dispersion effect in the fiber (only chromatic dispersion), but I don't know how. I only have a transfer functions like exp(-j*alpha*f.^2) and I don't know what to do with this. What's the right procedure to implement this kind of t.f. in a analog filter at the simulink?</p><p>Any help is welcome.</p><p>Kind regards</p>Francis/matlabcentral/answers/contributors/3914086-francistag:mathworks.com,2005:Question/1594172014-10-20T20:23:47Z2014-10-21T19:22:06ZHow to calculate the confidence interval<p>Hi</p><p>I have a vector x with e.g. 100 data point. I can easy calculate the mean but now I want the 95% confidence interval. I can calculate the 95% confidence interval as follows:</p><pre class="language-matlab">CI = mean(x)+- t * (s / square(n))
</pre><p>where s is the standard deviation and n the sample size (= 100).</p><p>Is there a method in matlab where I just can feed in the vector and then I get the confidence interval?</p><p>Or I can write my own method but I need at least the value of t (critical value of
the t distribution) because it depends on the number of samples and I don't want to lookup it in a table everytime. Is this possible?</p><p>Would be very nice if somebody could give an example.</p><p>Last but not least, I want 95% confidence in a 5% interval around the mean. For checking that I just have to calculate the 95% confidence interval and then check if the retrieved value is less than 5% of my mean, right?</p>Sepp/matlabcentral/answers/contributors/5293424-sepptag:mathworks.com,2005:Question/997262010-09-22T18:38:00Z2014-10-21T19:19:28ZWhy do I receive an error when I use the SPECTROGRAM function if the length of the window is equal to the signal length in Signal Processing Toolbox 6.13 (R2010a)?<p>I try to plot the spectrogram of a signal using the following code (data file attached):</p><pre class="language-matlab">load emg;
</pre><pre class="language-matlab">x = emg;
</pre><pre class="language-matlab">lenx = length(x);
</pre><pre class="language-matlab">window = ones(1, lenx);
</pre><pre class="language-matlab">nfft = lenx/8;
</pre><pre class="language-matlab">fs = 1000;
</pre><pre class="language-matlab">noverlap = 32;
</pre><pre class="language-matlab">F = [1:1:fs/2];
</pre><pre class="language-matlab">spectrogram(x,window,noverlap,F,fs)
</pre><p>The error I receive is the following:</p><pre class="error"> ??? Error using ==> surf at 78
Z must be a matrix, not a scalar or vector.
Error in ==> spectrogram>displayspectrogram at 250
hndl = surf(args{:},'EdgeColor','none');
Error in ==> spectrogram at 184 displayspectrogram(t,f,Pxx,isFsnormalized,faxisloc);</pre>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:mathworks.com,2005:Question/1593652014-10-20T13:46:26Z2014-10-21T19:14:51ZForecast Modeling with different time period datas<p>I want to model electricity price forecasting. However I have different time period datas. For example; I have hourly and daily datas for different variables. I do not know how to combine them in a model? Do you have any idea?</p>Adam/matlabcentral/answers/contributors/5623862-adamtag:mathworks.com,2005:Question/1595372014-10-21T15:24:16Z2014-10-21T19:12:34ZHow to integrate using while loop?<p>Hi all,</p><p>I have a function: PM =@(w) (5/16*3^2.*(0.5578^4./w.^5).*exp(-5/4.*(w./0.5578).^(-4)));</p><p>its integral: A=integral(PM, 0, 5);</p><p>I want to divide the area under the function into equal area pieces. Each beeing of a size= A/n, where n is any number desired. To achieve this I was trying to use while loop, but did not succed. Additionally, I need to keep trace at which values of w the condtion is met.</p><p>Thanks.</p>Andrejus/matlabcentral/answers/contributors/5709378-andrejustag:mathworks.com,2005:Question/1595282014-10-21T14:46:26Z2014-10-21T19:11:08ZError while evaluating unicontral callback calculator<p>Hi!</p><p>I am trying to create a simple calculator in matlab
I have created it and put all the codes but when i push play i get error:
Error while evaluating unicontrol callback</p><p>The path is right, in matlab folder</p><p>Any idea to what could be wrong=</p><p>codes:</p><p>function varargout = calculator(varargin)
% CALCULATOR MATLAB code for calculator.fig
% CALCULATOR, by itself, creates a new CALCULATOR or raises the existing
% singleton*.
%
% H = CALCULATOR returns the handle to a new CALCULATOR or the handle to
% the existing singleton*.
%
% CALCULATOR('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CALCULATOR.M with the given input arguments.
%
% CALCULATOR('Property','Value',...) creates a new CALCULATOR or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before calculator_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to calculator_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES</p><p>% Edit the above text to modify the response to help calculator</p><p>% Last Modified by GUIDE v2.5 21-Oct-2014 16:10:36</p><p>% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @calculator_OpeningFcn, ...
'gui_OutputFcn', @calculator_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end</p><p>if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT</p><p>% --- Executes just before calculator is made visible.
function calculator_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to calculator (see VARARGIN)</p><p>% Choose default command line output for calculator
handles.output = hObject;</p><p>% Update handles structure
guidata(hObject, handles);</p><p>% UIWAIT makes calculator wait for user response (see UIRESUME)
% uiwait(handles.figure1);</p><p>% --- Outputs from this function are returned to the command line.
function varargout = calculator_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</p><p>% Get default command line output from handles structure
varargout{1} = handles.output;</p><p>function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double</p><p>% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called</p><p>% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end</p><p>% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = (')')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('^')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton3.
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data 3(see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('(')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pi.
function pi_Callback(hObject, eventdata, handles)
% hObject handle to pi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('pi')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('7')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('8')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('9')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('+')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('4')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('4')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('6')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('-')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
textstring=get(handles.text1,'string')
textstring=eval(textstring)
set(handles.text1,'string',textstring)</p><p>% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('2')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('3')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('*')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('0')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton18.
function pushbutton18_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('.')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton19.
function pushbutton19_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('1')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in pushbutton20.
function pushbutton20_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
OLDstring = get(handles.text1,'string');
NEWstring = ('/')
textstring = strcat (OLDstring,NEWstring);
set (handles.text1,'string',textstring);</p><p>% --- Executes on button press in Tan.
function Tan_Callback(hObject, eventdata, handles)
% hObject handle to Tan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
textstring = get(handles.text1,'string');
textstring = strcat(textstring,'Tan(pi/180*')
set(handles.text1,'string',textstring);</p><p>% --- Executes on button press in Sin.
function Sin_Callback(hObject, eventdata, handles)
% hObject handle to Sin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
textstring = get(handles.text1,'string');
textstring = strcat(textstring,'Sin(pi/180*')
set(handles.text1,'string',textstring);</p><p>% --- Executes on button press in Cos.
function Cos_Callback(hObject, eventdata, handles)
% hObject handle to Cos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
textstring = get(handles.text1,'string');
textstring = strcat(textstring,'Cos(pi/180*')
set(handles.text1,'string',textstring);</p><p>% --- Executes on button press in Clear.
function Clear_Callback(hObject, eventdata, handles)
% hObject handle to Clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.text1,'string','');</p>Gry/matlabcentral/answers/contributors/4949822-grytag:mathworks.com,2005:Question/1595542014-10-21T17:58:49Z2014-10-21T19:07:51ZProblem with derivative function syntax<p>Ok so basically what I'm doing here is trying to graph a function and its derivative in matlab. This is what I have:</p><p>clear; clc; close all;
x=(-2:0.1:4);
y=x.^3-2*x.^2-10*sind(x).^2-exp(0.9*x);
yd=3*x.^2-4*x-20*sind(x)*cosd(x)-0.9*exp(0.9*x);
plot(x,y,x,yd,'--');
xlabel('X Values');
ylabel('Y Values');
legend('function', 'first derivative')</p><p>There are no errors in my original function. But for some reason, the derivative function keeps giving me an error. It says "Error using *
Inner matrix dimensions must agree. If anyone can help me fix the syntax, it would be greatly appreciated!</p>Nathaniel/matlabcentral/answers/contributors/5681078-nathanieltag:mathworks.com,2005:Question/1595632014-10-21T19:01:47Z2014-10-21T19:01:47Zusing ODE45 when parameters in my function change in time?<p>Hi,</p><p>I am using ode45 to simulate a model of a mass linked to a pivot through a spring. Radial force and torque are applied and can change in time.</p><p>I used previously ode45 with equations that do not change in time, by creating a function eg dtheta= fn (t, theta) as suggested on Mathworks. I am not sure how to do with variable parameters though.</p><p>This is my code:</p><pre class="language-matlab">function [ dtheta ] = leg( t,theta)
% theta (1) is theta, Theta (2) is angular velocty
m=1;
g=9.8;
tau=0;
f=0;
k=500;
r0=0.01;
</pre><pre class="language-matlab">dtheta=zeros(2,1);
dtheta(1)=theta(2);
dtheta(2)=tau/m+g*sin(theta(1))*( (f - m*g*cos(theta(1)))/k +r0 );
end
</pre><p>which I will call with</p><pre class="language-matlab">close all
</pre><pre class="language-matlab">t0=0;
tf=10;
theta0=pi/2;
angvel0=0;
</pre><pre class="language-matlab">[T,THETA] = ode45(@leg,[t0 tf],[theta0 angvel0]);
plot(T,THETA(:,1))
xlabel('time')
ylabel('theta (radians)');
</pre><p>Right now I am simulating the model with 0 torque and 0 radial force. As well I could simulate it with constant torque and force. But I need them to change in time (eg being vectors in time). How do I do that?</p><p>Thanks!!!
Cristina</p>Cristina Rossi/matlabcentral/answers/contributors/4421909-cristina-rossitag:mathworks.com,2005:Question/1594002014-10-20T17:27:34Z2014-10-21T18:59:46ZMatlab 2014b on ubuntu 14.04 seems not to work; no command can be executed<p>Hi, it seems that matlab 2014b on my ubuntu 14.04 is not able to execute any command.
Installation is fine (at least, matlab starts up fine and I do not get any errors).
When matlab is loaded and ready to be used, if I issue a command (any command, even quit) it gets stuck and remains 'busy' indefinitely.</p><p>Any suggestion?</p><p>Many thanks,</p><p>Lorenzo</p>Lorenzo/matlabcentral/answers/contributors/5371972-lorenzotag:mathworks.com,2005:Question/1594342014-10-20T23:16:48Z2014-10-21T18:58:03ZWhy do I get java.lang null pointer exception?<p>I installed 2104a and Financial Toolbox, but later my laptop was broken and repaired as a new one. When I re-downloaded my MATLAB, I found 2014b was available and installed it. But after installation I found no Financial Toolbox is there though 2014b worked well, so I uninstalled it and re-installed 2014a. In installation, I see Financial Toolbox is on the list, and the installation is successful. But when I try to open MATLAB, I get the error as attached.</p><p>My laptop is Mac and the system is Yosemite.</p><img src = "/matlabcentral/answers/uploaded_files/19742/Screen%20Shot%202014-10-20%20at%207.10.51%20PM.png">Haojie/matlabcentral/answers/contributors/5734152-haojietag:mathworks.com,2005:Question/1595622014-10-21T18:31:38Z2014-10-21T18:53:28ZI have a problem with the Matlab version R2014a as i have upgraded from os mavericks to os yosemite. <p>I have a problem with the Matlab version R2014a. as i have upgraded from os mavericks to os yosemite. What should i do. do i have to buy the new version of matlab for students or will the older version will be supported after some time.</p>Harpal/matlabcentral/answers/contributors/5445092-harpaltag:mathworks.com,2005:Question/1595262014-10-21T14:28:07Z2014-10-21T18:48:11ZI have a function returning a 3x1 vector. I now want to plot three graphs for these three outputs.<p>Here is my function:</p><pre class="language-matlab">function [ T] = inlamning1( F, m, l )
%Ax = b, A = alla skalärer framför T1,T2,T3 i de tre ekvationerna.
%T = [T1, T2, T3]
%b = skalärerna mg och F
</pre><pre class="language-matlab">A = [cosd(30), cosd(30), cosd(45); -1*sind(30), sind(30), sind(45); 10*cosd(30), 0, -1*cosd(45).*l];
b = [F*cosd(45)+ m*9.81; -1*F*sind(45) ; -1*F*cosd(45)*10];
T = A\b;
</pre><p>I now want to draw three diffrent graphs showing how T1, T2 and T3 differs for different values of l (l = linspace(5,10))</p><p>How can i do that?</p>Karim El Ghamrawi/matlabcentral/answers/contributors/5671513-karim-el-ghamrawitag:mathworks.com,2005:Question/1595432014-10-21T16:45:07Z2014-10-21T18:39:59Zhow to write a function in interval?<p>hi,</p><p>can you please help me to write this function code in matlab?</p><p>thank you in advance</p>lina/matlabcentral/answers/contributors/5187045-linatag:mathworks.com,2005:Question/1593042014-10-20T06:04:24Z2014-10-21T18:36:17ZHow Can I simulate non uniform background illumination? <p>I would like to add non uniform background illumination to some images to test some thresholding algorithms.</p>Laila Kazemi/matlabcentral/answers/contributors/2627338-laila-kazemitag:mathworks.com,2005:Question/1594142014-10-20T19:37:32Z2014-10-21T18:27:17ZCreating subplot from saved semilog plots<p>If I've saved plots that were generated by semilogy as files, how can I place them into a figure with subplots? Note that</p><p><a href = "http://www.mathworks.com/matlabcentral/answers/101806-how-can-i-insert-my-matlab-figure-fig-files-into-multiple-subplots">http://www.mathworks.com/matlabcentral/answers/101806-how-can-i-insert-my-matlab-figure-fig-files-into-multiple-subplots</a></p><p>does not work for figures generated by semilogy, though I do not really understand why, even after trying to read up on handle graphics.</p>Stephen Shank/matlabcentral/answers/contributors/2924202-stephen-shanktag:mathworks.com,2005:Question/1589472014-10-17T02:08:07Z2014-10-21T18:26:12ZMatlab 2014a won't run in Yosemite!!<p>I just updated my OS X to Yosemite today, and when I try to use matlab it says You can't use this version of the application "Matlab R2014a.app" with this version of OS X.</p><p>Is there any fix??</p>Fan/matlabcentral/answers/contributors/4699030-fantag:mathworks.com,2005:Question/1590022014-10-17T11:20:55Z2014-10-21T18:25:56ZMatlab R 2014 a not workin on official Yosemite Update?!<p>Hey .. Since I updated my Macbook to Yosemite Matlab won't work ...
Tried the Patch Fix (<http://www.mathworks.com/support/bugreports/1098655>) , which still didnt hit the right spot..
I constantly get an Error "You can’t use this version of the application “MATLAB_R2014a” with this version of OS X. You have “MATLAB_R2014a” R2014a (8.3.0)."
Can Someone help ?
Appreciate it .. thx</p>Tobias/matlabcentral/answers/contributors/4748795-tobiastag:mathworks.com,2005:Question/1436012014-07-28T12:34:15Z2014-10-21T18:25:32ZI cannot install Matlab 2014a on OS X Yosemite 10.10 public beta<p>When I install Matlab 2014a on OS X Yosemite 10.10 public beta, it shows Matlab logo and then it says: “Install MATLAB quit unexpectedly.”</p><p>1.I install JDK/JRE before I try to install Matlab, but it still not works.</p><p>2.I changed ProductVersion in SystemVersion.plist to 10.90 or 10.9 according to this video https://www.youtube.com/watch?v=GoQnzIyOkB0 before I install Matlab, but it also still not works.</p><p>What can I do? Thank you!</p>Hongbo Miao/matlabcentral/answers/contributors/5485988-hongbo-miaotag:mathworks.com,2005:Question/1595612014-10-21T18:23:07Z2014-10-21T18:23:07ZVelocity Profile at Specifc Locations<p>Hello Everyone,
I am hoping someone can point me in the right direction with my issue. I am taking velocity measurements within a tube to derive a 2D laminar profile (should be a parabolic profile). I have measurements in a 10 mm X 10 mm grid pattern (x and y directions). Each measurement is taken at 1 mm increments from top to bottom and left to right, in a snaking pattern. I have 100 measurements total. My question is how would I be able to take all this data and create a profile at each x location? I should have a total of 10 parabolic profiles, 1 at 1 mm, 2 mm, 3 mm, etc. I hope that I was able to explain the issue clearly enough. I have only been able to take all the 100 data points and derive one profile, but I would like to segregate it by the specific x location to verify that the profile remains constant.</p><p>Any help would be appreciated.</p>Cy/matlabcentral/answers/contributors/5786379-cytag:mathworks.com,2005:Question/1593942014-10-20T16:18:02Z2014-10-21T18:20:44ZHelp with multilevel parallel programming<p>Greetings All,</p><p>I am trying to design a bioinformatics program to perform efficient local (SWA) alignment to a set of 1200 reference sequences over a long list of FASTQ sequences (1-10 million).</p><p>I have minimal experience with parallelism but would like to code the individual FASTQ reads to be analyzed in parallel with each analysis taking the individual read and aligning to all the 1200 reference reads in parallel.</p><p>Does anyone have any suggestions on how to get around not being able to perform nested parallelism in MATLAB?</p><p>Thank in advance.</p>Etienne/matlabcentral/answers/contributors/5157489-etiennetag:mathworks.com,2005:Question/1595602014-10-21T18:20:17Z2014-10-21T18:20:17ZHow to write a repeat loop of generation srting<p>the string includes 0 and 1:</p><p>with 2 conditions:the nodes can be in four directions in a matrix & the edges connect 2 nodes dont cut each other & nodes(0&1) dont put on each other. The value of optimization calculate with couple nodes and the distance between 2 couple nodes is 1. I want to generate this string
for example for string s1 =</p><img src = "/matlabcentral/answers/uploaded_files/19795/2.JPG"><p>and its graph is=
red nodes show 1 , black nodes show 0 and blue lines show couple nodes.</p><img src = "/matlabcentral/answers/uploaded_files/19798/3.JPG"><pre> Thanks for all answers very much...</pre>helena/matlabcentral/answers/contributors/5797569-helenatag:mathworks.com,2005:Question/1595302014-10-21T14:49:54Z2014-10-21T18:13:22ZLicense checkout failed - License Manager Error -96<p>Why do I get "License checkout failed - License Manager Error -96" and have attached the image</p><p><a href = "http://i.imgur.com/QjZTruZ.png">http://i.imgur.com/QjZTruZ.png</a>, Thanks in advance</p>Ramas Sami/matlabcentral/answers/contributors/2539490-ramas-samitag:mathworks.com,2005:Question/1587372014-10-15T14:30:52Z2014-10-21T18:12:22ZIs there any possibility of S-function written in C language calling matlab function library, and if so, then how ? I will appreciate that if someone can tell me.<p>Is there any possibility of S-function written in C language calling matlab function library, and if so, then how ?
I will appreciate that if someone can tell me.</p>li/matlabcentral/answers/contributors/5775244-litag:mathworks.com,2005:Question/1595592014-10-21T18:09:24Z2014-10-21T18:09:24ZExtract Data from for loop<pre> I am attempting to plot SFC and TSFC vs The PRC values based on each value of Mach. I am trying to find a way to extract all calculated values of SFC and TSFC for plotting.</pre><pre> U = Mach*sqrt(gamman*R*Ta);
Toa = Ta.*((1+(((gammad-1)/2).*(Mach^2))));
To2 = Toa;
To2sTa = (1+((etad.*((To2./Ta)-1))));
Po2 = Pa.*((To2sTa).^(gammad/(gammad-1)));</pre><pre> for PRC = 5:5:100
Po3 = PRC.*Po2;
To3 = To2.*(1+((1./etac).*(PRC.^((gammac-1)/gammac))-1));
for To4 = [1500 1600 1700]</pre><pre> Cpb = ((R*gammab)/(gammab-1));
f = ((To3.*((To4./To3)-1))./((QR/Cpb)-To4)); </pre><pre> Po4 = Po3;
To5 = To4-To3+To2;
Po5 = (Po4.*(1-(1./etat)*(1-(To5/To4))).^(gammat/(gammat-1)));</pre><pre> U7 = sqrt((2*etan*R*(gamman/(gamman-1)))*To5*((1-(Pa/Po5)).^(gamman-1/(gamman))));
SFC = ((1+f)*U7-U)/1000; %((kN*s)/(kg))
TSFC = f*SFC; %((kg)/(kN*s))
end</pre><pre> end</pre><pre class="language-matlab">end
</pre>Gerard/matlabcentral/answers/contributors/4000106-gerardtag:mathworks.com,2005:Question/195782011-10-27T10:11:26Z2014-10-21T18:07:11Zi need the matlab program codes to run <p>I'm struggling with my MATLAB code to get a bifurcation plot.</p><p>My equation is a kind of differential equation of second order.
I am trying to get the bifurcation for any kind of old well known differential equation of any order.</p>Rizwana Junaid/matlabcentral/answers/contributors/3134283-rizwana-junaidtag:mathworks.com,2005:Question/1595552014-10-21T17:59:16Z2014-10-21T17:59:16ZI need matlab code for standard gossip algorithm for calculate averaging in wireless sensor network and also I need matlab code for push sum algorithm to calculate averaging in WSNs<p>I need matlab code for standard gossip algorithm for calculate averaging in wireless sensor network
and also I need matlab code for push sum algorithm to calculate averaging in WSNs</p>maha ismail/matlabcentral/answers/contributors/5774280-maha-ismailtag:mathworks.com,2005:Question/1595532014-10-21T17:50:40Z2014-10-21T17:54:05Z[HOW do I assign multiple colorbars on same figure<pre class="language-matlab">files = dir('*.mat');
for i=1:2
load((['Mean_process_image_pos',num2str(i),'.mat']));
end
</pre><pre class="language-matlab">pos_1_cut_0 = Mean_process_image_pos1;
pos_1_cut_1 = rot90(pos_1_cut_0,-3);
pos_1_cut_2 = pos_1_cut_1(:,x:768);
pos_1_cut_3 = rot90(pos_1_cut_2,3);
</pre><pre class="language-matlab">pos_2_cut_0 = Mean_process_image_pos2;
pos_2_cut_1 = rot90(pos_2_cut_0,-3);
pos_2_cut_2 = pos_2_cut_1(:,x:768-x);
pos_2_cut_3 = rot90(pos_2_cut_2,3);
</pre><pre class="language-matlab">stacked_cut_image= [pos_2_cut_3;pos_1_cut_3];
figure;imshow(stacked_cut_image(:,:),[0,3.2]);colormap jet;colorbar;
</pre><p>This is my current code, and this compute just one figure with one colorbar.
However, I want to have two colorbars, one for pos2_cut_3, and another one for pos_1cut3 then put two things on same figure.</p><p>I tried, put figure:~~~~ line under pos#_cut_3 then save and load them then stack them, however there are blank in between figures.</p><p>can anyone give me a guideline??</p><p>ps. I might need 4 colorbars in one figure</p>YJ/matlabcentral/answers/contributors/5190234-yjtag:mathworks.com,2005:Question/1593462014-10-20T11:34:15Z2014-10-21T17:53:27ZI have recently installed Matlab 2014b and the x-ticks seems to overlap with the axis. Can you tell me how to fix it?<p>If I execute the following code in 2014b</p><pre> axes
set(gca,'FontSize',14)</pre><img src = "/matlabcentral/answers/uploaded_files/19705/2014b.JPG"><p>The same code in 2014a has much better spacing between the axis and the ticks</p><img src = "/matlabcentral/answers/uploaded_files/19706/2014a.JPG"><p>Can you help me fix it? I would appreciate a simpler solution than having to convert the ticks to text.</p>Rajiv Boddeda/matlabcentral/answers/contributors/5253835-rajiv-boddedatag:mathworks.com,2005:Question/1595472014-10-21T17:26:03Z2014-10-21T17:51:04ZIs there a function similar to rbbox that draws a line from corner to corner?<p>I am currently using rbbox to select a point on the axis and draw a ray to some other point. The rbbox draws the outline of the rectangle as I drag the mouse cursor around. When rbbox is done, I draw the line from the starting corner to the ending corner. However, my goal is to make a line parallel to a feature on the axis (image) and I find that I cannot do this precisely being able to see only the rectangle outline. I'd really like rbbox to draw a line corner-to-corner as I drag the mouse cursor. Is there a function similar to rbbox that can help me with this? Or do I need to write my own "real-time" line drawer?</p>AJ/matlabcentral/answers/contributors/122260-ajtag:mathworks.com,2005:Question/1593672014-10-20T13:48:07Z2014-10-21T17:49:36ZGithub support for Matlab files<p>Which type of files used within matlab has support from git?</p><p>Especially .m files and .mat files</p>Mikael Sahlin/matlabcentral/answers/contributors/3303293-mikael-sahlintag:mathworks.com,2005:Question/1588952014-10-16T16:47:44Z2014-10-21T17:43:49ZWhen will MATLAB be updated for OS X Yosemite?<p>When OS X Yosemite launches in the upcoming days (perhaps even today), will it be safe to update to OS X Yosemite from Mavericks? I ran the Yosemite Beta and MATLAB wasn't working so I had to downgrade back to Mavericks and MATLAB worked perfectly.
I am aware of the workarounds for Yosemite, but will those work for the official release of Yosemite?</p>Parth Patel/matlabcentral/answers/contributors/5748722-parth-pateltag:mathworks.com,2005:Question/1595512014-10-21T17:43:25Z2014-10-21T17:43:25ZUsing Model Explorer with Model References<p>Is there a way to search throughout the entire simulink models including the references? It seems like Im required to select each individual referenced model in order to find a parameter I am looking for. This is extremely unpractical as you would imagine.</p><p>Thanks</p>Michael/matlabcentral/answers/contributors/4064471-michaeltag:mathworks.com,2005:Question/1594662014-10-21T07:14:44Z2014-10-21T17:41:29Zparallel prime number code<p>Hi</p><p>How can I do the following code into parallel code? <b>(prime Number)</b></p><p>clc</p><p>close all</p><p>clear all</p><p>%%</p><p>tic</p><p>n = input('Enter Number:');</p><p>array = 2:n;</p><p>ones = [];</p><p>for i = 1:length(array)</p><pre> if ~ array(i) == 0 </pre><pre> for j = i+1: length(array) </pre><pre> if rem(array(j), array(i)) == 0 </pre><pre> array(j) = 0; </pre><pre> end </pre><pre> end </pre><pre> end </pre><pre> if ~ array(i) == 0 </pre><pre> ones(length(ones)+1) = array(i)</pre><pre> end</pre><p>end</p><p>toc</p><p>please help</p>hadi/matlabcentral/answers/contributors/5740666-haditag:mathworks.com,2005:Question/1595502014-10-21T17:36:15Z2014-10-21T17:36:15Zerror in RUN the embedded function in simulink<p>Hi everybody</p><p>I am working on the the Matlab function in simulink
I insert a simple function into embedded function the output of the function connected to the scope, when the run this massage will be displayed :</p><p>"Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler."</p><p>after this massage in the matlab comment I trying to determine default complier c (Microsoft visual c++ 2012 ) with mex –setup , but this compiler didn’t installed ,I download and install Microsoft Visual studio 2012 and SDK 2012 and visual C++ 2012. I determine the c compiler.
BUT this massage exist yet !!!</p>mohammad/matlabcentral/answers/contributors/5679599-mohammadtag:mathworks.com,2005:Question/1595342014-10-21T15:06:51Z2014-10-21T17:34:11ZRetrieve circle from image<p>Hi there!</p><p>I have created a black and white image from a droplet. This droplet has a few smaller droplets very close to it, these smaller droplets appear in the black and white image as if they are connected with the larger one. See image:</p><p><a href = "http://oi59.tinypic.com/2q0q5qv.jpg">http://oi59.tinypic.com/2q0q5qv.jpg</a></p><img src = "http://oi59.tinypic.com/2q0q5qv.jpg"><p>Now, I want to retrieve the largest droplet by erasing the smaller ones. I have tried routines such as bwareaopen and imfill, but with no success. Any ideas?</p><p>Thanks for your help!</p><p>Kind regards,
Rudy</p>Rudy/matlabcentral/answers/contributors/1959031-rudytag:mathworks.com,2005:Question/1595492014-10-21T17:33:26Z2014-10-21T17:33:26Zerror in RUN the embedded function in simulink<p>Hi everybody</p><p>I am working on the the Matlab function in simulink
I insert a simple function into embedded function the output of the function connected to the scope, when the run this massage will be displayed :</p><p>"Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler."</p><p>after this massage in the matlab comment I trying to determine default complier c (Microsoft visual c++ 2012 ) with mex –setup , but this compiler didn’t installed ,I download and install Microsoft Visual studio 2012 and SDK 2012 and visual C++ 2012. I determine the c compiler.
BUT this massage exist yet !!!</p>mohammad/matlabcentral/answers/contributors/5679599-mohammadtag:mathworks.com,2005:Question/1595482014-10-21T17:27:18Z2014-10-21T17:27:18ZCVX on Machine with Dual boot (Windows/Linux)<p>Hi</p><p>I am using matlab on both windows 7 and Linux. They are installed on separate partitions, but the MATLAB folder with my files is on a shared partition.</p><p>When installing CVX, I need to choose between a windows version and a linux version. A folder named cvx is created (usually in the MATLAB folder) which contains all the cvx-relevant files.
My problem is that e.g. Linux does not want to run the Windows version and vice-versa.</p><p>Any ideas? Thanks!</p>Ced/matlabcentral/answers/contributors/4692786-ced