https://la.mathworks.com/matlabcentral/answers/questions MATLAB Answers — New Questions 2021-06-16T08:18:47Z tag:la.mathworks.com,2005:Question/855335 2021-06-13T20:26:23Z 2021-06-16T08:18:47Z Reed Solomon encoding/decoding for binary data I want to encode a binary data with the rsenc. It does the work but it generates random integer parities appenended in the end of the data vector. And when I try to manipulate it with adding random binary values and then pass it through the decoder all the results are messed up. I do get the final result correctly but the rest of the properties are all messed up. Here's one small example of what I did. message_in_bin_enc = rsenc(message_in_bin_gf,n,k); % example message is [0 0 1] as a galois field. bin_Rs_enc = message_in_bin_enc; binRandom = randi([0 1],1,4); bin_Rs_enc (1,4)= binRandom(1,1); bin_Rs_enc (1,5)= binRandom(1,2); bin_Rs_enc (1,6)= binRandom(1,3); bin_Rs_enc (1,7)= binRandom(1,4); %So here I tried to manipulate the parity bits with my very own random %binary bits cause I need the entire data as a binary stream. % Let's say now the message looks something like [0 0 1 0 0 0 1] assuming % its a (7,3) RS code. %Then once it passes through my circuit which (can)randomly flips the %message bits. e.g : [0 1 0 0 0 0 0] (error) error = gf(bin_Rs_enc_1,m); % bin_Rs_enc_1 is when it passes through the ciruit and error in introduced. [corrected_message,sheesh] = rsdec(error,n,k); %Now if I decode all the results are butchered up for some odd reason tho I %get the correct final ans. Please guide me through this. Thank you in advance. Das Siddharth https://la.mathworks.com/matlabcentral/profile/authors/20317153 tag:la.mathworks.com,2005:Question/857435 2021-06-16T07:28:33Z 2021-06-16T08:17:20Z How to accumulate output from a function in a single table? I am working with an EEG data file that has 26 columns (1 column = one channel) and that contains the data points from three conditions. My goal is to perform Detrended Fluctuation Analysis for each channel and each condition. For this I am using the function DFA_fun. Ideally, I would like the output (a scaling exponent and intercept) from this function to appear in a 3x26 table (3 rows for the conditions and 26 columns for the channels). My supervisor suggested the following code to me (I have tried to modify it so now it is probably useless): pts = 500:250:12500; % Time windows that need to be defined for the function interval ={[201:214958],[291379:591327],[591728:816677]}; % The intervals corresponding with the conditions channel = AlphaHilbert(:,1:26); % AlphaHilbert is the file that I am working with alpha = zeros(3,26); % This should create the 3x26 table that should be filled in for interval = {[201:214958],[291379:591327],[591728:816677]} for channel = 1:26 alpha(interval,channel) = DFA_fun(AlphaHilbert(interval,channel),pts); end end Doing it like this I get the following error: Unable to use a value of type cell as an index. If you need more information feel free to let me know! In case someone is able to help me I would be grateful beyond what I can express. I am in a really stressful situation right now and my supervisor is busy himself so he cannot help me. Lasse Lorenz https://la.mathworks.com/matlabcentral/profile/authors/22083160 tag:la.mathworks.com,2005:Question/857355 2021-06-16T05:24:56Z 2021-06-16T08:14:45Z Training accuracy remains constant and loss keeps decreasing Hi… I am using CNN for image classification. From the simulation results it is observed that the mini batch accuracy reaches 100% after few epochs and mini batch loss keeps on decreases as shown below: |Epoch | Iterations | Time Elasped | Mini-batch accuracy | Mini-batch loss | base learning rate | 1 | 1 |00:00:10 | 43.75% | 8.9676 | 1.0000e-04 | | 1 | 9 | 00:00:34 | 43.75% | 2.3432 | 1.0000e-04 | | 2 | 18 | 00:00:57 | 68.75% | 0.4471 | 1.0000e-04 | | 3 | 27 | 00:01:19 | 56.25% | 0.8530 | 1.0000e-04 | | 4 | 36 | 00:01:43 | 81.25% | 0.4184 | 1.0000e-04 | | 5 | 45 | 00:02:08 | 93.75% | 0.3022 | 1.0000e-04 | | 6 | 54 | 00:02:33 | 81.25% | 0.2594 | 1.0000e-04 | | 7 | 63 | 00:02:59 | 87.50% | 0.5467 | 1.0000e-04 | | 8 | 72 | 00:03:23 | 93.75% | 0.1394 | 1.0000e-04 | | 9 | 81 | 00:03:50 | 100.00% | 0.0409 | 1.0000e-04 | | 10 | 90 | 00:04:14 | 100.00% | 0.0920 | 1.0000e-04 | | 11 | 99 | 00:04:38 | 100.00% | 0.0318 | 1.0000e-04 | | 12 | 108 | 00:05:02 | 93.75% | 0.1280 | 1.0000e-04 | | 13 | 117 | 00:05:26 | 93.75% | 0.1724 | 1.0000e-04 | | 14 | 126 | 00:05:50 | 87.50% | 0.2529 | 1.0000e-04 | | 15 | 135 | 00:06:14 | 100.00% | 0.0252 | 1.0000e-04 | | 16 | 144 | 00:06:38 | 100.00% | 0.0362 | 1.0000e-04 | | 17 | 153 | 00:07:04 | 100.00% | 0.0345 | 1.0000e-04 | | 18 | 162 | 00:07:28 | 100.00% | 0.0400 | 1.0000e-04 | | 19 | 171 | 00:07:53 | 100.00% | 0.0552 | 1.0000e-04 | | 20 | 180 | 00:08:17 | 100.00% | 0.0704 | 1.0000e-04 | Is it correct to get such results or I am doing something wrong?? What is the reason behind these values?? navneet brar https://la.mathworks.com/matlabcentral/profile/authors/7000171 tag:la.mathworks.com,2005:Question/857455 2021-06-16T07:45:46Z 2021-06-16T08:14:02Z Integration with variable limit Hope you all are fit and sailing the storm perfectly. I need help in writing a MATLAB code for the problem attached herewith . I shall be thankful to you. Thank you, Vivek Sharma Vivek Sharma https://la.mathworks.com/matlabcentral/profile/authors/19048059 tag:la.mathworks.com,2005:Question/856385 2021-06-15T02:50:46Z 2021-06-16T08:13:32Z Understanding the difference between ndgrid and meshgrid (from Numpy) Hello everyone, I am just trying to understand a diffrance between ngrid. Please observe the code below when I check the size of the Ngrid2 I get two cells of $10 \times 10$ and three cells of 15 15 15, but when I do something similar in numpy meshgrid function I get . Can someone please explain to me the diffrance? Also please advise if there is any way to make Matlab ngrid behave as meshgrid from numpy. Thank you very much in advance for the consideration! %Matlab x = linspace(0,1,5); [Ngrid2{:}] = ndgrid(x,x); [Ngrid3{:}] = ndgrid(x,x); %Python Numpy x = np.linspace(0,1,5) z = np.array(np.meshgrid(x,x)) Radoslav Vuchkov https://la.mathworks.com/matlabcentral/profile/authors/8815310 tag:la.mathworks.com,2005:Question/857480 2021-06-16T08:10:58Z 2021-06-16T08:10:58Z Creating NetCDF file with new variables Jello MatLab users, I have a NetCDF file whose resolution is 9 km (1/12˚). (Dimensions = 489 x 376 x 20) Variables: 'Longitude', 'Latitude', 'Depth', 'Time', 'zu', 'zv' and 'zw' Now I created new a new mesh that is 2 km. (Dimensions = 1501 x 1953 x 20) Variables: 'lon', 'lat, 'Depth', 'Time', 'zuc', 'zvc' and 'zwc' QUESTION How can I create a NEW.nc with 'lon', 'lat', 'Depth', 'Time', 'zuc', 'zvc' and 'zwc'? SCRIPT filename='mydata.nc'; ncdisp(filename); % Load in variables Time = ncread(filename,'Time'); Longitude=ncread(filename,'Longitude'); Latitude=ncread(filename,'Latitude'); Depth=ncread(filename,'Depth'); zu=ncread(filename,'zu'); zv=ncread(filename,'zv'); zw=ncread(filename,'zw'); % Permute matrices to be interpolated and create a mesh [lo, la, dep]=meshgrid(Longitude,Latitude,Depth); Au=permute(zu,[2 1 3]); Av=permute(zv,[2 1 3]); Aw=permute(zw,[2 1 3]); % Define new resolution @ 0.02 lon=Longitude(1):.02:Longitude(end); lon=lon'; lat=Latitude(1):.02:Latitude(end); lat=lat'; [X, Y, Z]=meshgrid(lon,lat,Depth); % New mesh zuc = interp3(lo,la,dep,Au,X,Y,Z); zuc=permute(zuc,[2 1 3]); zvc = interp3(lo,la,dep,Av,X,Y,Z); zvc=permute(zvc,[2 1 3]); zwc = interp3(lo,la,dep,Aw,X,Y,Z); zwc=permute(zwc,[2 1 3]); Felipe Torquato https://la.mathworks.com/matlabcentral/profile/authors/22749646 tag:la.mathworks.com,2005:Question/857350 2021-06-16T05:17:26Z 2021-06-16T08:07:10Z Save as xlswrite file in user specified path and user specified name Hi, I have an excel templete created using matlab, I want to use the same templete to store data from appdesigner, I want the new excel sheet with data to be stored in user specified name and path. Please help me with this. Thank you in advance for your help! Harish M Y https://la.mathworks.com/matlabcentral/profile/authors/22095537 tag:la.mathworks.com,2005:Question/857470 2021-06-16T08:07:03Z 2021-06-16T08:07:03Z Time Lag between Arduino and Matlab for Live data plotting Hi everyone, I'm plotting live sine wave data from arduino to MATLAB using serial communication. The sine wave plots great, however there is a lag/noise at the start of the live plotting and not quite sure why it's happening. I've added a delay in arduino IDE to allow time for serial communication and a delay in matlab to allow time for the plot to update but not quite sure why it's happening. Any help is appreciated. The error at the start of the plot is shown below: Matlab Code: delete(instrfindall); clc; serialPort = 'COM4'; plotTitle = 'Sine Wave'; xLabel = 'Time (s)'; yLabel = 'Data'; plotGrid = 'on'; min = -1.5; max = 1.5; delay = .01; %Define Function Variables time = 0; data = 0; count = 0; %Set up Plot plotGraph = plot(time,data,'-r'); title(plotTitle,'FontSize',18); xlabel(xLabel,'FontSize',15); ylabel(yLabel,'FontSize',15); axis([0 10 min max]); grid(plotGrid); %Open Serial COM Port s= serial(serialPort); disp('Close Plot to clear data'); fopen(s); % start stopwatch timer tic %Loop when Plot is Active while time <=50 %Read Data from Serial as Float dat = fscanf(s,'%f'); if(~isempty(dat) && isfloat(dat)) %Make sure Data Type is Correct count = count + 1; time(count) = toc; %stop the stopwatch and extract time data(count) = dat(1); %Extract 1st Data Element set(plotGraph,'XData',time,'YData',data); axis([0 time(count) min max]); end %Allow MATLAB to Update Plot pause(delay); end %Close Serial COM Port and Delete useless Variables fclose(s); flushinput(serialPort); clear count dat delay max min plotGraph plotGrid plotTitle s ... scrollWidth serialPort xLabel yLabel; Arduino Code: double x = 0; void setup() { Serial.begin(9600); x = 0; } void loop() { Serial.flush(); Serial.println(sin(x)); x += .05; if(x >= 2*3.14) x = 0; //Allow Time to Process Serial Communication delay(50); } Ashleigh Reid https://la.mathworks.com/matlabcentral/profile/authors/14812425 tag:la.mathworks.com,2005:Question/857465 2021-06-16T08:00:28Z 2021-06-16T08:00:28Z Error using reshape To RESHAPE the number of elements must not change. can anyone tell me where is the error? yw=Eband; k=NoOfBands; xrtemp=reshape(Eband(k),1,S(1,1)*S(1,2)); k=k-1; for i=2:size(S,1)-1 xrtemp=[xrtemp reshape(Eband(k-1),1,S(i,1)*S(i,2)) reshape(Eband{k},1,S(i,1)*S(i,2)) reshape(Eband{k-2},1,S(i,1)*S(i,2))]; k=k-3; end DImg=(waverec2(xrtemp,S,wname)); nl_mnt=im_nl+DImg; nl_mnt8=uint8(nl_mnt); toc pallavi singh https://la.mathworks.com/matlabcentral/profile/authors/11458993 tag:la.mathworks.com,2005:Question/582179 2020-08-20T12:35:56Z 2021-06-16T07:59:32Z How to assign a category to my file exchange file The categories assigned to my file exchange files are not really appropriate. How are they chosen? How can I edit them? I suspect that going by categories would not lead someone to them. Considering someone who searches by categories they appear to be hidden very efficiently. For example, for my file "Vectorial ray-based diffraction integral (VRBDI)" I miss the following obvious category: Science & Industry > Sciences > Physics > Atomic, Molecular & Optical > Optics & Lasers > Optics In another case the given category is so far off, I wonder if it has been randomly chosen. The file "Simple Transport of Intensity Unwrapper (stiepu.m)" has the category: Language Fundamentals > Data Types > Numeric Types > Logical What the hell is going on there? Birk Andreas https://la.mathworks.com/matlabcentral/profile/authors/476535 tag:la.mathworks.com,2005:Question/856140 2021-06-14T19:00:39Z 2021-06-16T07:59:02Z Problem with exporting Assemblies in Creo Parametric 7.0 with Simscape Multibody Link I am trying to set up Simscape Multibody Link with Creo Parametric 7.0.0.0 Student Edition and Matlab R2021a on a win64 machine and am encountering an error when exporting my assemblies to XML. For my setup, I have followed the Installation Guide for Simscape Multibody Link Plugin step by step. I am using Matlab R2021a with Simscape Multibody Link 7.3. After this, I followed this guide for enabling the Simscape Multibody Link with Creo. I created the protk.dat file and set the paths to my installation of Matlab. protk.dat: name Simscape Multibody Link startup dll exec_file C:/Program Files/MATLAB/R2021a/bin/win64/cl_proe2sm.dll text_dir C:/Program Files/MATLAB/R2021a/toolbox/physmod/smlink/cad_systems/proe/text unicode_encoding false end I then updated the config.pro file: toolkit_registry_file C:/Users/Ente/Documents/protk.dat When I start Creo, the Simscape Multibody Link option shows up under tools, just like the instruction says it should. However, when I run the command regmatlabserver in Matlab (as administrator) and try to export my assembly, I get the error "An error occured while exporting the current assembly to XML file." with no further information. An XML is still created though, but Matlab crashes when I try to load it with smimport. Does anyone have an Idea what I'm doing wrong? I have tried everything I can think of (restarting Matlab and Creo, re-installing the plugin, shortening the paths to where the protk.dat, config.pro and my assembly are saved, trying multiple different assemblies). The only thing I can think of is that I'm using the Student Version of Creo. This also prevents me from opening and testing the demo assemblies provided by the plugin (found in .toolbox\physmod\smlink\smlinkdemos\proe). Any help to this problem would be greatly appreciated Anthony Flöter https://la.mathworks.com/matlabcentral/profile/authors/19855415 tag:la.mathworks.com,2005:Question/857290 2021-06-16T03:13:23Z 2021-06-16T07:57:44Z How do I supply different constants into a function of a loop? My code is currently supplying 2 constants of A only. How do I supply another 2 constants of B into the same function? n=30; % Initialization T=zeros(n,n); T(1,:) = 410; % Top T(end,:) = 420; % Bottom T(:,1) = 400; % Left T(:,end) = 400; % Right T_old = T; % Constants of A k1 = 0.02; k2 = 0.33; % Constants of B % k1 = 0.04; % k2 = 0.67; for k = 1:20 %time steps for j = 2: (n-1) for i = 2: (n-1) T(i,j) = T_old(i,j)*(1-2*k1-2*k2)+k1*(T_old(i-1,j)+T_old(i+1,j))+k2*(T_old(i,j-1)+T_old(i,j+1)); end end T_old = T; end Amanda Liu https://la.mathworks.com/matlabcentral/profile/authors/22829493 tag:la.mathworks.com,2005:Question/857065 2021-06-15T17:47:44Z 2021-06-16T07:53:51Z How can I apply logics to Spatial Contact Force signals Hi, Thanks for your support. I am trying to simulate contact between bodies of a complex shape. Since the convex hull does not approximate well the shape, I divided each body into one solid that has the shape of the core (which will never get in contact) and one solid for each 'protrusion' that I welded in place. The convex hull approximates the shape of each protrusion very well and the contact modeling is working perfectly. From the problem itself I know for sure that there could be only two simultaneous contacts at a time, and since it is possible to easily compute the position of each protrusion at each timestep, I can define a logic to choose only 2 of them for each body and apply the contact only for those 2, for each timestep. Otherwise I would need to define n x m connections, where n and m are the number of protrusions of each couple of bodies. To do so, I would need to apply this logic to the signal that connects Convex Hulls to Spatial Contact Force blocks, but I failed to find a block that works with that signal. Is there any way to accomplish this? Also a bus for that kind of signals would be really helpful, especially if there is no solution to the question above, in order to tidy those signals up. Huge thanks for your time and your support. Best regards, Fabio Mamone Fabio Mamone https://la.mathworks.com/matlabcentral/profile/authors/5793323 tag:la.mathworks.com,2005:Question/857390 2021-06-16T06:54:28Z 2021-06-16T07:52:21Z Save image with same resolution Hello, I've drawn some circles on an image and i wish to save that image...Though the image was saved with imwrite() command, the image became blur (the resolution reduced). How can I save the image without its quality reduced? The coding used is as follows: %Risk Contour I = imread('Plant latest layout.jpg') ; imshow(I) th = linspace(0,2*pi) ; hold on message = sprintf('Click where you want the center to be'); uiwait(helpdlg(message)); [xCenter, yCenter] = ginput(1); for radius =Y x = radius * cos(th) + xCenter; y = radius * sin(th) + yCenter; plot(x, y, '-'); end hold off imwrite(F.cdata,'Plant latest layout.jpg') %Save the contour drawn HAINGKHARRAN GUNASEKARAN https://la.mathworks.com/matlabcentral/profile/authors/13121243 tag:la.mathworks.com,2005:Question/857460 2021-06-16T07:48:12Z 2021-06-16T07:48:12Z Kittel curve fitting in Matlab for out of plane magnetic field Hi, I want fit a kittel function to the data resonance field (x) versus frequency (y). The equation goes like where and are obtained by solving the coupled equations and . Can someone please help me perform a least-square curve fitting for this function to obtain the values of best values for and ? The code below calculates for a given value of and . I need help to use this in a least squares minimization routine and find the best possible values for and for given data. Example data is given at the begining of the code below H_ext_ex = [0.03242;0.05736;0.08891;0.09903;0.13238;0.16757;0.21348;0.25397;0.2978;0.3457;0.39299;0.44411;0.51146;0.57886]; f_ex = [2;2.5;3;3.5;4;4.5;5;5.5;6;6.5;7;7.5;8;8.5]; % Example data that needs to be fit. H_ext_mu0 = linspace(0,0.6,100); % x data f = zeros(1,length(H_ext_mu0)); % y data gamma = 20.3*2*pi;% gamma value (parameter 1) mu0 = 4*pi/10^(7); % just a constant H_ext = H_ext_mu0/mu0; % x data divided by a constant Ms = 1.12; % Ms value (parameter 2) Ms = Ms/mu0; % Ms divided by a constant) theta_ext = 76*pi/180; % theta_ext is a constant for a given measurement %% for i = 1:length(H_ext) C1 = H_ext(i)*mu0*cos(theta_ext); C2 = H_ext(i)*mu0*sin(theta_ext); syms H_int theta_int [sol_H_int, sol_theta_int] = vpasolve([C1 == H_int*cos(theta_int*pi/180), C2 == (H_int + Ms)*sin(theta_int*pi/180)],[H_int, theta_int]); %% f(i) = (gamma*mu0/(2*pi))*sqrt((sol_H_int/mu0 + H_k)*(sol_H_int/mu0 + H_k + Ms*cos(sol_theta_int*pi/180)^2)); end %z=ones(size(H_ext)); plot(H_ext_ex,f_ex,'*',H_ext_mu0,f,'-'); Shreyas Muralidhar https://la.mathworks.com/matlabcentral/profile/authors/8422056 tag:la.mathworks.com,2005:Question/855615 2021-06-14T08:50:45Z 2021-06-16T07:43:45Z Gazebo Customized Plugin: Read contact positions that contains both a variable sized element and an array of sub-buses Hello, I have tired to use the customized Gazebo plugin with Simulink and Gazebo in the virtual machine (Ubuntu). The communication works between Gazebo in the virtual machine and Simulink. However, when I try to read the contact-positions information (multiple contacts), the error occurs as shown below. Simulation 1 04:28 AM Elapsed: 3 sec Diagnostics 1 01:52 AM Elapsed: 20 sec Simulation 1 01:52 AM Elapsed: 2 sec Simulation 1 02:30 AM Elapsed: 3 sec Simulation 1 02:31 AM Elapsed: 3 sec The bus object 'Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts' associated with the block 'gazeboCosimControl_ys_v3/Gazebo Robot/Bus Selector13' contains both a variable sized element and an array of sub-buses. Arrays of buses cannot be used in conjunction with bus objects that contain variable sized elements. Component: Simulink | Category: Block error In addition, the contact-positions have the following variable sized elements based on Gazebo simulation. I mean multiple contacts can include to this information as shown below. To solve this issue, I have tried to use several blocks related to 'bus' such as, bus to vector, to virtual bus, bus selector, etc, but I couldn't solve it. Do you have any advice to address this issue? Thank you so much in advance, Yun Yunsik Jung https://la.mathworks.com/matlabcentral/profile/authors/13334235 tag:la.mathworks.com,2005:Question/157184 2014-10-03T04:18:39Z 2021-06-16T07:42:37Z Integration numerical with variable limits I am trying to find a double integration numerically where the inner integral has variable limits while the outer integral has scalar limits and not the other way round. As I understand integral2 allows you do the reverse of what I want i.e you can have the outer variable limits non scalar while the inner should be scalar. fxy=@(x,y)1/x+1/y xmin=0; xmax=@(y)2*y; ymin=0; ymax=+inf; integral2(fxy,xmin,xmax,ymin,ymax) I get the following error Error using integral2 (line 76) XMAX must be a floating point scalar. DM https://la.mathworks.com/matlabcentral/profile/authors/5723273 tag:la.mathworks.com,2005:Question/857410 2021-06-16T07:15:33Z 2021-06-16T07:40:18Z this function returns only C_ga of the last iteration. How I can make it returns C_ga of each iteration. I want to return one value of C_ga in each iteration(not vector) %% I want to return one value of C_ga in each iteration(I don't want to return it as a vector) function C_ga = Genetic_A_Set(x) global AT G Pn Pt F H theta = (2*pi)*(x); %Reflecting Angle IRS Phi = diag(exp(1i*theta)); %Phase Shift Matrix for IRS. Amplitude = 1 HT = H+F*Phi*G; %Channel Matrix for r = 2:size(AT,1) HT_Reorder = HT(AT(r,:),:); % Matrix HT Combinations (Users Combinations) HT_Final = HT_Reorder; W = pinv(HT_Final); %Precoding Matrix W_bar = W./sqrt(sum(abs(W.^2),1)); D_Matrix = HT_Final*W_bar; %Diagonal Matrix D_Square = (abs(diag(D_Matrix))').^2; % Channel Gains %% Water_filling P = waterfill(Pt,Pn./D_Square); R = P.*D_Square/Pn; C_ga = sum(log2(1+R)); %Capacity end Ali Algushti https://la.mathworks.com/matlabcentral/profile/authors/16470484 tag:la.mathworks.com,2005:Question/857445 2021-06-16T07:38:45Z 2021-06-16T07:38:45Z Training data from a read of the input datastore contains invalid bounding boxes? Hello guys i'm trying this code and i don't know what to do to fix the problem data = load('Damagevehicle.mat'); trainingData = data.Damaaaage; rng(0); shuffledIdx = randperm(height(trainingData)); trainingData = trainingData(shuffledIdx,:); imds = imageDatastore(trainingData.imageFilename); blds = boxLabelDatastore(trainingData(:,2:end)); ds = combine(imds, blds); net = load('yolov2VehicleDetector.mat'); lgraph = net.lgraph; lgraph.Layers; options = trainingOptions('sgdm','InitialLearnRate',0.001,... 'Verbose',true,'MiniBatchSize',32,'MaxEpochs',30,... 'Shuffle','never','VerboseFrequency',30,... 'CheckpointPath',tempdir); [detector,info] = trainYOLOv2ObjectDetector(ds,lgraph,options); The error i got: Invalid transform function defined on datastore. The cause of the error was: Error using vision.internal.cnn.validation.checkTrainingBoxes (line 12) Training data from a read of the input datastore contains invalid bounding boxes. Bounding boxes must be non-empty, fully contained within their associated image and must have positive width and height. Use datastore transform method and remove invalid bounding boxes. Error in vision.internal.cnn.yolo.validateImagesAndBoxesTransform (line 22) vision.internal.cnn.validation.checkTrainingBoxes(images, boxes); Error in trainYOLOv2ObjectDetector>@(data)vision.internal.cnn.yolo.validateImagesAndBoxesTransform(data,params.InputSize) (line 285) transformFcn = @(data)vision.internal.cnn.yolo.validateImagesAndBoxesTransform(data,params.InputSize); Error in matlab.io.datastore.TransformedDatastore/applyTransforms (line 607) data = ds.Transforms{ii}(data); Error in matlab.io.datastore.TransformedDatastore/read (line 222) [data, info] = ds.applyTransforms(data, info); Error in nnet.internal.cnn.DataLoader/manageReadQueue (line 182) data = read(self.Datastore); Error in nnet.internal.cnn.DataLoader/readAhead (line 213) manageReadQueue(self); Error in nnet.internal.cnn.DataLoader (line 81) readAhead(self); Error in nnet.internal.cnn.GeneralDatastoreDispatcher (line 275) this.DataLoader = nnet.internal.cnn.DataLoader(ds,... Error in nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO (line 186) nnet.internal.cnn.GeneralDatastoreDispatcher( ... Error in vision.internal.cnn.trainNetwork>iCreateTrainingDataDispatcher (line 208) dispatcher = nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO( ... Error in vision.internal.cnn.trainNetwork (line 46) trainingDispatcher = iCreateTrainingDataDispatcher(ds, mapping, trainedNet,... Error in trainYOLOv2ObjectDetector>iTrainYOLOv2 (line 434) [yolov2Net, info] = vision.internal.cnn.trainNetwork(... Error in trainYOLOv2ObjectDetector (line 198) [net, info] = iTrainYOLOv2(ds, lgraph, params, mapping, options, checkpointSaver); Error in final1 (line 17) [detector,info] = trainYOLOv2ObjectDetector(ds,lgraph,options); Hind Haboubi https://la.mathworks.com/matlabcentral/profile/authors/17383478 tag:la.mathworks.com,2005:Question/406 2011-01-25T19:27:47Z 2021-06-16T07:37:05Z How do I skip items in a legend? How do I skip items in legend? Say I have 6 plots with 3 actual values and 3 interpolated curves. I only want to label the actual value curves so legend('first','','second','','third') doesn't really work because the interpolated curve still shows. henry wang https://la.mathworks.com/matlabcentral/profile/authors/2295846 tag:la.mathworks.com,2005:Question/857440 2021-06-16T07:36:23Z 2021-06-16T07:36:23Z Training data from a read of the input datastore contains invalid bounding boxes? Hello guys i'm trying this code and i don't know what to do to fix the problem data = load('Damagevehicle.mat'); trainingData = data.Damaaaage; rng(0); shuffledIdx = randperm(height(trainingData)); trainingData = trainingData(shuffledIdx,:); imds = imageDatastore(trainingData.imageFilename); blds = boxLabelDatastore(trainingData(:,2:end)); ds = combine(imds, blds); net = load('yolov2VehicleDetector.mat'); lgraph = net.lgraph; lgraph.Layers; options = trainingOptions('sgdm','InitialLearnRate',0.001,... 'Verbose',true,'MiniBatchSize',32,'MaxEpochs',30,... 'Shuffle','never','VerboseFrequency',30,... 'CheckpointPath',tempdir); [detector,info] = trainYOLOv2ObjectDetector(ds,lgraph,options); The error i got: Invalid transform function defined on datastore. The cause of the error was: Error using vision.internal.cnn.validation.checkTrainingBoxes (line 12) Training data from a read of the input datastore contains invalid bounding boxes. Bounding boxes must be non-empty, fully contained within their associated image and must have positive width and height. Use datastore transform method and remove invalid bounding boxes. Error in vision.internal.cnn.yolo.validateImagesAndBoxesTransform (line 22) vision.internal.cnn.validation.checkTrainingBoxes(images, boxes); Error in trainYOLOv2ObjectDetector>@(data)vision.internal.cnn.yolo.validateImagesAndBoxesTransform(data,params.InputSize) (line 285) transformFcn = @(data)vision.internal.cnn.yolo.validateImagesAndBoxesTransform(data,params.InputSize); Error in matlab.io.datastore.TransformedDatastore/applyTransforms (line 607) data = ds.Transforms{ii}(data); Error in matlab.io.datastore.TransformedDatastore/read (line 222) [data, info] = ds.applyTransforms(data, info); Error in nnet.internal.cnn.DataLoader/manageReadQueue (line 182) data = read(self.Datastore); Error in nnet.internal.cnn.DataLoader/readAhead (line 213) manageReadQueue(self); Error in nnet.internal.cnn.DataLoader (line 81) readAhead(self); Error in nnet.internal.cnn.GeneralDatastoreDispatcher (line 275) this.DataLoader = nnet.internal.cnn.DataLoader(ds,... Error in nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO (line 186) nnet.internal.cnn.GeneralDatastoreDispatcher( ... Error in vision.internal.cnn.trainNetwork>iCreateTrainingDataDispatcher (line 208) dispatcher = nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO( ... Error in vision.internal.cnn.trainNetwork (line 46) trainingDispatcher = iCreateTrainingDataDispatcher(ds, mapping, trainedNet,... Error in trainYOLOv2ObjectDetector>iTrainYOLOv2 (line 434) [yolov2Net, info] = vision.internal.cnn.trainNetwork(... Error in trainYOLOv2ObjectDetector (line 198) [net, info] = iTrainYOLOv2(ds, lgraph, params, mapping, options, checkpointSaver); Error in final1 (line 17) [detector,info] = trainYOLOv2ObjectDetector(ds,lgraph,options); Hind Haboubi https://la.mathworks.com/matlabcentral/profile/authors/17383478 tag:la.mathworks.com,2005:Question/856780 2021-06-15T11:46:16Z 2021-06-16T07:33:35Z Finding the indices of the maximum k elements (even if repeated) I have an array e.g A=[1 1 0 0 2 0 3 3 0 0] and would like to get the maximum 3 elements (even if repeated ) and their indices Any help is highly appreciated. Thanks rana karem https://la.mathworks.com/matlabcentral/profile/authors/22226129 tag:la.mathworks.com,2005:Question/92033 2009-07-27T15:25:00Z 2021-06-16T07:33:11Z Is it possible to install an Individual or Designated Computer license of MATLAB and access Concurrent toolboxes? I have MATLAB installed locally and I would like to be able to access toolboxes under a Concurrent license from a server machine. MathWorks Support Team https://la.mathworks.com/matlabcentral/profile/authors/4622813 tag:la.mathworks.com,2005:Question/856545 2021-06-15T07:34:02Z 2021-06-16T07:29:36Z DC gain discrete-time transfer function error Hello everyone, I'm trying to plot the trasfer function of a CIC filter and I think I'm getting an error in DC gain. The code I'm using is shown here: M = 8; %Decimation factor N = 1; %Order of the filter fs = 25e6; %Sampling frequency T = 1/fs; %Sampling period z = tf('z',T); gain = 1/(M); num_tf = 1-z^(-M); den_tf = 1-z^(-1); tf_tf = (gain*num_tf/den_tf)^N; figure(1) plot_tf=bodeplot(tf_tf); setoptions(plot_tf,'FreqUnits','Hz'); dcgain(tf_tf) The printed bodeplot is: that shows a DC gain grather than 1 while the line dcgain(tf_tf) gives 1 as result (which should be the right one). What am I doing wrong? Why am I finding thi misbehaviour og bodeplot function? Thanks in advance Francesco Laezza https://la.mathworks.com/matlabcentral/profile/authors/6682721 tag:la.mathworks.com,2005:Question/857370 2021-06-16T05:47:57Z 2021-06-16T07:28:43Z does the grayscale image always give the temperature value corresponding to thermal image? does the grayscale image always give the temperature value corresponding to thermal image? RICHA SINGH https://la.mathworks.com/matlabcentral/profile/authors/22123928 tag:la.mathworks.com,2005:Question/856845 2021-06-15T13:02:00Z 2021-06-16T07:28:33Z diff function rearranges symbolic expression leading to non-vanishing terms I am trying to feedback linearize my non-linear system in Matlab. To that end I have to represent it in the following form: So after I have modeled my system in the form of nonlinear differential equations, , I use the diff function to take the derrivative with respect to u to aquire g, and . This works, of course only if the system can be represented in the mentioned form. However, the diff function rewrites some of my expressions, which then after subtraction lead to non-vanishing factors multiplying u. For example, my input is still present in multiplied with a factor 5.7024e-18. I suspect, there is some quantization error introduced due to diff re-writing the derivative . Can this be somehow avoided? g_x=[diff(dxdt,[Q_g]) diff(dxdt,[Q_b])]; for i=1:size(g_x,1) i f_x(i,:)=simplify(dxdt(i,:)-g_x(i,1)*Q_g-g_x(i,2)*Q_b,'steps',10,'IgnoreAnalyticConstraints',true); end Here Q_g and Q_b are my inputs. An example of the re-writing of expressions: dxdt = - (1297036692682702848*Q_b*(C_carbv - 47/20000))/15694143981460705 + .................. g_x=1905022642377719808/9808839988412940625 - (1297036692682702848*C_carbv)/15694143981460705 f_x=Q_b*((1297036692682702848*C_carbv)/15694143981460705 - 1905022642377719808/9808839988412940625) - (1297036692682702848*Q_b*(C_carbv - 47/20000))/15694143981460705 + .............................. simplify(Q_b*((1297036692682702848*C_carbv)/15694143981460705 - 1905022642377719808/9808839988412940625) - ... (1297036692682702848*Q_b*(C_carbv - 47/20000))/15694143981460705) ans = (47*Q_b)/8242150268041428750 The .................. stands for terms that do not depend on Q_b. Martin Elenkov https://la.mathworks.com/matlabcentral/profile/authors/5157104 tag:la.mathworks.com,2005:Question/857430 2021-06-16T07:27:27Z 2021-06-16T07:27:27Z How can I fix model reduction method? Hi, I'm Cha I study Model reduction method in matlab. As you may already know, The conventional approach is to show a little bad performance on the PID controller. So , I intend to incorporate the new clause into the existing SOPTD(second order plus time delay model) and even apply the effect of ZERO in model reduction method. existing SOPTD(second order plus time delay model) G(s) = ((-0.3*s+1)*exp(-0.3*s))/(s+1)^3; added SOPTD(second order plus time delay model) G(s) = ((exp(0.22*s)+s)*(-0.3*s+1)*exp(-0.3*s))/(s+1)^3; I want to get the parameters of "added SOPTD G" with a model reduction method. This is the code I did. 1. function [G]=g_mr_first_aft(w) s= 1i*w; G= ((exp(0.22*s)+s)*(-0.3*s+1)*exp(-0.3*s))/(s+1)^3; end 2. clear; w=0.0; delta_w=0.05; s=1i*w; while(1) % search boundary in which wu exists w=w+delta_w; g=g_mr_first_aft(w); if(imag(g)>0.0) break; end end w1=w-delta_w; w2=w; % w 1< wu < w2 while(1) % find wu using the bisection method w=(w1+w2)/2; g1=g_mr_first_aft(w1); g=g_mr_first_aft(w); if(imag(g)*imag(g1)>0.0) w1=w; else w2=w; end if(abs(imag(g))<0.000001) break; end end wu=w; % ultimate frequency wu is found k=abs(g_mr_first_aft(0)); for j=1:10 % least square method w=(j-1)*wu/9.0; G(j)=g_mr_first_aft(w); y(j,1)=((exp(0.22*s)+s)^2)*k^2-(abs(G(j))^2); phi_1(j,1)=(abs(G(j))^2)*w^4; phi_2(j,1)=(abs(G(j))^2)*w^2; end % P_hat: solution of the least square method PHI=[phi_1 phi_2]; Y=y; P_hat=inv(PHI'*PHI)*PHI'*Y; tau=P_hat(1)^(1.0/4.0); xi=((P_hat(2)+2*tau^2)/(4*tau^2))^0.5; theta=(pi+atan2(-2*xi*tau*wu,1-wu^2*tau^2))/wu; % % tau: time contant, xi: damping factor, theta: time delay τ ξ Θ fprintf('k=%5.3f tau=%5.3f \n',k,tau); fprintf('xi=%5.3f theta=%5.3f \n',xi,theta); But you know, I think the way to get "Theta" is a little wrong, but I don't know how to fix it. So Can I get some help? Plz.. 창규 이 https://la.mathworks.com/matlabcentral/profile/authors/22346086 tag:la.mathworks.com,2005:Question/857425 2021-06-16T07:25:48Z 2021-06-16T07:25:48Z Inconsistent sampling time error Inconsistent sample times. Sample time (9.765625e-06) of 'rtlsdr_QPSK_carrier_timing/Timing Synchronisation Loop (Early Late)/Loop Filter/Add1' is slower than sample time (6.510416666666666e-07) at input port 2. This is likely because there is a loop of blocks, containing 'rtlsdr_QPSK_carrier_timing/Timing Synchronisation Loop (Early Late)/Loop Filter/Add1' that do not specify sample time (all are inherited (-1)). Either specify the sample time of this block or specify sample times for the blocks that drive this block's inputs. I am getting this error while running a simulink model for QPSK reciever how can i resolve this error muhammad ahmad https://la.mathworks.com/matlabcentral/profile/authors/11234519 tag:la.mathworks.com,2005:Question/857360 2021-06-16T05:25:56Z 2021-06-16T07:23:42Z How do you resolve "Execution of script lsqnonlin as a function is not supported" problem in matlab? I'm trying to run a gaussian curve code in matlab but keep on getting this note: Execution of script lsqnonlin as a function is not supported. Hope you can help. thanks! this is the code by the way x=lsqnonlin(@gaussian,X0,lb,ub,[],Size,Signal) Krysthal Vasallo https://la.mathworks.com/matlabcentral/profile/authors/22745257 tag:la.mathworks.com,2005:Question/857420 2021-06-16T07:22:45Z 2021-06-16T07:23:18Z how can i solve this problem with rk4 method? In this case, m=20, k=20, c=40 and initial x=1, initial v=0, t is 0 to 15. please tell me what's wrong in my code This is my code when 'c=40' please tell me what's wrong in it f=@(t,x,v) -0.25*v -x; %dvdt g=@(t,x,v) v; %dxdt t0=1; tl=15; h=0.1; n=(tl-t0)/h; T=t0:h:tl; X=zeros(1,n+1); V=zeros(1,n+1); X(1)=1; V(1)=0; for j = 1: n k1f = f(T(j),X(j),V(j)); k1g = g(T(j),X(j),V(j)); k2f = f(T(j)+h/2,X(j)+k1g*h/2,V(j)+k1f*h/2); k2g = g(T(j)+h/2,X(j)+k1g*h/2,V(j)+k1f*h/2); k3f = f(T(j)+h/2,X(j)+k2g*h/2,V(j)+k2f*h/2); k3g = g(T(j)+h/2,X(j)+k2g*h/2,V(j)+k2f*h/2); k4f = f(T(j)+h,X(j)+k3g*h,V(j)+k3f*h); k4g = g(T(j)+h,X(j)+k3g*h,V(j)+k3f*h); X(j+1)= X(j) + (k1g + 2*k2g + 2*k3g + k4g)/6; V(j+1)= V(j) + (k1f + 2*k2f + 2*k3f + k4f)/6; end plot(T,V) jameslk https://la.mathworks.com/matlabcentral/profile/authors/10017153 tag:la.mathworks.com,2005:Question/857415 2021-06-16T07:19:15Z 2021-06-16T07:19:15Z Legend does not match with the bar chart in MATLAB Hello, I have a bar chart in Matlab. and I have changed every 24 bar to the same color. For example, the first 24 of them to the red, the second 24 of them to the blue, the third 24 of them to green, and the fourth 24 of them to black, but the color of the legend is incorrect and does not match with my plot. Here is my code: data_kind2=xlsread('kind2.xlsx'); colors={'r','g','b','k'}; figure(); hold on bar(data_kind2) for ii=0:3 bar(ii*24+(1:24),data_kind2(ii*24+(1:24)),'FaceColor',colors{ii+1}) end legend('Summer','Autumn','Winter','Spring'); set(gca,'Xtick',1:1:96,'XTickLabel',{'Evapotranspiration Deforestation Areas','Evapotranspiration Forest Areas','Evapotranspiration Transition Areas',... 'Soil moisture Deforestation Areas','Soil moisture Forest Areas','Soil moisture Transition Areas',... 'Air Temperature Deforestation Areas','Air Temperature Forest Areas','Air Temperature Transition Areas',... 'Total Runoff Deforestation Areas','Total Runoff Forest Areas','Total Runoff Transition Areas',... 'Sensible Heat Flux Deforestation Areas','Sensible Heat Flux Forest Areas','Sensible Heat Flux Transition Areas',... 'Soil Temperature Deforestation Areas','Soil Temperature Forest Areas','Soil Temperature Transition Areas',... 'ET/P Deforestation Areas','ET/P Forest Areas','ET/P Transition Areas','R/P Deforestation Areas','R/P Forest Areas','R/P Transition Areas',... 'Evapotranspiration Deforestation Areas','Evapotranspiration Forest Areas','Evapotranspiration Transition Areas',... 'Soil moisture Deforestation Areas','Soil moisture Forest Areas','Soil moisture Transition Areas',... 'Air Temperature Deforestation Areas','Air Temperature Forest Areas','Air Temperature Transition Areas',... 'Total Runoff Deforestation Areas','Total Runoff Forest Areas','Total Runoff Transition Areas',... 'Sensible Heat Flux Deforestation Areas','Sensible Heat Flux Forest Areas','Sensible Heat Flux Transition Areas',... 'Soil Temperature Deforestation Areas','Soil Temperature Forest Areas','Soil Temperature Transition Areas',... 'ET/P Deforestation Areas','ET/P Forest Areas','ET/P Transition Areas','R/P Deforestation Areas','R/P Forest Areas','R/P Transition Areas' 'Evapotranspiration Deforestation Areas','Evapotranspiration Forest Areas','Evapotranspiration Transition Areas',... 'Soil moisture Deforestation Areas','Soil moisture Forest Areas','Soil moisture Transition Areas',... 'Air Temperature Deforestation Areas','Air Temperature Forest Areas','Air Temperature Transition Areas',... 'Total Runoff Deforestation Areas','Total Runoff Forest Areas','Total Runoff Transition Areas',... 'Sensible Heat Flux Deforestation Areas','Sensible Heat Flux Forest Areas','Sensible Heat Flux Transition Areas',... 'Soil Temperature Deforestation Areas','Soil Temperature Forest Areas','Soil Temperature Transition Areas',... 'ET/P Deforestation Areas','ET/P Forest Areas','ET/P Transition Areas','R/P Deforestation Areas','R/P Forest Areas','R/P Transition Areas' 'Evapotranspiration Deforestation Areas','Evapotranspiration Forest Areas','Evapotranspiration Transition Areas',... 'Soil moisture Deforestation Areas','Soil moisture Forest Areas','Soil moisture Transition Areas',... 'Air Temperature Deforestation Areas','Air Temperature Forest Areas','Air Temperature Transition Areas',... 'Total Runoff Deforestation Areas','Total Runoff Forest Areas','Total Runoff Transition Areas',... 'Sensible Heat Flux Deforestation Areas','Sensible Heat Flux Forest Areas','Sensible Heat Flux Transition Areas',... 'Soil Temperature Deforestation Areas','Soil Temperature Forest Areas','Soil Temperature Transition Areas',... 'ET/P Deforestation Areas','ET/P Forest Areas','ET/P Transition Areas','R/P Deforestation Areas','R/P Forest Areas','R/P Transition Areas'}); set(gca,'XTickLabelRotation',90) title('Relative Change v.s Monthly water balance in Deforestation,Forest, and Transition areas'); ylabel('Relative Change <%>') xlabel('Monthly water balance'); grid on Could anybody help me? I would really appreciate it if You help me. nazanin tavakoli https://la.mathworks.com/matlabcentral/profile/authors/20411356 tag:la.mathworks.com,2005:Question/855130 2021-06-13T11:13:54Z 2021-06-16T07:15:01Z Classification Lernner don't work Hello, I am currently writing my undergraduate thesis and I ran into a problem. When I select the dataset variable in the Workspace, I cannot select the response and predictors part, it does not become active If you could help with this situation, I would greatly appreciate it. Because I need to classify data? Baris DEMIR https://la.mathworks.com/matlabcentral/profile/authors/20299671 tag:la.mathworks.com,2005:Question/297849 2016-07-31T13:07:24Z 2021-06-16T07:14:42Z how cam start the trigger Hi, please help me , how can I start trigger in these .m file? those it have specific syntax or somthing else . my matlab is r2012a and i attach my .m file. Error using imaqdevice/trigger (line 49) OBJ must be running before TRIGGER is used. Error in start (line 101) trigger([vid1 , vid2]); thanks for devote your time for me. mohamad almasi https://la.mathworks.com/matlabcentral/profile/authors/6550114 tag:la.mathworks.com,2005:Question/857405 2021-06-16T07:13:51Z 2021-06-16T07:13:51Z Row-wise individual circshift of a 3D-matrix without using a loop Hello dear MATLAB community, I'm looking for an alternative to perform "circshift" without using a loop to optimize code process time. Let me first explain you what I want to do. I have several 3D data matrices "A(i,j,k)", that have to be circular shifted row by row for every dimension "k". The individual shift indices "RowsShift" for every single row in each dimension "k" are not equal. % Input data matrix (3D): every single row should be shifted individually % with its shifting index "RowsShift"; for example: % - A(2,:,1) should be shifted by 3 (RowsShift(2,:,1)) % - A(4,:,3) should be shifted by -4 (RowsShift(4,:,3)) A(:,:,1) = [0 0 0 1 0 0 0 0; 1 0 0 0 0 0 0 0; 0 0 0 0 0 1 0 0; 0 1 0 0 0 0 0 0; 1 0 0 0 0 0 0 0]; A(:,:,2) = [0 0 0 1 0 0 0 0; 1 0 0 0 0 0 0 0; 0 0 0 0 0 1 0 0; 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 1 0]; A(:,:,3) = [1 0 0 0 0 0 0 0; 1 0 0 0 0 0 0 0; 0 0 0 0 0 0 1 0; 0 0 0 0 1 0 0 0; 0 0 0 0 0 1 0 0]; % Matrix with circular shift indices RowsShift(:,:,1) = [0;3;-2;2;3]; RowsShift(:,:,2) = [0;3;-2;-4;-3]; RowsShift(:,:,3) = [0;0;-6;-4;-5]; I can perform the matrix reordering using a loop and the "circshift" function and get the right result "B(i,j,k)": % Old version with for looI canp and circular shift for j = 1:size(A,3) for i = 1:size(A,1) B(i,:,j) = circshift(A(i,:,j),RowsShift(i,:,j)); end end B(:,:,1) = 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 B(:,:,2) = 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 B(:,:,3) = 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 My problem is that I have to circshift more than one 3D matrix with these dimension ("i" & "j" remains the same size) and the dimension "k" can be up to millions. My current version (loop & circshift) takes way to much time, so I'm looking for an alternative way. Thanks in advance and best regards, Pascal Pascal Wielsch https://la.mathworks.com/matlabcentral/profile/authors/14507791 tag:la.mathworks.com,2005:Question/857400 2021-06-16T07:13:44Z 2021-06-16T07:13:44Z Least Trimmed Squares fitting Is there any toolbox or written code for least trimmed square in Matlab? NA https://la.mathworks.com/matlabcentral/profile/authors/13711668 tag:la.mathworks.com,2005:Question/856865 2021-06-15T13:24:58Z 2021-06-16T07:12:20Z undefined function in GUI Hello, can i ask why when i write code for GUI, it show Undefined function 'multiply' for input arguments of type 'double'.? Thank you. Lim Xiao Hui https://la.mathworks.com/matlabcentral/profile/authors/16984066 tag:la.mathworks.com,2005:Question/128381 2014-05-05T19:49:31Z 2021-06-16T07:09:16Z How to calculate mean wind direction Hello! I need help figuring out how to calculate mean wind direction when my data is in degrees (0-360). I just realized my current program does not take into account that the data is circular, and the mean of 355 and 5 will be 180, instead of 0. Any help is greatly appreciated! I am a beginner when it comes to MATLAB programming Jenna Marie https://la.mathworks.com/matlabcentral/profile/authors/5211601 tag:la.mathworks.com,2005:Question/705893 2020-12-31T06:49:13Z 2021-06-16T07:05:44Z Monitor & Tune Error: Code generation information file does not exist I have the Arduino Engineering Kit Rev 2 and using MATLAB R2020b and I received the following error when deploying the code for designing a Motor Control System (simple design using a Sine Wave Generator, 1-D Lookup Table, a gain, and a scope with an M3 M4 Motor block. This code is deployed on an Arduino Nano 33 IoT. ### Starting build procedure for: untitled_restored_from_autosave "### Generating static library." "C:/Program Files/MATLAB/R2020b/bin/win64/gmake" -j5 -C "C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles" SHELL="%SystemRoot%/system32/cmd.exe" -f samdcomm.mk all gmake: Entering directory C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles' "### Successfully generated libcomm.a library." gmake: Leaving directory C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles' "C:/Program Files/MATLAB/R2020b/bin/win64/gmake" -j5 -C "C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles" SHELL="%SystemRoot%/system32/cmd.exe" -f samdcore.mk all gmake: Entering directory C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles' "### Successfully generated libcore.a library." gmake: Leaving directory C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles' "C:/Program Files/MATLAB/R2020b/bin/win64/gmake" -j5 SHELL="%SystemRoot%/system32/cmd.exe" -f "untitled_restored_from_autosave.mk" all gmake: Entering directory C:/Users/elmal/AppData/Roaming/MathWorks/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw' "C:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -std=gnu++11 -fno-threadsafe-statics -fno-rtti -fno-exceptions -Os -c -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=10801 -MMD -MP -MF"MW_PWM.dep" -MT"MW_PWM.o" -MMD -mcpu=cortex-m0plus -fpermissive -DF_CPU=48000000L -DARDUINO_SAMD_NANO_33_IOT -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x8057 -DUSBCON -DUSB_MANUFACTURER=\""Arduino LLC\"" -DUSB_PRODUCT=\""Arduino NANO 33 IoT\"" -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_NANO33_IOT_ -DCRYSTALLESS -DARDUINO_VIRTUAL_COM_PORT -DARDUINO_WIFI_LIB_NINA -DARDUINO_NUM_SERIAL_PORTS=2 -DARDUINO_ARM_CORTEX_M0_PLUS -DARDUINO_ARM -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DMW_TIMERID=10 -DMW_PRESCALAR=512 -DMW_TIMERCOUNT=3125 -DMW_SCHEDULERCOUNTER=1 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_ANALOG_REF_=0 -DNANO_MOTOR_CARRIER -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=1 -DXCP_CUSTOM_PLATFORM -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=untitled_restored_from_autosave -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -IC:/Users/elmal/AppData/Roaming/MATHWO~1/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2 -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/shared/svd/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/include -IC:/Users/elmal/AppData/Roaming/MATHWO~1/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw -IC:/PROGRA~1/MATLAB/R2020b/extern/include -IC:/PROGRA~1/MATLAB/R2020b/simulink/include -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/src -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/ert -IC:/PROGRA~1/MATLAB/R2020b/toolbox/coder/rtiostream/src -IC:/PROGRA~1/MATLAB/R2020b/toolbox/coder/rtiostream/src/utils -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/cores/arduino -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/variants/nano_33_iot -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinotarget/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinotarget/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/armcortexmbase/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/shared/externalmode_daemon/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/armcortexmbase/xcp/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/libraries/Servo/src -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/libraries/Wire -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/libraries/SPI -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/libraries/Servo/src/samd -o "MW_PWM.o" "C:/ProgramData/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/src/MW_PWM.cpp" "C:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gcc" -std=gnu11 -Os -c -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=10801 -MMD -MP -MF"MW_PWMDriver.dep" -MT"MW_PWMDriver.o" -MMD -mcpu=cortex-m0plus -fpermissive -DF_CPU=48000000L -DARDUINO_SAMD_NANO_33_IOT -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x8057 -DUSBCON -DUSB_MANUFACTURER=\""Arduino LLC\"" -DUSB_PRODUCT=\""Arduino NANO 33 IoT\"" -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_NANO33_IOT_ -DCRYSTALLESS -DARDUINO_VIRTUAL_COM_PORT -DARDUINO_WIFI_LIB_NINA -DARDUINO_NUM_SERIAL_PORTS=2 -DARDUINO_ARM_CORTEX_M0_PLUS -DARDUINO_ARM -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DMW_TIMERID=10 -DMW_PRESCALAR=512 -DMW_TIMERCOUNT=3125 -DMW_SCHEDULERCOUNTER=1 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_ANALOG_REF_=0 -DNANO_MOTOR_CARRIER -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 arm-none-eabi-g++: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2: No such file or directory -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=1 -DXCP_CUSTOM_PLATFORM -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=untitled_restored_from_autosave -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -IC:/Users/elmal/AppData/Roaming/MATHWO~1/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2 -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/shared/svd/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/include -IC:/Users/elmal/AppData/Roaming/MATHWO~1/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw -IC:/PROGRA~1/MATLAB/R2020b/extern/include -IC:/PROGRA~1/MATLAB/R2020b/simulink/include -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/src -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/ert -IC:/PROGRA~1/MATLAB/R2020b/toolbox/coder/rtiostream/src -IC:/PROGRA~1/MATLAB/R2020b/toolbox/coder/rtiostream/src/utils -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/cores/arduino -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/variants/nano_33_iot -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinotarget/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinotarget/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/armcortexmbase/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/shared/externalmode_daemon/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/armcortexmbase/xcp/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/libraries/Servo/src -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/libraries/Wire -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/libraries/SPI -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/libraries/Servo/src/samd -o "MW_PWMDriver.o" "C:/ProgramData/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/src/MW_PWMDriver.c" arm-none-eabi-g++: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw: No such file or directory "C:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -std=gnu++11 -fno-threadsafe-statics -fno-rtti -fno-exceptions -Os -c -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=10801 -MMD -MP -MF"ArduinoPinHandleMap.dep" -MT"ArduinoPinHandleMap.o" -MMD -mcpu=cortex-m0plus -fpermissive -DF_CPU=48000000L -DARDUINO_SAMD_NANO_33_IOT -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x8057 -DUSBCON -DUSB_MANUFACTURER=\""Arduino LLC\"" -DUSB_PRODUCT=\""Arduino NANO 33 IoT\"" -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_NANO33_IOT_ -DCRYSTALLESS -DARDUINO_VIRTUAL_COM_PORT -DARDUINO_WIFI_LIB_NINA -DARDUINO_NUM_SERIAL_PORTS=2 -DARDUINO_ARM_CORTEX_M0_PLUS -DARDUINO_ARM -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DMW_TIMERID=10 -DMW_PRESCALAR=512 -DMW_TIMERCOUNT=3125 -DMW_SCHEDULERCOUNTER=1 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_ANALOG_REarm-none-eabi-gcc: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2: No such file or directory F_=0 -DNANO_MOTOR_CARRIER -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=1 -DXCP_CUSTOM_PLATFORM -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=untitled_restored_from_autosave -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -IC:/Users/elmal/AppData/Roaming/MATHWO~1/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2 -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/shared/svd/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/include -IC:/Users/elmal/AppData/Roaming/MATHWO~1/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw -IC:/PROGRA~1/MATLAB/R2020b/extern/include -IC:/PROGRA~1/MATLAB/R2020b/simulink/include -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/src -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2020b/rtw/c/ert -IC:/PROGRA~1/MATLAB/R2020b/toolbox/coder/rtiostream/src -IC:/PROGRA~1/MATLAB/R2020b/toolbox/coder/rtiostream/src/utils -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/cores/arduino -IC:/ProgramData/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/variants/nano_33_iot -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinotarget/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinotarget/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/armcortexmbase/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/shared/externalmode_daemon/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/armcortexmbase/xcp/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/libraries/Servo/src -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/libraries/Wire -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/portable/packages/arduino/hardware/samd/1.8.4/libraries/SPI -IC:/PROGRA~3/MATLAB/SupportPackages/R2020b/3P.instrset/arduinoide.instrset/libraries/Servo/src/samd -o "ArduinoPinHandleMap.o" "C:/ProgramData/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/src/ArduinoPinHandleMap.cpp" arm-none-eabi-gcc: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw: No such file or directory gmake: *** No rule to make target Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw/rtGetInf.c', needed by rtGetInf.o'. Stop. gmake: *** Waiting for unfinished jobs.... gmake: *** [MW_PWM.o] Error 1 gmake: *** [MW_PWMDriver.o] Error 1 arm-none-eabi-g++: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2: No such file or directory arm-none-eabi-g++: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw: No such file or directory gmake: *** [ArduinoPinHandleMap.o] Error 1 gmake: Leaving directory C:/Users/elmal/AppData/Roaming/MathWorks/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files_Rev_2/untitled_restored_from_autosave_ert_rtw' gmake: *** [all] Error 2 The make command returned an error of 2 ### Build procedure for untitled_restored_from_autosave aborted due to an error. I found a workaround where I change the Current Folder path to a path without any spaces (C:\Users\xxxx\AppData\Roaming\MathWorks) instead of the usual work path (C:\Users\xxxx\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Arduino_Engineering_Kit_Project_Files_Rev_2) - notice "MATLAB Add-Ons". However, is there a proper fix for this? Khaled Elmalawany https://la.mathworks.com/matlabcentral/profile/authors/16115491 tag:la.mathworks.com,2005:Question/856925 2021-06-15T14:45:17Z 2021-06-16T06:58:43Z Convert decimal to ASCII Hello everyone, I'm trying to convert some small decimal numbers (e.g. 0.250, 2.500) to ASCII values so I can send them to some power supply via serial. When using a simple MATLAB script it worked pretty well using "sprintf" (e.g. uint8(sprintf('SO:VO %.4f\n', voltage));) but when trying to use Simulink Realtime I am not able to use sprintf anymore. I would like to write a small function to do this but don't know where to start. Any advice is much appreciated! Mihai Ganga https://la.mathworks.com/matlabcentral/profile/authors/18163597 tag:la.mathworks.com,2005:Question/857380 2021-06-16T06:44:54Z 2021-06-16T06:56:15Z How to Realize 'Gradient Reversal Layer' ? How can i complete a 'Gradient Reversal Layer' in matlab like in pytorch or tensorflow? It is normally used in transfer learning network when a GAN-like loss is adopted. Could i realize it by define a custom layer? It is very grateful if you can offer an example of some detailed advice. Thank you for your help. The detailed description is as follows:The gradient reversal layer has no parameters associated with it. During the forward propagation, the GRL acts as an identity transformation. During the backpropagation however, the GRL takes the gradient from the subsequent level and changes its sign, i.e., multiplies it by -1, before passing it to the preceding layer. Implementing such a layer using existing object-oriented packages for deep learning is simple, requiring only to de�ne procedures for the forward propagation (identity transformation), and backpropagation (multiplying by -1). The layer requires no parameter update. Percy Hu https://la.mathworks.com/matlabcentral/profile/authors/20193367 tag:la.mathworks.com,2005:Question/857395 2021-06-16T06:56:10Z 2021-06-16T06:56:10Z MATLAB spinner component as next and prev button for changing images I want to use MATLAB spinner component. I want to use this component to change next and previous image Dolly https://la.mathworks.com/matlabcentral/profile/authors/15197313 tag:la.mathworks.com,2005:Question/857385 2021-06-16T06:49:42Z 2021-06-16T06:49:42Z How to give step Input to only one state of multi input dynamical system (state space model) and rest inputs are zero ? I have multi input and multi output system. I want to give only one input to step input and rest inputs are zero. What is the code for that? Aman https://la.mathworks.com/matlabcentral/profile/authors/16786942 tag:la.mathworks.com,2005:Question/857060 2021-06-15T17:42:08Z 2021-06-16T06:47:22Z New fields cannot be added when structure has been read or used, MATLAB coder. Hi, I am trying to convert my matlab project into C++ using MATLAB Coder. I have a Class and in the constructor, I am initializing all the values of the struct that I have declared in the properties. The code goes something like this. classdef ZCNET properties ZCNET_cfg; z_own_turbo_param_2bit_base; trellis; end methods function self = ZCNET() self.ZCNET_cfg.AP_ANT_NUM = 1; self.ZCNET_cfg.NODE_ANT_NUM = 1; self.ZCNET_cfg.useLTETurbo = 1; self.ZCNET_cfg.USE_SIMIC = 1; self.ZCNET_cfg.ANT_NUM = self.ZCNET_cfg.AP_ANT_NUM; if 1 load_perm = load ('ZCNET_permutations.mat'); % NOTE: to get load_perm.ZCNET_permutations. load_perm.ZCNET_permutations{100} has a random permutation of 100 numbers else for h=1201:1500 load_perm.ZCNET_permutations{h} = randperm(h); end load_perm.ZCNET_permutations_rev = cell(1,length(load_perm.ZCNET_permutations)); . . . . . Since I cannot convert a class directly, I have this function that create an object of the class and them I am using the object to display some valies. This is a test code in order to fix this issue. The function looks something like this. function call_zcnet() zc1 = ZCNET; x = zc1.ZCNET_cfg; disp(x.bandwidth); disp(x.permutations{1,5}); end I am passing "call_zcnet.m" to the coder but when it is giving quiet a few errors. I can run the code by callign 'call_zcnet' from the command window without any problem but coder is giving me following run-time issues. Any help is appreciated. Thank you. Raghav Rathi https://la.mathworks.com/matlabcentral/profile/authors/13445938 tag:la.mathworks.com,2005:Question/384579 2018-02-24T15:23:54Z 2021-06-16T06:42:23Z Thermal camera image processing I'm working on thermal camera image processing and I would like to create an equation to show what every pixel means in temperature. How can I create such equation and how can I put it in the code so it can give me temperatures for certain colors? Nasser Jarrar https://la.mathworks.com/matlabcentral/profile/authors/10712339 tag:la.mathworks.com,2005:Question/851285 2021-06-08T21:20:35Z 2021-06-16T06:38:19Z How to find new coordinates of a point after image rotation? I have an image that has a ROI inside it. I have the coordiantes for the ROI inside the image. Now I am rotating the image with 180 degree and wants to find the new coordinates for the image. I used this code: P = [31961;29101]; % coordinates of point alpha = 180; % angle for rotation RotatedIm = imrotate(im,alpha); % rotation of the main image (im) RotMatrix = [cosd(alpha) -sind(alpha); sind(alpha) cosd(alpha)]; ImCenterA = (size(im)/2)'; % Center of the main image ImCenterB = (size(RotatedIm )/2)'; % Center of the transformed image RotatedP = RotMatrix*(P-ImCenterA)+ImCenterB; And the output will be negative values of : -31273 -28305 How to solve this issue?! faran https://la.mathworks.com/matlabcentral/profile/authors/7609914 tag:la.mathworks.com,2005:Question/857305 2021-06-16T03:40:13Z 2021-06-16T06:24:06Z What is the essential difference in the use of these 2 functions, estimateGeometricTransform2D and fitgeotrans? For example, if there are a number of points (n>4) on two images that are projected to get the projection transformation matrix, and the specified parameter is transformationType = 'projective', which function should I choose to use first? cui https://la.mathworks.com/matlabcentral/profile/authors/3388605 tag:la.mathworks.com,2005:Question/857150 2021-06-15T20:55:02Z 2021-06-16T06:19:27Z using parts of matrix with different sub-vectors (Matlab) Dear members I have this vector V divided on sub-vectors: And I have also this matrix H: I have this parameters: T=5, M=5, N=10 For the first part of the matrix which is in the green screen, I use the vector [V0 V1]. For the second part of the matrix which is in the orange screen, I use the vector [V1 V2]. For the third part of the matrix which is in the black screen, I use the vector [V2 V3]. It means for the first step I always work on the first N rows and N*2 columns. Then I shif the screen with M columns and N rows. I tried to program that like this: sz=numel(V); q=sz/N; for ess=1:q % q here = 3 if ess == 1 Hc = H(1:T*2,1:N*2); % Hc=H(1:10,1:20) else if ess ==2 Hc = H(T+1:(T*2)+M,(T*2)+1:(T*2)+(N*2)); % Hc=H(6:15,11:30) else Hc = H((T*2)+1:end,(N*2)+1:end); % Hc=H(11:20,21:40) end But how can I program this loop in general way if I have a long vector V Afluo Raoual https://la.mathworks.com/matlabcentral/profile/authors/11372942 tag:la.mathworks.com,2005:Question/855340 2021-06-13T20:40:57Z 2021-06-16T06:18:46Z Update Image of a uiimage element in a Web App Hi everyyone, I developed a GUI with the AppDesigner in Matlab 2020b. Then I complied it to a Web App on a linux server. It runs quite good, however one strange problem occur. On that GUI, I have an uiimage element whose image should be dynamically loaded. The name of the picture is always the same but it changes due to some user inputs. So the code is always e.g. app.Image.ImageSource = 'picture1.png'; So first I load the picture into the uiimage element, that works. If new user inputs demand some changes of the picture, I reset the uiimage element to app.Image.ImageSource = '';,(that seems to work) Then the new picture is generated and after that I use the function rehash to update the folder and the new picture should be loaded. But it only shows the picture which was loaded first, on the server there is only the new one. It seems that the old picture is somehow cached and because the name is the same, the old image is simply reloaded. Note that no error message is in the log, the problem does not occur while testing in matlab (before compiling it to a web app). EDIT: I have rather the same problem as described here I used the proposed answer and it works if I am using it in the enviroment of the App designer but as a Web App imgArray = 'picture.png' and app.Image.ImageSource = imgArray; does not work. In fact, the uiimage is empty. Does anyone have an idea what the problem could be? Thanks in advance! Best Chris Christian Idzik https://la.mathworks.com/matlabcentral/profile/authors/8039505 tag:la.mathworks.com,2005:Question/857320 2021-06-16T04:07:04Z 2021-06-16T06:13:12Z how to perform data fit like excel? I have observed array of data ( y_obs) and predicted data (y_pred) Predicted data is obtained from an equation How do I fit the observed data to the predicted data by minimizing the coefficient "d" in the equation? ( This is possible in excel, but I could not find a suitable method in matlab Below is my code for steps 1 and 2: % observed data y_obs = [0.3 0.2 0.28 0.318 0.421 0.492 0.572 0.55 0.63 0.61 0.73 0.8 0.81 0.84 0.93 0.91]'; % If y_obs should equal to predicted, I can have more data. J us fo rthe code, I am providing limited observed data t1 = [300:300:21600]'; a=0.0011; gama = 0.01005; d=0.000000000302; n=1; t=300; L2 = zeros(14,1); L3 = zeros(14,1); L4 = zeros(14,1); At = zeros(14,1); t = 300; n =1; L1 = ((8*gama)/((pi*(1-exp(-2*gama*a))))); format shortE for t= 300:300:21600 for n=1:1:14 L2(n) = exp((((2*n + 1)^2)*-d*pi*pi*t)/(4*a*a)); L3(n) = (((-1)^n)*2*gama)+(((2*n+1)*pi)*exp(-2*gama*a))/(2*a); L4(n)= ((2*n)+1)*((4*gama*gama)+((((2*n)+1)*pi)/(2*a))^2); L5(n) = ((L2(n).*L3(n))/L4(n)); end S(t/300) = sum(L5); y_pred(t/300) = 1 -L1*S(t/300); % predicted data end Anand Rathnam https://la.mathworks.com/matlabcentral/profile/authors/20726099 tag:la.mathworks.com,2005:Question/747732 2021-02-17T09:14:11Z 2021-06-16T06:10:59Z Saving a plot as png 224*224*3 image Hi, I have generated a plot in Matlab as shown in figure.When i save it using 'saveas(gcf,'im1.png')' , it is saved as a 656*875*3 png image.I want to save it as 224*224*3 png image without the axis titles,labelling and colorbar.i.e.only the actual plot.Can anyone kindly guide on it? guide about Thanks ali https://la.mathworks.com/matlabcentral/profile/authors/5482129