https://es.mathworks.com/matlabcentral/answers/questions MATLAB Answers — New Questions 2019-08-24T12:14:08Z tag:es.mathworks.com,2005:Question/477419 2019-08-24T12:07:17Z 2019-08-24T12:14:08Z Graph with a "tube" Hallo MATLAB community, i am trying to create a 3D graph showing a thick black line as my mean (in this case 3D acceleration). Thats not a problem of course. I have further calculated a range which determines my standard deviation around the mean. This deviation should be displayed as a semi-transparent tube so that the mean can still be seen. I already found the function steamtube but I was not able to configre my graph. I also attached an example file containing the following data: A = acceleration X Y Z = coordinates L R = right and left foot std = die entsprechende Abweichung I would really really appreciate if anyone could help me to handle this challenge :) Thanks a lot! Enjoy your weekend Christian Christian Weich https://es.mathworks.com/matlabcentral/profile/authors/7904741-christian-weich tag:es.mathworks.com,2005:Question/477418 2019-08-24T11:59:40Z 2019-08-24T11:59:40Z geting report from AGI STK11 into Matlab2018b Hi I have problem with geting attitude report from AGI STK11 into Matlab2018b t ;I have searched in help of the agi programing and google but havent any resualt for me please help me moein ebrahimi https://es.mathworks.com/matlabcentral/profile/authors/14068621-moein-ebrahimi tag:es.mathworks.com,2005:Question/355695 2017-09-08T09:03:11Z 2019-08-24T11:46:46Z How to optimize a very large CO2 piping distribution network in matlab using optimization function in matlab? I have to optimize a large CO2 piping distribution network. CO2 is coming from a header and getting distributed into sub headers which supply CO2 to desired delivery points. There are no loops. I can optimize header pressure, header diameter, subheader diameters, delivery piping diameters to reduce overall costs. Diameters can only be from the standard table, meaning discrete values. I can also choose to have pressure reducing valves installed any where. How can i approach this problem? Which method is more appropriate? SUDHANSHU RAJ SINGH https://es.mathworks.com/matlabcentral/profile/authors/10496916-sudhanshu-raj-singh tag:es.mathworks.com,2005:Question/477414 2019-08-24T10:41:24Z 2019-08-24T11:38:13Z Sliding window centered at a given point Hi! I have a signal and I need to create a sliding window of known length (let's say x) but it needs to be centered at a given point (y). Can anyone help me? Thanks! Laura petrescu https://es.mathworks.com/matlabcentral/profile/authors/15435411-laura-petrescu tag:es.mathworks.com,2005:Question/477417 2019-08-24T11:36:22Z 2019-08-24T11:36:22Z Always have errors for image acquisition after 4 images acquired. I am using matlab to obtain images from 4 JAI CCD cameras(1 color, 2 mono, 1 uv). Matlab code sets exposure time to cameras with pulse generation and grab images by external trigger. However, for unknown reasons, after grabbing images 4 times, errors came up. I could find out that there was no trigger event log. Please provide me a piece of advice to solve this problem. Thank you inadvance. Here is the matlab code: clc; clear all; close all; prompt = {'Exposure_color (ms):','Exposure_UV (ms):'... ,'Exposure_BW1 (ms):','Exposure_BW2 (ms):'}; title = 'Exposure time'; dims = [1 35]; definput = {'25','12','5','5'}; answer = inputdlg(prompt,title,dims,definput); v_bw1 = videoinput('gige',3,'Mono8'); %ch.1~4 v_uv = videoinput('gige',4,'Mono8'); v_color = videoinput('gige',1,'BayerRG8'); v_bw2 = videoinput('gige',2,'Mono8'); s1 = v_bw1.Source; s2 = v_uv.Source; s3 = v_color.Source; v_color.ReturnedColorspace = 'grayscale'; s4 = v_bw2.Source; % Specify total number of frames to be acquired % One frame is acquired for each external signal pulse. numFrames = 1; % Enter the number of frame % BW1 s1.PulseGeneratorSelector = 'PulseGenerator1'; s1.PulseGeneratorClearActivation = 'RisingEdge'; s1.PulseGeneratorClearInverter = 'False'; s1.PulseGeneratorClearSource = 'Line5'; s1.PulseGeneratorClock = 0.446428571428571; %s1.PulseGeneratorFrequency = 0.500000080000013; % s1.PulseGeneratorLengthMs = 1.1*str2num(answer{3}); s1.PulseGeneratorLengthMs = 2000; s1.PulseGeneratorStartPoint = 1; s1.PulseGeneratorEndPointMs = str2num(answer{3}); % exposure time (ms) % UV s2.PulseGeneratorSelector = 'PulseGenerator1'; s2.PulseGeneratorClearActivation = 'RisingEdge'; s2.PulseGeneratorClearInverter = 'False'; s2.PulseGeneratorClearSource = 'Line5'; s2.PulseGeneratorClock = 0.446428571428571; %s2.PulseGeneratorFrequency = 0.500000080000013; % s2.PulseGeneratorLengthMs = 1.1*str2num(answer{2}); s2.PulseGeneratorLengthMs = 2000; s2.PulseGeneratorStartPoint = 1; s2.PulseGeneratorEndPointMs = str2num(answer{2}); % exposure time (ms) % Color s3.PulseGeneratorSelector = 'PulseGenerator1'; s3.PulseGeneratorClearActivation = 'RisingEdge'; s3.PulseGeneratorClearInverter = 'False'; s3.PulseGeneratorClearSource = 'Line5'; s3.PulseGeneratorClock = 0.446428571428571; %s3.PulseGeneratorFrequency = 0.500000080000013; %s3.PulseGeneratorLengthMs = 1.1*str2num(answer{1}); s3.PulseGeneratorLengthMs = 2000; s3.PulseGeneratorStartPoint = 1; s3.PulseGeneratorEndPointMs = str2num(answer{1}); % exposure time (ms) % BW2 s4.PulseGeneratorSelector = 'PulseGenerator1'; s4.PulseGeneratorClearActivation = 'RisingEdge'; s4.PulseGeneratorClearInverter = 'False'; s4.PulseGeneratorClearSource = 'Line5'; s4.PulseGeneratorClock = 0.446428571428571; %s4.PulseGeneratorFrequency = 0.500000080000013; % s4.PulseGeneratorLengthMs = 1.1*str2num(answer{4}); s4.PulseGeneratorLengthMs = 2000; s4.PulseGeneratorStartPoint = 1; s4.PulseGeneratorEndPointMs = str2num(answer{4}); % exposure time (ms) v_bw1.FramesPerTrigger = 1; v_uv.FramesPerTrigger = 1; v_color.FramesPerTrigger = 1; v_bw2.FramesPerTrigger = 1; v_bw1.TriggerRepeat = 0; v_uv.TriggerRepeat = 0; v_color.TriggerRepeat = 0; v_bw2.TriggerRepeat = 0; % Specify 'hardware' videoinput trigger type triggerconfig(v_bw1, 'hardware', 'DeviceSpecific', 'DeviceSpecific'); triggerconfig(v_uv, 'hardware', 'DeviceSpecific', 'DeviceSpecific'); triggerconfig(v_color, 'hardware', 'DeviceSpecific', 'DeviceSpecific'); triggerconfig(v_bw2, 'hardware', 'DeviceSpecific', 'DeviceSpecific'); s1.TriggerSelector = 'FrameStart'; s2.TriggerSelector = 'FrameStart'; s3.TriggerSelector = 'FrameStart'; s4.TriggerSelector = 'FrameStart'; s1.TriggerSource = 'PulseGenerator1'; s2.TriggerSource = 'PulseGenerator1'; s3.TriggerSource = 'PulseGenerator1'; s4.TriggerSource = 'PulseGenerator1'; s1.TriggerActivation = 'RisingEdge'; s2.TriggerActivation = 'RisingEdge'; s3.TriggerActivation = 'RisingEdge'; s4.TriggerActivation = 'RisingEdge'; s1.TriggerMode = 'on'; s2.TriggerMode = 'on'; s3.TriggerMode = 'on'; s4.TriggerMode = 'on'; s1.GainRaw = 336; s2.GainRaw = 336; s3.GainRaw = 100; s4.GainRaw = 336; % For exposure time control configure a TriggerWidth exposure mode s1.ExposureMode = 'TriggerWidth'; s2.ExposureMode = 'TriggerWidth'; s3.ExposureMode = 'TriggerWidth'; s4.ExposureMode = 'TriggerWidth'; answer = questdlg('Take a shot?','Take a shot','Shot','No','Shot');% Start hardware-triggered buffered continuous acquisition, and wait for % acquisition to complete start([v_bw1 v_uv v_color v_bw2]) wait([v_bw1 v_uv v_color v_bw2], 100) % wait(v_uv, 5) % wait(v_bw1, 5) % wait(v_bw2, 5) % Eventlog elog_color = v_color.EventLog; elog_uv = v_uv.EventLog; elog_bw1 = v_bw1.EventLog; elog_bw2 = v_bw2.EventLog; elog_bw1(1).Data elog_uv(1).Data elog_color(1).Data elog_bw2(1).Data elog_bw1(2).Data elog_uv(2).Data elog_color(2).Data elog_bw2(2).Data fn_color=mat2str(elog_color(2).Data.AbsTime); fn_uv=mat2str(elog_uv(2).Data.AbsTime); fn_bw1=mat2str(elog_bw1(2).Data.AbsTime); fn_bw2=mat2str(elog_bw2(2).Data.AbsTime); % Transfer acquired frames and timestamps from acquisition input buffer % into workspace data_color = getdata(v_color, v_color.FramesAvailable); data_uv = getdata(v_uv, v_uv.FramesAvailable); data_bw1 = getdata(v_bw1, v_bw1.FramesAvailable); data_bw2 = getdata(v_bw2, v_bw2.FramesAvailable); vid_bw1Image=imrotate(data_bw1,-90); % image processing vid_bw2Image=imrotate(data_bw2,90); vid_colorImage=imrotate(data_color,-90); vid_uvImage=imrotate(data_uv,90); % vid_colorImage = imadjust(vid_colorImage,[0 0 0;0.706 1 0.706],[]); vid_colorImage=demosaic(vid_colorImage, 'grbg'); DIRNAME1 = datestr(now,'yyyymmdd'); % create folders DIRNAME2 = datestr(now,'HHMMSS'); mkdir(DIRNAME1, DIRNAME2); pathname = ['C:\Users\admin\Documents\gyujin\code','\',DIRNAME1,'\',DIRNAME2,'\']; mkdir(pathname); imwrite(vid_bw1Image,[pathname,fn_bw1,'bw1.jpg']); % save images imwrite(vid_bw2Image,[pathname,fn_bw2, 'bw2.jpg']); imwrite(vid_uvImage,[pathname,fn_uv,'uv.jpg']); imwrite(vid_colorImage,[pathname,fn_color,'color.jpg']); subplot(2,2,1); imshow(vid_bw1Image); subplot(2,2,2); imshow(vid_bw2Image); subplot(2,2,3); imshow(vid_colorImage); subplot(2,2,4); imshow(vid_uvImage); delete(v_color); delete(v_uv); delete(v_bw1); delete(v_bw2); clear v_color; clear v_uv; clear v_bw1; clear v_bw2; Jungkeuk Park https://es.mathworks.com/matlabcentral/profile/authors/11085805-jungkeuk-park tag:es.mathworks.com,2005:Question/477410 2019-08-24T09:49:48Z 2019-08-24T11:35:50Z Sorting specific values of one matrix into another Hey there, so i got this problem where I have a dataset of "values" pointing to each other, as in this example: A=[1 2; 4 5; 5 6; 2 7; 7 3; 3 1; 6 4]; 1 -> 2 -> 7 -> 3 -> 1 Value 1 is associated with 2 and value 2 associated with 7 and so on, until I am back at value 1. Now I am trying to get only those values into another set of data like seen in matrix B. B=[1 2; 2 7; 7 3; 3 1]; So far I have tried out multiple things using for and while loops with the function "find" to locate the values I am looking for and trying to pick those out of Matrix A into B. Is there mybe an easiert way to accomplish this task? Thx in advance! xCuse https://es.mathworks.com/matlabcentral/profile/authors/11909708-xcuse tag:es.mathworks.com,2005:Question/106624 2013-11-18T15:54:01Z 2019-08-24T11:29:19Z Even and Odd parts Function that gives the even and the odd parts of any given signal zee https://es.mathworks.com/matlabcentral/profile/authors/4816588-zee tag:es.mathworks.com,2005:Question/477390 2019-08-24T02:18:53Z 2019-08-24T11:25:35Z how can replace randi instead randint? I need help ,please! long zhang https://es.mathworks.com/matlabcentral/profile/authors/14173845-long-zhang tag:es.mathworks.com,2005:Question/477332 2019-08-23T13:54:13Z 2019-08-24T11:20:15Z Using a Subroutine to Create a Plot I have the following subroutine which takes a point with radius 1 and then finds a velocity vector at that point. p = [0.282 0 0.959]'; %specify point where velocity is to be evaluated% [v]=StokesletVelocity(N,sing,p,Kn,f); function[v]=StokesletVelocity(N,sing,p,Kn,f) for i=1:N rij= (p - sing(1:3,i)); FF(1:3, 3*i-2:3*i) =((1/(8*pi*Kn))*((eye(3)/norm(rij)) + (rij*rij')/norm(rij)^3))'; %subroutine to find velocity at the point % end v=FF*f; end What I would like to do is plug in points to the subroutine with a range of radii going from 1 to 10 and get velocities for all of them. I was thinking of doing this in steps of 0.2 at a time, so the next p to plug into the subroutine would be [0.2*0.282 0 0.2*0.959] the next would be [0.4*0.282 0 0.4*0.959] and so on up until a radius of 10. This will produce an array of velocity vectors and I then need to find the radial component for each one and plot the radial component of each velocity vector against the corresponding value for the radius ie. the number which is mutliplying the numbers in the position vector for the point. Is it possible to use the subroutine I have to generate the array of velocity vectors and then plot radial component against radius in this way? Let me know if it is not clear what I mean. Tom https://es.mathworks.com/matlabcentral/profile/authors/13799312-tom tag:es.mathworks.com,2005:Question/477416 2019-08-24T11:17:08Z 2019-08-24T11:18:00Z So i wanted a dynamic way to read 3 files from these folders with extensions .w1 , .w2 and .hdr into variables. Shibu Clement https://es.mathworks.com/matlabcentral/profile/authors/6730761-shibu-clement tag:es.mathworks.com,2005:Question/477314 2019-08-23T11:12:17Z 2019-08-24T11:12:22Z How to fix: Index exceeds matrix dimensions Hi, I am new to matlab and am trying to write a function which produces the Fibonacci sequence of input n. I am required to write it in a way so that the program returns all Fibonacci numbers which are less than 3000, including the index of the highest term below 3000. However, I kept getting the error ( Index exceeds matrix dimensions ) at where the if loops is located. May i know how I can change it to make it work? function y=fibonacci(n) y(1)=1; y(2)=1; for i=3:n y(i) = y(i-1)+y(i-2); i=i+1; %#ok<*FXSET> if y(i) > 3000 disp(i-1); break end end Chun Yong Koh https://es.mathworks.com/matlabcentral/profile/authors/12228400-chun-yong-koh tag:es.mathworks.com,2005:Question/477415 2019-08-24T10:42:39Z 2019-08-24T11:08:12Z I have finished with my programming about making a script file could anybody help me fix the command? This is the command I could think of. Could anybody help me I'm really confused about the question. I don't know how to answer but this is the command i have got until now. for vector = 1:5 vector = rand(1,6) end Look Mai https://es.mathworks.com/matlabcentral/profile/authors/15934490-look-mai tag:es.mathworks.com,2005:Question/477411 2019-08-24T09:57:12Z 2019-08-24T10:53:50Z Index in position 2 exceeds array bounds (must not exceed 3). %% l2/l1=1 N=1; %revolution per minute theta=28 %dynamic angle of glass beads w=2*pi*N/60; % angular velocity D=.5; %drum radius R=D/2; %drum diameter g=9.81; %gravity l1=.05; %radial length in flight a=0:.5:1; l2=a.*l1; %l2=.05; %tangential length in flight beta=atand(l2./l1); flight_length_ratio=l2./l1; rh=R-l1; %distance from the centre to the radial length meu=tand(theta);%friction of coefficient alpha=atand(l2./rh); %flight angle %% froude= .0011; %foude number delta=-90:30:270; %discharge angle e=0; f=0; for u=1:length(a) e=e+1; for v=1:length(delta) f=f+1; nominator(e,f)=meu*cosd(alpha(e,f))+froude*rh/R*(cosd(delta(e,f))-meu*sind(delta(e,f))); end end nominator_1(1,f)=nominator(e,f); Error in filling_degree_try (line 28) nominator(e,f)=meu*cosd(alpha(e,f))+froude*rh/R*(cosd(delta(e,f))-meu*sind(delta(e,f))); I can't figure it out the error. plz help me to figure it out. Kashfia Mahin https://es.mathworks.com/matlabcentral/profile/authors/13150227-kashfia-mahin tag:es.mathworks.com,2005:Question/477407 2019-08-24T08:28:19Z 2019-08-24T10:53:39Z How to get the longest consecutive values in a column vector and the position at which it starts Hello, Suppose i have a single column vector A'=[0 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1] I only want the longest consecutive values of 1's and display only that. I'd really appreciate any help! Meghana Balasubramanian https://es.mathworks.com/matlabcentral/profile/authors/9170421-meghana-balasubramanian tag:es.mathworks.com,2005:Question/445628 2019-02-18T17:38:48Z 2019-08-24T10:48:59Z Spatial smoothing - 2D MUSIC [FMCW MIMO radar processing] Hi everyone, I'm using a 2D Music algorithm for the estimation of Range-Azimuth info in a ULA FMCW MIMO radar. The algorithm procedure is pretty simple (see "Belfiori F., Application of 2D MUSIC Algorithm to Range-Azimuth FMCW Radar data" or " Manokhin G., MUSIC-based algorithm for range-azimuth FMCW radar data processing without estimating number of targets"). I have some doubt with regard the application of the 2D FB spatial smoothing in order to decorrelate the covariance matrix of the data; I'm wondering if I do some error in the following code section (in the way I order the x_win_new vector): x= DataV'; %Data collected by the ULA (31 Spatial samples-31Antennas), 501 time samples N = size(x,1); % Number of antennas M = size(x,2); % Number of samples in fast-time dimension % window dimension for the smoothing dim[m1xm2] m1 = 25; m2 = 300; p1 = N-m1+1; %positions in the spatial dimension p2 = M-m2+1; %positions in the time dimension N_submat = p1*p2; %number of all the possible scan M_tot = m1*m2; ind_tot=1; for p1_ind = 1:p1 for p2_ind = 1:p2 x_win_new(:,ind_tot) = reshape (x(p1_ind:m1+(p1_ind-1),p2_ind:m2+(p2_ind-1)),[1,M_tot])'; ind_tot=ind_tot+1; end end X_win_cor = x_win_new*x_win_new'; X_win_cor_conj = conj(X_win_cor); J= fliplr(eye(M_tot)); %transition matrix C=(1/2*N_submat)*(X_win_cor + J*X_win_cor_conj*J); %data smoothed covariance matrix (forward+backward) so in my case I'm scanning the full 2D [NxM] matrix in this way: x x x . . x x x . . . . . . . . x x x . . x x x x x x . . x x x x x x . . x x x x x x . . x x x . . . . . . . . x x x . . x x x If I select m1=M and m2=N (so no spatial smoothing, only forward/backward averaging) I get good results as shown in the attached image. Thanks a lot in advance, Best regards, Luca, Luca Romano https://es.mathworks.com/matlabcentral/profile/authors/7358657-luca-romano tag:es.mathworks.com,2005:Question/477400 2019-08-24T06:00:00Z 2019-08-24T10:48:17Z two errors : "MEX compiler error" and "Index exceeds the number of array elements" Hi all, I am using GPU coder and having problems. This is my full script. clear all %% inputs load mq % I attached it. disp('Weights were loaded') %% Answer tic; output_accu=Main2_4_fun(countMax,H1,H2,H3,H4,B1,B2,B3,B4,obsRad,obsCenterX,obsCenterY,minmax,freq_min ); toc; I tried to make the function "Main2_4_fun" as a MEX file using GPU coder app. function output_accu_cpu=Main2_4_fun(countMax,H1,H2,H3,H4,B1,B2,B3,B4,obsRad,obsCenterX,obsCenterY,minmax,freq_min ) output_accu = zeros(countMax,1); minX= minmax(1); maxX= minmax(2); minY= minmax(3); maxY= minmax(4); obsRad_norm = obsRad; % inputs for Main2_4_fun obsCenterX_log = (obsCenterX - minX) / (maxX - minX);% inputs for Main2_4_fun obsCenterY_log = (obsCenterY - minY) / (maxY - minY);% inputs for Main2_4_fun for caseCount=0:countMax-1 %computing changing input freq_log. freq_log = log(caseCount + freq_min); X = transpose([obsRad_norm, obsCenterX_log, obsCenterY_log, freq_log]) ; %% computing output_accu(caseCount+1) = transpose(H4{caseCount+1})*max(0,transpose(H3{caseCount+1})*max(0,transpose(H2{caseCount+1})*max(0,transpose(H1{caseCount+1})*X+B1{caseCount+1})+B2{caseCount+1})+B3{caseCount+1})+B4{caseCount+1}; end output_accu_cpu=output_accu; end and I got this error message in the run-time issue check step of MEX file build stage. ??? Unable to determine MEX compiler: use mex -setup to configure your system. Compilation failed. Index exceeds the number of array elements (196). Use help codegen for more information on using this command. Index exceeds the number of array elements (196). My version is 2019a, windows 10. Question 1: I have installed MinGW-w64 C/C++ Compiler. (https://kr.mathworks.com/matlabcentral/fileexchange/52848-matlab-support-for-mingw-w64-c-c-compiler) But why I got " Unable to determine MEX compiler: " error? (I also installed Microsoft visual studio 2019, by this two pages. but errors are still not solved. https://kr.mathworks.com/support/requirements/supported-compilers.html#n11 https://kr.mathworks.com/help/gpucoder/gs/install-prerequisites.html#mw_aa8b0a39-45ea-4295-b244-52d6e6907bff ) Quesiton 2: I started using GPU coder after confirming that my code and function work well. But why I have "exceeds the number of array elements" error? I was doing this process even with the same workspace with code execution. nuri ahn https://es.mathworks.com/matlabcentral/profile/authors/12376053-nuri-ahn tag:es.mathworks.com,2005:Question/476590 2019-08-18T14:49:22Z 2019-08-24T10:47:14Z ERROR came as "Index exceeds matrix dimensions". %% When I incorporate 3 eqns, ERROR came as "Index exceeds matrix dimensions". %%Here I have initial condition f=[0 0 0 ], BC: gl=[coswt t t], gr =[0 0 0 ]. What next? Here is my trial: H=10;R=5;Pr=1;G1=5;G2=5;Kc=1;Sc=0.22;wt=pi/2;Q=H-(R/Pr); xl=0; xr=5; % x domain [xl,xr] J = 10; % J: number of division for x dx = (xr-xl)/ J; % dx: mesh size tf = 01; % final simulation time Nt = 100; % Nt: number of time steps dt = tf/Nt; mu = dt/(dx)^2; % Evaluate the initial conditions x = xl : dx : xr; % generate the grid point % f(1:J+1) since array index starts from 1 f1 = 0;f2 = 0;f3 = 0; %%%I.C % store the solution at all grid points for all time steps u = zeros(J+1,Nt); v = zeros(J+1,Nt); w = zeros(J+1,Nt); U=[u; v; w]; % Find the approximate solution at each time step for n = 1:Nt t = n*dt; % current time % boundary condition at left side gl = [cos(wt); t; t]; % boundary condition at right side gr = [0; 0; 0]; if n==1 % first time step for j=2:J % interior nodes u(j,n) = (1+dt*Q)*f1(j) + dt*(G1*f2(j)+G2*f3(j))+mu*(f1(j+1)-2*f1(j)+f1(j-1)); v(j,n) = (1+dt*Q)*f2(j) + (mu/Pr)*(f2(j+1)-2*f2(j)+f2(j-1)); w(j,n) = (1-dt*Kc)*f3(j) + (mu/Sc)*(f3(j+1)-2*f3(j)+f3(j-1)); U=[u(j,n) v(j,n) w(j,n)]; end U(1,n) = gl; % the left-end point U(J+1,n) = gr; % the right-end point else for j=2:J % interior nodes u(j,n)= (1+dt*Q)*u(j,n-1)+ dt*(G1*v(j,n-1)+G2*w(j,n-1))+ mu*(u(j+1,n-1)-2*u(j,n-1)+u(j-1,n-1)); v(j,n)= (1+dt*Q)*v(j,n-1)+ (mu/Pr)*(v(j+1,n-1)-2*v(j,n-1)+v(j-1,n-1)); w(j,n)= (1+dt*Q)*w(j,n-1)+ (mu/Sc)*(w(j+1,n-1)-2*w(j,n-1)+w(j-1,n-1)); U=[u(j,n) v(j,n) w(j,n)]; end U(1,n) = gl; % the left-end point U(J+1,n) = gr; % the right-end point end end % Plot the results tt = dt : dt : Nt*dt; figure(1) plot(x,u) hold on MINATI PATRA https://es.mathworks.com/matlabcentral/profile/authors/12692023-minati-patra tag:es.mathworks.com,2005:Question/477409 2019-08-24T09:08:01Z 2019-08-24T10:46:27Z Could any body check my work? (Plot the function) x = [-56:64]; y = [3.*x^2-5.*x-6]; plot(x,y,'--r','LineWidth',0.5) xlabel('e') ylabel('n') title('kg') Is this the proper answer for the question? Is there anything I should change for it to become the correct answer? Look Mai https://es.mathworks.com/matlabcentral/profile/authors/15934490-look-mai tag:es.mathworks.com,2005:Question/477413 2019-08-24T10:37:07Z 2019-08-24T10:37:07Z Convert Trained neural network to Arduino sketch i trained a pattern recognition neural netwrork in matlab and i wanna convert : Trained pattern recognition neural network to arduino sketch and compile it on my Arduino board to recognize signals from each others how to do it ? i also installed arduino hardware package for my matlab software. hamid salehi https://es.mathworks.com/matlabcentral/profile/authors/16002594-hamid-salehi tag:es.mathworks.com,2005:Question/477406 2019-08-24T08:21:40Z 2019-08-24T10:36:30Z LSQCURVEFIT for transfer function frequency response magnitude and phase curve fitting Hi all, can somebody please help me to find out transfer function time constants from LSQCURVEFIT function for identifying the transfer function through curvefitting the data available. Avaiable data frequency points (xdata) Magnitude and phase data(ydata) tau1Omega to tau6Omega are time constants required to be find out. current code is attached below, i'm encountering error ---------------------------------------------------------------------------------------------- Error using lsqcurvefit (line 251) Function value and YDATA sizes are not equal. Error in Untitled (line 32) e = lsqcurvefit(ObjFun01,var01,xdata,ydata2,lb,ub); ------------------------------------------------------------------------------------------------- cnst11 = 0.002777; lb = [0 0 0 0 0 0 0 0]; ub = [10 10 10 10 10 10 10 10]; var01 = [0 0 0 0 0 0 0 0]; xdata = load('xdata.txt'); ydata = load('ydata_in_magnitude_phase_form.txt'); ydata1 = ydata(1:1:end,:); ydata1(:,1) = ydata(:,1) ; %Load frequency ydata1(:,2) = ydata(:,2) ; %Load magnitude ydata1(:,3) = ydata(:,3) ; %Load frequency ydata1(:,4) = ydata(:,4) ; %Load phase ydata1(:,5) = 1; % weights ydata2 = ydata1(:,2).*exp(1i.*ydata1(:,4)); %converting to complex number form tau1Omga = var01(1,1) ; tau2Omga = var01(1,2) ; tau3Omga = var01(1,3) ; tau4Omga = var01(1,4) ; tau5Omga = var01(1,5) ; tau6Omga = var01(1,6) ; tau7Omga = var01(1,7) ; tau8Omga = var01(1,8) ; ObjFun01 = @(x,xdata)cnst11*((1+ tau1Omga*1i*x).*(1+ tau2Omga*1i*x).*(1+ tau3Omga*1i*x))./ ( (1+ tau4Omga*1i*x).*(1+ tau5Omga*1i*x).*(1+ tau6Omga*1i*x) ); e = lsqcurvefit(ObjFun01,var01,xdata,ydata2,lb,ub); any help in this regard would be greatly appreciated. PRAKASH G https://es.mathworks.com/matlabcentral/profile/authors/3967053-prakash-g tag:es.mathworks.com,2005:Question/475421 2019-08-08T14:27:37Z 2019-08-24T10:25:31Z how to totally match two images from heterogeneous stereo cameras. I set up a stereo cameras, one for color image and another for UV image. Due to the difficultiness to find lenses with same intrinsic parameters for both cameras. I used stereo camera calibration app and rectified both images. But checkerboard didn't totally match. It seems vertical grid was almost matched but horizontal grid was not matched(left image). For the next step, I translated UV image(magenta) using translation parameter obtained from the stereo calibration. It's been partially successful(right image). Here're my questions. 1) How does rectify fuction works? why does it seems to match images' vertial grid? 2) Is it correct procedure to rectify images; stereo calibration -> rectify both images -> translate? 3) When I use 'imtranslate' function, how can I estmate the pixel translation? Looking up reprojectedpoints data does't seem to be easy and clear way. Thank you for your answer in advance. Jungkeuk Park https://es.mathworks.com/matlabcentral/profile/authors/11085805-jungkeuk-park tag:es.mathworks.com,2005:Question/477370 2019-08-23T20:38:47Z 2019-08-24T10:24:36Z Why do i get this Warning: Warning: Solution does not exist because the system is inconsistent. clc clear x = [3.121 5.020 5.100 6.115 13.20 -0.250; 1.010 0.584 0.100 4.580 -5.650 6.100]; u = [0 -1 1 -2 -3 -1]; syms a11 a12 a21 a22 b1 b2 ; A = [a11 a12 ; a21 a22]; B = [b1;b2]; A1 = [x(:,1:5)' u(:,1:5)']; X = [A';B']; b = [x(1,2:6)']; m = A1'*A1*X==A1'*b; [C,Z] = equationsToMatrix([m(1,1), m(2,1), m(3,1)], [a11 ,a12 ,b1 ]) Sol=linsolve(C,Z); [C,Z] = equationsToMatrix([m(1,2), m(2,2), m(3,2)], [a21 ,a22 ,b2 ]); Sol=linsolve(C,Z); when the compiler gets to Sol=linsolve(C,Z); gives me the warning and not giving me the right answer What is the problem and a second question how to solve 2 equasions with 2 unknowns, i'm using [C,Z] = equationsToMatrix([m(1,1), m(2,1), m(3,1)], [a11 ,a12 ,b1 ]) and Linsolve to solve them but is there any other way? Rebal Kahwaji https://es.mathworks.com/matlabcentral/profile/authors/15982851-rebal-kahwaji tag:es.mathworks.com,2005:Question/477376 2019-08-23T22:16:15Z 2019-08-24T10:22:21Z Help in creating function , built in equation Hi All, I am trying to build in function, including equation which is a result of another code, I understand function is a separate script but I just need to do something smart, no to add the equation in every time , below is the code: clear all; clc; syms x y; an=solve(-15== 10*x+2*y,y); ap=solve(10*x+2*y ==20,y); yin=[an,ap] damontwo % Name of the function %% function function damontwo(x) x=input('please enter number ') yin(:,1)=input('Enter equation to solve ') end When I type an: I got an error ?, however, when I type equation, it works, so could anyone please help me, how could I introduce that to the function ? Thanks, Ali Tawfik https://es.mathworks.com/matlabcentral/profile/authors/13520758-ali-tawfik tag:es.mathworks.com,2005:Question/477412 2019-08-24T10:00:58Z 2019-08-24T10:00:58Z How to create a 4 layer MLP Neural Network with ReLU activation function for Regression Hello every one. I wan to create a multi-layer feed-forward neural network with ReLU activation function. In other word I want to create a 4 hidden layer MLP Neural Network with 512 neurons in each hidden layer assuming all layers are of the same size with ReLU activation function. I have 3000*28 Inputs and 3000*1 Target. I want to split the Data-set to 75% for training and 25% for testing and a min–max normalization between 0 and 1 to ease the network training. and I want to initialize the weight matrices Wij with a uniform distribution given as where n is the total number of input and output neurons at the layer (assuming all layers are of the same size). and I want to do layer Normalization as follows: I want to train the network via gradient descent with mean square error (MSE) as loss function and I want to use Adam optimizer with initial learning rate of 0.005 and batch size of 500. and I want to do a comparison between results of Network with applying DropOut to the last hidden layer by randomly removing 50% of the neurons in that layer and without DropOut. and at the end I want to get plot of R-squared, RMSE, MAE and MAPE at each epochs like these plots: Could you please help me with this (how to make my code)? Any comments will be greatlly appreciated. I really have no idea how to implement this? Best regards. mr mo https://es.mathworks.com/matlabcentral/profile/authors/7695076-mr-mo tag:es.mathworks.com,2005:Question/477330 2019-08-23T13:35:25Z 2019-08-24T09:54:33Z How can be generated aperiodic triangle carrier signal for PWM I would like to generate triangle signal starts from 0 degree and stops at 60 degree and then starts at 120 degree and stops at 180 degree for half cycle sine wave reference, and then it is repeat itself. If possible by coding or simulink. The attached picture would explain the required triangle wave. ali al-khayyat https://es.mathworks.com/matlabcentral/profile/authors/4439916-ali-al-khayyat tag:es.mathworks.com,2005:Question/477331 2019-08-23T13:45:49Z 2019-08-24T09:51:37Z How to simulate AM/AM and AM/PM distortion in MATLAB if I know the values of elements of the RF-PA? I have been given a designed Class-E RF-PA - meaning, the technology used for the MOSFET, the inductor and capacitor values attached to the MOSFET. I am suppossed to find the AM/AM and AM/PM distortion graphs using this information using MATLAB. I searched on the internet, and I could find memory polynomial block of the RF-PA in RF-Blockset. But, I do not know how to implement my model using this available block. Is there a better way to do this? Later on, I also want to implement the DPD and memory effect - which I figured out how to do. But, I do not know how to get started. Awani Khodkumbhe https://es.mathworks.com/matlabcentral/profile/authors/15988395-awani-khodkumbhe tag:es.mathworks.com,2005:Question/477395 2019-08-24T04:37:12Z 2019-08-24T09:31:25Z I want the code to randomize the rows and present each row for 10 times I want the code to randomize the rows and present the stimulus by taking the each row values for 10 times. Here is the code that I have written. Decentration = [0, 0.5; 0, 0; 0, -0.5; -0.5,0; 0.5, 0]; trial = 10; for i = 1:trial; for iter= 1:length(Decentration); Decentration = Shuffle(Decentration, 2); XDecentration = Decentration(:,1); YDecentration = Decentration(:,2); this presents the stimulus for 50 times but in a different proportion. Please suggest a code for presenting each row of Decentation to be selected 10 times. bhagya lakshmi https://es.mathworks.com/matlabcentral/profile/authors/9168541-bhagya-lakshmi tag:es.mathworks.com,2005:Question/477408 2019-08-24T08:58:19Z 2019-08-24T08:58:19Z I want to recognize only the handwriting numbers (blue color). I attached my code, it can only recognize the printed numbers. I used Mnist database to recognize them. How to recognize only the handwriting numbers? clear all clc load('MnistConv.mat'); I = imread('testnumber3.jpg'); % flipImage=flip(I,2); % rotate=imrotate(flipImage,180); image(I) % Convert to grayscale image Igray = double(rgb2gray(I)); % Convert to binary image Ibw1 = im2bw(Igray,graythresh(Igray)); Ibw=(256-Igray)/256; % Ibw = im2bw(Igray,graythresh(Igray)); % Edge detection Iedge = edge(Ibw,'Roberts'); % Morphology % * *Image Dilation* se = strel('square',2); Iedge2 = imdilate(Iedge, se); % * *Image Filling* Ifill= imfill(Iedge2,'holes'); [Ilabel num] = bwlabel(Ifill); disp(num); Iprops = regionprops(Ilabel); Ibox = [Iprops.BoundingBox]; Ibox = reshape(Ibox,[4 num]); % Plot the Object Location hold on; for cnt = 1:num kotak=rectangle('position',Ibox(:,cnt),'edgecolor','r'); crop=imcrop(Ibw,Ibox(:,cnt)); % Resizing imgLGE = imresize(crop, 5, 'bicubic'); X = abs(imresize(imgLGE, [28 28])); for i=1:28 for j=1:28 if X(i,j)<0. X(i,j)=0; elseif X(i,j)>0.5 X(i,j)=X(i,j)+0; end end end k=1; x = X(:, :, k); % Input, 28x28 y1 = Conv(x, W1); % Convolution, 20x20x20 y2 = ReLU(y1); % y3 = Pool(y2); % Pool, 10x10x20 y4 = reshape(y3, [], 1); % 2000 v5 = W5*y4; % ReLU, 360 y5 = ReLU(v5); % v = Wo*y5; % Softmax, 10 y(:,cnt) = Softmax(v); % end [max,result]=max(y); DONY DARMAWAN PUTRA https://es.mathworks.com/matlabcentral/profile/authors/10115029-dony-darmawan-putra tag:es.mathworks.com,2005:Question/352421 2017-08-11T10:58:51Z 2019-08-24T08:20:59Z plot hold on in GUI I am new to matlab and need a bit of help with a gui. I have two axes boxes (axes2 and axes3) where I use checkmarks to plot within. First checkbox creates two plots: one (x1,y1) in axes2 and the second (x1,ht) in axes3. The second checkbox also creates two plots: one(x2,y2) in axes2 and the second (x2,ht2) in axes3. I want to Hold on to the figures, so if I select both checkmarks both axes2 and axes3 will contain two plots. However, only axes2 work. In axes3 only show the plot connected to the last selected chechmark. Please help. The code is below: function checkbox1_Callback(hObject, eventdata, handles) if get(handles.checkbox1,'Value') hold on; handles.hCbox1Plot = plot(x1,y1,'LineWidth',2,'Color', [0 0 0],'parent',handles.axes2); hold on; handles.hCbox2Plot = plot(x1,ht,'LineWidth',2,'Color', [0 0 0],'parent',handles.axes3); guidata(hObject,handles); % do this to save the updated handles structure else if ~isempty(handles.hCbox1Plot); ~isempty(handles.hCbox2Plot); delete(handles.hCbox1Plot); delete(handles.hCbox2Plot); end end function checkbox2_Callback(hObject, eventdata, handles) if get(handles.checkbox2,'Value') hold on; handles.hCbox3Plot = plot(x2,y2,'LineWidth',2,'Color', [1 0 0],'parent',handles.axes2); hold on; handles.hCbox4Plot = plot(x2,ht2,'LineWidth',2,'Color', [1 0 0],'parent',handles.axes3); guidata(hObject,handles); % do this to save the updated handles structure else if ~isempty(handles.hCbox3Plot); ~isempty(handles.hCbox4Plot); delete(handles.hCbox3Plot); delete(handles.hCbox4Plot); end end JB https://es.mathworks.com/matlabcentral/profile/authors/4745460-jb tag:es.mathworks.com,2005:Question/477402 2019-08-24T07:10:06Z 2019-08-24T08:19:17Z How do you do a ttest for two data sets; Temperature and Carbon Monoxide with the same number of data? Temp = [28, 26, 30, 31, 28, 32]; CO = [82, 90, 91, 92, 85, 87]; Years = [2004, 2005, 2006, 2007, 2008, 2009]; Jose Rojas https://es.mathworks.com/matlabcentral/profile/authors/13754005-jose-rojas tag:es.mathworks.com,2005:Question/477373 2019-08-23T21:24:37Z 2019-08-24T08:12:12Z how to plot a function on each axis in matlab? Dear All, I've been having difficulty with this one. All the examples refer to making a meshgrid with x, y , then those last two gets mapped onto the function z(x,y) however I want to do something totally different. I'd like to plot each function 1st Axis X: 1st function g(t,u) where t on [0 : tstep: 10] , u = [-10: ustep : 10] ; % do we just do a meshgrid for those two ranges first off? 2nd Axis Y: 2nd function log10(g(t,u)) for log defined on [-1 :logstep: 1] 3rd Axis Z: time progression t from [0 : tstep: 10] I need to study the function g(t,u) in respect of its Log10 as time progresses, hopefully it would make more sense with the following pseudo code: define g(t,u) on [-10:gstep:10] , t on [0 : tstep: 10] , u = [-10: ustep : 10] ; define log10(g(t,u)) on [-1 :logstep: 1] define t on [0 : tstep: 10] plot3D ( g(t,u) , log10(g(t,u)) , t) ; % that's the Target End Result Ahmad Ahmatto https://es.mathworks.com/matlabcentral/profile/authors/9410720-ahmad-ahmatto tag:es.mathworks.com,2005:Question/477405 2019-08-24T08:10:33Z 2019-08-24T08:10:33Z Noise Power for the Band limited white Noise Block Hey everyone. I´m useing a band limited white noise block in my system, but I didn´t get a clue about how to interpret the Noise Power parameter. I have done already a research about the theory behind it, but there a still some open points. -) What is the Unit of the Noise Power ? -) How can it be interpreted? I appreciate your HELP Helmut Schlagnitweit https://es.mathworks.com/matlabcentral/profile/authors/14288151-helmut-schlagnitweit tag:es.mathworks.com,2005:Question/477404 2019-08-24T07:44:23Z 2019-08-24T07:51:35Z How can i use the ceil function rightly? i notice that the ceil function does not work right on some value and i do not know why for example:i used ceil(2.7/0.3) and it results 10 but the right result must be 9 However,when i tried another value,e.g ceil(2.4/0.3),it results 8 which is right this function also work wrong on some another values,like ceil(2.1/0.3),ceil (4.2/0.3) Thank you Chau Phong https://es.mathworks.com/matlabcentral/profile/authors/15770056-chau-phong tag:es.mathworks.com,2005:Question/460424 2019-05-06T01:40:47Z 2019-08-24T07:35:25Z Can I use Student MATLAB edition after finishing course? Hi, I'm currently a student at university interested in purchasing MATLAB and relevant toolboxes. My question is once I complete my course will I still have access to MATLAB and any purchased toolboxes or will I have to repurchase the home edition? Michael Hart https://es.mathworks.com/matlabcentral/profile/authors/6730082-michael-hart tag:es.mathworks.com,2005:Question/477403 2019-08-24T07:24:33Z 2019-08-24T07:24:33Z How to predict multiple time series data using deep learning My dataset (18000 * 7 ) consists of air quality parameters. The parameters are PM10 concentration, wind speed, wind direction,temp, pressure, humidity, solar radiation. I want to predict the future pm10 concentration. I tried with the code available, but i cannot use it. please help me with the code data=xlsread('pollutant.xlsx') data=data'; dataTrainStandardized = (dataTrain - mu) / sig; XTrain = dataTrainStandardized(1:end-1); YTrain = dataTrainStandardized(2:end); numFeatures = 6; numResponses = 1; numHiddenUnits = 200; numTimeStepsTrain = floor(0.8*numel(data)); dataTrain = data(1:numTimeStepsTrain+1); dataTest = data(numTimeStepsTrain+1:end); mu = mean(dataTrain); sig = std(dataTrain); layers = [ ... sequenceInputLayer(numFeatures) lstmLayer(numHiddenUnits) fullyConnectedLayer(numResponses) regressionLayer]; options = trainingOptions('adam', ... 'MaxEpochs',250, ... 'GradientThreshold',1, ... 'InitialLearnRate',0.005, ... 'LearnRateSchedule','piecewise', ... 'LearnRateDropPeriod',125, ... 'LearnRateDropFactor',0.2, ... 'Verbose',0, ... 'Plots','training-progress'); dataTestStandardized = (dataTest - mu) / sig; XTest = dataTestStandardized(1:end-1); net = predictAndUpdateState(net,XTrain); [net,YPred] = predictAndUpdateState(net,YTrain(end)); numTimeStepsTest = numel(XTest); for i = 2:numTimeStepsTest [net,YPred(:,i)] = predictAndUpdateState(net,YPred(:,i-1),'ExecutionEnvironment','cpu'); end YPred = sig*YPred + mu; YTest = dataTest(2:end); rmse = sqrt(mean((YPred-YTest).^2)) figure plot(dataTrain(1:end-1)) hold on idx = numTimeStepsTrain:(numTimeStepsTrain+numTimeStepsTest); plot(idx,[data(numTimeStepsTrain) YPred],'.-') hold off xlabel("Hour") ylabel("Pm10 hourly concentration") title("Forecast") legend(["Observed" "Forecast"]) Athira t https://es.mathworks.com/matlabcentral/profile/authors/14821400-athira-t tag:es.mathworks.com,2005:Question/219792 2015-05-27T20:48:16Z 2019-08-24T07:23:03Z Is it recommended to install all of the toolboxes in Matlab ~15GB? Hi All, I'm install Matlab for the first time. When it comes to customize what toolboxes to install, I'm not very sure which ones could be leave out. I was wondering if it is a huge burden to install them all. Thanks for any insights. Xueling https://es.mathworks.com/matlabcentral/profile/authors/3654131-xueling tag:es.mathworks.com,2005:Question/476988 2019-08-21T09:12:41Z 2019-08-24T07:21:03Z How to calculate power consumption of a function running on MATLAB? I want to calculate amount of energy consumption/power consumption of a function. Prachetha K SOC CSE https://es.mathworks.com/matlabcentral/profile/authors/14114787-prachetha-k-soc-cse tag:es.mathworks.com,2005:Question/472234 2019-07-17T20:50:52Z 2019-08-24T07:04:39Z How can I extract the frame around the windows? Hello, I need to extract the frame on the wall around the window. How can I do that? I have tried with edge detection and binarization, but I have got always a different result. There are images, where even the edges are not recognizable. But, there are images full with different edges where I can not eliminate the redundant components. I hope someone can help me. Thank you. L https://es.mathworks.com/matlabcentral/profile/authors/3290037-l tag:es.mathworks.com,2005:Question/49984 2012-10-05T11:36:53Z 2019-08-24T06:51:46Z How to remove dependent rows in a matrix? Let A be an m by n matrix whose rows are linearly dependent. I want to remove rows from A such that the rank does not decrease. How can I find such rows of A? Kees Roos https://es.mathworks.com/matlabcentral/profile/authors/978175-kees-roos tag:es.mathworks.com,2005:Question/477386 2019-08-24T00:30:41Z 2019-08-24T06:37:28Z I want to smooth the boarder of all white areas in this Binary Image (even the tiny ones). Consider it like smoothing with your hand. Muhammad Saafan https://es.mathworks.com/matlabcentral/profile/authors/15262815-muhammad-saafan tag:es.mathworks.com,2005:Question/477399 2019-08-24T05:52:58Z 2019-08-24T06:23:57Z quenstion about uiload in matlab i come cross this file online and i dont understand what is "uiload" use for in this situation can anybody explain this pls? and what kind of file should it be? clear %Load vector for coils with three separate components: x, y and z uiload clc vector=[x,y,z]; %Define range of computation maxx=1.01.*max(x); minx=1.01.*min(x); maxy=1.01.*max(y); miny=1.01.*min(y); maxz=1.01.*max(z); minz=1.01.*min(z); %define number of divisions between min and max range pts=input('Define number of divisions of grid:'); %Define Vertical position of horizontal plane for evaluation, center=0. zplane=input('Define Z-Plane on which to compute: (numeric) '); %The next block of code generates an array of computation points stepx=(maxx-minx)/pts; stepy=(maxy-miny)/pts; stepz=(maxz-minz)/pts; for p=0:pts ex(p+1)=minx+stepx.*p; ey(p+1)=miny+stepy.*p; ez(p+1)=minz+stepz.*p; end yrow=ey; zrow=ez; vectcomp=[]; for q=0:pts yrow(q+1,:)=ey(q+1); zrow(q+1,:)=ez(q+1); vect=[ex;yrow(q+1,:)]; vectcomp=[vectcomp,vect]; end zrow=vectcomp(1,:); for q=0:pts zrow(q+1,:)=ez(q+1); end vectcomp2=[]; for q=0:pts vect2=[vectcomp(1,:);vectcomp(2,:);zrow(q+1,:)]; vectcomp2=[vectcomp2,vect2]; end %End of computational array generation x0=vectcomp2(1,:); y0=vectcomp2(2,:); z0=zplane; I=input('I=? '); mu=4*pi*10^(-7); AllBi=[]; AllBj=[]; AllBk=[]; %The next block of code computes the magnetic field contribution of each %segment of wire defined by the input vectors at line 3. This computation %is carried out for each point in the array of computation. for q1=1:numel(zrow)-1 l=length(x)-1; for n=1:l sx(n)=x(n)-x(n+1); sy(n)=y(n)-y(n+1); sz(n)=z(n)-z(n+1); rx(n)=x(n)-x0(q1); ry(n)=y(n)-y0(q1); rz(n)=z(n)-z0; end s_cross_r_i=sy.*rz-ry.*sz; s_cross_r_j=-(sx.*rz-rx.*sz); s_cross_r_k=sx.*ry-rx.*sy; mag_r_squared=rx.^2+ry.^2+rz.^2; scri_divrsq=s_cross_r_i./mag_r_squared; scrj_divrsq=s_cross_r_j./mag_r_squared; scrk_divrsq=s_cross_r_k./mag_r_squared; i_all=transpose(scri_divrsq); j_all=transpose(scrj_divrsq); k_all=transpose(scrk_divrsq); i=sum(i_all); j=sum(j_all); k=sum(k_all); Bi=mu.*I./4./pi.*i; Bj=mu.*I./4./pi.*j; Bk=mu.*I./4./pi.*k; AllBi=[AllBi,Bi]; AllBj=[AllBj,Bj]; AllBk=[AllBk,Bk]; end %End of Biot-Savart Computations magB=sqrt(AllBi.^2+AllBj.^2+AllBk.^2); en=0; st=0; magBT=[]; %The next block of code generates matricies for plotting each of the %magnetic field components with the mesh function. for g=0:pts st=g*(pts+1)+1; en=en+pts+1; magBT=[magBT;magB(st:en)]; end en=0; st=0; magBi=[]; for g=0:pts st=g*(pts+1)+1; en=en+pts+1; magBi=[magBi;AllBi(st:en)]; end en=0; st=0; magBj=[]; for g=0:pts st=g*(pts+1)+1; en=en+pts+1; magBj=[magBj;AllBj(st:en)]; end en=0; st=0; magBk=[]; for g=0:pts st=g*(pts+1)+1; en=en+pts+1; st=g*(pts+1)+1; en=en+pts+1; magBk=[magBk;AllBk(st:en)]; end %Shrink size of z so coils can be super-imposed onto graphs zshrink=z.*(10^(-4)).*2; %Generate Summary plot Window with Magnitude, and 3 components of field subplot(2,2,1); meshc(ex,ey,magBT); title('Magnitude of B') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off subplot(2,2,2); meshc(ex,ey,magBi); title('Bi') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off subplot(2,2,3); meshc(ex,ey,magBj); title('Bj') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off subplot(2,2,4); meshc(ex,ey,magBk); title('Bk') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off %Generate individual plot windows of those created above for easier %viewing. figure mesh(ex,ey,magBT); title('Magnitude of B') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off figure mesh(ex,ey,magBi); title('Bi') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off figure mesh(ex,ey,magBj); title('Bj') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off figure mesh(ex,ey,magBk); title('Bk') hold on plot3(x,y,zshrink,'-g', 'linewidth', 2) hold off son nguyen xuan https://es.mathworks.com/matlabcentral/profile/authors/8462410-son-nguyen-xuan tag:es.mathworks.com,2005:Question/477231 2019-08-22T18:13:25Z 2019-08-24T06:01:07Z catalog data convert into csv Hi, I have a dataset in.catalog format. I need to convert it into .csv or .xlsx format for reading it in matlab.Is there is any tool freely available for this? Please help me.Thank you. Silpa K https://es.mathworks.com/matlabcentral/profile/authors/15760628-silpa-k tag:es.mathworks.com,2005:Question/477363 2019-08-23T19:14:49Z 2019-08-24T05:59:20Z Time reading in matlab Hi, I have a data set, using matlab I need to read all the data.But the date and time reading is not working.Please help me. Silpa K https://es.mathworks.com/matlabcentral/profile/authors/15760628-silpa-k tag:es.mathworks.com,2005:Question/466636 2019-06-12T08:53:41Z 2019-08-24T05:57:14Z caesar cyphor encryption problem . Caesar's cypher is the simplest encryption algorithm. It adds a fixed value to the ASCII (unicode) value of each character of a text. In other words, it shifts the characters. Decrypting a text is simply shifting it back by the same amount, that is, it substract the same value from the characters. Write a function called caesar that accepts two arguments: the first is the character vector to be encrypted, while the second is the shift amount. The function returns the output argument coded, the encrypted text. The function needs to work with all the visible ASCII characters from space to ~. The ASCII codes of these are 32 through 126. If the shifted code goes outside of this range, it should wrap around. For example, if we shift ~ by 1, the result should be space. If we shift space by -1, the result should be ~. for the first part of the code...this works function coded=caesar(A,n) char_set=char(32):char(126) coded=char(A+n); end But if i want to maintain the range between 32 and 126 ....and also wrap around the same values as asked in later half of question , it doesnt work function coded=caesar(A,n) char_set=char(32):char(126) while A <=char_set coded=char(A+n); end end please help me with the concerned code buiding ....( expect a simple approach , since iam a begineer) test for these outputs caesar('ABCD',1) ans = 'BCDE' caesar('xyz ~',1) ans = 'yz{! ' caesar('xyz ~',-1) ans = 'wxy~}' %these are correct answers to the code mayank ghugretkar https://es.mathworks.com/matlabcentral/profile/authors/15511283-mayank-ghugretkar tag:es.mathworks.com,2005:Question/477398 2019-08-24T05:47:48Z 2019-08-24T05:51:08Z optimized wavelet filter bank How to take coefficients to optimize the wavelet filter bank to decompose the image into LL,LH,HL and HH subband images in image enhancement process. While writing code how do we give coefficients. what is the best algorithm for the wavelet filter bank optimization. Could you please send the code for image enhancement using optimized wavelet filter bank hyma lakshmi https://es.mathworks.com/matlabcentral/profile/authors/4474294-hyma-lakshmi tag:es.mathworks.com,2005:Question/477396 2019-08-24T04:50:49Z 2019-08-24T05:34:24Z gender Counting in matlab Anyone can provide me source code for gender counting with face detection in matlab. i am facing the problem in gender counting Rida Yameen https://es.mathworks.com/matlabcentral/profile/authors/16016543-rida-yameen tag:es.mathworks.com,2005:Question/477397 2019-08-24T05:33:20Z 2019-08-24T05:33:20Z App designer for composite bars for n inputs Hey there, I am trying to build an app for composite bars, the inputs depend on the user's requirement. How do i get multiple inputs window ? (for ex: if n= 10, the edit field boxes must be the n for further inputs (i.e 10). Here's my code for the same on matlab disp('1 - Circular cross-section'); disp('2 - Rectangular cross-section'); choice = input('Enter the type of cross-section: '); n = input('Enter the number of cross-sections: '); F = input('Enter the load in N: '); if choice==1; A=zeros(n,1) Delta=A; for i=1:n fprintf('Enter the Youngs modulus of Bar %i : \n',i ); E = input('y ='); fprintf('Enter the length of Bar %i: \n',i ); L = input('b ='); fprintf('Enter the diameter of Bar %i:\n',i ); D = input('s ='); A(i,1) = (pi*(D^2)/4 ); Delta(i,1) = ((F*L)/(A(i,1)*E )); end for j=1:n fprintf(' Total extension of the bar %i: %f. \n' ,j,Delta(j,1 ) ); end elseif choice==2; A=zeros(n,1) Delta=A; for i=1:n fprintf('Enter the Youngs modulus of Bar %i : \n',i ); E = input('y ='); fprintf('Enter the length of Bar %i: \n',i ); L = input('b ='); fprintf('Enter the breadth of Bar %i:\n',i ); D = input('s ='); A(i,1) = L*D; Delta(i,1) = ((F*L)/(A(i,1)*E )); end for j=1:n fprintf(' Total extension of the bar %i: %f. \n' ,j,Delta(j,1 ) ); end end Syed Mustaqhim https://es.mathworks.com/matlabcentral/profile/authors/15294877-syed-mustaqhim tag:es.mathworks.com,2005:Question/285932 2016-05-26T12:24:54Z 2019-08-24T05:25:17Z What is this PPC compiler error in dSPACE? ======================================================================================== Configuring dSPACE(R) Software for MATLAB(R) 7.11.2.1031 (R2010b) Service Pack 2 ... RTI Real-Time Interface to Simulink (RTI1104) 6.6 29-Nov-2010 okay RTIFPGA RTI FPGA Programming Blockset 2.0 29-Nov-2010 okay MLIB/MTRACE MATLAB-dSPACE Interface Libraries 4.7.1 29-Nov-2010 okay DSSIMULINK ControlDesk to Simulink Interface 3.7 29-Nov-2010 okay ======================================================================================== *** RTI Platform Support RTI1104 activated. *** You have RTI relevant MATLAB Toolboxes or Simulink Blocksets installed. Details: Toolboxes Compatibility Information ---------------------------------------------------------------------- Starting build procedure with RTI 6.6 (RTI1104, 29-Nov-2010) Model: "untitled" (D:\untitled.mdl) ---------------------------------------------------------------------- *** Using configuration set : "Configuration" *** Working directory : "D:\" *** Initializing code generation ### Starting Real-Time Workshop build procedure for model: untitled ### Generating code into build directory: D:\untitled_rti1104 Warning: The model 'untitled' does not have continuous states, hence Simulink is using the solver 'FixedStepDiscrete' instead of solver 'ode5'. You can disable this diagnostic by explicitly specifying a discrete solver in the solver tab of the Configuration Parameters dialog, or by setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics tab of the Configuration Parameters dialog *** Optional User System Description File untitled_usr.sdf not available ### Invoking Target Language Compiler on untitled.rtw ### Using System Target File: d:\dSPACE7.0\matlab\rti1104\tlc\rti1104.tlc . ### Loading TLC function libraries .... ### Initial pass through model to cache user defined code .. *** Postprocessing RTI blocks *** Starting I/O block checking *** RTI Build: Invoking TLCCheck: + rti1104check()... passed. *** Passed I/O block checking ### Caching model source code ............................ ### Writing header file untitled.h ### Writing header file untitled_types.h ### Writing source file untitled.c . ### Writing header file rtwtypes.h ### Writing header file untitled_private.h ### Writing header file rtmodel.h . ### Writing source file untitled_data.c ### Writing header file rt_nonfinite.h ### Writing source file rt_nonfinite.c . ### Writing header file rtGetInf.h ### Writing source file rtGetInf.c ### Writing header file rtGetNaN.h . ### Writing source file rtGetNaN.c ### TLC code generation complete. ### Generating TLC interface API. ... *** Generating file untitled_rti.c *** Generating file untitled_rti.mk *** Generating Variable Description File untitled.trc ------------------------------------------------------------------------------- NOTE: The following option in the Configuration Parameters dialog has been used: Optimization: "Conditional input branch execution" On This leads to code optimization in which blocks are not computed if their outputs are not required in the simulation step, for example, if their output values are used as input for a Switch block and the Switch currently routes another signal. When the corresponding output signals are displayed in ControlDesk, their values are static. To ensure that the blocks are computed, turn off the "Conditional input branch execution" option and rebuild the model. ------------------------------------------------------------------------------- *** Found User-Code File untitled_usr.c from 26-May-2016 15:11:00 *** Found User Makefile untitled_usr.mk from 26-May-2016 15:11:00 *** Optional User Variable Description File untitled_usr.trc not available . ### Processing Template Makefile: d:\dSPACE7.0\matlab\rti1104\m\rti1104.tmf ### untitled.mk which is generated from d:\dSPACE7.0\matlab\rti1104\m\rti1104.tmf is up to date ### Building untitled: dsmake -f untitled.mk GENERATE_REPORT=0 EXTMODE_STATIC_ALLOC=0 TMW_EXTMODE_TESTING=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 EXTMODE_TRANSPORT=0 BUILDING APPLICATION "untitled" (Single Timer Task Mode) WORK DIRECTORY "D:\" BUILD DIRECTORY "D:\untitled_rti1104" TARGET COMPILER "d:\PPCTools37" ERROR: Cannot find PPC compiler. Possible reasons are: - Compiler not installed. - Environment variable PPC_ROOT not defined. - Environment variable PPC_ROOT points to wrong directory. Muhammed Fasil https://es.mathworks.com/matlabcentral/profile/authors/7484327-muhammed-fasil tag:es.mathworks.com,2005:Question/477278 2019-08-23T06:04:15Z 2019-08-24T04:50:40Z str2num strange behaviour Dear, I have this code: svmKernel ={'rbf','gaussian', 'linear','2','3','4'}; for k=1:numel(svmKernel) [p, status] = str2num(svmKernel{k}); if ~status; t = templateSVM('Standardize',true,'KernelFunction',svmKernel{indK}); else; t = templateSVM('Standardize',true,'KernelFunction','polynomial', 'PolynomialOrder', p); end WHY str2num returns p = Linear Function: Parameters: [1×1 struct] and status = 1 when issuing [p,status] = str2num('linear')? [p, status] = str2num('linear') Linear Function: Parameters: [1×1 struct] status = logical 1 Elena Casiraghi https://es.mathworks.com/matlabcentral/profile/authors/5998497-elena-casiraghi tag:es.mathworks.com,2005:Question/224807 2015-06-22T12:44:46Z 2019-08-24T04:46:20Z Load time from netcdf file and retain the 'Hour' value Hello, I have a time variable (attached) that I created from using netcdf_time = ncread('sample.netcdf','time'); When I use ncdisp on the netcdf file, time is described as the following: time Size: 102272x1 Dimensions: time Datatype: int32 Attributes: units = 'hours since 1900-01-01 00:00:0.0' long_name = 'time' calendar = 'gregorian' My question is, what do I do with the netcdf_time variable to get the time into matlab datenum format while retaining the 'hour'. I have used this based on online phishing time = double(netcdf_time/24 + datenum('1900-01-01 00:00:00')); But, datestr(time(1:7,1),'dd-mm-yyyy HH:MM:SS') returns 01-01-1980 00:00:00 01-01-1980 00:00:00 01-01-1980 00:00:00 02-01-1980 00:00:00 02-01-1980 00:00:00 02-01-1980 00:00:00 02-01-1980 00:00:00 When it should return 01-01-1980 03:00:00 01-01-1980 06:00:00 01-01-1980 09:00:00 01-01-1980 12:00:00 01-01-1980 15:00:00 01-01-1980 18:00:00 01-01-1980 21:00:00 Any ideas? mashtine https://es.mathworks.com/matlabcentral/profile/authors/4739967-mashtine