https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-08-19T15:40:22Ztag:www.mathworks.com,2005:Question/4154072018-08-19T14:07:00Z2018-08-19T15:40:22ZConverting grayscale image to indexed<p>I have a grayscale image with 3 random values signified by integers 91, 123, 255. When I use gray2ind(I, 3) I get only 2 indices: 1 and 2. But when I use gray2ind(I, 2) I get 0 and 1 as expected. How come? I would expect gray2ind(I, 3) to give me 0, 1 and 2.</p><p>I do have a colormap array which I am planning to later use, which has 3 individual colors, such that after I would properly convert this to 0, 1 and 2 indices I'd just do imshow(gray2ind(I, 3), colors).</p><p>Thanks</p>Michahttps://www.mathworks.com/matlabcentral/profile/authors/11517178-michatag:www.mathworks.com,2005:Question/4151692018-08-16T19:40:21Z2018-08-19T15:38:34ZImage Segmenting overlapping variable regions (watershed with edge detection issues) <p>I have attached three images below. The first image shows the the objects I want to segment. In the last image, I have indicated the segmentation as circles around the objects. I have so far tried using the watershed method with markers. The second image is the markers mask I have been using. However, this method has been inaccurate, due the stretches of overlay between different objects. I was wondering if there a specific way I can employ the watershed method to account for these type of images or if I should employ a sort of edge detection.</p><p>I was also thinking of perhaps going through each boundary and finding the points connected to each boundary when overlaying the markers on top of the original image. I would then try to employ a decider function for points connected to more than one boundary and see if I can decide which boundary those points belong to. It seems that the streaks coming out of the boundaries do follow a general path shape of the original boundary and are at parallel plane with the boundary.</p><img src = "/matlabcentral/answers/uploaded_files/129205/ocells.png"><img src = "/matlabcentral/answers/uploaded_files/129204/markers.png"><img src = "/matlabcentral/answers/uploaded_files/129203/segmented.png">Aa Mhttps://www.mathworks.com/matlabcentral/profile/authors/10264504-aa-mtag:www.mathworks.com,2005:Question/4153832018-08-18T21:22:35Z2018-08-19T15:32:27Zhow can ı write opposite of while loop<p>so i wanted to write loop but my loop need to be opposite of while loop,i mean you know when condition is true while loop keep doing loop and when condition is wrong, loop stop and continue to code.
So my loop need to stop when condition is true and my loop need to continue to looping when my condition is wrong.</p>mtshttps://www.mathworks.com/matlabcentral/profile/authors/13009833-mtstag:www.mathworks.com,2005:Question/4154122018-08-19T15:30:43Z2018-08-19T15:30:43Zcan CNN used in signal (EEG Signal) which is represented in matrix form ??<p>is it feasible to apply CNN in signal processing ?</p>arunnagiri murrugesanhttps://www.mathworks.com/matlabcentral/profile/authors/5535768-arunnagiri-murrugesantag:www.mathworks.com,2005:Question/4153932018-08-19T06:50:35Z2018-08-19T15:17:48Zquestion about determining the correct number of clusters (documentation)<p>I have a question about determining the correct number of clusters (in k-means clustering).</p><p>In the documentation, there is a section about 'determining the correct number of clusters'. Please help me understand what the arguments in the table are for: iter (which would mean iterations), phase (?), num (?), and sum(?).</p><p>In the example, you will see:</p><pre class="language-matlab">Best total sum of distances = 1771.1
</pre><p>Here are my questions:</p><ol><li>Are we going for the best total sum of distances?</li><li>From here, how are we able to determine that 4 is indeed the correct?</li></ol>cgohttps://www.mathworks.com/matlabcentral/profile/authors/5852688-cgotag:www.mathworks.com,2005:Question/4153922018-08-19T06:20:43Z2018-08-19T15:15:32Zreading excel files with texts in matlab<p>I have an excel file with fields that are texts that I want to read.</p><p>X = xlsread('filename') reads the numbers, but does not read the texts. How to solve this problem?</p>cgohttps://www.mathworks.com/matlabcentral/profile/authors/5852688-cgotag:www.mathworks.com,2005:Question/4154112018-08-19T15:09:28Z2018-08-19T15:09:28ZHow to classify new data according to pre-made K-means clusters<p>Hi, I am new to machine learning. What I want to do is explained below. Can anyone please point me in the right direction?</p><p>1. Use Data to form two clusters using K-means</p><p>2. Generate random data and find out which cluster it belongs to out of the two.</p><p>Many thanks in adnvance</p>Mahd Khalidhttps://www.mathworks.com/matlabcentral/profile/authors/8951078-mahd-khalidtag:www.mathworks.com,2005:Question/4154102018-08-19T15:08:48Z2018-08-19T15:08:48Zobtain 300 values from 840 values<p>Hello everybody,</p><p>I have one column S with 840 values. I would like to ultimately obtain 300 values because I would like to do a correlation analysis with another column containing 300 values. What would be the formula to use to do that? Could I do an average from several values, and how could I write that?</p><p>Thank you!</p>Anastasiahttps://www.mathworks.com/matlabcentral/profile/authors/5240162-anastasiatag:www.mathworks.com,2005:Question/4154062018-08-19T13:32:24Z2018-08-19T15:07:21Zis there any ready automatic code for Semantic Segmentation?<p>hi all
I need ready automatic code for Semantic Segmentation. I mean that Is there any package code for this?
thanks</p>sarahttps://www.mathworks.com/matlabcentral/profile/authors/5590407-saratag:www.mathworks.com,2005:Question/4153952018-08-19T08:40:07Z2018-08-19T15:05:44Zk-NN classification for numeric and text data<p>I have a dataset 400*10 size, the first 9 columns are numeric data of tests and the last one is a name for the 9 tests, I want to use k-NN classification and get the accuracy of the k-NN algorithm.
previously I were using "knnclassify" function, but now it is replaced from matlab with "fitcknn" and I don't know how to use it for my dataset.</p>wisam qadirhttps://www.mathworks.com/matlabcentral/profile/authors/9887729-wisam-qadirtag:www.mathworks.com,2005:Question/3464912017-06-27T18:47:17Z2018-08-19T15:05:17ZUse of sendmail function to send an email from a gmail account<p>I am trying to send an email, using the MATLAB sendmail function. I have been following the instructions of the sendmail function analysis in Mathworks on this link: https://uk.mathworks.com/help/matlab/import_export/sending-email.html</p><p>The code which I used on the command window is the following:</p><pre class="language-matlab">setpref ('Internet','E_mail','myemailaddress@gmail.com');
setpref ('Internet','SMTP_Server','smtp.gmail.com') ;
setpref('Internet',SMTP_Username','myusername');
setpref('Internet','SMTP_Password','mypassword') ;
sendmail('emailofreceiver@gmail.com','texttobesent') ;
</pre><p>The message that I am getting after running those commands is the following:</p><p>Error using sendmail (line 169)
530 5.7.0 Must issue a STARTTLS command first. i67sm1310611wri.61 -
gsmtp</p><p>From what I understand, I must change the arguments inside one of the setpref functions that I call, though I am not sure what exactly to include in them. Any help would be very much appreciated! Thank you in advance!</p>ZACHARIAS KOUNTOUPIShttps://www.mathworks.com/matlabcentral/profile/authors/10466922-zacharias-kountoupistag:www.mathworks.com,2005:Question/4154092018-08-19T15:03:43Z2018-08-19T15:03:43ZHow to get a inverse laplace of a tf?<p>Hello, I need to find the inverse laplace of a generic tf.
How could I do It in an easy way?</p><pre class="language-matlab">close all
clc
</pre><pre class="language-matlab">num = input('Insira o Polinomio do Numerador: ');
[3 7] % for example
den = input('Insira o Polinomio do Denominador: ');
[1 2 5] % for example
</pre><pre class="language-matlab">%function [z,p] = (num,den)
</pre><pre class="language-matlab">z= roots(num)
p= roots(den)
</pre><pre class="language-matlab">FT = tf(num,den)
h = zpk(num,den,1)
</pre><p>How Can I use the ilaplace function now?
thanks</p>Bruno Souzahttps://www.mathworks.com/matlabcentral/profile/authors/11799514-bruno-souzatag:www.mathworks.com,2005:Question/896652013-10-09T12:02:54Z2018-08-19T15:02:32ZGenerating an Array of Hexagonal Shape Pattern<p>Hi,</p><p>Here I have added a simple code, modifying my previous post (sorry for my repost, as I am trying to make my question much more understandable). The following code generates an array of values (i.e. H matrix here) having a dimension of 256x256 which is a square matrix (pattern looks like some black and white strips). I would like to modify this square matrix into a regular hexagonal shape through Matlab code. I have no idea how to do this,so can anyone plese help me in this regard?</p><p>Code:</p><pre class="language-matlab">mx=5;
my=10;
[x, y]=meshgrid(-1:2/255:+1, -1:2/255:+1);
H=(cos((x*pi*mx)+(y*pi*my)))>0;
</pre><pre class="language-matlab">figure(1)
imagesc(H); colormap gray; axis image; axis off
</pre>Pranjal Pathakhttps://www.mathworks.com/matlabcentral/profile/authors/3249268-pranjal-pathaktag:www.mathworks.com,2005:Question/4154082018-08-19T14:55:02Z2018-08-19T15:00:17ZTHETA1 must return a column vector.<p>In solving ode45 function, this error was appeared :</p><pre class="language-matlab">>> Error using odearguments (line 93)
>>THETA1 must return a column vector.
>>Error in ode45 (line 115)
>> odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
>>Error in Untitled2 (line 2)
>> [m, theta_int(0,:)]=ode45('theta1' ,0:.1:1,0);
</pre><p>as the function b=((w_theta./r).*((dr_m.*dz_s-dz_m.*dr_s)./(w_r.*dz_s-w_z.*dr_s))) is the equation demanded to solve with span 0:1</p>muhamed badawihttps://www.mathworks.com/matlabcentral/profile/authors/12527149-muhamed-badawitag:www.mathworks.com,2005:Question/4154022018-08-19T11:40:58Z2018-08-19T14:58:56Zextracting numbers from a cell<pre class="language-matlab">SP={{{1,4,5,6},{2},{3}}}
SP =
1×1 cell array
{1×3 cell}
d=SP{1}
d =
1×3 cell array
{1×4 cell} {1×1 cell} {1×1 cell}
d{1}
ans =
1×4 cell array
{[1]} {[4]} {[5]} {[6]}
</pre><p>I want d{1} to be</p><pre class="language-matlab">1 4 5 6
</pre><p>to be able to use these as indices of a matrix.</p>asim nadeemhttps://www.mathworks.com/matlabcentral/profile/authors/327004-asim-nadeemtag:www.mathworks.com,2005:Question/4153982018-08-19T09:55:08Z2018-08-19T14:54:30ZSemipositive definite matrix for quadratic term has a convex quadratic fucntion<p>Hello,
I am now using CPLEX to optimise a quadratic cost fucntion. In CPLEX documentation it is said that if the quadratic matrix Q is semipositive definite, then the function is convex, in the case that the cost function is written in f=x'Qx+f'x. However, I tried an example with two variables, the Q=[0 0;1 2], which is semipositive definite,i.e. with one 0 eigenvalue and one 2 eigenvalue; In matlab, I plot the the function f, which you could see in the attachment. You could see there are two minimum, highlighted in filled points. And from my point of view, this is not convex. What is the difference when Q is semipositive definite and Q is positive definite. If Q is positive definite, this is clear, only one minimum. If Q is semipositive definite, does it mean that there are several minimums? That would be great that someone could shed some lights.</p>Jingjie Jianghttps://www.mathworks.com/matlabcentral/profile/authors/8090179-jingjie-jiangtag:www.mathworks.com,2005:Question/4154002018-08-19T10:12:43Z2018-08-19T14:46:32ZEEGLAB - Edit event type with for loop<p>I will try to be the most precise and clear possible.</p><p>I am currently analyzing EEG data, using Matlab and EEGLAB. Here is a brief description of the experiment design: I showed sentences (word-by-word, five words for one sentence) to participants, with four conditions. For each word that appeared on the screen, a code was sent to the data acquisition system, so that I can epoch them afterwards. I give an example here of the codes that have been sent, for the four conditions:</p><ul><li>Condition 1 - 1 21 31 41 51</li><li>Condition 2 - 1 22 32 42 52</li><li>Condition 3 - 1 22 33 43 53</li><li>Condition 4 - 1 21 34 44 54</li></ul><p>I won't analyze the first word. But I realized that for the second word, I can't analyze according to the four conditions, since I haven't specified enough... (I'll know for the next time!)</p><p>What I would like to obtain is:</p><ul><li>Condition 1 - 1 21 31 41 51</li><li>Condition 2 - 1 22 32 42 52</li><li>Condition 3 - 1 23 33 43 53</li><li>Condition 4 - 1 24 34 44 54</li></ul><p>Simply said: "If the coding is 22 and the one after is 33, then change 22 to 23" and "If the coding is 21 and the one after is 34, then change 21 to 24".</p><p>With EEGLAB, I could do it manually, by going into the Workspace variable "ALLEEG", then going to "ALLEEG.event", where I obtain this:</p><img src = "/matlabcentral/answers/uploaded_files/129430/matlab_ALLEEG_event.JPG"><p>But If I had to do it manually, it's like 700 event codes to check, for more than 30 participants...</p><p>I have the impression that this could be done easilly with for loop and if condition. But here I'm blocked with two problems. The first one is that I am not familiar with Matlab (but with R, so it must be similar I guess), the second one is that I don't see how to write the loop!</p><p>Do you have any idea on how I could do it? Thanks in advance!</p>COLLART Aymerichttps://www.mathworks.com/matlabcentral/profile/authors/8585157-collart-aymerictag:www.mathworks.com,2005:Question/4153632018-08-18T12:15:21Z2018-08-19T14:29:04Zwhat are the reasons for error occured in matlab while loading the system in psat?<pre class="language-matlab">Error using load
Unable to read MAT-file C:\Program
Files\MATLAB\R2013a\toolbox\psat\tests\d_009.mdl: not a binary MAT-file.
Try LOAD -ASCII to read as text.
</pre><pre class="language-matlab">Error in fm_set (line 348)
load([pathname,file],'-mat')
</pre><pre class="language-matlab">Error while evaluating uicontrol Callback
</pre><pre class="language-matlab">Simulink Model Conversion
Simulink File <d_009.mdl>.
Loading Simulink Model
* * *
Check model version and blocks ...
* * All blocks belong to the PSAT-Simulink Library.
* * *
Statistics ...
Connections: #9#
Power Flow Components: #15#
Machines: #3#
Controls: #3#
* * *
Definition of component data ...
Data "Exc.con"
Data "Bus.con"
Data "Syn.con"
Data "Line.con"
Data "PQ.con"
Data "PV.con"
Data "SW.con"
Data "Line.con"
* * *
Definition of system connections ...
* * *
Writing Data File
Construction of Data File <d_009_mdl.m> completed.
Data file "C:\Program Files\MATLAB\R2013a\toolbox\psat\tests\d_009(mdl)" set
</pre><pre class="language-matlab">Newton-Raphson Method for Power Flow Computation
Data file "C:\Program Files\MATLAB\R2013a\toolbox\psat\tests\d_009(mdl)"
Writing file "fm_call" ...
Error using fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.
</pre><pre class="language-matlab">Error in fm_wcall (line 49)
count = fprintf(fid,'function fm_call(flag)\n\n');
</pre><pre class="language-matlab">Error in fm_spf (line 41)
fm_wcall;
</pre><pre class="language-matlab">Error in fm_set (line 720)
fm_spf
</pre><pre class="language-matlab">Error while evaluating uicontrol Callback
</pre><pre class="language-matlab">Solve base case power flow...
</pre><pre class="language-matlab">Newton-Raphson Method for Power Flow Computation
Error using fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.
</pre><pre class="language-matlab">Error in fm_wcall (line 49)
count = fprintf(fid,'function fm_call(flag)\n\n');
</pre><pre class="language-matlab">Error in fm_spf (line 41)
fm_wcall;
</pre><pre class="language-matlab">Error in fm_set (line 720)
fm_spf
</pre><pre class="language-matlab">Error in fm_threed (line 27)
fm_set('lf')
</pre><pre class="language-matlab">Error while evaluating uicontrol Callback
</pre><pre class="language-matlab">Index exceeds matrix dimensions.
</pre><pre class="language-matlab">Error using uicontrol
Error while evaluating uicontrol CreateFcn
</pre><pre class="language-matlab">Plotting Utilities: No data available for plotting.
Index exceeds matrix dimensions.
</pre><pre class="language-matlab">Error using uicontrol
Error while evaluating uicontrol CreateFcn
</pre><pre class="language-matlab">Plotting Utilities: No data available for plotting.
</pre>dhruvi patelhttps://www.mathworks.com/matlabcentral/profile/authors/5241189-dhruvi-pateltag:www.mathworks.com,2005:Question/4152672018-08-17T13:37:47Z2018-08-19T14:19:39ZHow to optimise five equations and four unknowns?<p>Hi, I am looking to find the optimal power output for four generators given the equations and conditions:</p><p>0.31246x1 + 0.15x2 + 0.15x3 + 0.15x4 = 46,</p><p>0.15x1 + 0.3x2 + 0.15x3 + 0.15x4 = 40,</p><p>0.15x1 + 0.15x2 + 0.3x3 + 0.15x4 = 55,</p><p>0.15x1 + 0.15x2 + 0.15x3 + 0.3x4 = 50.5,</p><p>x1+x2+x3+x4=200</p><p>25<=x1<=100</p><p>5.5<=x2<=30</p><p>20<=x3<=130</p><p>25.5<=x4<=160</p><p>To maximise x1, x2, x3 and x4.</p><p>Please help.</p>Sophie Caihttps://www.mathworks.com/matlabcentral/profile/authors/12969018-sophie-caitag:www.mathworks.com,2005:Question/207082011-11-09T01:52:45Z2018-08-19T14:17:08ZWriting Code for Pattern Recognition<p>Hies.</p><p>I am Tallha. I need a guideline to write a code for Pattern Recognition problems. All the stuff in the books are Mathematical Equations and i will not get good idea until i simulate them.Can anyone suggest me or refer me some website or tips or some books which i have to use . I prefer to work in Matlab.</p><p>Regards</p>Tallha Akramhttps://www.mathworks.com/matlabcentral/profile/authors/1419703-tallha-akramtag:www.mathworks.com,2005:Question/492262012-09-27T11:14:53Z2018-08-19T14:14:13ZHOW TO APPLY A MEAN FILTER FOR 3x3<p>I NEED TO APPLY THE 3x3 MEAN FILTER TO THE GRAY SCALE IMAGE. PLS SEND ME THE CODE FOR THAT</p>ajithhttps://www.mathworks.com/matlabcentral/profile/authors/3663085-ajithtag:www.mathworks.com,2005:Question/4154052018-08-19T12:31:00Z2018-08-19T13:57:10ZHow to plot Average of several plots( combined using copyobj) ?<p>Hi Everyone,
I have data sets of multiple subjects, and i plotted the desired output of each subject in separate plots. Then i wanted to compare them and plot in one figure, so i am using 'Copyobj' for that. It does the job.
Now i want to plot the 'Average' of all the subject's output plots.
Is it possible to do this when i have combined the separate plots (output of separate programs)?</p><p>Thanks</p>Nainahttps://www.mathworks.com/matlabcentral/profile/authors/12208106-nainatag:www.mathworks.com,2005:Question/4153962018-08-19T08:58:06Z2018-08-19T13:29:33ZHow can I save an axes which has multiple coordinate systems?<p>I have an UI which contains an axes with two Yaxes. I used the yyaxes command.
How can I save the axes to png or an other data format?
The problem is that when I save the whole figure, it will contain also parts of the UI Objects. The panels for example.
Instead I want to save just the axes. The advice I found, was to copy the axes to a new figure and save it there. Sadly, copyobj is not working with axes with multiple coordinate systems.
Can you help me?</p>vglocohttps://www.mathworks.com/matlabcentral/profile/authors/4721900-vglocotag:www.mathworks.com,2005:Question/4145232018-08-11T23:45:10Z2018-08-19T13:23:48ZHow can I use indexed image in neural network ?<p>I have converted RGB images into indexed images using function <i>rgb2ind</i> then I made their matrix and load it using the code</p><pre class="language-matlab">fprintf('Loading and Visualizing Data ...\n')
</pre><pre class="language-matlab">load('ClothingData.mat');
m = size(X, 1);
[sel] = randperm(size(X, 1)); % Randomly select 100 data points to display
sel = sel(1:100);
</pre><pre class="language-matlab">displayData(X(sel, :));
</pre><p>but it is throwing this error message</p><pre class="language-matlab">Warning: Size vector should be a
row vector with integer elements.
> In displayData at 30
In ex4 at 50
Error using reshape
Size arguments must be real
integers.
</pre><p>Please tell me how to fix this error, also can I use indexed images for neural network classification or not</p>jawad ashrafhttps://www.mathworks.com/matlabcentral/profile/authors/12894689-jawad-ashraftag:www.mathworks.com,2005:Question/506602012-10-12T19:46:30Z2018-08-19T13:16:08ZWhy is R2012a Matlab so very, very slow at starting up?<p>Matlab R2012a is really, really slow in starting up.</p><p>Brand new Dell Latitude E6230, Windows 7, Matlab R2012a with 32 bit and 64 bit versions. Psychtoolbox also installed, plus 15 Matlab toolboxes. Matlab takes several minutes to open, just sitting there saying "initialising". I ran it with "matlab -timing" and got the following:</p><pre class="language-matlab">Opening timing log C:\Users\PaLS\AppData\Local\Temp\timing_log.3840 ..
Toolbox Path Cache read in 0.01 seconds.
MATLAB Path initialized in 0.14 seconds.
MATLAB Startup Performance Metrics (In Seconds)
</pre><pre class="language-matlab">total item gap description
=====================================
0.00 0.00 0.00 MATLAB script
0.50 0.50 0.00 main
0.53 0.02 0.01 LM Startup
0.54 0.00 0.00 splash
0.74 0.13 0.07 InitSunVM
1.20 0.44 0.02 PostVMInit
1.20 0.59 0.07 mljInit
11.64 10.45 0.00 StartDesktop
11.64 11.04 0.07 Java initialization
11.66 0.02 0.00 hgInitialize
11.67 0.00 0.01 psParser
11.72 0.01 0.05 cachepath
11.94 0.13 0.09 matlabpath
13.70 2.06 11.65 Init Desktop
122.30 0.00 110.36 SettingsConstructo
122.32 110.59 0.00 matlabrc
=====================================
Items shown account for 101.6% of total startup time [TIMER: 2 MHz]
</pre><p>What is eating up the 110 seconds at the end (?SettingsConstructo).</p><p>For comparison, my old Latitude E4200, Win XP, Matlab R2010a, disk full to the gunwhales, starts in 8 seconds (and I thought the new one would be faster...).</p><p>Any help gratefully received.</p><p>Thanks! Chris</p>Chris McManushttps://www.mathworks.com/matlabcentral/profile/authors/224085-chris-mcmanustag:www.mathworks.com,2005:Question/4153812018-08-18T19:38:23Z2018-08-19T13:02:50ZSolving non-linear equations (0)<p>Dear all,</p><p>I solved non-linear equations using Matlab, but all values are close to 0.</p><p>I think this solution is not incorrect, and I would like to know my coding is correct or not.</p><p>In addition, I would like to get the value of Me1. Please let me know how to get this value.</p><p>Thank you very much in advance.</p><p>Sincerely yours,</p><p>J1</p><pre class="language-matlab">function F = costate2(x)
</pre><pre class="language-matlab">t = 0;
tlast = 30;
phi = 3.14;
</pre><pre class="language-matlab">ep = 0.1;
L1 = 157.5;
L2 = 799.5;
GHGs = 2954;
</pre><pre class="language-matlab">delta1 = 0.005;
gam1 = 0.10957;
eta11 = 0.40022;
eta21 = 0.99931;
</pre><pre class="language-matlab">ag1 = 20.49921;
</pre><pre class="language-matlab">alpha1 = 15.93413;
rhoq1 = 0.00710;
beta11 = 0.35;
beta21 = 0.63;
beta31 = 0.02;
</pre><pre class="language-matlab">g1 = 2.6005;
chi1 = 0.01;
xi1 = 0.02;
rhom1 = 0.0041773;
</pre><pre class="language-matlab">delta2 = 0.00581;
gam2 = 0.14990;
eta12 = 0.08;
eta22 = 0.59998;
</pre><pre class="language-matlab">ag2 = 21.49967;
</pre><pre class="language-matlab">alpha2 = 3.25702;
rhoq2 = 0.005;
beta12 = 0.60;
beta22 = 0.38;
beta32 = 0.02;
</pre><pre class="language-matlab">g2 = 2.8643;
chi2 = 0.01;
xi2 = 0.02;
rhom2 = -0.00800;
d = 0.05;
psi = 0.1;
</pre><pre class="language-matlab">K1 = 3486;
K2 = 1951;
Kg1 = 3.49;
Kg2 = 1.95;
Pw = 0.1;
Pg = 0.05;
GHG = 3162;
Q1 = 1496;
Q2 = 604;
E1 = 2216;
E2 = 2417;
</pre><pre class="language-matlab">a1 = 0.1;
a2 = 0.5;
b1 = 0.5;
b2 = 0.5;
</pre><pre class="language-matlab">Gbar = 12000;
P1 = 309;
P2 = 1338;
</pre><pre class="language-matlab">gam3 = 0.0492288;
gam4 = 0.0243931;
d1 = 1.2521405;
delta3 = 0.0250461;
</pre><pre class="language-matlab">lamda1 = x(1);
qg1 = x(2);
qp1 = x(3);
qe1 = x(4);
qc1 = x(5);
qk1 = x(6);
</pre><pre class="language-matlab">Gbar1 = (P1/(P1+P2))*Gbar;
Gbar2 = (P2/(P1+P2))*Gbar;
M1 = (g1*exp(-rhom1*t)-chi1*(Kg1/(K1+Kg1))^xi1)*E1;
W1 = (Pw-E1-Pg*(P1./(P1+P2))*Gbar)^2+4*beta31*Pw*Q1*M1*Pg;
J1 = (Pg*(P1./(P1+P2))*Gbar-Pw*E1)^2+4*beta31*Pw*Q1*M1*Pg;
Pe1 = ((Pw*E1-Pg*Gbar1) + sqrt(W1))/(2*E1);
Me1 = ((Pg*(P1./(P1+P2))*Gbar-Pw*E1)+sqrt(J1))/(2*Pg);
Me2 = (g2*exp(-rhom2*t)-chi2*(Kg2./(K2+Kg2))^xi2)*beta32*Q2;
Y1 = E1^2*Pe1^2+beta31*Pw*Q1*M1*Pg;
QQe1 = alpha1*exp(rhoq1*t)*(K1+Kg1)^beta11*L1^beta21*E1^beta31;
Op = Me1 - (P1./(P1+P2))*Gbar;
PP = P1*P2;
</pre><pre class="language-matlab">F(1) = x(1)*( phi/(2*tlast) )
-x(3)*( psi*(P1+P2)*Pg/(sqrt(PP)*Gbar) )*( (chi1*xi1*beta31*Pw*Q1*E1^2*Pe1*Kg1^xi1)/(Y1*(K1+Kg1)^(xi1+1)) )
-x(4)*chi1*xi1*E1*(Kg1^xi1)/(K1+Kg1)^(xi1+1)
-x(5)*a1*beta11*QQe1/(K1+Kg1)
-x(6)*b1*(beta31*Pw*Q1*Pg/(E1*Pe1^2))*( (chi1*xi1*beta31*Pw*Q1*E1^2*Pe1*Kg1^xi1)/(Y1*(K1+Kg1)^(xi1+1)) );
</pre><pre class="language-matlab">F(2) = x(2)*( phi/(2*tlast) + 1/ag1 )
-x(2).^2/(x(1)*2*ag1)
-x(1)*( 1/(2*ag1) - Pg*( (chi1*xi1*beta31*Pw*Q1*E1^2*Pe1*Kg1^xi1)*(1/(K1+Kg1)-1/Kg1)/(Y1*(K1+Kg1)^xi1) ) )
-x(3)*psi*(P1+P2)*Pg*(1/(sqrt(PP)*Gbar))* ( (chi1*xi1*beta31*Pw*Q1*E1^2*Pe1*Kg1^xi1)*(1/(K1+Kg1)-1/Kg1)/(Y1*(K1+Kg1)^xi1) )
-x(4)*chi1*xi1*E1*((Kg1/(K1+Kg1))^xi1)*(1/(K1+Kg1)-1/Kg1)
-x(5)*a1*beta11*QQe1/(K1+Kg1)
+x(6)*b1*beta31*Pw*Q1*Pg*(1/(E1*Pe1^2))*( (chi1*xi1*beta31*Pw*Q1*E1^2*Pe1*Kg1^xi1)*(1/(K1+Kg1)-1/Kg1)/(Y1*(K1+Kg1)^xi1) )
;
</pre><pre class="language-matlab">F(3) = x(3)*( phi/(2*tlast) )
+x(1)*( (Me1-Gbar1) - Pg*beta31*Pw*Q1*M1*(Me1-Gbar1)/Y1 )
+x(6)*b1*beta31*Pw*Q1*M1*(Me1-Gbar1)/Y1;
</pre><pre class="language-matlab">F(4) = x(4)*( phi/(2*tlast) )
+x(1).^((eta11*gam1+gam1)/(eta11*gam1+gam1-1)) * eta21*(ep/eta11)^(eta11*gam1/(eta11+gam1-1)) * GHGs^(-eta21*gam1/(eta11*gam1+gam1-1)) * GHG^(((eta21-eta11)*gam1-gam1+1)/(eta11*gam1+gam1-1));
</pre><pre class="language-matlab">F(5) = x(5)*( phi/(2*tlast) )
-x(1)*(1-Pg*beta31*Pw+M1*E1*Pe1/Y1)
-x(3)*psi*(P1+P2)*Pg*(1/(sqrt(PP)*Gbar))*beta31*Pw+M1*E1*Pe1/Y1
-x(6)*b1*beta31*Pw+M1*E1*Pe1/Y1;
</pre><pre class="language-matlab">F(6) = x(6)*( phi/(2*tlast) )
+x(1)*Pg*M1*(1/E1)*beta31*Pw*Q1*Pg*(Me1-Gbar1)/Y1
-x(3)*psi*(P1+P2)*Pg*(1/(sqrt(PP)*Gbar))*M1*(1/E1)*beta31*Pw*Q1*Pg*(Me1-Gbar1)/Y1
-x(4)*M1/E1
-x(5)*a1*beta31*QQe1/E1;
</pre><pre class="language-matlab">fun = @costate2;
x0 = [1,1,1,1,1,1];
x = fsolve(fun,x0)
</pre>Redwoodhttps://www.mathworks.com/matlabcentral/profile/authors/4232596-redwoodtag:www.mathworks.com,2005:Question/4154042018-08-19T12:26:34Z2018-08-19T12:27:03ZChange Loss Function in vgg16<p>Hey guys, I’m using vgg16 net to perform semantic segmentation on 2D images.</p><p>Is there a way I can fine-tine this network (vgg16) and change the loss function? An example would be great.</p><p>Thanks,
David</p>David Spearshttps://www.mathworks.com/matlabcentral/profile/authors/7141188-david-spearstag:www.mathworks.com,2005:Question/4153872018-08-19T00:08:31Z2018-08-19T12:21:13ZHOW I plotted the x1 and x2 and u in optimal control poblem? <pre class="language-matlab">% IN THE NAME OF GOD
% HAMED GHAFFARI
% page 198 - 202
% Book : Kirk
% exp 5.1-1
</pre><pre class="language-matlab">clc
clear
</pre><pre class="language-matlab">% state equation
syms x1 x2 u p1 p2 ;
DX1 = x2 ;
DX2 = -x2 + u ;
</pre><pre class="language-matlab">% cost function inside the integral
syms j
j = 1/2 * u^2 ;
</pre><pre class="language-matlab">% Hamiltonian
syms p1 p2 H
H = j + p1*DX1 +p2*DX2 ;
</pre><pre class="language-matlab">% costate equations
DP1 = -diff(H,x1)
DP2 = -diff(H,x2)
</pre><pre class="language-matlab">% solve for u control
du = diff(H,u)
sol_u = solve(du,u)
</pre><pre class="language-matlab">% substitute u to state eq DX2
DX2 = subs(DX2 , u , sol_u)
</pre><pre class="language-matlab">% Cocatenate String horizontal (الحاق کردن عبارات به صورت رشته ای)
% convert symbolic adjective to string for using 'dsolve'
eq1 = strcat('DX1 = ' , char(DX1))
eq2 = strcat('DX2 = ' , char(DX2))
eq3 = strcat('DP1 = ' , char(DP1))
eq4 = strcat('DP2 = ' , char(DP2))
% solve Hamiltonian
sol_h = dsolve(eq1,eq2,eq3,eq4)
sol_Dx1 = sol_h.X2
sol_Dx2 = sol_h.X1
sol_DP1 = sol_h.P1
sol_DP2 = sol_h.P2
</pre><pre class="language-matlab">% case Boundry condition x1(0) = x2(0) = 0 ; x1(2) = 5 , x2(2) = 2
cond1 = 'X1(0)= 0' ;
cond2 = 'X2(0)= 0' ;
cond3 = 'X1(2)= 5' ;
cond4 = 'X2(2)= 2' ;
</pre><pre class="language-matlab">sol_Hnew = dsolve(eq1,eq2,eq3,eq4,cond1,cond2,cond3,cond4)
sol_eq1 = sol_Hnew.X1
sol_eq2 = sol_Hnew.X2
sol_eq3 = sol_Hnew.P1
sol_eq4 = sol_Hnew.P2
</pre>Hamed Ghaffarihttps://www.mathworks.com/matlabcentral/profile/authors/10343509-hamed-ghaffaritag:www.mathworks.com,2005:Question/4152412018-08-17T10:24:46Z2018-08-19T12:11:41ZPlease how can I store values of variable size vectors inside a loop for<p>image processing</p>Mohamed ouahidihttps://www.mathworks.com/matlabcentral/profile/authors/13310637-mohamed-ouahiditag:www.mathworks.com,2005:Question/4154032018-08-19T12:09:39Z2018-08-19T12:09:39ZHow can I use Xcode9.4 as my C or C++ compiler in Matlab R2017b?<p>To use Xcode 9.4 as my C++ compiler in Matlab R2017b, I made the same changes to all the .xml files in "mexopts" (shown in the following picture).These changes are aimed to let the Matlab R2017b be used in Mac OS X 10.13.</p><img src = "/matlabcentral/answers/uploaded_files/129424/matlab%20.png"><p>I also downloaded the command line tool.</p><p>But I still can't use mex in Matlab to use Xcode9.4 as my C++ compiler.</p><p>Should I also download some patches like solutions in previous similar questions?</p><p>Or should I revise my changes in the .xml files?</p><p>Or should I just re-install the Matlab R2017b?</p><p>Please help me. Thank you!!</p>Anan Xiehttps://www.mathworks.com/matlabcentral/profile/authors/13318577-anan-xietag:www.mathworks.com,2005:Question/3578522017-09-22T06:15:08Z2018-08-19T11:45:47ZHow can I make MATLAB open .m files on the same window that is currently open (open as a new tab next to the current tab)?<p>I recently received a computer from our department and tried to open .m files. (R2017a)
Whenever I double-clicked them, they opened in new windows. But these new windows do not include the new .m files that I tried to open; they still had the old tabs that were open already.
I also tried to drag and drop .m files to MATLAB window that was open and it didn't let me open them, showing me a circle mouse icon with a cross in it.
My labtop has the same version of MATLAB (R2017a) and the things I mentioned above do not happen at all.
Can anybody help me with this issue?</p>SOO BUM BAEhttps://www.mathworks.com/matlabcentral/profile/authors/8921348-soo-bum-baetag:www.mathworks.com,2005:Question/4153532018-08-18T08:42:29Z2018-08-19T11:40:35ZSkip big header from a txt file<p>I would like to extract the data only from a text file. the text file has a header (the first 11 lines) which contains some numerical values as shown below, also the data is separated in three columns, one of these columns, has numerical values, but also the written characters: "No Data".
I also would like to change that "No Data" for the numerical value 0</p><pre class="language-matlab">1 9 1 6 "Thu Feb 13 13:12:30 2014 "
0 0 0 0 0 0
38 38 915 915
"CJE "
"2 "
"110321-025-01D-1ST
0 0 1 .1 73.7972 17 50
1 0 7 1 60 0 0 0 0
0 " "
1 0
#
38 38 No Data
39 38 No Data
40 38 No Data
41 38 3
42 38 No Data
43 38 4
44 38 4
45 38 5
</pre>Luis Paniaguahttps://www.mathworks.com/matlabcentral/profile/authors/13314752-luis-paniaguatag:www.mathworks.com,2005:Question/3796102018-01-29T17:36:19Z2018-08-19T10:38:29Zdo real time simulation and xPC work on x64 os?<p>I use model predictive control, which available in newer versions. I intend to run it as a real-time simulation on host pc as xPC Target, but as I read in the guide it only works on x32 OS.
so could anyone helps me and tells me how to run it on x64 os or how to make newer version run on x32 os.
Thanks</p>Mina Andrawshttps://www.mathworks.com/matlabcentral/profile/authors/11723395-mina-andrawstag:www.mathworks.com,2005:Question/3986482018-05-02T13:19:10Z2018-08-19T10:36:50ZSimulink Real-Time: boot in UEFI mode<p>Hi,</p><p>I am trying to start a target computer with Simulink Real-Time kernel.
This computer only supports the boot in UEFI mode.</p><p>Since DOS assumes a BIOS and does not work with UEFI, is there a solution for using "DOS Loader Boot Method" or "Standalone Boot Method" with my computer?</p>Simone Marcheschihttps://www.mathworks.com/matlabcentral/profile/authors/10672392-simone-marcheschitag:www.mathworks.com,2005:Question/4154012018-08-19T10:32:31Z2018-08-19T10:34:16ZPin toggle frequency in Simulink Real Time<p>For a project I need to simulate a Hall-Effect sensor. A Hall-effect sensor generates a block pulse with fixed amplitude and variable frequency. For this project, I need to achieve an accurate frequency signal with a maximum of 7.5 kHz.</p><p>I use Simulink Real time to gerenate the digital signal, with a MCDAQ Dio 24 Digital output.I measure the output frequency with a scope to my laptop. I am using a very high end TargetPC (i7 CPU, 16GB DDR3 etc.)</p><p>I have multiple models that can generate such a signal. However, I am running into problems with signal accuracy.
https://nl.mathworks.com/matlabcentral/fileexchange/35922-programmable-pulse-generator-using-simulink-s-basic-blocks</p><p>When running this model, I get the desired signal frequency, but the signal is oscillating around the input frequency. For example: Desired is 6 kHz, output is 5.8 kHz to 6.2 kHz. Average is good, but the fluctuating signal frequency is visible on the datalogger during testing. In the real world, no fluctuation occurs.</p><p>Furthermore, using this models to generate a pulse signal requires extreme sampling times of 0.0001 [s].</p><p>Having done a project like this with different hardware in the past, I have once succesfully generated extremely high frequency block pulses on a Olimexino STM32 using interrupts to generate this signal. This was all done with a custom simulink library.</p><p>It seems to be really hard for the hardware to generate a block signal by model calculation. There must be a simpler method.</p><p>What I really want:
Is there a way in Simulink Real Time to toggle a digital output state with a certain input frequency? In simple words: Can I just tell a digital output: 'toggle with 7.5 kHz now, and now with 7.4 kHz etc.?</p><p>Any help is greatly appreciated.</p><p>Kind regards, Peter</p>Peter Schoutenhttps://www.mathworks.com/matlabcentral/profile/authors/8687551-peter-schoutentag:www.mathworks.com,2005:Question/4153912018-08-19T05:46:45Z2018-08-19T10:25:08ZINDEX EXCEEDS MATRIX DIMENSION ERROR WHILE RUNNING EXAMPLE<p>Hi,</p><p>I am getting the error " Index exceeds martix dimension" while running an example given below.</p><p>"openExample('simulink/ConfigurePrelookupBlockToOutputIndexAndFractionAsABusExample')"</p><p>can anybody please tell me what is the possible problem and how it can be resolved.</p><p>Regards</p>BILAL ASADhttps://www.mathworks.com/matlabcentral/profile/authors/3139385-bilal-asadtag:www.mathworks.com,2005:Question/4153942018-08-19T08:01:14Z2018-08-19T10:21:32ZConnecting Matlab Mobile with my computer ?<p>I am trying to connect to MATLAB Mobile on my iPad. When I type <i>Connector on</i> command on my MATLAB R2018a window I get the following error " <b>Error in Connector: Did not start the server. Desired port was: 31415. Last error was: Server did not respond to initial request: 192.168.0.196:31614</b>"</p>Abdulla Alsowaidihttps://www.mathworks.com/matlabcentral/profile/authors/13276110-abdulla-alsowaiditag:www.mathworks.com,2005:Question/3843122018-02-22T22:58:06Z2018-08-19T10:18:11ZHexagonal Pattern Generator with 1/6th Symmetry <p>I am trying to create fuel loading patterns for a hexagon-shaped reactor core. Most of the design work is trial and error and I would like to see if I can use MATLAB to generate random patterns for possible core designs. The picture below illustrates what I am working with:</p><img src = "/matlabcentral/answers/uploaded_files/105879/Core5.png"><p>I only need a method to make patterns for 1/6th of the core since it is symmetric, though it would be helpful if I can apply the symmetry condition to make the full core. I only need to move around the orange and green cells.</p><p>I've found posts on how to make hexagonal lattices but I haven't found anything on filling in the hexagons or how to generate patterns with two colors. Any direction or suggestions on implementing this would be very helpful.</p>William Murrayhttps://www.mathworks.com/matlabcentral/profile/authors/5856907-william-murraytag:www.mathworks.com,2005:Question/4153992018-08-19T10:10:36Z2018-08-19T10:10:36ZHow can i initial coefficient of filter in genetic algorithm method?<p>I want to optimize a minimax filter by using genetic algorithm method ,</p><p>Code</p><pre class="language-matlab">[b,err,res]=gremez(22,[0 0.4 0.5 1],[1 1 0 0],[1,5]);
h=freqz(b);
</pre><p>In GA method ,must be initialize a set of population ,such population represent a chromosome ,the number of population is 80 and in such chromosome have a set of gene ,in this case the gene is the coefficients of filter <b>h</b>.
How can i initialization a set of population by randomly generated? by random in a coefficients?or by random the populations?</p>Johan Johanhttps://www.mathworks.com/matlabcentral/profile/authors/12590840-johan-johantag:www.mathworks.com,2005:Question/4145022018-08-11T15:58:11Z2018-08-19T09:56:47ZWhen is it needed to incorporate frequency offset correction in lteDLPerfectChannelEstimate?<p>Hey, I have a few questions regarding the use of time and frequency offset in the function lteDLPerfectChannelEstimate.</p><p>My general settings are as follows:</p><pre class="language-matlab">channel.DelayProfile = 'EPA';
channel.DopplerFreq = 0;
channel.InitTime = 0;
[rxwave, channel_info] = lteFadingChannel(channel,[txwave;zeros(25,1)]);
TimeOffset = lteDLFrameOffset(enb,rxwave);
FreqOffset = lteFrequencyOffset(enb,rxwave);
</pre><p>1) First thing I don't understand is why when I set zero Doppler and zero delay I'm still getting that the frequency offset "FreqOffset = lteFrequencyOffset(enb,rxwave)" and time offset "TimeOffset = lteDLFrameOffset(enb,rxwave)" are not 0.</p><p>Isn't frequency offset caused only by doppler effects? does the command lteFadingChannel adds additional delay and frequency offsets?</p><p>2) Basically, my main goal is getting the most precise (True) channel response.
I don't understand when should I incorporate the timeoffset and frequency offset.
I think that if Doppler frequency is set to 0 than the channel impulse response should stay constant.
But when I use the command:</p><pre class="language-matlab">[hestIdeal] = lteDLPerfectChannelEstimate(enb,channel,[TimeOffset ,FreqOffset]);
</pre><p>I'm getting that the impulse response changes over the <b>time</b> grid.</p><p>However, when I ignore the frequency offset and use:</p><pre class="language-matlab">[hestIdeal2] = lteDLPerfectChannelEstimate(enb,channel,[Timeoffset,0]);
</pre><p>I'm getting that the channel response is indeed constant over time.</p><p>What am I missing? I couldn't understand whether should I use the frequency offset? why is it not 0 in the first place?
Can anyone please clarify me this issue?
Thanks.</p>Omer Sholevhttps://www.mathworks.com/matlabcentral/profile/authors/8255974-omer-sholevtag:www.mathworks.com,2005:Question/3033692016-09-17T02:44:16Z2018-08-19T09:54:37ZMEX cannot find a supported compiler in MATLAB R2015b after I upgraded to Xcode 8.0<p>I installed Xcode 8.0 on my Mac and tried to use MEX. But I received the following error at the MATLAB command prompt. Please help, thanks.</p><p>>> mex -setup</p><p>Error using mex</p><p>No supported compiler or SDK was found. For options, visit</p><p><a href = "http://www.mathworks.com/support/compilers/R2015b/maci64.html">http://www.mathworks.com/support/compilers/R2015b/maci64.html</a>.</p>Nan Yehttps://www.mathworks.com/matlabcentral/profile/authors/7789073-nan-yetag:www.mathworks.com,2005:Question/1369022014-06-22T01:27:59Z2018-08-19T09:47:30Zhow to create a Hexagonal meshGrid?<p>Hi, I am trying to create a hexagonal meshGrid. I have the vertices (x and y coordinates) from a patch object. The hexagonal grid should contain 37 hexagons. Can anyone help me how to do this?</p>lakshmihttps://www.mathworks.com/matlabcentral/profile/authors/972536-lakshmitag:www.mathworks.com,2005:Question/4153972018-08-19T09:27:12Z2018-08-19T09:27:29ZIs it possible to stop the "snapping" behaviour in MATLAB figures when zooming?<p>In MATLAB figures, if you try to zoom in on a particularly small area, MATLAB "helpfully" snaps the zoom box closed, so that the zoom only occurs on one axis. It looks like this when it happens:</p><img src = "/matlabcentral/answers/uploaded_files/129415/annoyance.png"><p>The result in this case is zooming in on the x-axis, but not on the y-axis. I can safely say that I almost never want this behaviour, but I do quite often want to zoom in on particularly small regions of figures. Is there a way to turn off this "feature"? As far as I can remember, older versions of MATLAB didn't do this (though I don't know for certain when it was introduced).</p>Aaron Hendryhttps://www.mathworks.com/matlabcentral/profile/authors/4393635-aaron-hendrytag:www.mathworks.com,2005:Question/245362011-12-22T04:36:46Z2018-08-19T09:11:28Zplot histogram without using matlab hist() function<p>Hi all</p><p>There is a function called hist(), but if I want to plot a graph without using hist() command, how to plot a graph? I means using command to do the job same as hist().</p><p>Thank you.</p>wshttps://www.mathworks.com/matlabcentral/profile/authors/2694576-wstag:www.mathworks.com,2005:Question/2554762015-11-17T16:27:25Z2018-08-19T08:19:09ZDraw tangent line in step response ?<p>Hi all. I'm designing the PID controller. When I have drawn my step response function. I need to draw a tangent line at the maximum slope point of step response to find T1, T2 for designing PID controller(like the picture). Could you help me to do this ? This is my code and step response result.</p><pre class="language-matlab">if true
clc
num = [0.25 0.10875];
den = [1 2.496 1.7992 0.325383 0.021463];
plant = tf(num,den);
step(plant)
end
clc
num = [0.25 0.10875];
den = [1 2.496 1.7992 0.325383 0.021463];
plant = tf(num,den);
step(plant)
</pre><img src = "/matlabcentral/answers/uploaded_files/40359/Capdture.JPG"><img src = "/matlabcentral/answers/uploaded_files/40360/Captddure.JPG">Nguyen Trong Nhanhttps://www.mathworks.com/matlabcentral/profile/authors/4897936-nguyen-trong-nhantag:www.mathworks.com,2005:Question/4153542018-08-18T09:16:44Z2018-08-19T06:57:39ZKeep specific column variables and delete others?<p>Hi, I have a table with a list of column variables (Eg: [[Var1 Var2 Var3 Var4 VarN].
I am trying to keep only specific variables and associated column data, whilst deleting all others.</p><p>For example, I want only variable 2 and 4, while deleting all other columns.
Desired output --> [Var2 Var4]</p><p>It is possible to output only the desired columns without individually deleting unwanted variables?</p>Tyla Onohttps://www.mathworks.com/matlabcentral/profile/authors/6232804-tyla-onotag:www.mathworks.com,2005:Question/4153782018-08-18T18:09:07Z2018-08-19T06:29:22ZWhat is the best way to show a symbolic matrix in some tool in Guide?<p>Hello my friends.</p><p>I am developing a graphic interface in Guide, where I have to use matrix with variables, in this time I fill the data in a table, after of process I try to shows the final matrix in a listbox but if matrix has integer numbers, matrix is shown but if matrix has variables matlab show the next mistake.</p><p>1.- result with only integer numbers</p><img src = "/matlabcentral/answers/uploaded_files/129400/numeros.jpg"><p>2.- result with some variables</p><img src = "/matlabcentral/answers/uploaded_files/129401/variables.jpg"><p>3.- Matlab show this error</p><img src = "/matlabcentral/answers/uploaded_files/129402/error.jpg"><p>this is my code "Resolver" Button</p><pre class="language-matlab">if true
filas = str2double(get(handles.eslabones,'String'));
filas=filas-1;
F = sym('A', [filas 4]);
B = eye(4);
C = sym('C', [4 4]);
A=0;
A=cell2mat(get(handles.uitable1,'Data'));
med = str2double(get(handles.gradrad,'String'));
if med == 2
for i=1:filas
c1=(A(i,1))
c2=(A(i,2))
c3=(A(i,3))
c4=(A(i,4))
F(i,1)=c1;
F(i,2)=c2;
F(i,3)=c3;
F(i,4)=c4;
C=simplify([cos(F(i,4)) -sin(F(i,4))*cos(F(i,2)) sin(F(i,4))*sin(F(i,2)) F(i,1)*cos(F(i,4));
sin(F(i,4)) cos(F(i,4))*cos(F(i,2)) -cos(F(i,4))*sin(F(i,2)) F(i,1)*sin(F(i,4));
0 sin(F(i,2)) cos(F(i,2)) F(i,3);
0 0 0 1]);
eval(sprintf('A%d = C;',i));
B=B*C;
eval(sprintf('A%d',i))
end
else
for i=1:filas
</pre><pre> c1=(A(i,1))
c2=(A(i,2))
c3=(A(i,3))
c4=(A(i,4))</pre><pre> F(i,1)=c1;
F(i,2)=c2;
aux1=degtorad(F(i,2))
F(i,2)=aux1
F(i,3)=c3;
F(i,4)=c4;
aux1=degtorad(F(i,4))
F(i,4)=aux1</pre><pre> C=simplify([cos(F(i,4)) -sin(F(i,4))*cos(F(i,2)) sin(F(i,4))*sin(F(i,2)) F(i,1)*cos(F(i,4));
sin(F(i,4)) cos(F(i,4))*cos(F(i,2)) -cos(F(i,4))*sin(F(i,2)) F(i,1)*sin(F(i,4));
0 sin(F(i,2)) cos(F(i,2)) F(i,3);
0 0 0 1]);
eval(sprintf('A%d = C|;',i));
B=B*C;
eval(sprintf('A%d',i))
end
end
texto=[ ];
for k=1:4
texto1=sprintf(' %2.0f ',B(k,:));
texto=sprintf('%s %s \n',texto,texto1);
end
set(handles.resultado,'String',texto);
end</pre><p>4.- this code part is where I try to show in a list box.</p><pre class="language-matlab">if true
texto=[ ];
for k=1:4
texto1=sprintf(' %2.0f ',B(k,:));
texto=sprintf('%s %s \n',texto,texto1);
end
set(handles.resultado,'String',texto);
end
</pre><p>thanks I hope your answer.</p>Oscarinhttps://www.mathworks.com/matlabcentral/profile/authors/13316213-oscarintag:www.mathworks.com,2005:Question/4153862018-08-18T22:51:04Z2018-08-19T06:14:40ZHow can I calculate formula using loop?<p>Hello!</p><p>Excel file format as follows:</p><ul><li>A column: Year (from 1998 to 2018)</li><li>B column: Day of the year</li><li>C column: Hour</li></ul><p>I'd like to convert the values of B and C column as year.</p><p>Doy= C/24+B</p><p>Formula is:</p><p>Time=A+(Doy/365) or Time=A+(Doy/366)</p><p>Dividing 365 or 366 is related to divide by 4. That's why I benefitted from modulo operation but I didn't do what I want.</p><pre class="language-matlab">data=xlsread('R.xlsx');
Doy=data(:,2)+(data(:,3)/24);
M = mod(data(:,1),4);
j=1;
for i=1:176784;
if M ==0
Time=data(:,1)+(Doy/366);
else M~=0
Time=data(:,1)+(Doy/365);
j=j+1;
end
</pre>Suat YAZICIhttps://www.mathworks.com/matlabcentral/profile/authors/13285733-suat-yazicitag:www.mathworks.com,2005:Question/182632011-10-14T03:24:44Z2018-08-19T05:47:44Zmatlab view<p>Hi</p><p>I have a default view of Matlab. I want to see the editor, command window, workspace, current folder and the figures in the same window.
I am using version 7.11</p><p>Currently, the editor and the figures come in separate windows, and the main screen has command, workspace & current folder.</p><p>Can any advise help please?</p><p>Thanks</p><p>P</p>PChoppalahttps://www.mathworks.com/matlabcentral/profile/authors/2946496-pchoppalatag:www.mathworks.com,2005:Question/4153902018-08-19T04:40:19Z2018-08-19T04:40:19ZWhich toolboxes are recommended for civil engineering?<p>I'm a student studying for civil engineering.When I tried to purchase Matlab I found that there are many different toolboxes I can select. So I want to know which toolboxes I should buy.Thanks!</p>Jiajin Fenghttps://www.mathworks.com/matlabcentral/profile/authors/13314530-jiajin-feng