https://la.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2021-06-16T08:18:47Ztag:la.mathworks.com,2005:Question/8553352021-06-13T20:26:23Z2021-06-16T08:18:47ZReed Solomon encoding/decoding for binary dataI 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 Siddharthhttps://la.mathworks.com/matlabcentral/profile/authors/20317153tag:la.mathworks.com,2005:Question/8574352021-06-16T07:28:33Z2021-06-16T08:17:20ZHow 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 Lorenzhttps://la.mathworks.com/matlabcentral/profile/authors/22083160tag:la.mathworks.com,2005:Question/8573552021-06-16T05:24:56Z2021-06-16T08:14:45ZTraining accuracy remains constant and loss keeps decreasingHi… 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 brarhttps://la.mathworks.com/matlabcentral/profile/authors/7000171tag:la.mathworks.com,2005:Question/8574552021-06-16T07:45:46Z2021-06-16T08:14:02ZIntegration with variable limitHope 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 SharmaVivek Sharmahttps://la.mathworks.com/matlabcentral/profile/authors/19048059tag:la.mathworks.com,2005:Question/8563852021-06-15T02:50:46Z2021-06-16T08:13:32ZUnderstanding 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 Vuchkovhttps://la.mathworks.com/matlabcentral/profile/authors/8815310tag:la.mathworks.com,2005:Question/8574802021-06-16T08:10:58Z2021-06-16T08:10:58ZCreating NetCDF file with new variablesJello 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 Torquatohttps://la.mathworks.com/matlabcentral/profile/authors/22749646tag:la.mathworks.com,2005:Question/8573502021-06-16T05:17:26Z2021-06-16T08:07:10ZSave as xlswrite file in user specified path and user specified nameHi,
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 Yhttps://la.mathworks.com/matlabcentral/profile/authors/22095537tag:la.mathworks.com,2005:Question/8574702021-06-16T08:07:03Z2021-06-16T08:07:03ZTime Lag between Arduino and Matlab for Live data plottingHi 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 Reidhttps://la.mathworks.com/matlabcentral/profile/authors/14812425tag:la.mathworks.com,2005:Question/8574652021-06-16T08:00:28Z2021-06-16T08:00:28ZError 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);
tocpallavi singhhttps://la.mathworks.com/matlabcentral/profile/authors/11458993tag:la.mathworks.com,2005:Question/5821792020-08-20T12:35:56Z2021-06-16T07:59:32ZHow to assign a category to my file exchange fileThe 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 Andreashttps://la.mathworks.com/matlabcentral/profile/authors/476535tag:la.mathworks.com,2005:Question/8561402021-06-14T19:00:39Z2021-06-16T07:59:02ZProblem with exporting Assemblies in Creo Parametric 7.0 with Simscape Multibody LinkI 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 appreciatedAnthony Flöterhttps://la.mathworks.com/matlabcentral/profile/authors/19855415tag:la.mathworks.com,2005:Question/8572902021-06-16T03:13:23Z2021-06-16T07:57:44ZHow 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;
endAmanda Liuhttps://la.mathworks.com/matlabcentral/profile/authors/22829493tag:la.mathworks.com,2005:Question/8570652021-06-15T17:47:44Z2021-06-16T07:53:51ZHow can I apply logics to Spatial Contact Force signalsHi,
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 MamoneFabio Mamonehttps://la.mathworks.com/matlabcentral/profile/authors/5793323tag:la.mathworks.com,2005:Question/8573902021-06-16T06:54:28Z2021-06-16T07:52:21ZSave image with same resolutionHello, 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 drawnHAINGKHARRAN GUNASEKARANhttps://la.mathworks.com/matlabcentral/profile/authors/13121243tag:la.mathworks.com,2005:Question/8574602021-06-16T07:48:12Z2021-06-16T07:48:12ZKittel curve fitting in Matlab for out of plane magnetic fieldHi,
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 Muralidharhttps://la.mathworks.com/matlabcentral/profile/authors/8422056tag:la.mathworks.com,2005:Question/8556152021-06-14T08:50:45Z2021-06-16T07:43:45ZGazebo Customized Plugin: Read contact positions that contains both a variable sized element and an array of sub-busesHello,
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,
YunYunsik Junghttps://la.mathworks.com/matlabcentral/profile/authors/13334235tag:la.mathworks.com,2005:Question/1571842014-10-03T04:18:39Z2021-06-16T07:42:37ZIntegration numerical with variable limitsI 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.DMhttps://la.mathworks.com/matlabcentral/profile/authors/5723273tag:la.mathworks.com,2005:Question/8574102021-06-16T07:15:33Z2021-06-16T07:40:18Zthis 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
endAli Algushtihttps://la.mathworks.com/matlabcentral/profile/authors/16470484tag:la.mathworks.com,2005:Question/8574452021-06-16T07:38:45Z2021-06-16T07:38:45ZTraining 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 Haboubihttps://la.mathworks.com/matlabcentral/profile/authors/17383478tag:la.mathworks.com,2005:Question/4062011-01-25T19:27:47Z2021-06-16T07:37:05ZHow 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 wanghttps://la.mathworks.com/matlabcentral/profile/authors/2295846tag:la.mathworks.com,2005:Question/8574402021-06-16T07:36:23Z2021-06-16T07:36:23ZTraining 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 Haboubihttps://la.mathworks.com/matlabcentral/profile/authors/17383478tag:la.mathworks.com,2005:Question/8567802021-06-15T11:46:16Z2021-06-16T07:33:35ZFinding 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. Thanksrana karemhttps://la.mathworks.com/matlabcentral/profile/authors/22226129tag:la.mathworks.com,2005:Question/920332009-07-27T15:25:00Z2021-06-16T07:33:11ZIs 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 Teamhttps://la.mathworks.com/matlabcentral/profile/authors/4622813tag:la.mathworks.com,2005:Question/8565452021-06-15T07:34:02Z2021-06-16T07:29:36ZDC gain discrete-time transfer function errorHello 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 advanceFrancesco Laezzahttps://la.mathworks.com/matlabcentral/profile/authors/6682721tag:la.mathworks.com,2005:Question/8573702021-06-16T05:47:57Z2021-06-16T07:28:43Zdoes 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 SINGHhttps://la.mathworks.com/matlabcentral/profile/authors/22123928tag:la.mathworks.com,2005:Question/8568452021-06-15T13:02:00Z2021-06-16T07:28:33Zdiff function rearranges symbolic expression leading to non-vanishing termsI 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 Elenkovhttps://la.mathworks.com/matlabcentral/profile/authors/5157104tag:la.mathworks.com,2005:Question/8574302021-06-16T07:27:27Z2021-06-16T07:27:27ZHow 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/22346086tag:la.mathworks.com,2005:Question/8574252021-06-16T07:25:48Z2021-06-16T07:25:48ZInconsistent sampling time errorInconsistent 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 errormuhammad ahmadhttps://la.mathworks.com/matlabcentral/profile/authors/11234519tag:la.mathworks.com,2005:Question/8573602021-06-16T05:25:56Z2021-06-16T07:23:42ZHow 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 Vasallohttps://la.mathworks.com/matlabcentral/profile/authors/22745257tag:la.mathworks.com,2005:Question/8574202021-06-16T07:22:45Z2021-06-16T07:23:18Zhow 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)
jameslkhttps://la.mathworks.com/matlabcentral/profile/authors/10017153tag:la.mathworks.com,2005:Question/8574152021-06-16T07:19:15Z2021-06-16T07:19:15ZLegend does not match with the bar chart in MATLABHello,
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 tavakolihttps://la.mathworks.com/matlabcentral/profile/authors/20411356tag:la.mathworks.com,2005:Question/8551302021-06-13T11:13:54Z2021-06-16T07:15:01ZClassification Lernner don't workHello, 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 DEMIRhttps://la.mathworks.com/matlabcentral/profile/authors/20299671tag:la.mathworks.com,2005:Question/2978492016-07-31T13:07:24Z2021-06-16T07:14:42Zhow cam start the triggerHi, 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 almasihttps://la.mathworks.com/matlabcentral/profile/authors/6550114tag:la.mathworks.com,2005:Question/8574052021-06-16T07:13:51Z2021-06-16T07:13:51ZRow-wise individual circshift of a 3D-matrix without using a loopHello 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,
PascalPascal Wielschhttps://la.mathworks.com/matlabcentral/profile/authors/14507791tag:la.mathworks.com,2005:Question/8574002021-06-16T07:13:44Z2021-06-16T07:13:44ZLeast Trimmed Squares fittingIs there any toolbox or written code for least trimmed square in Matlab?NAhttps://la.mathworks.com/matlabcentral/profile/authors/13711668tag:la.mathworks.com,2005:Question/8568652021-06-15T13:24:58Z2021-06-16T07:12:20Zundefined function in GUIHello, 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 Huihttps://la.mathworks.com/matlabcentral/profile/authors/16984066tag:la.mathworks.com,2005:Question/1283812014-05-05T19:49:31Z2021-06-16T07:09:16ZHow to calculate mean wind directionHello!
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 programmingJenna Mariehttps://la.mathworks.com/matlabcentral/profile/authors/5211601tag:la.mathworks.com,2005:Question/7058932020-12-31T06:49:13Z2021-06-16T07:05:44ZMonitor & Tune Error: Code generation information file does not existI 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[1]: Entering directory `C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles'
"### Successfully generated libcomm.a library."
gmake[1]: 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[1]: Entering directory `C:/PROGRA~3/MATLAB/SupportPackages/R2020b/toolbox/target/supportpackages/arduinobase/staticmakefiles'
"### Successfully generated libcore.a library."
gmake[1]: 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[1]: 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[1]: *** 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[1]: *** Waiting for unfinished jobs....
gmake[1]: *** [MW_PWM.o] Error 1
gmake[1]: *** [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[1]: *** [ArduinoPinHandleMap.o] Error 1
gmake[1]: 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 Elmalawanyhttps://la.mathworks.com/matlabcentral/profile/authors/16115491tag:la.mathworks.com,2005:Question/8569252021-06-15T14:45:17Z2021-06-16T06:58:43ZConvert decimal to ASCIIHello 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 Gangahttps://la.mathworks.com/matlabcentral/profile/authors/18163597tag:la.mathworks.com,2005:Question/8573802021-06-16T06:44:54Z2021-06-16T06:56:15ZHow 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 Huhttps://la.mathworks.com/matlabcentral/profile/authors/20193367tag:la.mathworks.com,2005:Question/8573952021-06-16T06:56:10Z2021-06-16T06:56:10ZMATLAB spinner component as next and prev button for changing imagesI want to use MATLAB spinner component.
I want to use this component to change next and previous image Dollyhttps://la.mathworks.com/matlabcentral/profile/authors/15197313tag:la.mathworks.com,2005:Question/8573852021-06-16T06:49:42Z2021-06-16T06:49:42ZHow 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?Amanhttps://la.mathworks.com/matlabcentral/profile/authors/16786942tag:la.mathworks.com,2005:Question/8570602021-06-15T17:42:08Z2021-06-16T06:47:22ZNew 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 Rathihttps://la.mathworks.com/matlabcentral/profile/authors/13445938tag:la.mathworks.com,2005:Question/3845792018-02-24T15:23:54Z2021-06-16T06:42:23ZThermal 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 Jarrarhttps://la.mathworks.com/matlabcentral/profile/authors/10712339tag:la.mathworks.com,2005:Question/8512852021-06-08T21:20:35Z2021-06-16T06:38:19ZHow 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?!faranhttps://la.mathworks.com/matlabcentral/profile/authors/7609914tag:la.mathworks.com,2005:Question/8573052021-06-16T03:40:13Z2021-06-16T06:24:06ZWhat 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?cuihttps://la.mathworks.com/matlabcentral/profile/authors/3388605tag:la.mathworks.com,2005:Question/8571502021-06-15T20:55:02Z2021-06-16T06:19:27Zusing 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 VAfluo Raoualhttps://la.mathworks.com/matlabcentral/profile/authors/11372942tag:la.mathworks.com,2005:Question/8553402021-06-13T20:40:57Z2021-06-16T06:18:46ZUpdate Image of a uiimage element in a Web AppHi 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
ChrisChristian Idzikhttps://la.mathworks.com/matlabcentral/profile/authors/8039505tag:la.mathworks.com,2005:Question/8573202021-06-16T04:07:04Z2021-06-16T06:13:12Zhow 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 Rathnamhttps://la.mathworks.com/matlabcentral/profile/authors/20726099tag:la.mathworks.com,2005:Question/7477322021-02-17T09:14:11Z2021-06-16T06:10:59ZSaving a plot as png 224*224*3 imageHi,
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
Thanksalihttps://la.mathworks.com/matlabcentral/profile/authors/5482129