https://ww2.mathworks.cn/matlabcentral/answers/questions MATLAB Answers — New Questions 2020-01-20T03:29:58Z tag:ww2.mathworks.cn,2005:Question/501020 2020-01-20T01:05:09Z 2020-01-20T03:29:58Z How to split an array into two arrays? Hi, I have an array like x = [ 0:10] and need to split it into x1 = [x(0,1),x(4,5),x(8,9)] and x2 = [x1(2,3),x(6,7)]. I am able to do this by using loops but for big dara is very time consuming. Is there any other way to do this? Thanks Mohammad Torabi https://ww2.mathworks.cn/matlabcentral/profile/authors/6009385-mohammad-torabi tag:ww2.mathworks.cn,2005:Question/500898 2020-01-18T18:14:08Z 2020-01-20T03:22:35Z 3D Plotting in matlab I have got a function after integration in Matlab, f($\theta$,$g$) which is a complex function. I would like to get 3D plot the this function with respect to $\theta$ and g, where $g$ positive integer runs from 0 and $\theta$ runs from 0 to $\pi$. The function is very large and complicated one. Pl hep me to plot this. P Maity https://ww2.mathworks.cn/matlabcentral/profile/authors/17312484-p-maity tag:ww2.mathworks.cn,2005:Question/499948 2020-01-12T04:34:03Z 2020-01-20T03:13:10Z How to find the valley areas of the image? How to calculate the depth of the letters in the given image, so that i can find the valley areas ? Please help me. Sk https://ww2.mathworks.cn/matlabcentral/profile/authors/16144792-sk tag:ww2.mathworks.cn,2005:Question/500964 2020-01-19T13:18:49Z 2020-01-20T03:09:21Z Classification learner app input issue The Classification learner app is only able to add one csv file for each session. May I know how is it able to add several csv file in order to train the classifier ? Otherwise how can I combine few excel file into one to train the classifier ? Any suggestion or I can do because my train set is around 500 images. Teik Jin Lim https://ww2.mathworks.cn/matlabcentral/profile/authors/9770976-teik-jin-lim tag:ww2.mathworks.cn,2005:Question/500960 2020-01-19T13:00:06Z 2020-01-20T03:04:39Z how to plot to get four plots of descriptive statistics in one figure I have attached the descriptive statistics of 4 different zones below. Can you help me how to get the four plots in one figure? I would like something like this https://se.mathworks.com/help/stats/exploratory-data-analysis.html gjashta https://ww2.mathworks.cn/matlabcentral/profile/authors/12107468-gjashta tag:ww2.mathworks.cn,2005:Question/501025 2020-01-20T02:54:12Z 2020-01-20T02:54:12Z How to convert gray image to HSV plane S - value image? Hi, Given my image is a gray image and i don't have the rgb image of this gray image, can i know how can i convert this gray image to the HSV colour plane S - value plane image only? elsa chang https://ww2.mathworks.cn/matlabcentral/profile/authors/17319033-elsa-chang tag:ww2.mathworks.cn,2005:Question/501024 2020-01-20T02:44:35Z 2020-01-20T02:44:35Z How to convert datenum to datetime in a MATLAB Table Hello, I have a table with list Ids in numbers and corresponding datenum in which these Ids were occured. Can you please help me to convert these datenum to dates? The table is like this: ID_1 Dates_1 ID_2 Dates_2 2 737735.191331019 6 737735.182129630 3 737735.182013889 7 737735.141481482 I tried this: for counter= 1:(size(table,1)) if mod(counter,2)==0 col_name=table.Properties.VariableNames{counter}; table{:,col_name}=datetime(table{:,col_name},'ConvertFrom', 'datenum'); end end And i got error like this: The following error occurred converting from datetime to double: Undefined function 'double' for input arguments of type 'datetime'. To convert from datetimes to numeric, first subtract off a datetime origin, then convert to numeric using the SECONDS, MINUTES, HOURS, DAYS, or YEARS functions. Shambhavi Adhikari https://ww2.mathworks.cn/matlabcentral/profile/authors/12839231-shambhavi-adhikari tag:ww2.mathworks.cn,2005:Question/500926 2020-01-19T05:00:36Z 2020-01-20T02:43:43Z Error in resizing GUIDE gui Hello, I am using GUIDE, and now am getting this error in modifying a GUIDE gui. The gui works, but not sure what's going on here! Thanks.. Doug Anderson Douglas Anderson https://ww2.mathworks.cn/matlabcentral/profile/authors/4227986-douglas-anderson tag:ww2.mathworks.cn,2005:Question/500678 2020-01-17T01:36:45Z 2020-01-20T02:43:21Z Can I receive real LTE data with zynq board & RF board? I have zc706 and FMCOMMS5. I succeded to run example : Transmit and Receive LTE MIMO Using Analog Devices AD9361/AD9364 but, I want to receive the REAL LTE data in the air. Can I receive real LTE data? Thanks a lot. sarang Kim https://ww2.mathworks.cn/matlabcentral/profile/authors/10394942-sarang-kim tag:ww2.mathworks.cn,2005:Question/500677 2020-01-17T01:34:32Z 2020-01-20T02:37:49Z How to make predictions using an already-trained LSTM model? Hello everyone, I have the attached example LSTM code with the data file (omni.txt: hourly data). I would like to know how to use the trained LSTM model to make a prediction for new data. I think the answer lies within the lines starting from line 113, but I'm a novice with LSTM. ---------------------------------------------------------------------------------------------------------------------------------- A side question: This code is dealing with only one input (feature) to predict its own evolution with time, How can we transform it to deal with several inputs at once? How can we transform this code to take several inputs and predict the temporal evolution of another output? For instance, like the feedforward backpropagation network in which it can take several inputs to predict a single output (or several outputs). I appreciate your help! Thank you, Mohamed Nedal https://ww2.mathworks.cn/matlabcentral/profile/authors/7573601-mohamed-nedal tag:ww2.mathworks.cn,2005:Question/501003 2020-01-19T19:53:01Z 2020-01-20T02:29:02Z How to create a best fit line for data with an aymptote? I am currently trying to find the point at which the data reaches its max, the asymptote. However, te data fluctuates, so I need to create a best fit line, since finding the derivative of the data as it is now would not work. How would I programatically go about creating a best fit line for this? I need to be able to acess the equation from the code. The data takes the form of the attached images. Evan Shimoun https://ww2.mathworks.cn/matlabcentral/profile/authors/16122404-evan-shimoun tag:ww2.mathworks.cn,2005:Question/501023 2020-01-20T02:28:39Z 2020-01-20T02:28:39Z How to smooth out a surf plot I want a nice and smooth surface. Can someone please give me some hints ? clear zspan = linspace(0,2,100); v2in_vals = linspace(0.01,0.05,10); v0mat = [1 0.1 1]; N = size(v0mat, 1); zsol = cell(N,1); v1sol = cell(N,1); v2sol = cell(N,1); v3sol = cell(N,1); v2in = cell(N,1); for k=1:length(v2in_vals) v0 = v0mat; v0(2) = v2in_vals(k); [z,v] = ode45(@rhs,zspan,v0); zsol{k} = z; v1sol{k} = v(:,1); v2sol{k} = v(:,2); v3sol{k} = v(:,3); v2in{k} = v0mat(2) * ones(size(v2sol{k})); end all_z = [zsol{:}]; all_v2 = [v2sol{:}]; all_v2in = [v2in{:}]; v2in_vec = v2in_vals; z_vec = all_v2(:,2); surf(z_vec, v2in_vec, all_v2.') xlabel('z'); ylabel('dw'); zlabel('w'); function parameters=rhs(z,v) alpha=0.116; db= 2*alpha-(v(1).*v(3))./(2*v(2).^2); dw= (v(3)./v(2))-(2*alpha*v(2)./v(1)); dgmark= -0.01-(2*alpha*v(3)./v(1)); parameters=[db;dw;dgmark]; end Tigist Beyene https://ww2.mathworks.cn/matlabcentral/profile/authors/14703804-tigist-beyene tag:ww2.mathworks.cn,2005:Question/501021 2020-01-20T01:32:22Z 2020-01-20T01:58:31Z Output argument "XXX" (and maybe others) not assigned during call to "function". Not sure what this means. Code here: global T d t v T = 10; d = 0.3; [t,v]= ode23(@pwm,[0:1e-7:0.1], [0 0], options); v = pwm(t,T,d); figure,plot(t,v); %%Plot the datas %Below is the function declaration, in a different file in the same folder. function v = pwm(t,T,d) if T <= t <d*T v = 1; end if d*T <= t <T v = 0; end end Oscar Ip https://ww2.mathworks.cn/matlabcentral/profile/authors/16442085-oscar-ip tag:ww2.mathworks.cn,2005:Question/500744 2020-01-17T13:47:05Z 2020-01-20T01:44:21Z How to create a table of 3 variables ? I have a matrix Thm = [hours,days,months], where hours is [1x24], days is [1x31] and months [1x12]. I would like to create a table of hours and days [hours, days] for each month. I was wondering if i could substitute a vector of months 1:12 to a vector of a string {'Jan','Feb',...}...Could anyone help me with this, please ? Aleksandra Ksiezyk https://ww2.mathworks.cn/matlabcentral/profile/authors/7645635-aleksandra-ksiezyk tag:ww2.mathworks.cn,2005:Question/500986 2020-01-19T17:21:11Z 2020-01-20T01:37:10Z dgemv produces only zero vectors as results Hello, I am trying to link this simple matlab script A = [2 3; -1 4]; B = [5; 3]; C = zeros(2, 1); alpha = 1; beta = 1; C = mv_mult(A, B, alpha, beta) with the following mexFunction #include "stdio.h" #include "stdlib.h" #include "string.h" #include "blas.h" #include "mex.h" #include "matrix.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* pointers to input & output matrices*/ double *A, *v, *Y, *a, *b; ptrdiff_t rows_A, cols_A; ptrdiff_t rows_v, cols_v; // create input matrix (A) A = mxGetDoubles(prhs); rows_A = mxGetM(prhs); cols_A = mxGetN(prhs); // create input vector (v) v = mxGetDoubles(prhs); rows_v = mxGetM(prhs); cols_v = 1; // parse scalars (a, b) a = mxGetDoubles(prhs); b = mxGetDoubles(prhs); // create output matrix (Y) plhs = mxCreateDoubleMatrix(rows_A, cols_v, mxREAL); Y = mxGetPr(plhs); printf("A: %lf\n", A); printf("A: %lf\n", A); // compute mm multiplication using blas2 operations char chn = 'N'; const long int i_one = 1; dgemv_(&chn, &rows_A, &cols_A, a, A, &cols_v, v, &i_one, b, Y, &i_one); } The function compiles without errors nor warnings but matlab replies with [0 0]' instead of [19 7]'. I can't understand why though. Note that I am trying to use blas2 operations only. Nikolaos https://ww2.mathworks.cn/matlabcentral/profile/authors/16951974-nikolaos tag:ww2.mathworks.cn,2005:Question/500894 2020-01-18T17:25:55Z 2020-01-20T01:28:00Z RMSE between original and predicted values. Hi, If I have thousand samples of my signal in a vector form like 1*1000, and I will predict my signal at each iteration that results into 1*1000 also. Then In this case, how will I find the RMSE of my model? Many Thanks Asad Rasheed https://ww2.mathworks.cn/matlabcentral/profile/authors/15162628-asad-rasheed tag:ww2.mathworks.cn,2005:Question/501009 2020-01-19T22:03:03Z 2020-01-20T01:09:34Z Blank figures using plot I am running the following code and when the figures pop-up, they are blank without any lines. I have tried running the Matlab in the software mode, thinking that the problem is in the OpenGL, but nothing changed. So the error must be in the code , but I cannot figure out where. I appreacate any help on this, as I am stuck.. c1=3.74*10^8; c2=1.44*10^4; T1=30; T2=90; T3=120; a1=0; a2=0; a3=0; max1=0; max2=0; max3=0; figure(1); for a=0:0.01:300 M=c1/((a^5)*(exp(c2/(a*T1))-1)); plot(a,M,'b') if M>max3 max3=M; a3=a; end hold on end figure(2); for a=0:0.01:80 M=c1/((a^5)*(exp(c2/(a*T2))-1)); plot(a,M,'r') if M>max2 max2=M; a2=a; end hold on end figure(3); for a=0:0.01:80 M=c1/((a^5)*(exp(c2/(a*T3))-1)); plot(a,M,'g') if M>max1 max1=M; a1=a; end hold on end Ivaylo Ivanov https://ww2.mathworks.cn/matlabcentral/profile/authors/7687354-ivaylo-ivanov tag:ww2.mathworks.cn,2005:Question/86717 2013-09-09T15:17:06Z 2020-01-20T01:01:43Z How to convert a video file to a bit stream in matlab? I'm trying to extract the motion vectors from a h.264 coded video. For this, I need to convert the video to its a respective bit stream first. Any idea or lines of code to do this will be appreciated. Joel https://ww2.mathworks.cn/matlabcentral/profile/authors/4074689-joel tag:ww2.mathworks.cn,2005:Question/501019 2020-01-20T01:00:23Z 2020-01-20T01:00:23Z How to increase font size in the System Identification app window on Mac OS X? I've just started using the System Identification app for a course I am taking. I have an Apple Mac Mini with a 27" Thunderbolt display. When I open the System Identification app it appears very small on the display and the fonts are so small they are straining my eyes. I know how to increase the font size in the main MATLAB_R2019b application (in MATLAB > Preferences) but it doesn't change the font in the System Identification app. I see Simulink preferences but no font setting there. Couldn't find anything about fonts in the System Identification App help pages (although there is no search function). System details Mac Mini, 2012, OS X Mojave 10.14.6 Apple Thunderbolt Display, 27-inch, (2560×1440 pixels) MATLAB: R2019b Update 2 System Identification Toolbox 9.11 Bill Tubbs https://ww2.mathworks.cn/matlabcentral/profile/authors/4985015-bill-tubbs tag:ww2.mathworks.cn,2005:Question/501018 2020-01-20T00:54:48Z 2020-01-20T00:57:02Z How to read an plot with coordinates a .tiff file? I'm currently using this code: [X,map]= imread('Z1.tiff'); image(X); colormap(map); This is the file im trying to read: http://www.mediafire.com/view/dzifgp0s3ima3z2/Z1.tiff/file And this is the plot im trying to obtain: Any idea why my code is not working? Philippe Corner https://ww2.mathworks.cn/matlabcentral/profile/authors/7103813-philippe-corner tag:ww2.mathworks.cn,2005:Question/330794 2017-03-20T09:24:18Z 2020-01-20T00:40:31Z Field List of IQFeed Realtime Data Hi, I am getting IQFeed realtime data via MATLAB using a built-in function 'realtime'. As the data format is 1x67 cell for each record, I do not know the meaning of each column in one record. Could you please give me the field list for these 67 columns of data? I also want to know the data sending frequency. I got one more question is when will you send me a new data (I mean what is the minimum difference between the adjacent data). Any help is appreciated! Rui Zhang https://ww2.mathworks.cn/matlabcentral/profile/authors/8609554-rui-zhang tag:ww2.mathworks.cn,2005:Question/501017 2020-01-20T00:34:11Z 2020-01-20T00:34:11Z Assigning values to the array of Enumeration Class seems to be very slow Hi, I met this problem when parsing a gps log. I made an Enumeration Class GpsState as follows. classdef GpsState enumeration Lost Single RTD RTK_Float RTK_Fix end end Then I created an array of GpsState to record all the states of the log. The process was painfully slow. Finally, I found out what the problem was caused by the assign of Enumeration Class array. I simplified the code as follows, the process takes about 4.6s. tic test_num = 1e5; gps_state = repmat(GpsState.Lost,test_num,1); for ii = 1:test_num gps_state(ii) = GpsState.RTK_Fix; end toc Is there any problem with my usage mode of Enumeration Class? Thanks for your reading. pingping zhang https://ww2.mathworks.cn/matlabcentral/profile/authors/15381093-pingping-zhang tag:ww2.mathworks.cn,2005:Question/493419 2019-11-27T05:22:53Z 2020-01-20T00:28:00Z Defining Simulink block parameters which are dependent on a signal value in Simulink I would like to define one of the parameters of a block in simulink as a function of the value of a signal in simulink. For example, suppose that I want to define the amplitude of a Sine wave as the RMS value of a random signal. How can I do that? Ali Hajnayeb https://ww2.mathworks.cn/matlabcentral/profile/authors/13465240-ali-hajnayeb tag:ww2.mathworks.cn,2005:Question/459284 2019-04-30T01:11:35Z 2020-01-20T00:26:56Z Datafeed Toolbox IQFeed Level 1 Data Fields Description Where can I get a list of the fields returned by the realtime command from the Datafeed Toolbox? For example: realtime(q,'ABC') openvar('IQFeedLevelOneData') returns the 67 fields from IQFeed. Where can I get a description of the fields? Marc McLean https://ww2.mathworks.cn/matlabcentral/profile/authors/14895585-marc-mclean tag:ww2.mathworks.cn,2005:Question/292819 2016-06-29T03:16:55Z 2020-01-20T00:26:39Z Calculating a time duration from the graph Hello I am interested in finding out the time between two points in a graph (x-axis is the time, y-axis is the quantity of interest). For testing my logic, I'm using a sinusoidal wave to see if I get the correct responses. In the sinusoidal wave defined below, I'm interested in calculating the starting and ending x-coordinate when the y-axis value is less than 0.4. t= [0:0.1:2*pi]; a=sin(t); figure; h=plot(t,a); for i=1:max(t) y=get(h,'ydata'); if a < 0.4 start=get(h,'xdata'); if a > 0.4 fin=get(h,'xdata'); end end This is an infinite loop, which doesn't give any output. I'm not really familiar with matlab and am not able to figure out how to get the start and fin values above. Any help is appreciated. Thanks! Mridul Garg https://ww2.mathworks.cn/matlabcentral/profile/authors/7142910-mridul-garg tag:ww2.mathworks.cn,2005:Question/500859 2020-01-18T11:58:21Z 2020-01-20T00:10:21Z Help text does not work for user-defined functions I just installed R2019b and the help function does not work. Example: I created the addme function from the Add Help for Your Program page in the documentation. Result: >> help addme addme is a function. c = addme(a, b) The help text in the file was not shown. Also: >> help help help not found. A similar question was asked before, but the answer was not very helpful for me. help seems to work ok for built-in functions. Are Mjaavatten https://ww2.mathworks.cn/matlabcentral/profile/authors/3934907-are-mjaavatten tag:ww2.mathworks.cn,2005:Question/500699 2020-01-17T06:57:56Z 2020-01-20T00:07:55Z eigs gives wrong eigenvalues Hi, I am using MATLAB R2019b to compute eigenvalues of sparse matrices and discovered that eigs gives wrong results if I only ask for the first several smallest eigenvlues. The sparse matrices come from the mass and stiff matrices of an ANSYS model I build for modal analysis. Here I provide the toy example of a mass connected to the ground with a translational spring, and I know for sure that this toy example will have eigenvalues with real parts and NO imaginary parts. Here is my question: If I compute all the 1047 eigenvalues in my toy example by eig and eigs, I can get matching and correct results. However, if I use eigs to compute only the first several smallest eigenvalues, it gives wrong results with imaginary parts! To be specific, if I ask eigs to give out eigenvalues for the first 523 smallest eigenvalues (the length being equal or shorter than half of 1047), the results are WRONG. eigs only computes correctly when I ask for more than half of the available eigenvalues. I have read many posts on this forum about why eigs is different than eig, due to the former uses the random start, but this does not solve my problem. My real ANSYS model is way more complex than this toy example, and I cannot afford to use eig to find all eigenvalues, instead, I will use eigs to find the first 20~50 smallest eigenvalues. What can I do with eigs being wrong when I ask it to give eigenvalues shorter than half of the total available eigenvalues? I have included my data and script blow. Thank you, Chiao-Ting clear; close all; clc; K = load('stiff_mtx_NoMass.txt'); % Symmetric sparse matrix in MMF format K = spconvert(K(2:end,:)); K = K + K' - speye(size(K,1)).*diag(diag(K)); M = load('mass_mtx_NoMass.txt'); M = spconvert(M(2:end,:)); M = M + M' - speye(size(M,1)).*diag(diag(M)); [V, D, flag] = eigs(K, M, 523, 'sm'); % NG % [V, D, flag] = eigs(K, M, 524, 'sm'); % OK % [V, D, flag] = eigs(K, M, 1047, 'sm'); % OK D = diag(D); vecWn = sqrt(D)/2/pi; K2 = full(K); M2 = full(M); [V2, D2] = eig(K2, M2); D2 = diag(D2); D2 = sort(D2); vecWn2 = sqrt(D2)/2/pi; figure(1); clf; plot(real(vecWn2), 's-', 'markersize', 4); hold on; % plot(imag(vecWn2), '+-', 'markersize', 4); plot(real(vecWn), 'x-', 'markersize', 4); % plot(imag(vecWn), 'o-', 'markersize', 4); grid on; xlabel('DOF'); ylabel('Eigenfrequency (Hz)'); legend('eig; Re(\omega)', 'eigs; Re(\omega)'); set(legend, 'location', 'northwest'); Chiao-Ting Li https://ww2.mathworks.cn/matlabcentral/profile/authors/10052213-chiao-ting-li tag:ww2.mathworks.cn,2005:Question/99127 2009-06-27T01:11:00Z 2020-01-20T00:04:33Z Why does the HOLD ON command not work when I try to update figures with subplots? I have subplots in my figure. I execute HOLD ON before making changes to the subplots, however the plot on one of the axes gets removed when I make changes. As an example consider the following code: figure(1), h1 = subplot(1,2,1),line h2 = subplot(1,2,2),line hold on figure(1) axes(h1),plot(sin(0:1)) axes(h2),plot(sin(0:1)) % subplot(1,2,1),plot(sin(0:1)) % subplot(1,2,2),plot(sin(0:1)) MathWorks Support Team https://ww2.mathworks.cn/matlabcentral/profile/authors/4622813-mathworks-support-team tag:ww2.mathworks.cn,2005:Question/500845 2020-01-18T08:31:00Z 2020-01-19T23:57:00Z Where's the debug tab? On the page Start the Simulink Debugger the text mentions a Debug tab. Where can I find it? Starhowl https://ww2.mathworks.cn/matlabcentral/profile/authors/6025396-starhowl tag:ww2.mathworks.cn,2005:Question/500990 2020-01-19T18:03:02Z 2020-01-19T23:52:32Z how can i solve this error? dx=0.1; x=1:dx:6; b=0.32; ki=0; for i=2:length(x) temp(i-1,:)=Es*I*... (- b^2*cos(x(i-1,:)*b) - b^2*cosh(x(i-1,:)*b) - ((cos(6*b) + cosh(6*b))*(b^2*sin(x(i-1,:)*b) + b^2*sinh(x(i-1,:)*b)))/(sin(6*b) + sinh(6*b))); ki(i-1,:)=temp(i-1,:)*dx; end Es and I are constant. error is Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-51. Error in m2 (line 69) ki(i-1,:)=temp(i-1,:)*dx; zahra zamani https://ww2.mathworks.cn/matlabcentral/profile/authors/16077155-zahra-zamani tag:ww2.mathworks.cn,2005:Question/501015 2020-01-19T23:24:33Z 2020-01-19T23:50:54Z Problem finding the nearest value to specific number Hello, I am using this code seen in this thread: https://es.mathworks.com/matlabcentral/answers/375710-find-nearest-value-to-specific-number %Initial amplitud (50%time - 10%time) time_10=((max(A)-min(A))*0.1)+min(A); time_50=((max(A)-min(A))*0.5)+min(A); [~,~,idx]=unique(abs(A-time_10)); [~,~,idx2]=unique(abs(A-time_50)); minVal_10=A(idx==1); minVal_50=A(idx2==1); T10=find(A==minVal_10); %Gives you the row where 10% of the time lies in the Intensity matrix T50=find(A==minVal_50); %Gives you the row where 50% of the time lies in the Intensity matrix I_T10=B1(T10,1); I_T50=B1(T50,1); ini_Amp=(I_T50-I_T10)*10^6; However, I have problems with minVal_50. there are two values equally near to time_50. Therefore I got this warning: Matrix dimensions must agree. Error in foot_signal_analysis1 (line 60) T50=find(A==minVal_50); %Gives you the row where 50% of the time lies in the Intensity matrix T50=10.53350, and minVal_50 is either 10.53352 or 10.53348. How can I code to take the biggest number in this case? If statement? Jose Rego Terol https://ww2.mathworks.cn/matlabcentral/profile/authors/10100100-jose-rego-terol tag:ww2.mathworks.cn,2005:Question/312890 2016-11-18T13:13:07Z 2020-01-19T23:50:12Z With eSignal/InteractiveData being discontinued in the DataFeed Toolbox, are there any other "mid-range" cost options for financial vendors? eSignal/InteractiveData is being discontinued in the DataFeed Toolbox. Any other "mid-range" cost options, that aren't \$30,000+ per year for a data terminal, other than IQfeed which is mainly N. American data? Free data sources work for testing, but actual trading needs something more reliable. I think my only cost effective workaround is importing real-time interday data into excel and then reading that into Matlab at one minute intervals. Any suggestions? Richard McKee https://ww2.mathworks.cn/matlabcentral/profile/authors/488937-richard-mckee tag:ww2.mathworks.cn,2005:Question/501012 2020-01-19T23:03:22Z 2020-01-19T23:48:16Z Can I have an older runtime environment than the complier version I am using? For several reasons, I am using R2018a for distributing my software. I have discovered that on the Mac that the installers that the Matlab compiler generates do not run under Catalina (they just sit there displaying their splash screen). This situation has lead me to wonder if I can compile under the latest version of Matlab but have the compiler use R2018a's runtime library. Even if this does does not my installer problem, it would be very useful to have this ability. Don https://ww2.mathworks.cn/matlabcentral/profile/authors/49289-don tag:ww2.mathworks.cn,2005:Question/501016 2020-01-19T23:27:21Z 2020-01-19T23:46:30Z This link pops up when I'm trying to download MATLAB through my school https://www.mathworks.com/licensecenter/total_headcount/6678493399004520332698519 why is it saying this? Michael Dotson https://ww2.mathworks.cn/matlabcentral/profile/authors/17318280-michael-dotson tag:ww2.mathworks.cn,2005:Question/500999 2020-01-19T19:32:11Z 2020-01-19T23:46:02Z Don't know how to make the loop works with variable Sorry new to all of this. Whenever I try using 'Lb' as a range (from 0 to 15000 with load step of 1000) that I want the program to calculate for each, errors keep showing, and it won't continue with the calculations. Thanks in advance. %CALCULATIONS OF THE LATERAL TORSIONAL BUCKLING %--------------- Cb = 1; Lb = 0:1000:15000; if (Sxt/Sxc >= 0.7) FL = 0.7*Fy; elseif (Sxt/Sxc < 0.7) if (Fy*Sxt/Sxc >= 0.5*Fy) FL = Fy*Sxt/Sxc; elseif (Fy*Sxt/Sxc < 0.5*Fy) FL = 0.5*Fy; end end %CALCULATIONS OF THE LIMITING LATERALLY UNBRACED LENGTH FOR THE LIMIT STATE %OF YIELDING, mm Lp = 1.76*ry*sqrt(E/Fy); %CALCULATIONS OF THE LIMITING UNBRACED LENGTH FOR THE LIMIT STATE %OF INELASTIC LATERAL TORSIONAL BUCKLING, mm Lr = 1.95*rt*(E/FL)*sqrt((J/(Sxc*h0))+sqrt(((J/(Sxc*h0))^2)+(6.76*(FL/E)^2))); %CALCULATIONS OF THE NOMINAL MOMENT (Lp < Lb <= Lr) if (Iyc/Iy > 0.23) R1 = Mp/Myc; elseif (Iyc/Iy <= 0.23) R1 = 1; end for Mn2 = Cb*((R1*Myc)-(((R1*Myc)-(FL*Sxc))*((Lb-Lp)/(Lr-Lp)))) if (Mn2 < R1*Myc) disp('Mn2 = Cb*((R1*Myc)-((R1*Myc)-((FL*Sxc)*((Lb-Lp)/(Lr-Lp)))))') Mn2 = Cb*((R1*Myc)-(((R1*Myc)-(FL*Sxc))*((Lb-Lp)/(Lr-Lp)))); elseif (Mn2 >= R1*Myc) disp('Mn2 <= R1*Myc') Mn2 = R1*Myc; end end %CALCULATIONS OF THE NOMINAL MOMENT (Lb > Lr) if (Iyc/Iy <= 0.23) R1 = 1 & 'J = 0'; end R2 = sqrt(1+(0.078*(J/(Sxc*h0))*(Lb/rt)^2)); for Mn3 = Cb*pi*pi*E*Sxc*R2/(Lb/rt)^2 if (Mn3 < R1*Myc) disp('Mn3 = Cb*pi*pi*E*Sxc*R2/(Lb/rt)^2') Mn3 = Cb*pi*pi*E*Sxc*R2/(Lb/rt)^2; elseif (Mn3 >= R1*Myc) disp('Mn3 = R1*Myc') Mn3 = R1*Myc; end end if Lb <= Lp disp('Mn = Mn1') Mn = Mn1 else if Lb > Lp && Lb <= Lr disp('Mn = Mn2') Mn=Mn2 else Lb > Lr disp('Mn = Mn3') Mn=Mn3 end end plot(Lb,Mn) Ahmed Sayed https://ww2.mathworks.cn/matlabcentral/profile/authors/17317395-ahmed-sayed tag:ww2.mathworks.cn,2005:Question/500967 2020-01-19T13:24:44Z 2020-01-19T23:38:29Z how can i make this loop? hi friends im new in matlab could you please help me in this problem. I have an equations A ; A=x*a-b x=[1 2 5 8 10]; i want to put x values into equation A one by one to solve it, which i mean x1=1, to solve A1 and x2=2 to solve A2 and so on. after that i want to use the results that i found in this equation B= (A1...An / c). thanks Mamad Mamadi https://ww2.mathworks.cn/matlabcentral/profile/authors/14468931-mamad-mamadi tag:ww2.mathworks.cn,2005:Question/497721 2019-12-22T13:32:28Z 2020-01-19T23:33:28Z merge images from diffrent folder Hi,I need a code that merges 2 folders Jpg images that inside each of the folders 120 images,the format that I need to merge is on by on (1 from folder1 by 1 from folder2, 2 from folder 1 by 2 from folder 2, so on.) and pastes the merged images into a separate folder(new path). Thank for help. Hamid Ebrahimi https://ww2.mathworks.cn/matlabcentral/profile/authors/17138242-hamid-ebrahimi tag:ww2.mathworks.cn,2005:Question/500994 2020-01-19T18:38:50Z 2020-01-19T23:25:46Z Matrix sequence manipulation for multiple value assignment Is there a quick (& simple) way to do the following without a loop? Not even sure why I don't want loops but still figured it'd be nice to know if there was a way. Feels like something obvious I'm just not thinking of.. I have an array and a matrix of indices, e.g. A = zeros(20, 1); idxes = [1, 5; ... 10, 13; ... 19, 20]; and I'd like to convert it such that the following is achieved without hardcoding in the indices: A([1:5, 10:13, 19:20]) = 1; Equivalent solution with a loop: for i = 1:size(idxes, 1) A(idxes(i, 1):idxes(i, 2)) = 1 end Kevin Chen https://ww2.mathworks.cn/matlabcentral/profile/authors/6124791-kevin-chen tag:ww2.mathworks.cn,2005:Question/500970 2020-01-19T14:31:33Z 2020-01-19T23:25:43Z Make entries of first row and column of matrix all equal to zero. I'm trying to create an nxn matrix that has all entries in the first row and column equal to zero, and also all of the diagonal entries need to be equal to zero. The other entries are random 1's and 0's. I have so far made the diagonals equal to zero but am struggling with making the first row and column equal to zero. Below is what I have so far: n = 10; B = randi([0,1],n,n); v = zeros(1,n); B = B + diag(v-diag(B)); Thanks Ciara McHugh https://ww2.mathworks.cn/matlabcentral/profile/authors/17274312-ciara-mchugh tag:ww2.mathworks.cn,2005:Question/501014 2020-01-19T23:22:13Z 2020-01-19T23:24:20Z Comparing natural frequency by Rayleigh Ritz method(RRM) and assumed mode method(AMM) for simply supported beam with point masses I am trying to get similar results from RRM and AMM for simply supported beam with point masses. But I am getting totaly different result from both cases. Please help me in pointing out error in codes. Below is image representing loading condition and code. clc clear %Program to compute Natural frequency using AMM L=5; b=0.05; E=69e9; rho=2500; % Material Propertise syms x ld h=0.2; %Beam height m1=200; m2=90; m3=50; m4=30; m5=10; %Point Masses Ar=h*b; % Beam Area I=(1/12)*b*(h)^3; %Beam Inertia phi=[sin(pi*x/L) sin(2*pi*x/L) sin(3*pi*x/L) sin(4*pi*x/L) sin(5*pi*x/L) ... sin(6*pi*x/L) sin(7*pi*x/L) sin(8*pi*x/L)]; dphi=diff(phi,x); ddphi=diff(dphi,x); for i=1:7 for j=1:7 im=rho*Ar*int(phi(i)*phi(j),x,0,L)... +m1*subs(phi(i)*phi(j),x,0.2*L)+m2*subs(phi(i)*phi(j),x,0.4*L)... +m3*subs(phi(i)*phi(j),x,0.5*L)+m4*subs(phi(i)*phi(j),x,0.6*L)... +m5*subs(phi(i)*phi(j),x,0.8*L); M(i,j)=im; ik=E*I*int(ddphi(i)*ddphi(j),x,0,L); K(i,j)=ik; end end A=K-(ld*M); p=coeffs(det(A),ld); l=roots(p); %End of AMM % Code for RRM L=5; N=11; b=0.05; E=69e9; rho=2500; % Material Propertise as per paper syms x h=0.2; m1=200; m2=90; m3=50; m4=30; m5=10; %Design parameters Ar=h*b; % Beam Area I=(1/12)*b*(h)^3; %Beam Inertia % Mass and Stiffness matrix for i=1:N for j=1:N im=double(int(rho*Ar*sin(i*pi*x/L)*sin(j*pi*x/L), x, 0, L)... +m1*sin(i*pi*0.2)*sin(j*pi*0.2)+m2*sin(i*pi*0.4)*sin(j*pi*0.4)... +m3*sin(i*pi*0.5)*sin(j*pi*0.5)+m4*sin(i*pi*0.6)*sin(j*pi*0.6)... +m5*sin(i*pi*0.8)*sin(j*pi*0.8)); ik=double(int(E*I*sin(i*pi*x/L)*sin(j*pi*x/L)*(pi/L)^4*(i*j)^2, x, 0, L)); K(i,j)=ik; %Stiffness matrix M(i,j)=im; %Mass matrix end end %Natural Frequency and modal vector A=M\K; [v,e]=eig(A); w=double(sqrt(e)); C=length(v); %End of RRM Aniket Bharamgonda https://ww2.mathworks.cn/matlabcentral/profile/authors/16166538-aniket-bharamgonda tag:ww2.mathworks.cn,2005:Question/501013 2020-01-19T23:14:41Z 2020-01-19T23:14:41Z Recolouring Sentinel2 multispectral image Hello, I am trying to recolour an image composed of the red, green and blue channels of Sentinel 2 imagery (Bands 4, 3 and 2, respectively). I have processed this imagery in the SNAP toolbox and exported in netCDF4-BEAM format. Firstly, I read in the required image bands and create the RGB image: address = %file location on computer; ncid = netcdf.open(address); bands{1} = transpose(im2double(netcdf.getVar(ncid,4))); %Red channel bands{2} = transpose(im2double(netcdf.getVar(ncid,3))); %Green channel bands{3} = transpose(im2double(netcdf.getVar(ncid,2))); %Blue channel Image = cat(3,bands{1},bands{2},bands{3}); %RGB image, datatype of double When I try to visualise the image with imshow(Image), the result is near monochromatic. I understand this is due to correlation between channels and so I wish to recolour the image. What is the best way to do this? I have tried to use the code below, however this makes no difference: stretchedImage = imadjust(Image,stretchlim(Image)); I have also investigated the image histograms however I don't understand why there is a difference between histogram(Image) and imhist(Image). I think the differences in the outputs of these may be related to my issues with strethlim, hopefully you can help shine a light on this for me! Many thanks. Aidan Wood https://ww2.mathworks.cn/matlabcentral/profile/authors/9032996-aidan-wood tag:ww2.mathworks.cn,2005:Question/364551 2017-11-01T04:00:00Z 2020-01-19T23:12:53Z Why is MATLAB unable to run the MATLABWindow application on Linux? Why is MATLAB unable to run the MATLABWindow application on Linux, with the following warning? &gt;&gt; simulink Warning: MATLABWindow application failed to launch. Unable to launch the MATLABWindow application MathWorks Support Team https://ww2.mathworks.cn/matlabcentral/profile/authors/4622813-mathworks-support-team tag:ww2.mathworks.cn,2005:Question/500867 2020-01-18T13:56:59Z 2020-01-19T23:00:47Z Matlab gives no result when I use the ODE (Ordinary Differential Equations) When trying to find the symbolic solution in the following code, I got a warning and empty sym! syms y(t) y0 Dy0 A=1; B=2; Dy = diff(y,t); D2y = diff(y,t,2); ode = diff(y,t,2)-A*(y)^2-B^2*y==0; cond1 = y(0) == 1; cond2 = Dy(1) == 0; conds = [cond1 cond2]; ySol(t) = dsolve(ode,conds); ySol = simplify(ySol, 'Steps',20) disp(ySol(t)) Warning: Explicit solution could not be found. > In dsolve (line 201) In symbolic_Fun (line 11) ySol(t) = [ empty sym ] [ empty sym ] What was my mistake? Please advise. Samer Atawneh https://ww2.mathworks.cn/matlabcentral/profile/authors/14055129-samer-atawneh tag:ww2.mathworks.cn,2005:Question/500992 2020-01-19T18:24:25Z 2020-01-19T23:00:13Z Non-linear Multivariate regression using genetic algorithm I would like to perform non-linear multivariate regression using genetic algorithm in matlab. I have five independent variables and one response. How can I do non-linear regression by minimizing the mean square error in matlab using genetic algorithm? R = f (x1, x2, x3, x4) I want to fit the data to the equation similar to the following: Thus, my objective is to find the constants C1, C2, C3,..., C21 using the GA in matlab by minimizing the difference between the actual response and the response from the model. Tad2020 https://ww2.mathworks.cn/matlabcentral/profile/authors/17317080-tad2020 tag:ww2.mathworks.cn,2005:Question/501006 2020-01-19T20:57:05Z 2020-01-19T22:51:38Z Getting the coordinates of vertices of an A4 sheet with coins on it, for its further projective transformation and coin detection I need to transform my tilted image in a way I can find coins on an A4 paper. So far, I have been getting four coordinates of edges of my paper by manually selecting them with ginput. targetImageData = imread('coin1.jpg'); imshow(targetImageData); fprintf('Corner selection must be clockwise or anti-clockwise.\n'); [X,Y] = ginput(4); Is there a way to automate this process, say, apply some edge detector and then find coordinates of each vertex and then pass them as the coordinates needed for transformation? Baldr Odinson https://ww2.mathworks.cn/matlabcentral/profile/authors/17056864-baldr-odinson tag:ww2.mathworks.cn,2005:Question/501007 2020-01-19T21:13:25Z 2020-01-19T22:46:24Z Pleaaaaaaaase i need help !!!! I want to solve this error in simulink. ""Derivative of state '1' in block 'Moteur4/Integrator' at time 0.0039708154447165821 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) " Component: Simulink | Category: Block error yousra yahia https://ww2.mathworks.cn/matlabcentral/profile/authors/11672404-yousra-yahia tag:ww2.mathworks.cn,2005:Question/501011 2020-01-19T22:38:14Z 2020-01-19T22:38:14Z Prediction function code? What is the MATLAB code to find the optimal ˆθ for the prediction function fθ such that θ = argmin θ LLS(θ)? Bao Le https://ww2.mathworks.cn/matlabcentral/profile/authors/7609984-bao-le tag:ww2.mathworks.cn,2005:Question/500802 2020-01-17T20:43:13Z 2020-01-19T22:21:19Z How can I write a function for this I finally wrote a simple code to plot two slope lines but the problesm is when I run it the next slope line begins a bit high then the first one. How can I fix that like the graph belowe? K1 = 3; K2 = 8; Idff1 = 20; endline=100; XIntersect=50; IB =[]; ID = []; for Ibias=0:endline if Ibias<=XIntersect Idiff = Idff1 + K1 * Ibias; ID=[ID, Idiff]; IB = [IB, Ibias]; else Idiff = K2 * Ibias; ID=[ID, Idiff]; IB = [IB, Ibias]; end end plot(IB, ID); Saman https://ww2.mathworks.cn/matlabcentral/profile/authors/2714358-saman tag:ww2.mathworks.cn,2005:Question/478819 2019-09-04T07:41:33Z 2020-01-19T22:08:59Z Remove baseline wander from ECG I am using the AD8232 and the Arduino pro mini 328-3V. I want to remove the motion artifacts from my signal. I am using matlab for the signal processing and this code for the serial communication with arduino. How can I do the motion artifacts removal? clc close all clear all if ~isempty(instrfind) fclose(instrfind); delete(instrfind); end %close all clc disp('Serial Port Closed') s = serial('COM5','BaudRate',9600); fopen(s); fprintf(s,'*IDN?'); i = 1; while true x(i) = str2double(fscanf(s)); i = i + 1; plot(x) pause(0.1) end Anna Karima https://ww2.mathworks.cn/matlabcentral/profile/authors/16117637-anna-karima tag:ww2.mathworks.cn,2005:Question/501008 2020-01-19T21:36:36Z 2020-01-19T21:36:36Z IOT4SH01DS problem Thingspeak-automatic parameter reset Hi, I have a big problem, I perfectly made the device parameters work and set and connected to the ThingViever app, but as soon as I write L'apikey and I enable Thingspeak the IOT4SH01DS device correctly sends about 4 times the temperature to the app and after you it disconnects from the network and all its settings return as factory. Also the access password that I tried to change returns to the factory one (Littlepig). Until he transmits all the settings remain correct, as soon as I enable Thinghspeak after a while the settings that I had modified for its correct functioning return to the factory settings. What could be the problem? Being in a remote area where there is no internet, the device is connected to a Telenor router wifi data modem with a IOT Thingmobile sim card that connects to the wind network. Thanks. Rosario Rosario https://ww2.mathworks.cn/matlabcentral/profile/authors/17299241-rosario-rosario