https://www.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-07-11T12:07:36Ztag:www.mathworks.com,2005:Question/5532072020-06-23T09:34:37Z2020-07-11T12:07:36ZZERO 🤦🏻♂️Hello every one
I use simulink to do my projects , I've used a random integer , a clock , a constant value and sum all of these , then it goes to a fcn whichnI have defined a code for it , ecery thing us great , then I've taken it to a controlled voltage source and it has connected to S input . Again I ve recognized the parameters of this controlled voltage source . Buuuuuuut the problem is here . It shows just zero . I want to have a variable ac source between for example 180 v to 220 v . Mir Reza Hashemihttps://www.mathworks.com/matlabcentral/profile/authors/17167426-mir-reza-hashemitag:www.mathworks.com,2005:Question/5632972020-07-11T11:27:27Z2020-07-11T12:06:20ZSimple assertion giving incorrect result?Here's a simple version of something that's arising in some code. The student needs to use vpasolve. The reference solution is this:
syms x
x1 = vpasolve(exp(abs(0.1*x))+2*sin(x)==0,-2)
This reference solution returns a value:
x1 =
-2.4487454187687442582374719820392
When the student puts in a different seed value for vpasolve:
syms x
x1 = vpasolve(exp(abs(0.1*x))+2*sin(x)==0,-3)
The learner solution returns the same value as the reference solution:
x1 =
-2.4487454187687442582374719820392
However doing a simple assertion test of whether these two variables are equal fails. Why would this happen?Justin Wyss-Gallifenthttps://www.mathworks.com/matlabcentral/profile/authors/5768087-justin-wyss-gallifenttag:www.mathworks.com,2005:Question/5633122020-07-11T12:01:59Z2020-07-11T12:02:29Zhow to match x-axis subplots?Hi all,
I've attached a figure that contains three subplots which have three different years
what I need is to make all the Ticks matched to each other and in alignment
Any help would be appreciated. Lola SEhttps://www.mathworks.com/matlabcentral/profile/authors/6648456-lola-setag:www.mathworks.com,2005:Question/5632852020-07-11T10:26:00Z2020-07-11T11:53:34ZIgnore comments in a csv fileI have a .csv file that reads as the following:
# nodes.csv file for V-REP kilobot motion planning scene.
# All lines beginning with a # are treated as a comment and ignored.
# Each line below has the form
# ID x y heuristic-cost-to-go
# where ID is the unique integer ID number of the node (1 through N)
# (x y) is the location of the node in the plane and heuristic-cost-to-go
# is an optimistic estimate of the path length from that node to the
# goal node as needed by A* search.
1 -0.5 -0.5 1.4142
2 -0.09 -0.4 1.0762
3 -0.285 -0.305 1.1244
4 0.0575 -0.225 0.8494
5 -0.0525 -0.0175 0.7604
6 -0.37 0.3 0.8927
7 0.3525 -0.0525 0.5719
8 0.0625 0.255 0.5014
9 -0.1 0.3725 0.6134
10 0.4275 0.195 0.3135
11 0.345 0.3525 0.214
12 0.5 0.5 0
The file formatting is not fixed per se and can have multiple lines of comments/nodes when necessary. I realise the csvread() function does not ignore the comments. Can someone suggest a suitable snippet to ignore comments and extract numbers from the .csv file? I am fairly new to programming with Matlab and would appreaciate any help.Aditya Mehrotrahttps://www.mathworks.com/matlabcentral/profile/authors/7721382-aditya-mehrotratag:www.mathworks.com,2005:Question/3952582018-04-16T14:18:51Z2020-07-11T11:51:46ZMost efficent way of finding submatrices of a matrixSay we have a matrix of zeros and ones
0 1 1 1 0 0 0
1 1 1 1 0 1 1
0 0 1 0 0 1 0
0 1 1 0 1 1 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
and we want to find all the submatrices (we just need the row indices and column indices of the corners) with these properties:
# contain at least L ones and L zeros
# contain max H elements
i.e. take the previous matrix with L=1 and H=5, the submatrix 1 2 1 4 (row indices 1 2 and column indices 1 4)
0 1 1 1
1 1 1 1
satisfies the property 1 but has 8 elements (bigger than 5) so it is not good;
the matrix 4 5 1 2
0 1
0 0
is good because satisfies both the properties.
The objective is then to find all the submatrices with min area 2*L, max area H and containg at least L ones and L zeros.
If we consider a matrix as a rectangle it is easy to find all the possibile subrectangles with max area H and min area 2*L by looking at the divisors of all the numbers from H to 2*L.
For example, with H=5 and L=1 all the possibile subrectangles/submatrices are given by the divisors of
* H=5 -> divisors [1 5] -> possibile rectangles of area 5 are 1x5 and 5x1
* 4 -> divisors [1 2 4] -> possibile rectangles of area 4 are 1x4 4x1 and 2x2
* 3 -> divisors [1 3] -> possibile rectangles of area 3 are 3x1 and 1x3
* 2*L=2 -> divisors [1 2] -> possibile rectangles of area 2 are 2x1 and 1x2
I wrote this code, which, for each number finds its divisors and cycles over them to find the submatrices. To find the submatrices it does this: take for example a 1x5 submatrix, what the code does is to fix the first line of the matrix and move step by step (along all the columns of the matrix) the submatrix from the left edge of the matrix to the right edge of the matrix, then the code fixes the second row of the matrix and moves the submatrix along all the columns from left to right, and so on until it arrives at the last row.
It does this for all the 1x5 submatrices, then it considers the 5x1 submatrices, then the 1x4, then the 4x1, then the 2x2, etc.
The code do the job in 2 seconds (it finds all the submatrices) but for big matrices, i.e. 200x200, a lot of minutes are needed to find all the submatrices. So I wonder if there are more efficient ways to do the job, and eventually which is the most efficient.
This is my code:
clc;clear all;close all
%% INPUT
P= [0 1 1 1 0 0 0 ;
1 1 1 1 0 1 1 ;
0 0 1 0 0 1 0 ;
0 1 1 0 1 1 1 ;
0 0 0 0 0 0 1 ;
0 0 0 0 0 0 1];
L=1; % a submatrix has to containg at least L ones and L zeros
H=5; % max area of a submatrix
[R,C]=size(P); % rows and columns of P
sub=zeros(1,6); % initializing the matrix containing the indexes of each submatrix (columns 1-4), their area (5) and the counter (6)
counter=1; % no. of submatrices found
%% FIND ALL RECTANGLES OF AREA >= 2*L & <= H
%
% idea: all rectangles of a certain area can be found using the area's divisors
% e.g. divisors(6)=[1 2 3 6] -> rectangles: 1x6 6x1 2x3 and 3x2
tic
for sH = H:-1:2*L % find rectangles of area H, H-1, ..., 2*L
div_sH=divisors(sH); % find all divisors of sH
disp(['_______AREA ', num2str(sH), '_______'])
for i = 1:round(length(div_sH)/2) % cycle over all couples of divisors
div_small=div_sH(i);
div_big=div_sH(end-i+1);
if div_small <= R && div_big <= C % rectangle with long side <= C and short side <= R
for j = 1:R-div_small+1 % cycle over all possible rows
for k = 1:C-div_big+1 % cycle over all possible columns
no_of_ones=length(find(P(j:j-1+div_small,k:k-1+div_big))); % no. of ones in the current submatrix
if no_of_ones >= L && no_of_ones <= sH-L % if the submatrix contains at least L ones AND L zeros
% row indexes columns indexes area position
sub(counter,:)=[j,j-1+div_small , k,k-1+div_big , div_small*div_big , counter]; % save the submatrix
counter=counter+1;
end
end
end
disp([' [', num2str(div_small), 'x', num2str(div_big), '] submatrices: ', num2str(size(sub,1))])
end
if div_small~=div_big % if the submatrix is a square, skip this part (otherwise there will be duplicates in sub)
if div_small <= C && div_big <= R % rectangle with long side <= R and short side <= C
for j = 1:C-div_small+1 % cycle over all possible columns
for k = 1:R-div_big+1 % cycle over all possible rows
no_of_ones=length(find(P(k:k-1+div_big,j:j-1+div_small)));
if no_of_ones >= L && no_of_ones <= sH-L
sub(counter,:)=[k,k-1+div_big,j,j-1+div_small , div_big*div_small, counter];
counter=counter+1;
end
end
end
disp([' [', num2str(div_big), 'x', num2str(div_small), '] submatrices: ', num2str(size(sub,1))])
end
end
end
end
fprintf('\ntime: %2.2fs\n\n',toc)giannithttps://www.mathworks.com/matlabcentral/profile/authors/11208505-giannittag:www.mathworks.com,2005:Question/5633062020-07-11T11:45:58Z2020-07-11T11:51:32ZHow do I create separate bits sequences from one big frame I am generate frame with 2688 bits dimension from matlab code. Now I want separate this frame on 16 parts with 168 bits dimensions. For this purpose I create For iteration subsystem in Simulink, which depicted on picture. But this subsystem return last sequence wirh 168 bits on output instead 16 sequences. How I can resolve this problem in triggered subsystem?
MaksymHolub99https://www.mathworks.com/matlabcentral/profile/authors/17025780-maksymholub99tag:www.mathworks.com,2005:Question/5633092020-07-11T11:49:17Z2020-07-11T11:49:17ZPcolor equivalent for 3D arrayHi guys,I want to draw the figure below. I know to use the pcolor function to draw 2D graphics. But now I have a 3D array and I would like a 3D plot of such an array - essentially a 3D cube consisting of 8 "subcubes", with different colors for different numbers just like shown below.
Can anyone help me plot this? Thanks.
CH XYhttps://www.mathworks.com/matlabcentral/profile/authors/18951775-ch-xytag:www.mathworks.com,2005:Question/5632942020-07-11T11:25:40Z2020-07-11T11:48:30ZUnable to perform assignment because the size of the left side is 7-by-1 and the size of the right side is 7-by-7Hi, I would like to pass some extra arguments to my ODE as follows:
[T,H] = ode23t(@(t,h) MYODE(t,h,G,N,e,n,z,initialnode,w,Qcell,lambda), tspan, h0, opts);
[~,Qcell] = cellfun(@(t,h) MYODE(t,h,G,N,e,n,z,initialnode,w,Qcell,lambda), num2cell(T), num2cell(H,2), 'uni',0);
but I get this error:
Unable to perform assignment because the size of the left side is 7-by-1 and the size of the right side is 7-by-7.
Any idea on how to fix it?Simhttps://www.mathworks.com/matlabcentral/profile/authors/14233052-simtag:www.mathworks.com,2005:Question/5633032020-07-11T11:34:26Z2020-07-11T11:38:55ZSelecting specific columns in a for loop Hi everyone,
I would like to select to multiply integers between 401:500 with a matrix as shown in the code below
for j=401:500
Meas_Load{j,1}= RLoad2 - j.*RPVR;
end
My expectation is that the variable Meas_Load is a cell if dimension 100 by 1. Unfortunately the resulting dimension is 500 by 1. How can I achieve a 100 by 1 cell in this loop? ThanksLuihttps://www.mathworks.com/matlabcentral/profile/authors/12223275-luitag:www.mathworks.com,2005:Question/5409982020-06-03T02:25:51Z2020-07-11T11:37:13ZHow to solve such a system of nonlinear equations?My specific problem is: on a fixed (320*320) size image, there are 2 known object-detection boundingboxes, shown in green in the figure, The problem is that only the width and height (W and H) of another object-detection boundingbox(red color) are known, how to determine the x and y of the red object-detection boundingbox so that its intersection with all other green object-detection boundingboxes is 0 (All IOU=0)?
The object-detection boundingboxes is represented by four elements [x, y, w, h], respectively representing the x coordinate, y coordinate, rectangle width and height of the upper left corner of the image.
In the following example, the solution set of the coordinate range of the upper left corner of the red object-detection boundingbox should be {0<x<20,150<y<220}, but the program cannot solve it，and I tried to solve my problem in 2 ways, but I still can't get my answer. Why?
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
我的具体问题是：在一副固定（320*320）大小尺寸的图像上，有2个已知的目标检测框，在图中用绿色显示，问题是仅已知另外一个检测框的宽和高（W和H)情况下,如何确定该红色检测框的x,y，使得其与其他所有绿色检测框的交并比都为0？
检测框用[x,y,w,h]四个元素表示，分别表示图像左上角x坐标，y坐标，矩形宽和高。
在以下示例中，红色检测框的左上角点坐标范围解集应该为 {0<x<20,150<y<220}，但程序无法解出，我尝试2种方法求解，但程序无法得到我的答案，请问为什么？
%%
% The first method is to solve inequalities. The problem is that I don't know how to list the desired equations.（第一种方法，解不等式求解，出现问题是不知道如何列出想要的等式）
objectROIs = [50,50,100,100;
80,80,200,230];
image = zeros(320,320,3,'uint8');
image = insertObjectAnnotation(image,'rectangle',objectROIs,'object','Color','green');
imshow(image)
W = 60;
H = 100;
% solve eqns
syms x y
eqn1 = x>0;
eqn2 = y>0;
eqn3 = x<320-W;
eqn4 = y<320-H;
eqn5 = sum(bboxOverlapRatio([x,y,W,H],objectROIs),'all')==0; % error!!!
f = @(x,y)bboxOverlapRatio([x,y,W,H],objectROIs);
% 红色检测框的左上角点坐标范围解集应该为 {0<x<20,150<y<220}，但程序无法解出
eqns = [eqn1,eqn2,eqn3,eqn4,eqn5];
S = solve(eqns,[x,y],'ReturnConditions',true)
%% The second method, the optimization solution fails, exitflag has no solution（第二种方法，优化求解失败，exitflag无解）
W = 60;
H = 100;
fun = @(x)sum(bboxOverlapRatio([x(1),x(2),W,H],objectROIs),'all');
lb = [0,0];
ub = [320-W,320-H];
A = [];
b = [];
Aeq = [];
beq = [];
% nonlcon = @mycon(x,W,H,objectROIs);
x0 = (lb + ub)/2;
options = optimoptions('fmincon','Display','iter','Algorithm','interior-point');
[x,fval,exitflag] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,@(x)mycon(x,W,H,objectROIs),options)
ious = bboxOverlapRatio([round(x),W,H],objectROIs)
image = insertObjectAnnotation(image,'rectangle',[round(x),W,H],'insert','Color','red');
imshow(image)
-----------------------------------------------------method1 error!-----------------------------------------------
Error using bboxOverlapRatio
The value of 'bboxA' is invalid. Expected input to be one of these types:
uint8, int8, uint16, int16, uint32, int32, single, double
Instead its type was sym.
Error in bboxOverlapRatio>validateAndParseInputs (line 195)
parser.parse(bboxA,bboxB,varargin{:});
Error in bboxOverlapRatio>iParseInputs (line 94)
[bboxA, bboxB, ratioType] = validateAndParseInputs(bboxA, bboxB, varargin{:});
Error in bboxOverlapRatio (line 55)
[bboxA, bboxB, ratioType, isUsingCodeGeneration] = iParseInputs(bboxA,bboxB,varargin{:});
Error in TEST (line 17)
eqn5 = sum(bboxOverlapRatio([x,y,W,H],objectROIs),'all')==0;
------------------------------------------------------------method2, No feasible solution! ？？？ ----------------------------------------------------------------------------------
Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the value of the step size tolerance but constraints are not
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
x =
150.0000 110.3551
fval =
0.1304
exitflag =
-2
ious =
0 0.1304
function [c,ceq] = mycon(x,W,H,objROIs)
c = []; % Compute nonlinear inequalities at x.
ceq = sum(bboxOverlapRatio([round(x),W,H],objROIs),'all'); % Compute nonlinear equalities at x.cuihttps://www.mathworks.com/matlabcentral/profile/authors/3388605-cuitag:www.mathworks.com,2005:Question/5632912020-07-11T11:03:43Z2020-07-11T11:36:34Zhow to run a function file in for loopDear all,
I am new to matlab. I want to run a function file in for-loop in different m-file.
suppose my function file is
function p =RCfilter(fs)
fs = 15;
-----
-----
p = sincOp.*cosOp;
end
i want to call this function in another file in for loop:
for l=1:1:4
Channel=Channel+j*alpha(l)*a(:,l)'*RCfilter(Ts - ndelay(l))-------how to call function RCfilter here;
end
please help!!jyotihttps://www.mathworks.com/matlabcentral/profile/authors/4744431-jyotitag:www.mathworks.com,2005:Question/5633002020-07-11T11:34:26Z2020-07-11T11:34:26ZHow to apply fluorescent filtering on an already working edge detection code?Hi all, back again!
I have a really great piece of code for edge detection (see attached) however prior to getting it working, my previous code created fluorescent style images such as attached. The code for it is seen here:
"
Function Vid_Edge_Detection_flourescent
v = VideoReader('VID00125.AVI');
n = v.NumFrames;
for i = 1:n
I0 = read(v,i);
I1 = im2bw(I0,graythresh(I0)-0.03); % binarize image with treshold
I2 = bwareaopen(I1,50); % remove small regions (50 pixels)
I3 = edge(I2);
II = imfuse(I0,I3);
imshow(II,'initialmagnification','fit')
pause(0.1)
end
end
"
From what I understand, the old code produced a double layer, the background one being altered to a green background and the forground being the edge detection. Essentially, I'm trying to get the same thing for the new attached code but because of all the for loops, I really have no idea where/what to change. Can anyone assist?
Thanks in advance,
Ben Ben Timmhttps://www.mathworks.com/matlabcentral/profile/authors/17828366-ben-timmtag:www.mathworks.com,2005:Question/5625142020-07-09T20:01:46Z2020-07-11T11:30:29ZUse struct data from MATLAB workspace in StateflowI have a struct in the MATLAB workspace with some values and some arrays stored in it. I need to access some of the values from this struct in a Stateflow block in Simulink. What is the best way to be able to access these values?
My struct name is 'A' and I want to access the value 'b'. In Stateflow, I tried just referencing 'A.b' as I would in MATLAB, and it does not work.
I have seen that using a bus might be possible, but I cannot find a way to convert a struct to a bus and then use that bus as an input to the Stateflow.Cole Pratthttps://www.mathworks.com/matlabcentral/profile/authors/16004889-cole-pratttag:www.mathworks.com,2005:Question/5628562020-07-10T12:56:39Z2020-07-11T11:29:46ZFor loop in matrixI'd like to create the matrix by two loops.
I tried to make the form below. Using "For loop"function, how can I make the code?
A=1;%dV/dx when x=1,A(0)=1
V=2;%V when x=1,V(0)=1
a=0; b=1;
n=100;
x=linspace(a,b,n);
h=x(n+1)-x(n);
V(i+1)=V(i)-A(i)-h.^2;% when i is from 0 to n
A(i+1)=A(i)+h;% when i is from 0 to n
plot(transpose(x),V,'r')sookyung Kanghttps://www.mathworks.com/matlabcentral/profile/authors/18559995-sookyung-kangtag:www.mathworks.com,2005:Question/5617282020-07-08T15:32:17Z2020-07-11T11:29:37ZWORKER NOT RESPONSIVE issue on matlab on-ramp courseHi,
Currently, i am facing a problem while progressing in the matlab on-ramp course, but we cant proceed any further anymore while i reached 13.2 due to "WORKER NOT RESPONSIVE" or non-stop loading.
Could i get some assists here? Thanks in advance.KOK FU JIEhttps://www.mathworks.com/matlabcentral/profile/authors/18675977-kok-fu-jietag:www.mathworks.com,2005:Question/5611432020-07-07T16:48:09Z2020-07-11T11:29:36ZMatlab Grader & LMS Viewing Student SolutionsThis is a different issue than a recent post of mine regarding downloading student solutions.
When I view Learner Solutions in Canvas+Grader there's no identification of which student submitted which solution. In other words it's not at all clear to me how (if?) I can look at the submission for a particular student of my choosing. The "Selected Learner" tab within the page lets me select a student but apparently not by student name.
So - how can I, for a given student, look at (for example) the most recent code that the student has submitted? If a student mails me and asks me to look at the code they submitted, how can I do this basic thing?Justin Wyss-Gallifenthttps://www.mathworks.com/matlabcentral/profile/authors/5768087-justin-wyss-gallifenttag:www.mathworks.com,2005:Question/5629252020-07-10T15:22:42Z2020-07-11T11:23:40ZPassing bus signals through a switch block Hi
I've a model.slx which has 2 inports with 2 datatypes of equivalent child busses. These child buses are fed into a subsystem, for further processing.
I want the feed bus be switching from source inport 1 to inport 2, based on a certain condition. I'm using switch block for this.
To exlempify this:
Bus1 and Bus2 at in1 and in2, whose child busses are selected using a busSelector.
Bus1_child1 and Bus2_child1 are to be fed to a certain subsystem, and are inputs of a switch block (at inport 1 and 3).
Swicth block has a condition making it switch between both busses.
But it gives an error:
Data type mismatch. Input port 3 of 'switch_demo/Switch1' expects a signal of data type 'Bus2_child1'. However, it is driven by a signal of data type 'Bus1_child1'.
Data type mismatch. Output port 1 of 'switch_demo/From1' is a signal of data type 'Bus1_child1'. However, it is driving a signal of data type 'Bus2_child1'.
Component:Simulink | Category:Modelerror
NOTE1: This error is seen to be noticed when a non Virtual bus is being fed to swicth, if it helps identify the issue.
NOTE2: Both child busses (Bus1_child1 and Bus2_child1) have equivalent structure, except for names of child busses. Although, there is change in datatypes but i changed to while trying to resolve the error, but no luck.
So, my question will be that if the documentation says switch block can handle signals with bus DTs, then it should right ?
If the approach I've chosen to go is somewhat wrong or doesn't align with the modelling guidelines, do let me know.
Any better suggestions for switching between two equivalent busses will be more than appreciated.
Thanks!!
Umeshyou messhttps://www.mathworks.com/matlabcentral/profile/authors/12982275-you-messtag:www.mathworks.com,2005:Question/2644592016-01-20T07:35:13Z2020-07-11T11:20:30ZFailed to Call Classification Learner's Testing FunctionI was using a Matlab R2015b's Classification Learner Toolbox. I was successful in importing file data and export it into an Export Model, and i got a structure named *_trainedClassifier_*.
Import process #1
<</matlabcentral/answers/uploaded_files/43947/Capture.JPG>>
Import process #2
<</matlabcentral/answers/uploaded_files/43948/Capture2.JPG>>
Training process with PCA implemented & Multi Class SVM (One vs All validation)
<</matlabcentral/answers/uploaded_files/43949/Capture3.JPG>>
*trainedClassifier* variable generated from ToolBox
<</matlabcentral/answers/uploaded_files/43950/Capture4.JPG>>
*fetureVector* variable which used for testing
yfit = trainedClassifier.predictFcn(featureVector)
<</matlabcentral/answers/uploaded_files/43951/Capture5.JPG>>
After it, i want to doing a test with a new data with this code (i got this code from <http://www.mathworks.com/help/stats/export-classification-model-for-use-with-new-data.html here> ) :
>> yfit = trainedClassifier.predictFcn(featureVector)
Then i got an error output as a follows :
Function 'subsindex' is not defined for values of class 'cell'.
Error in mlearnapp.internal.model.DatasetSpecification>@(t)t(:,predictorNames) (line 135)
extractPredictorsFromTableFcn = @(t) t(:,predictorNames);
Error in mlearnapp.internal.model.DatasetSpecification>@(x)extractPredictorsFromTableFcn(splitMatricesInTableFcn(convertMatrixToTableFcn(x)))
(line 136)
extractPredictorsFcn = @(x) extractPredictorsFromTableFcn(splitMatricesInTableFcn(convertMatrixToTableFcn(x)));
Error in mlearnapp.internal.model.DatasetSpecification>@(x)exportableClassifier.predictFcn(extractPredictorsFcn(x)) (line 137)
exportableClassifier.predictFcn = @(x) exportableClassifier.predictFcn(extractPredictorsFcn(x));
What is the problem and solutions?
Thanks in advance.Angga Lisdiyantohttps://www.mathworks.com/matlabcentral/profile/authors/6804712-angga-lisdiyantotag:www.mathworks.com,2005:Question/4713052019-07-11T15:21:47Z2020-07-11T10:54:26ZHow to train net with high class imbalance?Hi, I am doing a semantic segmentation that has a large difference between the two classes. So that, it tends to overpredict when I train the network. Is there any way to train the network specifically in one of the classes?
I am using classweights already, but as most of the pictures is background, the training accuracy tends to increase and the loss to decrease until constant, which generates zero accuracy when testing in the most important but imbalanced class.Carlos Loredo López-Moragohttps://www.mathworks.com/matlabcentral/profile/authors/13335098-carlos-loredo-lopez-moragotag:www.mathworks.com,2005:Question/5185642020-04-17T02:40:00Z2020-07-11T10:52:21ZHow to deal with imbalanced dataset classification by support vector machineI have a dataset that is heavily skewed in one class. The training with support vector machine (SVM), by either fitcsvm.m or fitcecoc.m, cannot give desirable results. The accuracy for the class that has more samples is more than 90%, but for the class with much fewer samples is barely 70%. Is there any way to improve the training by SVM? or other methods that can be used to tackle the umbablanced data training?Yuzhen Luhttps://www.mathworks.com/matlabcentral/profile/authors/8338519-yuzhen-lutag:www.mathworks.com,2005:Question/5632882020-07-11T10:48:51Z2020-07-11T10:48:51ZDerivatice of vector and Test it using spline functionHello Everyone,
I made a 3D Track using spline function and i would like to take the derivatives of the vectors and want to test with 1st and second order spline function.I used diff() function to take derivatives but results are not okay.Can anybody help how can i do it.I have attached my code.Thank you.Imtiaz Ahmadhttps://www.mathworks.com/matlabcentral/profile/authors/16456545-imtiaz-ahmadtag:www.mathworks.com,2005:Question/4052532018-06-12T12:03:22Z2020-07-11T10:48:04Zdealing imbalanced data in neural networkI want to use deep learning network for classification problem.
I have an issue of imbalanced data, means one of the classes have less training examples than the others.
I know there is an option to remove training data from the other classes, but I wonder if there is other solution.
For example, is there an option to modify the cost layer such that the cost of miss classification a specific class will be larger?
Thanks,
Tallyhttps://www.mathworks.com/matlabcentral/profile/authors/3777204-tallytag:www.mathworks.com,2005:Question/5630812020-07-10T21:44:30Z2020-07-11T10:45:06ZError in smimport(' ') command: Illegal use of reserved keyword "end" AND Attempt to execute SCRIPT smimport as a functionHello. I tried to import a CAD model from solidworks (xml file format) to simsape multibody, using the smimport command. The command does not seem to work as i get the following error:
Error: File: smimport.m Line: 170 Column: 1
Illegal use of reserved keyword "end".
When i click on the error the following file appears:
Does anyone knows what is this error?
I then tried to run the matlab as administrator and delete the 'end' from line 170. Then i got a different error:
>> smimport('sm_Assem.xml')
Attempt to execute SCRIPT smimport as a function:
C:\Program Files\MATLAB\R2018b\toolbox\physmod\sm\import\m\smimport.m
I have no idea what is this script file and i am afraid i will mess it up if i try to modify it.
Any help would be really appreciated.
Thank you
Eleni.Thttps://www.mathworks.com/matlabcentral/profile/authors/16876768-eleni-ttag:www.mathworks.com,2005:Question/5623942020-07-09T16:25:06Z2020-07-11T10:39:36ZPrint the Matlab App designer "Design View"Hi,
Is there a way to print the Matlab App designer "Design View"? I could not find a way to save it as 500 DPI so maybe printing and scanning will solve this issue (BTW Using screen capture and than print give very bad results).
Thanks.Lluis Rocahttps://www.mathworks.com/matlabcentral/profile/authors/4250935-lluis-rocatag:www.mathworks.com,2005:Question/5629102020-07-10T15:02:19Z2020-07-11T10:23:44Zanother app designer tooltip bug?I have quite a few uicontrols in my_ App, which I have just migrated from GUIDE to Appdesigner. Because HTML does not work in Appdesigner, I started editing all my tooltips removing HTML code from them. Everything was OK up to some point. Beginning from that point, Appdesigner suddenly started adding additional apostrophes and brackets, such that those apostrophes and brackets are displayed explicitly in my_App. In the exported m-file, the following examples can be seen:
app.EditField.Tooltip = '''text1 example''';
app.EditField.Tooltip = '{''text2 example''}';
app.EditField.Tooltip = '{''text31'';''text32 example''}';
app.EditField.Tooltip = '{''''text4 example''''}';
It happens in tooltips for EditField.
All my attempts to remove not needed brackets and apostrophes using 'Inspector' (COMPONENT BROWSER) lead to adding additional apostrophes. Also, new attempt to edit previously correctly displayed tooltip text leads to addition of aliased apostrophes and/or brackets. After deleting the text from the box comletely, there are still brackets {}, which you cannot get rid of - they appear with mouse click automatically.
Is any way to stop this kind of activity from Appdesiner? Or what could went wrong? Of course, I can use the exported m-file and correct all the quoted tooltips there, however, it is annoying.
Finally, I have decided that the best strategy for me is to get rid of HTML in tooltips within GUIDE and then to migrate to Appdesigner.
version is r2020aG Ahttps://www.mathworks.com/matlabcentral/profile/authors/958668-g-atag:www.mathworks.com,2005:Question/5622742020-07-09T13:11:58Z2020-07-11T10:23:19ZHow to find bouding boxes of objects ? I'm working on a video synopsis project and i have trouble finding the bouding boxes of detected objects. I want to find which bouding boxes correspond to which object
Let's say i have three objects detected in the current frame so i have a bouding box matrix with three lines, which line corresponds to which object ? Saïd Aissiouhttps://www.mathworks.com/matlabcentral/profile/authors/12373883-said-aissioutag:www.mathworks.com,2005:Question/5632822020-07-11T10:22:35Z2020-07-11T10:22:35Zstop band ripples vs stop band attenuation?What is difference between stop band ripples and stop band attenuation?Please show/explain with matlab plotABTJhttps://www.mathworks.com/matlabcentral/profile/authors/13735689-abtjtag:www.mathworks.com,2005:Question/349312012-04-09T16:12:54Z2020-07-11T10:22:21Zsearching any string and sorting in DNS queries (question updated)problem statement:-
i have a nx2 matrix with n rows and 2 columns. one of the columns is having hostnames, i.e www.google.com , www.facebook.com etc...
the matrix has been derived out of the DNS queries in a network. so its a huge number of DNS queries or queried hostnames.
momentarily leave all the previous stuff aside , now i get a list of hostnames that are malware affected or blacklisted or infected. and what i need to do is to find whether any of the blacklisted domain(i get from a different source , say an antivirus compay) is there in the DNS queries of my network log or not.
say for example : - ww w .ma thworks . com (space intentionally left)
is an infected site and i want to look into my DNS traffic that is there any hostname queried that matches with mathworks.com ? and that would let me an insight into if i my network is a part of a botnet or a victim of a trojan or something like that.
so i was planning that if i sort out the words like mathworks in above case and matching the strings in the network traffic log or DNS log . for that i need to get all the keywords between two dots in a hostname , say
we have to get (google and co) from www.google.co.in
and if we get the keywords between dots then we can match it with the original DNS log file to get whether my network is infected or not.
i seriously think i am pretty bad at explaining things :(Karanhttps://www.mathworks.com/matlabcentral/profile/authors/3421777-karantag:www.mathworks.com,2005:Question/5632702020-07-11T09:56:13Z2020-07-11T10:20:21Zimporting cad geometry from solidworki have convert my solid work file in stl
>> model = createpde('structural','static-solid');
>> importGeometry(model,'knucle upper.stl');
Error using pde.EquationModel/importGeometry (line 45)
File "knucle upper.stl" does not exist.
it is showing this error how to deal eith that
Rupesh Chitkarahttps://www.mathworks.com/matlabcentral/profile/authors/15765681-rupesh-chitkaratag:www.mathworks.com,2005:Question/5632792020-07-11T10:15:45Z2020-07-11T10:15:45ZConfusion implementing chebyshev type 2 band pass filter in matlabI want to implement chebyshev type 2 band pass filter in matlab;actually i am not getting band pass oytput,output looks like low pass
My code is below
% Design a band pass Chebyshev Type II filter using analog prototyping. The
% order of filter is 20 with a value of 60 dB stop band attenuation and 0.75 dB pass band
% ripple where,
% Pass band edge = 800 Hz
% Stop band edge = 2000 Hz
% Sampling frequency = 6000
clc; close all; clear all;
Rp = 0.75; Rs = 60;
fp = 800;
fs = 2000;
Fs = 6000;
fn = Fs/2; % nyquist frequency
wp = fp/fn; % Pass band corner frequency
ws = fs/fn; % Stop band corner frequency
[n,Wn] = cheb2ord(wp,ws,Rp,Rs);
[num,den] = cheby2(20,Rs,Wn);
freqz(num,den,512,Fs);
I have also attached snapshot of output which shows that output frequency plot looks like low pass,
ABTJhttps://www.mathworks.com/matlabcentral/profile/authors/13735689-abtjtag:www.mathworks.com,2005:Question/926342013-01-03T19:04:00Z2020-07-11T10:09:19ZWhy do I get a connection error when installing or activating MATLAB or another MathWorks product?I get an error that I cannot connect to MathWorks when running the MATLAB installer or the activation client. However, I can access the website. Why can't the activation client connect to the MathWorks?
Connection Error
The application could not connect to MathWorks.
For more information on resolving this issue, see this Support Article.
MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/5632732020-07-11T09:56:51Z2020-07-11T09:57:47ZDisplay data from structure into Table using AppDesignerHello guys,
im trying to fill a table in AppDesigner with data which i have stored in a structure before. I have added the errors in the code. (just the last few lines).
function EinlesenButtonPushed(app, event)
%Diese Funktion dient dem direkten Lesen der auf dem übergeben Pfad
%hinterlegten CSV-Datei. Diese Datei muss exakt der Formatierung der
%Dateien entsprechen die das Program "Power" des Diagnostikgerätes
%liefert.
%Einlesen der Datei über den Umweg mit strings
% Öffnen eines Fensters zur Auswahl der zu öffnenden .csv Dateien.
[filename,pathname] = uigetfile('*.csv;','MultiSelect',"on");
for i = 1:length(filename)
filepath=fullfile(pathname, filename);
fid = fopen (filepath{i});
%[file,path]=uigetfile('*.csv');
A = textscan(fid, '%s%s%s%s%s%s%s%s%s%s%s%s%s','Delimiter',';');
%Umwandeln von Cell --> String
B=string([A{:}]);
%',' durch '.' ersetzen
B=replace(B,',', '.'); % ',' durch '.' ersetzen
% Aufteilen in Header und Messdaten
Daten(i).Header=B(1:30,:);
Daten(i).Messdaten=str2double(B(31:end,7));
end
for i = 1:length(filename)
app.UITable.Data(i,1) = filename{i};
%Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
app.UITable.Data(i,2) = Daten(i).Header(11,1);
app.UITable.Data(i,3) = Daten(i).Header(12,1);
% I dont get an error here but in my Table the values is shown as "NaN".
app.UITable.Data(i,4) = Daten(i).header(21,1);
% Reference to non-existent field 'header'.
end
i dont want to extract the filename, just the end of the name which is sth. like "P1"," P2" etc. but i thought im trying to read in the whole name in first before i try to extract the information in want (im just trying to code it step by step, since im really new to matlab).
The same thing goes for the information i want from my .csv file.
the .csv file looks like this:
Johannes Kilianhttps://www.mathworks.com/matlabcentral/profile/authors/18856656-johannes-kiliantag:www.mathworks.com,2005:Question/5632762020-07-11T09:56:57Z2020-07-11T09:56:57ZHow do I draw overlapping circles wich change color?
It shoul look like thisSeverin Stoophttps://www.mathworks.com/matlabcentral/profile/authors/16824480-severin-stooptag:www.mathworks.com,2005:Question/5632642020-07-11T09:41:53Z2020-07-11T09:46:35ZRECORD SYSTEM AUDIO IN MATLAB (NO MICROPHONES)How to record system audio in MATLAB (for example: Song playing on Youtube) without third party app.
Actually my goal is to uninstall all the apps and do everything with MATLAB (i know it's silly)
Regards,
Sugar
Sugar Daddyhttps://www.mathworks.com/matlabcentral/profile/authors/18657416-sugar-daddytag:www.mathworks.com,2005:Question/5624782020-07-09T18:46:54Z2020-07-11T09:46:00ZEffect of Step Size ODEHello,
my big deal is to demonstrate the effect of the step size of differential equations with an intial value problem.
Make a choice for two methods of different orders (like Euler combined with Hern), (in total we have 4 Methods - Euler, Heun, Runge-Kutta, Simpson)
start to apply both methods in order to compute (t_k,y_k) from (t_(k-1),y_(k-1)) with both methods using a step size h,
compute the difference between the two values y_k (Euler) and y_k (Heun); this is called local error e_k here,
When the local error is high (let us say, e_k> 0.01), the step size has to be reduced (for example h is replecd by h/2), and the computation is redone. Otherwise, when the local error is very small (let us say, e_k > 0.0001), the step size is increased (for example h is replaced by 1.5*h), and the computation of the y_k is redone with the new step size.
how can i combine the user input, if the user choose two variables? --> I think the switch case is not correct....
i have an error in the functions, matlab told me, that y has too many output arguments and i should consider the preallocating, but in the beginning, i defined y=zeros; what can i do?
clear all;
clc;
clf;
F=@(t,y) 200*(y+0.01).^2*(0.2-y); %Initial Value Problem
m = input ('Please choose the first method (1=Euler; 2=classical Runge-Kutta; 3=modified Simpson; 4=Heun: ');
l = input ('Please choose the second method (1=Euler; 2=classical Runge-Kutta; 3=modified Simpson; 4=Heun: ');
a = input('Enter left end ponit, a: ');
b = input('Enter right end point, b: ');
N = input('Enter no. of subintervals, n: ');
y0 = input('Enter the initial value problem, y0: ');
h = (b-a)/N; %Stepsize
x=a:h:b;
y=zeros;
% User Choice
switch m
case 1
plot(x,euler,'--','red')
case 2
plot(x,runge,'--','green')
case 3
plot(x,simpson,'--','black')
case 4
plot(x,heun,'--','blue')
end
switch l
case 1
plot(x,euler,'--','red')
case 2
plot(x,runge,'--','green')
case 3
plot(x,simpson,'--','black')
case 4
plot(x,heun,'--','blue')
end
% Euler´s Method
function euler
for i=1:(lenght(x)-1)
y(i+1)=y(i)+h*F(x(i),y(i));
end
end
% Runge-Kutta Method
function runge
for i=1:(lenght(x)-1)
k1 = F(x(i-1),y(i-1));
k2 = F(x(i-1)+0.5*h,y(i-1)+0.5*h*k1);
k3 = F((x(i-1)+0.5*h),(y(i-1)+0.5*h*k2));
k4 = F((x(i-1)+h),(y(i-1)+k3*h));
y(i) = y(i-1) + (h/6)*(k1+2*k2+2*k3+k4);
end
end
% modified Simpson Method
function simpson
for i=1:(lenght(x)-1)
k1=F(x(i-1),y(i-1));
k2=F(x(i-1)+(h/2),y(i-1)+(h/2)*k1);
k3=F(x(i-1)+h,y(i-1)+h*k2);
y(i)=y(i-1)+(h/6)*(k1+4*k2+k3);
end
end
% Heuns's Method
function heun
for i=1:(lenght(x)-1)
k1=F(x(i-1),y(i-1));
k2=F(x(i-1)+h,y(i-1)+h*k1);
y(i)=y(i-1)+(h/2)*(k1+k2);
end
endmiluuuhttps://www.mathworks.com/matlabcentral/profile/authors/16301361-miluuutag:www.mathworks.com,2005:Question/5632672020-07-11T09:45:04Z2020-07-11T09:45:04ZDifference in background normalizatinhello everyone,
i just wanted to know what is the difference between background normalizatin and background correction .
thank you for the helpshmuel manashirovhttps://www.mathworks.com/matlabcentral/profile/authors/15027393-shmuel-manashirovtag:www.mathworks.com,2005:Question/5632612020-07-11T09:34:03Z2020-07-11T09:34:03ZWhy we Need scaling offset ?Why we need scaling offset in fixed point conversation .Arun reddyhttps://www.mathworks.com/matlabcentral/profile/authors/14407532-arun-reddytag:www.mathworks.com,2005:Question/5632582020-07-11T09:33:24Z2020-07-11T09:33:24ZTip for running MATLAB scripts in Python CodeHi,
I've used Windows to develop a MATLAB script, and wish to use it from within a Linux Python application.
As I've searched online, my options are:
1) Get a MATLAB license for Linux, compile the code to .sh file in the Linux host computer / container and run the MATLAB script from within the Python app as an os command (I should get both the MATLAB for Linux, also MCR for linux to be later on run by the Python app)
2) Get a MATLAB license for Linux, install the matlab.engine in the host computer / container, and run the MATLAB script (called help_please.m) as is using the following code:
```
import matlab.engine
eng = matlab.engine.start_matlab()
eng.help_please(nargout=0)
```
(Here, I don't have to get the MCR)
Which option should work more efficiently? In general, which one do you recommend?
Is there any other way that works better which I haven't thought about already?
Thanks!
(As far as I know, there's no escape from getting a MATLAB license for Linux, as you cannot compile MATLAB in Windows to be executed in Linux).Ron Sinaihttps://www.mathworks.com/matlabcentral/profile/authors/18004544-ron-sinaitag:www.mathworks.com,2005:Question/5632552020-07-11T09:32:44Z2020-07-11T09:32:44ZHow to remove invalid architectures from the total number of architectures using a functionGreetings to all,
I am working on a function, which eliminates the invalid architectures from total number of architectures, using the function, "selectvalidarch". I have written the function and also applied the function into the script, but it is still showing me the total number of architectures.
when I run the code, the total number of architectures is 59049 and when this function used, it is supposed to eliminate the non feasible or invalid archs.
I am attaching the code with the function below:
Code:
total_archs = 59049;
n_arch = total_archs;
n_arch=0;
archs = strings(total_archs,10);
for SP=1:3
SP_opt = arch_deci_options(1,SP);
for LS=1:3
LS_opt = arch_deci_options(2,LS);
for SF=1:3
SF_opt = arch_deci_options(3,SF);
for MF=1:3
MF_opt = arch_deci_options(4,MF);
for AB=1:3
AB_opt = arch_deci_options(5,AB);
for BC=1:3
BC_opt = arch_deci_options(6,BC);
for CD=1:3
CD_opt = arch_deci_options(7,CD);
for PUP=1:3
PUP_opt = arch_deci_options(8,PUP);
for LKG=1:3
LKG_opt = arch_deci_options(9,LKG);
for PAT=1:3
PAT_opt = arch_deci_options(10,PAT);
%Check if the Architecture is valid
stsArchValid = selectvalidarch(SP,LS,SF,MF,AB,BC,CD,PUP,LKG,PAT)
%Update only if the architecture is valid
if stsArchValid
n_arch = n_arch+1;
archs(n_arch,:) = [SP_opt LS_opt SF_opt MF_opt AB_opt BC_opt CD_opt PUP_opt LKG_opt PAT_opt ];
%else
%continue
end
end
end
end
end
end
end
end
end
end
end
n_arch % this number should match total_archs
In the code above, total_archs shows the total number and n_arch, in the last line should give the total valid archs after elimination, using the function.
function: selectvalidarch:
%%
% Function to list invalid functions
function stsArchValid = selectvalidarch(SP,LS,SF,MF,AB,BC,CD,PUP,LKG,PAT)
if SP == 5
if LS == 8
stsArchValid = invalid;
end
end
if LS == 7
if SF == 10
stsArchValid = invalid;
end
end
if SF == 10
if MF == 13
stsArchValid = invalid;
end
end
if MF == 13
if AB == 16
stsArchValid = invalid;
end
end
if MF == 15
if BC == 20
stsArchValid = invalid;
end
end
if MF == 15
if CD == 23
stsArchValid = invalid;
end
end
if AB == 16
if PUP == 27
stsArchValid = invalid;
end
end
if AB == 16
if LKG == 30
stsArchValid = invalid;
end
end
if AB == 16
if PAT == 33
stsArchValid = invalid;
end
end
if exist('stsArchValid','var') == 0
stsArchValid = true;
end
end
It would be really grateful of you if anyone of the experts could help me here find the invalid archs and write it into the script in order to eliminate invalid archs.
Also, I am new to the Matlab, so I kindly request you to consider it too.
Thanking you all in advance.
kaivlya patelhttps://www.mathworks.com/matlabcentral/profile/authors/17013867-kaivlya-pateltag:www.mathworks.com,2005:Question/5632522020-07-11T09:29:00Z2020-07-11T09:29:00ZCutoff frequency from the filter coefficientsHello,
how to calculate cutoff frequency and ripple magnitude of passband an stopband from the filter coefficients:
for exemple:
b=[0.3752 0.7504 0.3752]
a=[1 0.3120 0.1888]
thenk you.zelmat mohamedhttps://www.mathworks.com/matlabcentral/profile/authors/12603122-zelmat-mohamedtag:www.mathworks.com,2005:Question/5632492020-07-11T09:05:07Z2020-07-11T09:10:50ZDatabase Toolbox Explorer Connect Crashes with WindowStyle dockedAfter installing Database toolbox, and configuring Data Source to an ODBC MySQL server using Database explorer app. I get a long set of error messages when I click on Connect.
Here is a short initial set of error messages that goes on for many lines:
Warning: Error occurred while executing the listener callback for event ConnectRequest defined for class
dbgui.internal.ToolStripDisplay:
Error using figure
Cannot set DockControls to 'off' while WindowStyle is 'docked'.
Error in dbgui.internal.ConnectDialog (line 33)
this.Figure = figure('DockControls','off',...
Error in dbgui.internal.dbSession/attemptConnection (line 1171)
dbgui.internal.ConnectDialog(this,dsName,driverType);
I did solve the problem by removing one line of code from my startup.m file:
addpath(genpath(userpath)) % add subdirectories to matlab userpath
% set(0, 'DefaultFigureWindowStyle', 'docked')
set(0, 'DefaultFigureColormap', jet), close all
With the line of code commented out: set(0, 'DefaultFigureWindowStyle', 'docked')
The errors were resolved.
I posted this question (with a workaround answer) here because I saw no help related to this issue. Hopefully MATLAB team could find a better error message or an automated "undocking" event so a first time user of Database toolbox can have a better initial user experience. But at least this post can now serve to help unravel this mystery for new users as well.
Product: R2020a update 3Ron Frederickshttps://www.mathworks.com/matlabcentral/profile/authors/16750336-ron-frederickstag:www.mathworks.com,2005:Question/5627962020-07-10T10:01:14Z2020-07-11T09:07:46ZEuler's method to plot orbital trajectory of cometI am trying to use eulers method to plot the trajectory of a comet but no matter what I i get linear plots for position,velocity, and acceleration and generally numbers that don't make sense. I am pretty sure it has something to do with my step size, but Ive tried hundreds f combinations and I dont know how exactly to fix that. The units are all in kilometers.
% Euler's Method
% Initial conditions and setup
h = 1; % step size
t = 0:h:100; % the range of x
y = zeros(size(t)); % allocate
x = zeros(size(t));
vx = zeros(size(t));
vy = zeros(size(t));
ax = zeros(size(t));
ay = zeros(size(t));
y(1) = 0; % the initial values
x(1) = 193929400;
vx(1) = -5.909;
vy(1) = 50.00294822;
[ax(1),ay(1)] = newaccel(x(1),y(1));
n = numel(y);
for i=1:n-1
vx(i+1) = vx(i) + h * ax(i);
vy(i+1) = vy(i) + h * ay(i);
y(i+1) = y(i) + h * vy(i+1);
x(i+1) = x(i) + h * vx(i+1);
[ax(i+1),ay(i+1)] = newaccel(x(i+1),y(i+1));
end
This is what my function to determine acceleration looks like.
function [a_newx a_newy] = newaccel(Xx_n,Xy_n)
X_n = [Xx_n * 1000,Xy_n * 1000];
G = 6.67408e-11;
ms = 1.989e30;
mag_X = sqrt(X_n(1).^2 + X_n(2).^2);
a_new = vpa((-(G*ms)/(mag_X)^3)*(X_n));
a_newx = a_new(1)/1000;
a_newy = a_new(2)/1000;
endDominic Trochehttps://www.mathworks.com/matlabcentral/profile/authors/15691977-dominic-trochetag:www.mathworks.com,2005:Question/2174442015-05-18T20:55:53Z2020-07-11T09:05:42ZMatlab jokes or punsAre there any good Matlab jokes? I don't mean |why| or any other Easter eggs, I mean good jokes involving Matlab. Actually, that |bar| may be a bit too high. Any jokes, good or bad, let's hear 'em. Chad Greenehttps://www.mathworks.com/matlabcentral/profile/authors/1062128-chad-greenetag:www.mathworks.com,2005:Question/5631832020-07-11T04:23:30Z2020-07-11T08:52:51ZBlock Tri-diagonal MatrixIn the process of a solvng a system of coupled pdes I have finally got a block tri-diagonal matrix. How to write the whole matrix in MATLAB. Is there any built in function to write such kind of block tri-diagonal matrix?Neeladri Sekhar Berahttps://www.mathworks.com/matlabcentral/profile/authors/14417696-neeladri-sekhar-beratag:www.mathworks.com,2005:Question/5632132020-07-11T07:06:18Z2020-07-11T08:41:40Zi=1, 2, 3,,, However, when (a-i)> 0 is calculated.i=1, 2, 3,,,
However, when (a-i)> 0 is calculated.
N, a is any positive integer,
station(2+i)=(a-(a-i))*N
I am trying to make a do statement, but I get an error
I am wondering how I should write the code to run it.
for example.
if a=4
i=1 station(3)=(4-(4-1))*N
i=2 station(4)=(4-(4-2))*N
i=3 station(5)=(4-(4-3))*N
i=4 station(6)=(4-(4-4))*N %->This case is not considered. Because (a-i) <= 0 (when (a-i)> 0 is calculated.)haeyeon JIhttps://www.mathworks.com/matlabcentral/profile/authors/14933940-haeyeon-jitag:www.mathworks.com,2005:Question/5632432020-07-11T08:24:53Z2020-07-11T08:24:53ZAppdesigner duplicated EditFields in different tabsIn my app I have different tabs with Edit Fields (numeric) and CheckBoxes. While designing the app I needed to move some Edit Fields and Checkboxes from one tab to another one.
Therefore I cut and pasted these from tab number 1 to tab number 3, as I already created Callbacks from the different Edit Fields and Checkboxes. Everything worked fine.
The next day when starting the app I get this error:
Children may only be set to a permutation of itself.
Error in appdesservices.internal.interfaces.controller.DesignTimeParentingController/processClientCreatedPeerNode (line
234)
obj.Model.Children = arrangeChildren;
As well as about 33 more errors concerning mainly the appdesservices.internal....
Now I see that in my tab number 1 the cut out Edit Fields and Checkboxes still exist. However they also exist in tab number 3 but only parts of them. (The Edit Field label is there but the Edit Field itself is missing).
In the code view I can see the duplicated Properties but as the code is grey I cannot delete them. When deleting them manually in the design view I cannot save the code as the save button and run button are also greyed out.
I already restarted and reinstalled Matlab 2020a but nothing changed. I tried using the mlapp2classdef.m file to generate the .m code from my app which worked but I don't find a function to reconvert .m to .mlapp
I also tried to use the Guide to Appdesigner Migration Tool as I now had the .m code however I didn't have the .fig file that you need for conversion.Kenneth Laureyshttps://www.mathworks.com/matlabcentral/profile/authors/11129104-kenneth-laureystag:www.mathworks.com,2005:Question/5632222020-07-11T07:30:42Z2020-07-11T08:21:56ZIs this program free from bugs? The program is to find the position of the element greater than 100.%% Example
for ii= 1:length(readings)
if readings(ii)>100
fprintf('first reading above 100 is at position %d\n', ii);
return;
end
end
fprintf('no values greater than 100 upto position %d\n',ii);
Khiyanat Deorihttps://www.mathworks.com/matlabcentral/profile/authors/18954896-khiyanat-deoritag:www.mathworks.com,2005:Question/5195082020-04-21T07:13:16Z2020-07-11T08:12:16ZGAN examples for Neural Network/Deep Learning Toolbox of R2018b or earlier?Hello All,
In R2019b the Matlab Deep Learning (ex Neural Network) Toolbox added functions for Generative Adversarial Networks (GANs).
I am interested to learn more about these but have only R2018b. Searching the File Exchange resulted in some projects listed as "Compatible with any release" but it turned out those, too, use functions available only in R2019b or later.
Does anyone know of any (very basic) older GAN examples or demos which could be run with the R2018b (or earlier) Neural Network/Deep Learning Toolbox?
Thanks in advance for all hints.Martin Erdelenhttps://www.mathworks.com/matlabcentral/profile/authors/8929208-martin-erdelentag:www.mathworks.com,2005:Question/5632072020-07-11T06:35:00Z2020-07-11T08:10:56ZSetting Common Axes for all Figuresfig_id = 1 ; % This is my figure id
I have to plot many figures, so is there a way to set common axes properties for all figures.
Currently I have to set same axes (e.g. below code) all the time for each new figure.
x = linspace(0,2*pi,100); y = sin(x); y1 = cos(x);
figure(fig_id); fig_id=fig_id+1;
axes1 = axes('Parent',figure(fig_id-1), 'TickDir','out','YMinorTick','on', 'YMinorGrid','on','XGrid','on', 'GridLineStyle','-' )
set(axes1,'TickLabelInterpreter','latex','FontSize',Font_axes);
plot(x,y,'Parent',axes1,'LineWidth',2);
figure(fig_id); fig_id=fig_id+1;
axes1 = axes('Parent',figure(fig_id-1), 'TickDir','out','YMinorTick','on', 'YMinorGrid','on','XGrid','on', 'GridLineStyle','-' )
set(axes1,'TickLabelInterpreter','latex','FontSize',Font_axes);
plot(x,y1,'Parent',axes1,'LineWidth',2);Dhirendu Somanihttps://www.mathworks.com/matlabcentral/profile/authors/9053052-dhirendu-somanitag:www.mathworks.com,2005:Question/2609692015-12-19T06:37:10Z2020-07-11T08:10:40Zwhy do I receive an empty document [#document: null] when I read a xml file with xmlread?I tried to read a simple xml file
{<rows>
<row id='0'>
<cell>65</cell>
</row>
<row id='1'>
<cell>565</cell>
</row>
<row id='2'>
<cell>6565</cell>
</row></rows>}
and received [#document: null].Siahlo Ivanhttps://www.mathworks.com/matlabcentral/profile/authors/6723726-siahlo-ivan