http://nl.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2016-09-27T08:43:34Ztag:nl.mathworks.com,2005:Question/3046792016-09-27T08:43:34Z2016-09-27T08:43:34ZHi, I have this code and there some errors in line 12 and 14 can any one help me. Thanks<p>%Inputs
L = 0.01; % Plate thickness (m)
k = 0.2; % Conductivity (W/m-K)
rho = 2000; % Density (kg/m^3)
cp = 200; % Specifi c heat capacity (J/kg-K)
T_in = 343.15; % Initial temperature (K)
T_f = 298; % Gas temperature (K)
h = 17; % Heat transfer coeffi cient (W/m^2-K)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Setup Grid
N = 10; % Number of nodes (-)
for i = 1:N
x(i)=(i-1)*L/(N-1); % Position of each node (m)
end
DELTAx=L/(N-1); % Distance between adjacent nodes (m)
tau_sim = 10; % Simulation time (s)
OPTIONS = odeset('RelTol',1e-6);
[time,T] = ode45(@(time,T) dTdt_functionv(time,T,L,k,rho,cp,T_f,h),[0,tau_sim],T_in * ones(N,1),OPTIONS);
% Plot fi gure of transient heat conduction through fuel cell plates
surf(T);
xlabel('Number of Nodes');
zlabel('Temperature (K)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FUNCTION(dTdt)= dTdt_functionv(time,T,L,k,rho,c,T_f,h);
[N,g]=size(T); % Determine the size of T
DELTAx=L/(N-1); % Calculate the distance between adjacent nodes
dTdt=zeros(N,1); % Create dTdt vector
dTdt(1)=2 * k * (T(2)-T(1))/(rho * c * DELTAx^2);
for i=2:(N-1)
dTdt(i)=k * (T(i-1)+T(i+1)-2 * T(i))/(rho * c * DELTAx^2);
end
dTdt(N)=2 * k * (T(N-1)-T(N))/(rho * c * DELTAx^2)+2 * h * (T_f-T(N))/(rho * c * DELTAx);
END</p>saad Alrwashdehhttp://nl.mathworks.com/matlabcentral/profile/authors/8839441-saad-alrwashdehtag:nl.mathworks.com,2005:Question/3046762016-09-27T08:09:38Z2016-09-27T08:43:02ZHow to rewrite matrix ‘Y’ as matrix ‘A’? <p>Let ‘Y’ be a matrix of ‘N’ rows and ‘T’ columns. How to rewrite matrix ‘Y’ as matrix ‘A’? Where matrix ‘A’ is having ‘N*(T-2)’ rows and ‘((T-1)*(T-2))/2’ columns.</p>SAGAR MATURhttp://nl.mathworks.com/matlabcentral/profile/authors/8829136-sagar-maturtag:nl.mathworks.com,2005:Question/490272012-09-25T11:55:26Z2016-09-27T08:38:29ZHow to manipulate Plot Legend to show markers and colours seperatly?<p>Hi there everyone!</p><p>I want to display the results of a numerical computation in which I varyed two discretisation parameters.</p><p>Now I want to show in which way any parameter effects the results.
By using the same color I want to show the lines representing calculations with the same number of discrete elements.
And by using the same marker I want to show the lines that represent calculations with the same number of time steps.</p><p>I got as far as changing the colors and markers in the plot itself goes, but now I need a legend that clearly displays the correlations of color and marker.
My legend contains one entry for every line which is not useful.
I want a legend that first shows:</p><p>- this color means that many elements</p><p>- this marker means that many time steps.</p><p>Is it possible to tweak the legend like that?</p><p>Your help will be greatly appreciated! Thank you,</p><p>-Jakob.</p>Jakobhttp://nl.mathworks.com/matlabcentral/profile/authors/2168484-jakobtag:nl.mathworks.com,2005:Question/3046782016-09-27T08:37:19Z2016-09-27T08:39:14Zplot using for loop?<p>hi all,
I have the following code to plot 5 different subplot hist. for 5 different matrices but it has the same dim. for each</p><pre> x=-0.09 : 0.01 : 0.9;
hist(Y,x)
h = findobj(gca,'Type','patch');
set(h,'FaceColor','k','EdgeColor','w')
axis([-0.12 0.12 0 200]) </pre><p>I want to use for loop to plot it (i.e. Y is the changed matrix that mentioned above)
can anyone help me to do it? thank you in advance.</p>Lina Eyounihttp://nl.mathworks.com/matlabcentral/profile/authors/6648456-lina-eyounitag:nl.mathworks.com,2005:Question/3046402016-09-27T00:58:22Z2016-09-27T08:36:33ZRelated to Arabic langage <p>Hi there, I have problem to deal with Arabic language in mat lab,
the output appear like???????. I try to used this code</p><pre class="language-matlab">stopword='هذه'
stopword=native2unicode(stopword ,'UTF-8');
</pre><p>but it the out put and the array in work space print ??????? rather than Arabi</p>Ebtesam Almansorhttp://nl.mathworks.com/matlabcentral/profile/authors/8757257-ebtesam-almansortag:nl.mathworks.com,2005:Question/3038872016-09-21T12:04:05Z2016-09-27T08:36:03ZPDF calcutaion and graphs<p>I have different types of datasets, by looking at the data set we can not tell what type of distribution it has. so, how can I plot the probability density function?
Ex: x =</p><pre> 53
70
71
72
73
75
76
76
77
77
77
77
77
78
79
79
79
80
80
80
80
80
81
81
82
83
83
83
84
85
85
86</pre><p>would be grateful if anyone can suggest a method. Thanks in advance.</p>Nadeera Gunartnahttp://nl.mathworks.com/matlabcentral/profile/authors/7237813-nadeera-gunartnatag:nl.mathworks.com,2005:Question/3045712016-09-26T15:12:59Z2016-09-27T08:35:00ZUpdating a data file for a compiled application<p>I have a matlab application that uses a .mat file where the database is stored. When I create the application I included the .mat file and it creates the standalone application.</p><p>The thing is that sometimes I need to update the .mat file, and until now I haven't found a way to just replace the .mat file without the need to compile the application again. I tried including the .mat file in the "Files installed for your end user" section. But it seems the application does not read that file anyway, when I change it the old data is shown.</p><p>thank you</p>Oliver Silvahttp://nl.mathworks.com/matlabcentral/profile/authors/8563047-oliver-silvatag:nl.mathworks.com,2005:Question/1011032011-06-16T19:54:00Z2016-09-27T08:31:19ZHow do I download the MATLAB .ISO image?<p>I am interested in DVD images for MATLAB installation. Is there a way that I can download an ISO image?</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/3046772016-09-27T08:24:41Z2016-09-27T08:26:35ZHow could i shorten my for loop code?<p>I made a script to print out a diamond, but would like to make my script shorter. Only for loops are allowed. Is there a different logical way that could eliminate some for loops?</p><p>Here is the code:</p><pre> row=input('enter an odd number: \n');
%% part 2
for i= 1:ceil(row/2);
for j=1:row-i
fprintf(' ')
end
for k=1:2*i-1
fprintf('*')
end
fprintf('\n')
end
for j=ceil(row/2)-1:-1:1
for q=1:row-j
fprintf(' ')
end
for k=2*j-1:-1:1
fprintf('*')
end
fprintf('\n')
end</pre><p>Also, the index logic could probably be simpler.
Thanks!</p>Dan Pohttp://nl.mathworks.com/matlabcentral/profile/authors/8304822-dan-potag:nl.mathworks.com,2005:Question/3046632016-09-27T06:07:22Z2016-09-27T08:15:03ZSystem Identification Toolbox - How is the quality of the model output calculated?<p>Hello,</p><p>I'm searching for the calculation of the quality of the estimated model output compared to the measured data. I'm working with the System Identification Toolbox. You can see an example here <a href = "http://de.mathworks.com/help/ident/ref/compare.html">http://de.mathworks.com/help/ident/ref/compare.html</a> at the first graph.
Is the percentage calculated with an integral or any other method?</p><p>Thank you
hockeyman</p>hockeymanhttp://nl.mathworks.com/matlabcentral/profile/authors/7965193-hockeymantag:nl.mathworks.com,2005:Question/3046552016-09-27T04:02:51Z2016-09-27T08:14:55ZThe inbuilt code "bode " is not working in my matlab. <p>When I try to enter a simple program like</p><pre> N=[100 2e3 1e4]; D=[1e-6 1e-4 1 0 0]; bode(N,D)</pre><p>It shows an error as below.</p><pre class="language-matlab">Error using freqfocus
Too many input arguments.
</pre><pre class="language-matlab">Error in ltipack.ltidata/freqresp (line 75)
FocusInfo = freqfocus(Grade,w,mag.*exp(1i*ph),z,p,Ts,linDelay,[]);
</pre><pre class="language-matlab">Error in resppack.ltisource/magphaseresp (line 34)
[mag,phase,w,FocusInfo] = freqresp(SysData(ct),grade,wspec,true);
</pre><pre class="language-matlab">Error in wavepack.waveform/draw (line 25)
feval(this.DataFcn{:});
</pre><pre class="language-matlab">Error in wrfc.plot/draw (line 17)
draw(wf)
</pre><pre class="language-matlab">Error in wrfc.plot/init_listeners>LocalRefreshPlot (line 79)
draw(this)
</pre><p>Can anyone help me to resolve this?</p><p>Thank you</p>Brindha chellaiahhttp://nl.mathworks.com/matlabcentral/profile/authors/7300442-brindha-chellaiahtag:nl.mathworks.com,2005:Question/990922010-06-01T13:36:00Z2016-09-27T08:14:47ZHow do I define colors for individual bars on my bar graph according to their values in MATLAB 7.1 (R14SP3) ?<p>I am trying to change colors on the individual bars in a bar graph according to the value of my data. When I issue the following command,</p><pre class="language-matlab">mydata=rand(1,5);
</pre><pre class="language-matlab">h=bar(mydata);
</pre><p>all the bars in my bar graph have the color blue. I want the bar colors to be such that if the value of 'mydata' is between [0, 0.2), the bars are black, if the value of my data is between [0.2, 0.6), the bars are blue, and if the value of my data is between [0.6, 1] then the corresponding bars are red.</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/3045402016-09-26T11:01:55Z2016-09-27T08:12:30ZHow I can save workspace variables to an excel file, storing them coloumn by coloumn with their respective name in the first row?<p>I have workspace variables (numbers) out of a simulation by Simulink. I'd like to save them in an excel file, each one with its name on the first row, then the values in coloumn. Than I'd like to automatically open the saved file in excel. Here below my draft code:</p><pre> filename='workspace_variable.xls';
save(filename,'time','Temperature','-ASCII','-double');
winopen('workspace_variable.xls');</pre><p>I get error in excel that the file format and extension of the "workspace_variable.xls" don't match, then i click ok and it opens the file anyway. The cells are filled just in the first coloumn with "time" values, but not the coloumn for Temperature values.</p><p>Thank you.</p>eugenio penazzihttp://nl.mathworks.com/matlabcentral/profile/authors/8687226-eugenio-penazzitag:nl.mathworks.com,2005:Question/3046112016-09-26T19:23:49Z2016-09-27T08:09:56ZError using VideoReader/init (line 607) The filename specified was not found in the MATLAB path. Any ideas how to fix that error?<p>Error using VideoReader/init (line 607)
The filename specified was not found in the MATLAB path.</p>abbxucy11http://nl.mathworks.com/matlabcentral/profile/authors/5643759-abbxucy11tag:nl.mathworks.com,2005:Question/3046672016-09-27T06:39:01Z2016-09-27T08:05:12Zaudiowrite and audioread is not case-sensitive<p>I am using MATLAB 2016b on Mac with Sierra, and MATLAB 2010a on Windows 10. For some reason, the commands AUDIOREAD and AUDIOWRITE become case-insensitive. For example,</p><pre class="language-matlab">audiowrite('test.wav', 0.1, 44100);
audioread('TEST.wav')
</pre><p>This returns 0.1 (although the second line reads the audio file with the capital 'TEST'). Furthermore,</p><pre class="language-matlab">audiowrite('TEST.wav', 0.2, 44100);
</pre><p>overwrites 'test.wav', meaning that 'test.wav' is automatically deleted and 'TEST.wav' is generated.</p><p>Please help with this. Thanks in advance.</p>Do Heon Leehttp://nl.mathworks.com/matlabcentral/profile/authors/8395577-do-heon-leetag:nl.mathworks.com,2005:Question/1312362014-05-26T21:43:53Z2016-09-27T07:57:46Zchanging fontsize in a figure<p>I'm using "set(gca,'fontsize', 18);" in a function to change fonts in a figure. My code does not throw an error, but it also does not change the font size. I can manually change the fonts via the UI, but this is a slow process. I'm running MATLAB 2013a on RHEL6.5</p><p>I've also tried "set(gca,'FontSize', 18);" and specifying 'FontSize', 18 in title, xlabel, ylabel and legend. None of these have worked.</p><p>Please advise!</p>Edwardhttp://nl.mathworks.com/matlabcentral/profile/authors/1083733-edwardtag:nl.mathworks.com,2005:Question/3045532016-09-26T13:04:34Z2016-09-27T07:56:01ZUse of arrayfun and sprintf to order data<p>Hi,
I have a 1x4cell (files) with 1x1struct in each cell. Each structure contains several variables. I would like to extract from each structure only the variables called: SL_X_Y, where X can be numbers from 1 to 7 and Y could be numbers from 1 to 3 i.e. SL_5_2. Not all the combinations are found in each structure.
The resulting 1x4cell will only contain structures with the variables SL_X_Y that are found.</p><p>Thanks</p>Isma_gphttp://nl.mathworks.com/matlabcentral/profile/authors/8206515-isma_gptag:nl.mathworks.com,2005:Question/925062013-07-03T14:51:00Z2016-09-27T07:52:41ZHow can I configure MATLAB to allow access to self-signed HTTPS servers?<p>I am trying to access an HTTPS server with a self-signed certificate from MATLAB. I have tried various methods in various MATLAB releases:</p><pre class="language-matlab">>> urlread('https://self-signed.badssl.com/')
</pre><p>In all MATLAB releases throws:</p><pre class="error"> Error using urlreadwrite (line 98)
Error downloading URL. Your network connection may be down or your proxy settings improperly configured.
Error in urlread (line 36)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});</pre><p>And when trying to use pure Java:</p><pre class="language-matlab">>> u = java.net.URL('https://self-signed.badssl.com/');
>> conn = u.openConnection;
>> conn.connect
</pre><p>I receive:</p><pre class="error"> Java exception occurred:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
(snip)</pre><p>Further, webread:</p><pre class="language-matlab">>> webread('https://self-signed.badssl.com/')
</pre><p>In MATLAB releases prior to R2016b actually returns the data without any error or warning for this server:</p><pre class="language-matlab">ans =
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/icons/favicon-red.ico"/>
<link rel="apple-touch-icon" href="/icons/icon-red.png"/>
<title>self-signed.badssl.com</title>
<link rel="stylesheet" href="/style.css">
<style>body { background: red; }</style>
</head>
<body>
<div id="content">
<h1 style="font-size: 12vw;">
self-signed.<br>badssl.com
</h1>
</div>
</pre><pre class="language-matlab"></body>
</html>
</pre><p>But for another server:</p><pre class="language-matlab">>> webread('https://localhost/')
</pre><p>I receive:</p><pre class="error"> Error using readContentFromWebService (line 45)
The server returned the message: "sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target" for URL, 'https://localhost/' (with HTTP response code unknown).
Error in webread (line 122)
[varargout{1:nargout}] = readContentFromWebService(connection, options);</pre><p>And in MATLAB release R2016b:</p><pre class="language-matlab">>> webread('https://self-signed.badssl.com/')
</pre><p>Throws:</p><pre class="error"> Error using webread (line 119)
Could not establish a secure connection to "self-signed.badssl.com". The reason is "error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed".
Check your certificate file (C:\MATLAB\R2016b\sys\certificates\ca\rootcerts.pem) for expired, missing or invalid certificates.</pre><p>For both servers actually.</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/3046602016-09-27T05:23:36Z2016-09-27T07:52:41ZHow to compare two images using spatial frequency of image blocks?<p>I have divided two images into blocks separately, now i have to compare the corresponding blocks from two images to find out which block is sharper using spatial frequency. Then that sharper block will be selected in the fused image</p>Haritha K Chttp://nl.mathworks.com/matlabcentral/profile/authors/8452737-haritha-k-ctag:nl.mathworks.com,2005:Question/3046482016-09-27T01:56:42Z2016-09-27T07:51:01ZRunge-kutta (rk2) for radio decay <p>solve the equation</p><p>dN(t)/dt=-N(t)/tau</p><p>decay constant=1</p><p>initial nuclei=1000 @ t=0</p><p><b>my code so far is:</b></p><p>%radioactive decay</p><p>t0=0</p><p>N0=1000</p><p>tf=5</p><p>dt=.05</p><p>tau=1</p><p>%Initialize</p><p>t=t0:dt:tf;</p><p>N=zeros(size(t));</p><p>N(1)=N0;</p><p>t(1)=t0;</p><p>for i =2:length(t);</p><pre> tn=t(i-1);</pre><pre> Nn=N(i-1);</pre><pre> Y1=dt*decay(tn,Nn);</pre><pre> Y2=dt*decay(tn+dt/2,Nn+Y1/2,tau);</pre><pre> Y3=dt*decay(tn+dt/2,Nn+Y2/2,tau);</pre><pre> Y4=dt*decay(tn+dt,Nn+Y3,tau);</pre><pre> N(i)=Nn+((Y1+Y4)/2+(Y2+Y3))/3;</pre><p>end;</p><p>plotcompare(t,N,N0,tau,'RK4')</p><p>it keeps running the error message 'too many input arguments'</p><p>Am i headed in the right direction? anything will help</p><p>thanks</p>brandon frieshttp://nl.mathworks.com/matlabcentral/profile/authors/8619302-brandon-friestag:nl.mathworks.com,2005:Question/3046752016-09-27T07:50:31Z2016-09-27T07:50:31ZHow to link static libs, e.g. libmex.a libmx.a libmat.a using gcc under Ubuntu Linux 16.04 LTS <p>Hello!</p><p>I have Matlab/Simulink (R2015b) project that is correctly compiles and runs under MSVS on Windows.</p><p>I would like to move this project on GCC and Ubuntu.</p><p>The question:
How to correctly link libmex.so, libmx.so, libmat.so if it seems there are no static versions of these libs in Matlab for Linux?</p><p>Where can i get static versions to link them?</p><p>Thanks for help!</p>Eliahttp://nl.mathworks.com/matlabcentral/profile/authors/5599703-eliatag:nl.mathworks.com,2005:Question/3045852016-09-26T16:12:58Z2016-09-27T07:49:00ZHow to update the position of legend with 'Best' Location?<p>Hi,</p><p>I have an output function which I use with <i>fmincon</i> to plot some of variables during optimization process. I use</p><pre class="language-matlab">legend(...,'Location', 'Best')
</pre><p>to define the legend, and in the first iteration it looks really okay. However, as the optimization goes, I update my graph with:</p><pre class="language-matlab">set(h, 'YData', new_data);
</pre><p>And sometimes the legend overlaps with the new plot (it doesn't reposition to adjust for new data). Is there any way I could reposition automatically my legend (I guess apart from deleting it and constructing again every iteration)?</p><p>Cheers,
Aleksander</p>Aleksander Marekhttp://nl.mathworks.com/matlabcentral/profile/authors/7241692-aleksander-marektag:nl.mathworks.com,2005:Question/3046742016-09-27T07:40:26Z2016-09-27T07:40:26Zi have a gui in matlab 2015a. when i run it in matlab 2014a it's not work.... all the variables changed to values (numbers).... why??? and how we can fix it??<p>i have a gui in matlab 2015a. when i run it in matlab 2014a it's not work.... all the variables changed to values (numbers).... why??? and how we can fix it??</p>ammar egbareyehttp://nl.mathworks.com/matlabcentral/profile/authors/8252204-ammar-egbareyetag:nl.mathworks.com,2005:Question/3046732016-09-27T07:33:43Z2016-09-27T07:33:43Zfiltfilt returns unexpected large value when using with LPC<p>Hi, I am just trying source-filter separation with lpc function and filtfilt function.
However, when the signal pass through filtfilt, it becomes extremely large.
When I use filter instead of filtfilt, there is no problem with it.</p><p>Is there any problems in my code?</p><pre class="language-matlab">a = lpc(source,50);
e = source - filtfilt([0 -a(2:end)],1,source);
recovered = filtfilt(1,a,e); % this filtfilt makes the problem
</pre>Sangeon Yonghttp://nl.mathworks.com/matlabcentral/profile/authors/3695561-sangeon-yongtag:nl.mathworks.com,2005:Question/3046412016-09-27T01:12:32Z2016-09-27T07:33:40Zpagefun makes an error<p>The following code makes an error. How can I solve it?</p><pre class="language-matlab">b = gpuArray(repmat([1 2 ; 2 2; 4 3], 1, 1, 3));
pagefun(@norm, b)
</pre><p>Error using gpuArray/pagefun
Function passed as first input argument contains unsupported or unknown function 'norm'.</p><p>What is the corrected code?</p><p>I am using Matlab 2014a, Parallel Computing Toolbox Version 6.4 and Gigabyte GTX750.</p><p>Thanks.</p>sungho Kanghttp://nl.mathworks.com/matlabcentral/profile/authors/8395445-sungho-kangtag:nl.mathworks.com,2005:Question/3046492016-09-27T02:08:23Z2016-09-27T07:33:27ZHow can I use pagefun?<pre class="language-matlab">function gputest()
% pagefun
function res = ttt_gpu(bb)
res = bb + 1;
end
b = gpuArray(repmat([1 2 ; 2 2; 4 3], 1, 1, 3));
</pre><pre class="language-matlab">pagefun(@ttt_gpu, b)
</pre><pre class="language-matlab">end
</pre><p>The line "pagefun(@ttt_gpu, b)" makes an error.
Can't I use pagefun with user defined function?</p>sungho Kanghttp://nl.mathworks.com/matlabcentral/profile/authors/8395445-sungho-kangtag:nl.mathworks.com,2005:Question/3046052016-09-26T18:29:54Z2016-09-27T07:27:38ZFor similar feature points in two image, How can i find angular displacements between all similar points? <p>I have located the similar feature points in two consecutive image frames by A-SIFT. Now i need to find the angular displacements between similar feature points in two images.</p><img src = "/matlabcentral/answers/uploaded_files/59992/Capture.PNG"><p>Similar work was done in the paper ''A Video-based Speed Estimation Technique for Localizing the Wireless Capsule Endoscope inside Gastrointestinal Tract''(screenshot attached)</p>monzurul ARASHhttp://nl.mathworks.com/matlabcentral/profile/authors/8767941-monzurul-arashtag:nl.mathworks.com,2005:Question/3046642016-09-27T06:12:21Z2016-09-27T07:12:55ZSolving simultaneous non linear equation<p>What code do I use to solve these equations?
{(40/t)-(20/t+1)-3.8+[(7.6*k*e^-3.8*t)((1/(t+1)^2)-(t+1+3.8*t)/(t+1))]/1-k+(2*k*e^-3.8*t)(t+1+3.8*t)/(t+1)}=0
,{[-1+(2*e^-3.8*t)(t+1+3.8*t)/(t+1)]/(1-k+(2*k*e^-3.8*t)(t+1+3.8*t)/(t+1)}=0</p>Ianhttp://nl.mathworks.com/matlabcentral/profile/authors/8838451-iantag:nl.mathworks.com,2005:Question/3044582016-09-25T23:47:00Z2016-09-27T07:12:21ZWord Guessing game code, with a bit of a twist. (matlab)<p>I'm writing a program about guessing a 4 letter word.
I have to propose a word for the computer to guess
and then display the amount of correct letters guessed
(per guess) and how many letters were in the correct
position of the guess and the number of guesses.</p><p>e.g. if the word I select is 'tank'
and the computer guesses 'bank'
the display should read:
'There are 3 correctly guessed letters, 3 characters are in the right position.
In the end it should say 'you've guessed the right word, it took 4 attempts'.</p><p>The twist part is that it has to work systematically and not just random guesses. If possible, otherwise I'd settle for assistance on just the random guessing. Any help would be appreciated.</p>T-man1011http://nl.mathworks.com/matlabcentral/profile/authors/8812682-t-man1011tag:nl.mathworks.com,2005:Question/3046712016-09-27T07:04:22Z2016-09-27T07:08:54ZCreating a randomly generated 4 character string (A-Z)<p>So I'm trying to make the computer guess a word that I have given. It essentially has to randomly guess a 4 character long string (A-Z). Basically a guessing game with the computer guessing the word that I picked. Any help would be appreciated. I'm mainly stuck on the part where it generates a random string as it's guess.</p>T-man1011http://nl.mathworks.com/matlabcentral/profile/authors/8812682-t-man1011tag:nl.mathworks.com,2005:Question/3046702016-09-27T07:00:22Z2016-09-27T07:07:34ZHow to check if right axis is visible?<p>I have a finction that process all the lines in the current graph. Since the introduction of</p><pre class="language-matlab">yyaxis right
</pre><p>I need my function to be able to figure out if the right axis is visible or not.</p><p>If I just run</p><pre class="language-matlab">yyaxis right
</pre><p>then I cant check if it is visible because the command will invoke the right axis to appear. Anny suggestions?</p>Micke Malmströmhttp://nl.mathworks.com/matlabcentral/profile/authors/1567078-micke-malmstromtag:nl.mathworks.com,2005:Question/3045452016-09-26T11:41:41Z2016-09-27T07:04:44ZHow to add velocity colourbar to graph<p>Hey,</p><p>I have a 3D graph plotting the trajectory of a particle. My plot therefore provides the point to point position of the particle.</p><p>I was wondering if there was a method to add a color bar that represents the particle velocity at each position.
I have the particle velocity at each position stored as vectors.</p><p>My plot is basically a curved line.Is there a way to use the colorbar command to enable the colour of the particle at each of the points to change correlating to the velocity?</p><p>Any help would be greatly appreciated :)</p>Alexander Hamiltonhttp://nl.mathworks.com/matlabcentral/profile/authors/6744443-alexander-hamiltontag:nl.mathworks.com,2005:Question/3046692016-09-27T06:47:03Z2016-09-27T07:03:16Zhow to compare the characteristics of two graphs <img src = "/matlabcentral/answers/uploaded_files/60024/matlabb.jpg"><p>I want to get a result by comparing the characteristics(patterns) of the two graphs above from Matlab. From the above graph we can see that the two graphs are of same characteristics but how to get the same result using Matlab? I have tried it using pattern recognition tool but didn't get any relevant results.please suggest me any other method/toolbox.</p>Princy Manaswinihttp://nl.mathworks.com/matlabcentral/profile/authors/8305502-princy-manaswinitag:nl.mathworks.com,2005:Question/343022012-04-02T19:29:37Z2016-09-27T06:54:12ZHow to find consecutive numbers<p>So i have an array:
a=[16 17 32 33 48 63 79 80 81 97 98 113 114 129 130]</p><p>how can i write a program to find where those consecutive numbers are?
i've tried using a for loop but haven't really got anywhere..
Please note that at one point there is 3 consecutive numbers..
The idea is each of these numbers is an index of another array:
value=[3 0 2 5 3 2 1 0 0 2 7 7 3 7 8];
all equally spaced,
which is supposed to mean:
realvalue=[30 25 3 2 100 27 73 78];
and im trying to get the array 'realvaue' from arrays 'a' and 'value'</p>Edwardhttp://nl.mathworks.com/matlabcentral/profile/authors/3416399-edwardtag:nl.mathworks.com,2005:Question/3046612016-09-27T06:02:53Z2016-09-27T06:54:00ZNeed help with this code - linear regression/least squares<p>the question and problem statement is on the pdf attachment. Tried my best with writing a code for it but I havn't taken matlab in 2 years so I'm extremely fuzzy. Down below is my first function statement but it didn't get included in the main code for some reason.</p><p>function CP2SmithTristen
sumx=0;
sumy=0;
x= 1:5 ;
y= [4, 7.1, 10.1, 12.5, 14.5];
end</p><pre> function [a0,a1]=linear_regression(x,y)
for i = 1:5
n=length(x);
sumx = sumx + x(i);
sumy = sumy + y(i);
end
n = length(x);
a1=(n*(sumx*sumy)-sumx*sumy)/((n*sumx^2)-sumx^2);
a0=ym-(a1*xm);
xm = sumx/n
ym = sumy/n
end</pre>Tristen Smithhttp://nl.mathworks.com/matlabcentral/profile/authors/8578868-tristen-smithtag:nl.mathworks.com,2005:Question/3044832016-09-26T04:23:42Z2016-09-27T06:45:33ZHow to use for loop for segmentation of multiple image in a folder?<p>i have 17 images in a folder how do I use for loop to segment all 17 images without having to do it one by one?</p>Pui Choo Wonghttp://nl.mathworks.com/matlabcentral/profile/authors/8667422-pui-choo-wongtag:nl.mathworks.com,2005:Question/3046682016-09-27T06:43:24Z2016-09-27T06:43:24ZHow to do for loop?<p>Im doing a program where I've used for loop to segment all the images in a folder. How do I do for loop for the original image as well?(when the segmented images is display it display the original image concurrently as well. The images and files are in the link provided. Please help if you can. All help is greatly appreciated.
https://drive.google.com/open?id=0B3u6R-8b6PPuNjFnOUtxTmNJSTg</p><p>https://drive.google.com/open?id=0B3u6R-8b6PPuVFpMRlFxa21sYzQ</p><p>https://drive.google.com/open?id=0B3u6R-8b6PPuZTVyVXgtUGZxVnc</p>Pui Choo Wonghttp://nl.mathworks.com/matlabcentral/profile/authors/8667422-pui-choo-wongtag:nl.mathworks.com,2005:Question/3046652016-09-27T06:24:16Z2016-09-27T06:24:16ZHow to write the Mtlab Code for the Estimation error of the different CD-EKF approximation for the Van Der Pol model.? Kindly help for the following tag<p>whats the matlab command for this model,where did we got the DELY .?v(0)=%3.2f' is not a valid product
10); title(sprintf('Phase portait showing limit cycle. x(0)=%3.2f is not a valid product
'MarkerSize' is not a valid product
'*r' is not a valid product
v0 is not a valid product
2)); xlabel('x(t)'); ylabel('v(t)'); hold on; plot(x0 is not a valid product
x(: is not a valid product
1) is not a valid product
2); plot(x(: is not a valid product
1 is not a valid product
k)); subplot(2 is not a valid product
c is not a valid product
k=%3.2f' is not a valid product
c=%3.2f is not a valid product
time is not a valid product
position vs is not a valid product
1)); xlabel('t'); ylabel('x(t)'); title(sprintf('Van Der Pol is not a valid product
x(: is not a valid product
1); plot(t is not a valid product
1 is not a valid product
v0]); subplot(2 is not a valid product
[x0 is not a valid product
t is not a valid product
x] = ode45( @rhs is not a valid product
function nma_project_511() % % This function solves the Van Der Pol nonlinear % ode numerically using Matlab's ode45. % Van Der Pol ode is % x''(t) - c (1-x^2(t)) x'(t) + k x(t) = 0 % % % DATA t = 0:0.001:100; % time scale c = 3; k = 1; x0 = 10; v0 = 3; [t is not a valid product</p>Saima ishaqhttp://nl.mathworks.com/matlabcentral/profile/authors/8838583-saima-ishaqtag:nl.mathworks.com,2005:Question/3046622016-09-27T06:04:38Z2016-09-27T06:08:27ZMy for loop is not executing. Atleast that's what I think becoz its not returning any value. What seems to be the problem?<pre class="language-matlab">a = load('ra1.dat');
x = a(:,1);
y = a(:,2);
hold on
plot(x,y)';
for i=1:1950;
a(((y(i+50)-y(i))/(x(i+50)-x(i)))>10);
end
</pre>Anuradha Bhattacharyahttp://nl.mathworks.com/matlabcentral/profile/authors/6141329-anuradha-bhattacharyatag:nl.mathworks.com,2005:Question/3045012016-09-26T06:55:54Z2016-09-27T06:05:21ZCompare string in different file <p>Hi there I need matlab code to compare the input word with list (for example if the input word is BRB which is abbrivation )I want to search for BRB in Abbrivation list and replace it with the full stanser word</p>Ebtesam Almansorhttp://nl.mathworks.com/matlabcentral/profile/authors/8757257-ebtesam-almansortag:nl.mathworks.com,2005:Question/3046502016-09-27T02:26:46Z2016-09-27T05:40:10ZConfusion matrix neural network plot interpretation<p>I would greatly appreciate if someone could help me interpret the confusion matrix below. I don't understand the red, green and grey boxes.Also, what is the difference between test, validation, training and all confusion matrix.
Thanks in advance!</p>Swathi Ganeshhttp://nl.mathworks.com/matlabcentral/profile/authors/6022739-swathi-ganeshtag:nl.mathworks.com,2005:Question/3042622016-09-23T17:41:59Z2016-09-27T05:31:41ZHow to convert the name of a table or cell array to string<p>Dear Experts,</p><p>I have a cell array named "cat" and a table named "dog"
So cat has a series of data within. Likewise for dog.</p><p>I just want to extract the name of the cell array (cat) and name of the table (dog) to be label in title when plotting a figure.</p><p>Any ideas?
LL</p>Cheerfulhttp://nl.mathworks.com/matlabcentral/profile/authors/3386189-cheerfultag:nl.mathworks.com,2005:Question/3046532016-09-27T02:59:09Z2016-09-27T05:27:52ZHow to obtain vertices of all smaller squares in a large square?<p>Hi all,</p><p>I am going to generate a square map of side length rs and then divide it up into smaller squares of side length dc using meshgrid. Refer to the image and code below.</p><pre class="language-matlab">coord = 0:dc:rs;
[X,Y] = meshgrid(coord);
</pre><p>How would I obtain the vertices of all smaller squares? Some sort of combination of X and Y must have them but I would like that a new matrix XV is an Nx5 matrix with the x-coordinates of the squares and a matrix YV is an Nx5 matrix with the y-coordinates of the squares. Each row of each matrix would correspond to a different square where N is the number of squares. Also, columns = 5 to duplicate the first column so the vertices are closed and can be used for the inpolygon function.</p><img src = "/matlabcentral/answers/uploaded_files/60016/map.png">Jonathan Mayershttp://nl.mathworks.com/matlabcentral/profile/authors/7139932-jonathan-mayerstag:nl.mathworks.com,2005:Question/3046592016-09-27T05:12:21Z2016-09-27T05:27:26ZProblem with "Subscript indices must either be real positive integers or logicals."<p>I've downloaded a code for load flow distribution. I tried to modify the code introducing a loop using a while-loop with the condition iteration<20. However, I figured out that whenever it reaches the second iteration, the line "vbp=[abs(vb), angle(vb)*180/pi]" will always give me the mentioned error, which does not happen at the first iteration. Been trying to figure out how this happen but I cant see why.</p><p>This is the link to it if it helps, <a href = "https://www.mathworks.com/matlabcentral/fileexchange/40376-load-flow-of-radial-distribution-system">https://www.mathworks.com/matlabcentral/fileexchange/40376-load-flow-of-radial-distribution-system</a></p><p>*iteration2 is just variable i used for debugging</p><p>ok i editted cause I cant figure out the editting. Here's the slightly modified program</p>Aaron Mok Ji Yionghttp://nl.mathworks.com/matlabcentral/profile/authors/7260904-aaron-mok-ji-yiongtag:nl.mathworks.com,2005:Question/3044602016-09-26T00:27:41Z2016-09-27T05:20:41ZCan not use "imaqhwinfo"<p>When I use "imaqhwinfo" , it returns nothing only I am wrong .
I did have installed "Image Acquisition Toolbox" and "MATLAB Compiler SDK",but it did not work .
Thanks in advance .</p>Lizhao Duhttp://nl.mathworks.com/matlabcentral/profile/authors/8544747-lizhao-dutag:nl.mathworks.com,2005:Question/3041692016-09-23T04:02:48Z2016-09-27T05:18:32Zhow to generate chaotic sequence using logistic map of n*n image<p>how to generate chaotic sequence using logistic map of n*n image matlab code provide</p>mosarrat jahanhttp://nl.mathworks.com/matlabcentral/profile/authors/8789223-mosarrat-jahantag:nl.mathworks.com,2005:Question/3046582016-09-27T05:04:52Z2016-09-27T05:04:52ZAbout image processing on fpga<p>HI i am using matlab 2015b i want to generater VHDL code for sobel edge detection from the simulink model but some blocks for that are not compatible with the HDL code generation.. so what can i do? is it possible to generate VHDL code for the same? and this generated code can be implemented on FPGA(ALTERA)?</p>shraddha swamihttp://nl.mathworks.com/matlabcentral/profile/authors/8801753-shraddha-swamitag:nl.mathworks.com,2005:Question/3046572016-09-27T04:56:05Z2016-09-27T04:56:05Zhow to automatically click a pushbutton continously<p>for a gui project i want to click a pushbutton automatically after every 1 second...please provide code......
my code is
t=clock;
c=fix(t);
v=c(1,4);
b=c(1,5);</p><p>set(handles.text2,'string',[v,b]);
set(handles.text3,'string',[v,b+30]);</p><p>now how to run set function after every 1 second without clicking pushbutton manually</p>Prasanna kulkarnihttp://nl.mathworks.com/matlabcentral/profile/authors/8376723-prasanna-kulkarnitag:nl.mathworks.com,2005:Question/3045592016-09-26T13:53:09Z2016-09-27T04:32:09Zwhy haart2 function isn't found in matlab ?<p>I am trying to use haart2 in matlab , but everytime it shows me this error</p><pre class="language-matlab">Undefined function or variable 'haart2'.
</pre><pre class="language-matlab">Error in haar (line 5)
[a2,h2,v2,d2] = haart2(im,2);
</pre><p>So i checked if i have the wavelet toolbox and it turns out that it exists in my matlab :</p><pre class="language-matlab">>> ver wavelet
---------------------------------------------------------------------------------------------
MATLAB Version: 8.5.0.197613 (R2015a)
MATLAB License Number: 161052
Operating System: Microsoft Windows 8 Pro Version 6.2 (Build 9200)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) Client VM mixed mode
---------------------------------------------------------------------------------------------
Wavelet Toolbox Version 4.14.1 (R2015a)
</pre><p>so what is wrong?</p>Hadeer tawfikhttp://nl.mathworks.com/matlabcentral/profile/authors/3944762-hadeer-tawfiktag:nl.mathworks.com,2005:Question/3046562016-09-27T04:25:10Z2016-09-27T04:25:10ZCreate a function in simulink<p>Hi guys,</p><p>I'm working in circuit breaker switching and I would like to ask if I want to create a function in simulink (ode23s) to call a data from workspace or if there is an easy way to take the measurement direct from block measurement:
v(:,1), i(:,1), g, po, and a.</p><p>to make the calculation for the following formula:
g=i./v;
P=v.*i;
PP=po.*g.^a; % note po & a are constant.
then execute the result: plot (p & pp).</p><p>Thanks in advance for your attention.</p>Khalidhttp://nl.mathworks.com/matlabcentral/profile/authors/4287932-khalid