https://nl.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-07-03T23:59:51Ztag:nl.mathworks.com,2005:Question/5592232020-07-03T23:58:59Z2020-07-03T23:59:51ZStuck on Scattering Based Algorithms for monthsI need help with my code. You will probably have to download all the files I attached.
1703.04125 (1).pdf is the alogrithm that I want to code up, but I want to code it up with respect to Dirac combs which refers to Theorem 2, Theorem 3 and Figure 2 in the research paper.
ScatBasedAlg.m is my algorithm that works for regular functions.
smoothramp.m is my zeta function.
DiracDelta.m is my alpha (dirac comb) function, which may be also why I am having trouble with this.
ScatBasedAlgDirac.m is my algorithm that I want it to work for distributions especially for Dirac combs. I believe that I just need to edit a few lines in ScatBasedAlg.m to get it to work for ScatBasedAlgDirac.m, but that is where I am stuck. I don't know how to get it to work.
Currently, ScatBasedAlgDirac.m gives me a figure where it looks like Figure 2 in the research paper, but the space between the x-axis and amplitudes are all filled in and I think it is most likely due to my DiracDelta.m code as it touches 0's at some points.
I would really appreciate it if you can help me directly and not send me to other links. Please edit the code for me to get it to work. I have been stuck on this since January.Chien-Cheng Chiuhttps://nl.mathworks.com/matlabcentral/profile/authors/16781340-chien-cheng-chiutag:nl.mathworks.com,2005:Question/5580462020-07-01T21:01:16Z2020-07-03T23:59:37Z¿Cómo puedo encontrar los indices de un arreglo con valores repetidos con la función find y operadores relacionales?Hola, estoy intentando hallar los indices de una matriz A, cuando (A==B(i)). Pero en la matriz A puede haber valores repetidos que hacen fallar el código, por no saber cuál índice seleccionar.
Ejemplo:
A = [1 2 3 0 4 5 6 7 0 3 9 0 10];
B = mink(A(A~=0), 4); es decir, B = [1 2 3 3];
En este punto, necesito encontrar la posición que tenían los elementos de B, en la matriz original A. Debido a que debo excluir los 'ceros', no puedo usar la función así:
[B, I] = mink(A(A~=0), 4);
Por lo tanto, utilizo la siguiente:
for i=1:1:4
indice(i) = find(B(i)==A);
end
Todo funciona, pero cuando find encuentra que el valor tres aparece dos veces en A, no sabe cuál índice tomar.
¿Qué puedo hacer en este caso?
Espero haberme explicado bien, quedo atento, ¡muchas gracias!
Edwing Hernandez Herrerahttps://nl.mathworks.com/matlabcentral/profile/authors/15247251-edwing-hernandez-herreratag:nl.mathworks.com,2005:Question/5592262020-07-03T23:59:13Z2020-07-03T23:59:13ZMy code is not able to fit some data on a graphHi,
I have written a code to analyse series of dicom images from selected 3 ROIs from each image, fit their average measurements exponentially in one graph , and then plotting the results.
The code runs well for all parts except when it reachs the fit command it just does not work. I do not get any error messages, but when I run the code on that specific 'fit line', I get this command: error Fcn = iCreateError Function (nargout >4).
I really do not understand what is happening. Can someone help me please by resolving this problem?
The code is below:
xzdxbnfile_name={'E:\copied folders from CD A-H_IRONQUANTI\1818000'};
clear all
%Which image to display for selecting region
Num = 18;
dirName = pwd; %# folder path
files = dir( fullfile(dirName,'*') );
files = {files.name}'; %'# file names
files = files(3:end);
a=mat2gray(dicomread(fullfile(dirName,files{Num})));
y = [];
jj = 1;
N = 3;
figure(1);
im = imshow(a);
meanInt = [];
%%y = [];
for ii = 1:N
%%create an ROI
e = imellipse(gca,[]);
BW = createMask(e);
for k = 30:41
fname = fullfile(dirName,files{k}); %# full path to file
avoidMe = strcmp(fname,'forFilesInDir.m');
if ~avoidMe
diimg = dicomread(fname);
if ~isempty(diimg)
meanReg = diimg(BW);
meanInt(k) = mean(meanReg);
else
meanInt(k) = 0;
end
end
y(jj) = meanInt(k);
%%y = meanInt(k);
jj = jj+1;
end
end
g = y(1:12)';
h = y(13:24)';
m = y(25:36)';
x = [0.9,2,3,4.1,5.2,6.2,7.3,8.4,9.5,10.5,11.6,12]';
options = fitoptions('exp1');
options.Normalize = 'on';
options.Algorithm = ('Levenberg-Marquardt');
options.StartPoint = [209.356287641061 -0.223283499455681];
%f1 = fit(x,g,'exp1',options);
figure
f1 = fit(x,g, 'exp1', options);
hold on
f2 = fit(x,h,'exp1', options);
%plot(x,h,'b-');
hold on
f3 = fit(x,m,'exp1', options);
plot(x,g,'r', x,h,'g',x,m, 'b');
Gamra Samhahttps://nl.mathworks.com/matlabcentral/profile/authors/18910239-gamra-samhatag:nl.mathworks.com,2005:Question/5592202020-07-03T23:50:57Z2020-07-03T23:50:57ZWhy is my code showing the error:" Error using matlab.graphics.primitive.Image/set; Invalid or deleted object.I would love some assistance with the following code. Im setting up a security/motion detection camera as shown in a tutorial put on by mathworks. I have a little different hardware set up that I think may be part of the problem. I am simply using my built in camera on my surface to compare a reference photo to a snapshot taken from live video and seeing if there is motion detected. However, I am getting the following error as shown in the title:
Error using matlab.graphics.primitive.Image/set
Invalid or deleted object.
Error in Sentry_Cam (line 29)
set(hShow,'CData',object_detected);
Im new at all this and tried following the online example as closely as possible. Could it be a data type issue? hShow says its a 1x1 Image in the workspace window and Object_detected is assigned as a uint8. Could this be the issue with the line reading set(hShow,'CData',object_detected)?
I also tried looking at hShow specfically and it says it is a "handle to deleted Image" ? Where could my code be deleting it? Any assistance would be wonderful. Thanks for any help you can give!
function Sentry_Cam()
%%
clear all; close all; clc; imaqreset;
%% Setup Image Acquisition
hCamera= videoinput('winvideo',1);
% Create a hangle to an imshow figure for faster updating
hShow=imshow(zeros(480,640,3,'uint8'));title('Sentry Cam')
%% Acquire reference image
set(hCamera,'ReturnedColorSpace', 'RGB')%Need this to convert YUY2 to RBG to get rid of pink coloring
ref_vid_img=getsnapshot(hCamera);
%image(ref_vid_img)
%% Quantize images and outputing to the screen
frames=2000;
for i=1:frames
%Acquire an image form the webcam
vid_img=getsnapshot(hCamera);
% Call the live segmentation function. This is a seperate function that seems to working just fine when run line by line
object_detected=Segmentation_Fn(vid_img,ref_vid_img);
% Update the imshow handle with a new image
set(hShow,'CData',object_detected);
drawnow;
end
%% Shutdown webcam by deleting handle
clear hShow;
end
Outout following the my code:
Error using matlab.graphics.primitive.Image/set
Invalid or deleted object.
Error in Sentry_Cam (line 29)
set(hShow,'CData',object_detected);Scott Kaiserhttps://nl.mathworks.com/matlabcentral/profile/authors/18849466-scott-kaisertag:nl.mathworks.com,2005:Question/5592142020-07-03T23:35:23Z2020-07-03T23:49:54ZIs that possible to view the codes of standalone application?Hi there,
I am coding some engineering problems on MATLAB for my MSc. graduation thesis. I use "Application Compiler" to convert my codes into the stand-alone application. Due to plagiarism possibility, I don't want anyone to see my codes during using my .exe applications. Is there any way that someone views the codes through using .exe files? Or can anyone open them such as opening a .m file? I tried to open with Notepad and Notepad++. The codes didn't show up.
Please let me know. Thank you! Cem Aylahttps://nl.mathworks.com/matlabcentral/profile/authors/13742312-cem-aylatag:nl.mathworks.com,2005:Question/5584362020-07-02T13:07:51Z2020-07-03T23:42:15Zgetting error about wrong input argumenti have tried following code for upsampling of data with input values
smote('C:\Users\Haleema\Desktop\skin matlab\orignal', 8,{327,514,1099,115,1113,6705,142})
but got error
Error using bar (line 127)
Input arguments must be numeric, datetime, duration or categorical.
Error in barh (line 44)
h = bar(varargin{:});
Error in smote (line 22)
barh(sortedIDX);
function allData_smote = smote(allData, k,sortedIDX)
% mySMOTE Synthetic Minority Oversampling Technique. A technique to
% generate synthetic samples as given in: https://www.jair.org/media/953/live-953-2037-jair.pdf
% Usage:
% X_smote = mySMOTE(X, N, k)
%
% Inputs:
% allData: Original dataset
% k: number of nearest neighbors to consider while performing
% augmentation
% sortedIDX: sorted labels
%
% Outputs:
% X_smote: augmented dataset containing original data as well.
%
% See also datasample, randsample
%% plot the bar plot for number of classes
figure
barh(sortedIDX);
ylabel('number of classes-->')
xlabel('Sampels in each class-->')
title('Original imbalance data distirbution')
%% number of each classes
labels=allData(:,end);
class=unique(sortedIDX);
for ii=1:numel(class)
classNo(ii)=numel(find(labels==class(ii)));
end
%% required addon samples in each minority class
%add on samples will be calculated by taking the difference of each
%classSamples with highest number of class samples
[maximumSamples,sampleClass]=max(classNo); % number of maximum samples
for ii=1:numel(class)
samplediff(ii)=maximumSamples-classNo(ii);
N (ii) = ceil(samplediff(ii)/ 100);
end
%% oversample the minority classes
allData_smote=[];
for ii=1:numel(class)
X=allData(labels==class(ii),:);
T = size(X, 1);
X_smote = X;
for i = 1:T
y = X(i,:);
% find k-nearest samples
[idx, ~] = knnsearch(X,y,'k',k);
% retain only N out of k nearest samples
idx = datasample(idx, N(ii));
x_nearest = X(idx,:);
x_syn = bsxfun(@plus, bsxfun(@times, bsxfun(@minus,x_nearest,y), rand(N(ii),1)), y);
X_smote = cat(1, X_smote, x_syn);
end
allData_smote=cat(1,allData_smote,X_smote);
end
%%
balanced_sortedIDX=allData_smote(:,end);
figure
barh(balanced_sortedIDX);
ylabel('number of classes-->')
xlabel('Sampels in each class-->')
title('Balanced data distirbution')
%% randomize the data
shuffleindex=randperm(size(allData_smote,1));
allData_smote=allData_smote(shuffleindex,:);
endHaleema Ahsanhttps://nl.mathworks.com/matlabcentral/profile/authors/16091120-haleema-ahsantag:nl.mathworks.com,2005:Question/5592172020-07-03T23:38:06Z2020-07-03T23:38:06ZError checking code functionsI am having some trouble developing some error checking code for several inputs, I first use:
Testdate=input('What is the test date?(dd-mm-yyyy)','s')
Teststr=convertCharsToStrings(Testdate);
TestT=ERRORT(Testdate);
Acceldata=input('What are your accel values?( Separated by commas and from 0 deg to 270 deg)','s')
AccelD=ERRORD(Acceldata);
Tempdata=input('What are your temp values?( Separated by commas and from 0 deg to 270 deg)','s')
TempD=ERRORTemp(Tempdata);
outA=regexp(Acceldata,',','split');
outAccel=outA(1:end);
outT=regexp(Tempdata,',','split');
outTemp=outT(1:end);
Then for the first input (Testdate) I use a function displayed as:
function Testdate = ERRORT(Testdate)
if (length(Testdate)~=10) || isempty(Testdate)
Testdate=input('Input the test date in the correct format: dd-mm-yyyy.','s')
end
yearstr=Testdate(7:10);
year=str2double(yearstr);
if Testdate(7)<1 || ~ischar(year)==1 || isempty(year)==1 || (length(year)~=4) || year<0
Testdate=input('Input for the yyyy is incorrect. Try again.','s')
end
monthstr=Testdate(4:5);
month=str2double(monthstr);
if isempty(month) || ~ischar(month)==1 || month<01 || month>12 || (length(month)~=2)
Testdate=input('Input for the mm is incorrect. Try again.','s')
end
if Testdate(3)~='-' || Testdate(6)~='-'
Testdate=input('Input the test date in the correct format: dd-mm-yyyy.','s')
end
daystr=Testdate(1:2);
day=str2double(daystr);
if isempty(day) || ~isnumeric(day)==1
Testdate=input('Input for the dd is incorrect. Try again.','s')
end
if month==01 || month==03 || month==05 || month==07 || month==08 || month==10 || month==12
if day<1 || day>31
Testdate=input('Input for the dd is invalid. Try again.','s')
end
end
if month==04 || month==06 || month==09 || month==11
if day<1 || day>30
Testdate=input('Input for the dd is invalid. Try again.','s')
end
end
if month==02
if day<1 || day>29
Testdate=input('Input for the dd is invalid. Try again.','s')
end
end
This causes the inputted error message to display at the wrong time as I error check to ensure if there isn't a number for the day, month, or year, the input is left blank, or even reasonable values for the year, month, or day, or not in the presented format results in the inputted error message.
I also use another function to error check the input of Acceldata:
function Acceldata = ERRORD(Acceldata)
while isempty(Acceldata) || ischar(outAccel)==0
Acceldata=input('Must type a numerical value. Try again.')
end
This also displays the error message at the wrong time as I would like for the code to display while the Acceldata input is blank or is not a number or doesn't not have four values( as the values are supposed to be separated by commas) or the values are not separated by commas results in an input of the error message.
I also use another function to error check the input of Tempdata:
function Tempdata = ERRORTemp(Tempdata)
while isempty(Tempdata)
Tempdata=input('Must type a numerical value. Try again.')
end
if Tempdata>3 || Tempdata<2.8
Tempdata=input('Check the inputs, the values are invalid. Try again.')
end
This code displays an error for the second portion. I intend the code to display while the Tempdata input is blank or are not numbers results in the input of the error message and if the Tempdata values(separated by commas) are above 3 or below 2.8 or there aren't 4 Tempdata values or the values aren't separated by a comma results in the input of the error message.
Any suggestions or corrections that I should make?Alexandra Philiphttps://nl.mathworks.com/matlabcentral/profile/authors/18685519-alexandra-philiptag:nl.mathworks.com,2005:Question/5588542020-07-03T07:14:52Z2020-07-03T23:37:51Zsyntax error in simulinki cannot run my simulation due on this function. can you help me to identify the problem.
p(1)*u(2) + p(2)*u(1) + p(3)*u(1)*u(1) + p(4)*u(1)*u(2) + p(5)Fadzliana Aidahttps://nl.mathworks.com/matlabcentral/profile/authors/18450021-fadzliana-aidatag:nl.mathworks.com,2005:Question/5590552020-07-03T15:45:44Z2020-07-03T23:37:05ZHow to write a function?<</matlabcentral/answers/uploaded_files/326318/P_20200703_221948_1.jpg>>
Please anyone can help me write this following function in matlabDen Jakahttps://nl.mathworks.com/matlabcentral/profile/authors/18699516-den-jakatag:nl.mathworks.com,2005:Question/5592112020-07-03T23:32:32Z2020-07-03T23:32:32ZConvert several columns char matrix into one column char matrixI have a 200x12 matrix, with hours, minutes, seconds info. Each row has a time format like this: "13:35:43,050", but each column is composed of a single character of the time format ("1" in column 1; "3" in column 2; ":" in column 3, etc).
I would like to end up with a 200x1 matrix, where all the column characters would appear in a single column, with no spaces.
Can you help me, please? Thank you very much.Cláudia Oliveirahttps://nl.mathworks.com/matlabcentral/profile/authors/18910182-claudia-oliveiratag:nl.mathworks.com,2005:Question/5587642020-07-03T03:05:33Z2020-07-03T23:27:04ZHow to matlab display matrix in different way matlab display matrix is very problenatic question. my question is How to matlab display matrix as image and Table
example:
For example:
B = magic(3)
disp('The ANS is:')
disp(B)
then how I can display I am see the ans on matlab but i need in detailed.Sachin Pagarhttps://nl.mathworks.com/matlabcentral/profile/authors/18903129-sachin-pagartag:nl.mathworks.com,2005:Question/95722011-06-15T18:50:12Z2020-07-03T23:24:40Zkeep figures from popping up when running.I am doing a lot of batch processing in which I creating many figures. I would like to keep these figures in the background while running the Matlab code without the Figure window popping up each time a new figure is created. Is there an easy way to do this?
When the figure pops up it disrupts anything else you are doing on the computer.Michael Marcushttps://nl.mathworks.com/matlabcentral/profile/authors/910744-michael-marcustag:nl.mathworks.com,2005:Question/5591992020-07-03T22:15:01Z2020-07-03T23:23:28ZCalculate marginal effect in Probit model with log-transformed covariateI have using probit to regress my model with dependent variable as a binary variable, and have 5 out of 6 of my covariates transformed into log form. So my X 1 by 6 vector would be
X=[X1 logX2 logX3 logX4 logX5 logX6]
But I don't know whether I am writing the right code to calculate the marginal effect after I got my beta estimated.
%define X_bar as average of all covariates and Log_X_bar be the average of the logged covariates
X_bar=[mean(X1) mean(X2) mean(X3) mean(X4) mean(X5) mean(X6)]
Log_X_bar=[mean(X1) mean(logX2) mean(logX3) mean(logX4) mean(logX5) mean(logX6)]
So I use the following formula to get the marginal for x2, for example
So I wrote the following matlab code to get the marginal for all X's
normcdf(Log_X_bar*b2)*b2./X_bar'
But I don't know whether this code is correctWenhan Yanhttps://nl.mathworks.com/matlabcentral/profile/authors/18486364-wenhan-yantag:nl.mathworks.com,2005:Question/5592082020-07-03T23:10:32Z2020-07-03T23:10:32Zhow to transfer a setting from an old version to a new versionI have 2019b and installed a newer 2020a in a same PC. How can one transfer a setting (path, etc) of 2019b to 2020a? Then, how can one uninstall 2019b?alpedhuezhttps://nl.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:nl.mathworks.com,2005:Question/5590252020-07-03T14:59:39Z2020-07-03T23:07:37ZHow to set "dbstop if error" only to stop in my codeI use:
dbstop if error
often, to debug on any kind of error in my code.
The problem is that, when an error, it jumps to a breakpoint not only in my files, but in internal matlab functions.
And it is annoying trying to get out of those functions to reach my line where I did the error.
Jonathan Alejandro Zeahttps://nl.mathworks.com/matlabcentral/profile/authors/9345370-jonathan-alejandro-zeatag:nl.mathworks.com,2005:Question/5560242020-06-28T10:27:32Z2020-07-03T23:07:14ZWhat frustrates you about MATLAB? #2Similar to what has happened with the wishlist threads (#1 #2 #3 #4 #5), the "what frustrates you about MATLAB" thread has become very large. This makes navigation difficult and increases page load times.
So here is the follow-up page.Rikhttps://nl.mathworks.com/matlabcentral/profile/authors/3073010-riktag:nl.mathworks.com,2005:Question/5591752020-07-03T20:54:49Z2020-07-03T23:06:36Zhow to user grpstats function in this caseI have a table like (the real table is more complicated)
date month person spending
1/1/2020 January-2020 John 30
1/1/2020 January-2020 Mike 15
1/2/2020 January-2020 John 20
1/3/2020 January-2020 Kate 30
then I want to create a summary table such as
person 'count of John's spending data' 'sum of John's spending' 'average of John's spending per observation'
January-2020
February-2020
Please advise.alpedhuezhttps://nl.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:nl.mathworks.com,2005:Question/5592052020-07-03T22:59:21Z2020-07-03T22:59:59ZDon't simplify while using 'latex'Hey, each time I use Matlabs fabulous latex function the term automatically becomes simplified. However, sometimes I want to emphasize some expression that get reduced by the simplification. So: How to surpress it? Niklas Kurzhttps://nl.mathworks.com/matlabcentral/profile/authors/18516014-niklas-kurztag:nl.mathworks.com,2005:Question/5587762020-07-03T03:32:30Z2020-07-03T22:57:28ZConvert Fortran code to MatlabHi, I need help in converting the following Fortran code to Matlab
* This program reads binary data for 365/366 days and writes in ascii file.
PROGRAM READ
PARAMETER(ISIZ=31,JSIZ=31)
DIMENSION T(366,ISIZ,JSIZ)
OPEN(1,FILE='D:\\DailyT\\MeanT\\MEANT1980.GRD',
1 FORM='UNFORMATTED',ACCESS='DIRECT',
2 RECL=ISIZ*JSIZ*4,STATUS='OLD')
OPEN(2,FILE='D:\\DAILYT\\MEANT15APR1980.TXT',STATUS='UNKNOWN')
* TAKE NDAY=366 FOR LEAP YEARS
NDAY=366
DO IDAY = 1,NDAY
READ(1,REC=IDAY)((T(IDAY,I,J),J=1,JSIZ),I=1,ISIZ)
ENDDO
WRITE(2,'('' Daily Tempereture for 15 APR 1980 '')')
DO I = 1,ISIZ
WRITE(2,'(31F6.2)')(T(106,I,J),J=1,JSIZ)
ENDDO
STOP
END
Thanks
ShubhamKalore Shubham Arunhttps://nl.mathworks.com/matlabcentral/profile/authors/13904198-kalore-shubham-aruntag:nl.mathworks.com,2005:Question/5589112020-07-03T09:52:47Z2020-07-03T22:49:33ZPlotting with gaps in x-axis dataI am plotting data against time. The time variable has a uniform sampling rate, but there are times when there may be gaps in the data, for example, when something is powered off. These gaps can be any length of time. When you plot a variable against this time, if there is a gap between two points in time that is greater than the sampling rate, you naturally end up with a plot that has a single line between those two points. Visually, this can be deceiving and can make the gap difficult to identify at first glance, depending on the values of the other variable at those two points. Ideally, I would want to supress the line between those two points, leaving a visual gap. This could obviously be done manually by identifying gaps and then plotting different "chunks" of data with separate commands, but this is not practical beyond a one-off situation. You could potentially create a wrapper around the plot function and choose a time value that identifies gaps in the data that are "too large," plotting "chunks" of data defined in that manner. This would suffer from the use of a static value for that "too large" designation. Does anyone have any good ideas for handling the situation I described, or perhaps seen anything creative out there that would be useful? I realize I'm fighting against the nature of the plot function, but I thought someone else might have already thought of a creative way to address the issue.
Edit:Here's an example of the time vector for reference:
Let's say I have data that is logged at ~1 Hz and the time variable has a range of 10 hours. It might start out like this (I'll assume index 1 is time=0 for ease of dicussion):
[0, 1.00, 2.01, 3.02, 4.01, 5.01, 5.99, 6.98, 7.99, 9.01, 10.00...]
Then you might see a number of gaps of several seconds throughout the 10 hours, maybe a few gaps of several minutes, and a couple gaps of 30 or 45 minutes. Obviously, for the values that are ~1 second apart, I want to connect the data points with a line normally.
Thanks for the help.
MattMatthttps://nl.mathworks.com/matlabcentral/profile/authors/1460942-matttag:nl.mathworks.com,2005:Question/5591962020-07-03T22:12:40Z2020-07-03T22:39:25ZDoes anyone know what block is this?Does anyone know what block is the one that is connected between the mux and the output of this subsystem?
ronaldbm93https://nl.mathworks.com/matlabcentral/profile/authors/5812920-ronaldbm93tag:nl.mathworks.com,2005:Question/5592022020-07-03T22:17:20Z2020-07-03T22:38:53Zcreate 5 minute bar intervals of time dataI have a csv file with price data and it is organized in date in MM/dd/yyyy and time in HH:mm:ss. The data is in 1 second intervals. I am trying to create specific intervals of that data let's say 5 minute intervals and read the prices at that time and plot a bar chart.
However, in trying to do so I found the data maybe missing few seconds here and there. So what is the best way to get something like
date Time Price
7/3/2020 17:00:00 452
7/3/2020 17:05:00 430
7/3/2020 17:10:00 444Akram Husseinhttps://nl.mathworks.com/matlabcentral/profile/authors/18649540-akram-husseintag:nl.mathworks.com,2005:Question/5559252020-06-28T02:26:42Z2020-07-03T22:25:41ZDoes anyone know how to use the matlab to calculate the minimu distance between a point outside oval and the oval surface？Does anyone know how to use the matlab to calculate the minimu distance between a point outside oval and the oval surface？huazai2020https://nl.mathworks.com/matlabcentral/profile/authors/18100603-huazai2020tag:nl.mathworks.com,2005:Question/5588842020-07-03T08:51:18Z2020-07-03T22:25:13ZHow can I save UIAxes as an image when button is pushed in app designer?How can I save UIAxes as an image when button is pushed in app designer?
newfigure = figure;
copyobj(app.UIAxes, newfigure);
hgsave(newfigure, 'testFIgure.fig');
I tried this but it gives me an error.Yaren Severhttps://nl.mathworks.com/matlabcentral/profile/authors/15756083-yaren-severtag:nl.mathworks.com,2005:Question/2569142015-11-23T03:32:50Z2020-07-03T22:23:49ZSolving Meijer G function!!Can anyone solve the following Meijer-G function in matlab for any numerical value of z, k, Q1 and Q2?
<</matlabcentral/answers/uploaded_files/40662/MeijerGFuntion.JPG>>
Thanks in advance for your help
kaderhttps://nl.mathworks.com/matlabcentral/profile/authors/2841233-kadertag:nl.mathworks.com,2005:Question/5590612020-07-03T15:51:26Z2020-07-03T22:23:25ZHow to find all related nodes in directed graph?Hi! I have a dirested graph "G" (figure is represented bellow). How can I find all nodes that are ONE BY ONE connected with certain node "n". For example if we talk about node 11 required nodes are 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23.
I tried to use a "successors" function but I'm stcuk. Can anybody help me please? Here's the code (my attempts):
clc; clear;
S = [1 2 3 3 4 5 6 6 8 9 11 11 12 12 14 16 16 17 17 19 20 22];
T = [2 3 4 11 5 6 7 8 9 10 12 16 13 14 15 17 22 18 19 20 21 23];
weight = [0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
G = digraph (S, T, weight);
B = [S' T' weight'];
for i = 1:22
if B(i,3)==1
N = successors (G, B(i,2)) %% equivalent of N = (12; 16)
k = N';
for j=1:length(N)
N = successors(G,N(j))
end
end
endArtur Iskhakovhttps://nl.mathworks.com/matlabcentral/profile/authors/17767832-artur-iskhakovtag:nl.mathworks.com,2005:Question/4919672019-11-19T18:20:33Z2020-07-03T22:14:58ZFormat colorbar using engineering notationHow can I set the scale of a color bar to use exponential notation, with all exponents being a multiple of 3?
I know that format shortEng will set the format I want for values printed to the Command Window, but I cannot find anything to format string printed elsewhere using this format.Peterhttps://nl.mathworks.com/matlabcentral/profile/authors/3579250-petertag:nl.mathworks.com,2005:Question/5591932020-07-03T22:03:40Z2020-07-03T22:08:50ZMultiple numerics as one map key / Merge Objects based on parametersI want to use two numerics as a single key for a map to merge similar objects of a class. How can I do that?
My class looks like this:
classdef Foo
properties
a double
b double
val double
end
methods
function obj = Foo(a,b,val)
obj.a = a;
obj.b = b;
obj.val = val;
end
function o = plus(l,r)
o = Foo(l.a,l.b,l.val+r.val);
end
function k = getKey(obj)
<...>
end
end
end
The code should do the following:
fooCell = {Foo(3,4,100) Foo(3,4,20) Foo(2,5,20)};
fooMap = containers.Map('KeyType', <...> ,'ValueType','any');
for i=1:length(fooCell)
k = fooCell{i}.getKey;
if fooMap.isKey(k)
fooMap(k) = fooMap(k)+fooCell{i};
else
fooMap(k) = fooCell{i};
end
end
fooMap.values %Should contain 2 objects: Foo(3,4,120) & Foo(2,5,20)
How should the getKey method look like?Jan Siegmundhttps://nl.mathworks.com/matlabcentral/profile/authors/8320658-jan-siegmundtag:nl.mathworks.com,2005:Question/5591902020-07-03T22:03:38Z2020-07-03T22:03:38Zconnect database to matlabi have database created in mysql and i want to use it in matlab so i used matlab connector ODBC
then i used this code to item file in my database
conn = database('kk2','root','');
curs = exec(conn,'INSERT INTO `item`(`name`) VALUES (`pen`)');
but nothing happend and ther is no error in command window
kareem hassanhttps://nl.mathworks.com/matlabcentral/profile/authors/14965625-kareem-hassantag:nl.mathworks.com,2005:Question/5587552020-07-03T02:34:21Z2020-07-03T21:47:43ZNew load error (must be string scalar or character vector) in data collecting codeI am using an extensive set of functions my team and I have built that essentially looks in a folder, collects all of the necessary files (with extensions like .mat, .csv, and .txt) that we need. All of the files of interest are in one folder, easy to access, and the outcome of the code is the highlighted bit. For the below picture, the code worked (from February 3, 2020.)
However, when using data from a different date (different folder, but same exact format with same type of files other than the final highlighted file being absent), the code does not work. Below is the file setup that I loaded into Matlab via the function.
(No difference in setup, other than some files being larger in size.)
The following is the error message I receive. I think the problem I am encountering is that the function is not able to load in the .csv file called ttlDATA (located outside of both of the pictures folders, in one SINGLE location.) Therefore, it is undefined and can't collect any components from it, which contribute to the later errors in lines 97 and 220 (shown.)
This is the overall error message, referencing an inability to load the file needed for the command we named MATlist and MAT_list (from the ttlDATA.csv that is accessible to the program.
This is line 97, where it uses components within the ttlDATA.csv to compile data of interest.
This is line 220, where it uses the same extracted data from line 97 to further organize it.
**I have checked that the added paths and the file directory in the function align as they did with the February 3, 2020 file which had NO PROBLEMS.
Where could my problem lie? All variables are the same; I have not changed the code at all; only which files it is accessing. I have tried restarting the program, adding/deleting paths so that it can re-recognize it, ensuring that elements of the problematic file can load onto Matlab (they can, via load('file'). How do I fix this error?
Thank you very much.
Sunderland Bakerhttps://nl.mathworks.com/matlabcentral/profile/authors/18883341-sunderland-bakertag:nl.mathworks.com,2005:Question/5591872020-07-03T21:41:22Z2020-07-03T21:41:22ZFrequency-dependent performance of the pattern function to calculate antenna directivityI am using the pattern function on an antenna object to calculate a specific directivity at multiple frequencies. I've found that calcluating at a frequency far from what the antenna has been designed for takes significantly longer than at a frequency near what it was designed for. I've inlcuded some code the replicates what I'm taking about.
Is there any way to imporve the performance seen when I need to calculate a frequency far from the design frequency? In my program the pattern function is called many times, and this limitation makes my program run signifcaly slower than if everything was being computed at the design frequency. I've tried to clear memory as much as I can throughout the program but I'm starting to think it may be the function itself. To be sure, the problem persists even clear all is called. The order of these calls to pattern doesn't seem to matter, it appears tha the only thing affecting performance the frequency I ask it to calculate at, dissuading me from thinking that it is a memory issue.
clear all
antenna = design(horn,1e9);
fprintf('Calculating directivity at 3x design frequency:\n');
tic
direct = pattern(antenna, 3e9, 45, 45, 'Polarization', 'H');
toc
fprintf('Calculating directivity at 2x design frequency:\n');
tic
direct = pattern(antenna, 2e9, 45, 45, 'Polarization', 'H');
toc
fprintf('Calculating directivity at 1.5x design frequency:\n');
tic
direct = pattern(antenna, 1.5e9, 45, 45, 'Polarization', 'H');
toc
fprintf('Calculating directivity at design frequency:\n');
tic
direct = pattern(antenna, 1e9, 45, 45, 'Polarization', 'H');
toc
% Output:
% Calculating directivity at 3x design frequency:
% Elapsed time is 280.637976 seconds.
% Calculating directivity at 2x design frequency:
% Elapsed time is 45.028886 seconds.
% Calculating directivity at 1.5x design frequency:
% Elapsed time is 17.726486 seconds.
% Calculating directivity at design frequency:
% Elapsed time is 5.945277 seconds.Alexander Murrayhttps://nl.mathworks.com/matlabcentral/profile/authors/11885885-alexander-murraytag:nl.mathworks.com,2005:Question/5590732020-07-03T16:15:38Z2020-07-03T21:40:37ZError in code: Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.function MOS=pesq(CleanSignal, DegradedSignal, rate)
% 1. Put clean and degraded wav files
% 2. build pesq from ITU source code (available on the ITU p.862) and
% generate pesq.exe
% 3. Put the pesq.exe in the current path
% 4. Use it like this exp. :
% MOS=pesq('CleanSignal.wav','DegradedSignal.wav','+8000')
% rate : Must select either +8000 or +16000.
%
[Return,strout]=system(['PESQ ',rate,' ',CleanSignal,' ',DegradedSignal, '']);
c=strfind(strout,'(Raw MOS, MOS-LQO):');
if isempty(c)
disp('Error!!!!!!!!');
MOS='It is not valid';
else
MOS_Raw=str2double(strout(c+23:c+28));
MOS_LQO=str2double(strout(c+29:end-1));
disp(' MOS_Raw MOS_LQO');
disp([MOS_Raw,MOS_LQO]);
MOS(1)=MOS_Raw;
MOS(2)=MOS_LQO;
end
I put the wav file and the rate in first line and i have this error: Error: File: pesq.m Line: 1 Column: 19
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses. How I can solve it?Francesco Santorohttps://nl.mathworks.com/matlabcentral/profile/authors/9137704-francesco-santorotag:nl.mathworks.com,2005:Question/5591842020-07-03T21:32:15Z2020-07-03T21:32:15ZSIMULINK - Wilkinson divider and RF not accepting my complex input signalA Wilkinson Divider with an input of a complex signal, but only the real part gets into the RF blockset. Why? This makes my Wilkinson output a flat line at -3200.Abigail Buenohttps://nl.mathworks.com/matlabcentral/profile/authors/16565911-abigail-buenotag:nl.mathworks.com,2005:Question/5591812020-07-03T21:21:12Z2020-07-03T21:30:12ZUnstack: how to create a pivot table like this?I have a table like (the real table is more complicated)
date month person spending
--------------------------
1/1/2020 January John 30
1/1/2020 January Mike 15
1/2/2020 January John 20
1/3/2020 January Kate 30
I want to create a pivot table like
month John's share of spending out of total spending | Mike's share | Kate's share
------------------------------------------
January
February
Please advise. alpedhuezhttps://nl.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:nl.mathworks.com,2005:Question/5591062020-07-03T17:33:31Z2020-07-03T21:21:09ZAvoid lower case in legend by plotting legend with 'DisplayName' Hello,
I have again a similar Problem, but in this case I can't separate legend, and : 'Interpreter','none' is here also not working. How can I print names like 001_M1_Distance_0.5m_AKG_C1000S_F1_MS1 without undercases?
label1 = extractBefore({i(j).name}, ".mat");
label1 = extractAfter(label1, "_");
...........
if any(M1)
plot(M1(:,2),M1(:,1),'-o','DisplayName',label1{1});
hold on
end
if any(M2)
plot(M2(:,2),M2(:,1),'-o','DisplayName',label2{1});
hold on
end
if any(M3)
plot(M3(:,2),M3(:,1),'-o','DisplayName',label3{1});
hold on
end
if any(M4)
plot(M4(:,2),M4(:,1),'-o','DisplayName',label4{1});
hold on
end
Thanks!Nik Rockyhttps://nl.mathworks.com/matlabcentral/profile/authors/7505467-nik-rockytag:nl.mathworks.com,2005:Question/5591782020-07-03T21:10:55Z2020-07-03T21:17:33Zhow to use saveas specify the size of plot when one save the plotI want to save plot to fit to the size of slides. How can one use saveas (or another command) to save a plot in a 16:9 ratio (or size)>alpedhuezhttps://nl.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:nl.mathworks.com,2005:Question/5566122020-06-29T13:59:17Z2020-07-03T20:58:05ZHow to create a pivot tableI have a table
date person spendings
----------------------------------------
1/1/2020 John $100
1/1/2020 Mike $50
1/2/2020 John $75
1/3/2020 Mike $40
I want to create a pivot table
John Spendings Mike Spendings
----------------------------------------------------------------------------------
January 2020
February 2020
March 2020
Please advise. alpedhuezhttps://nl.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:nl.mathworks.com,2005:Question/5591722020-07-03T20:52:19Z2020-07-03T20:52:19ZError using + Matrix dimensions must agree.close all
clear all
clc
G0=300; %initial positions
I0=2.5;
q=1/1;
A=90;
D(1)=A;
Gd=80;
Z(1)=0;
Ib=2.5;
Comm=0;
x(:,1)=[G0 0 20]'; %states initial values
xob(:,1)=[G0 0 20]';
lam(:,1)=[0 0 0]';
% patient 1
p1=0;
p2=0.0142;
p3=154*10^-5;
n=0.2814;
Pn=[p1 p2 p3 n];
%%% patient 2
%p1=0;
%p2=0.0072;
%p3=2.16*10^-5;
%n=0.2865;
Pn=[p1 p2 p3 n];
Comande(1)=10;
i=1;
B=0.05;
t(1)=0;
h=1/6;%0.005;1/6
% ODE solving
% opt1=odeset('RelTol',1e-10,'AbsTol',1e-20,'NormControl','off');
%[T,X] = ode45(@(t,x) glucoz(t,x,Pn,Gb,Comm),Ts,x0);
%V(1)=0;
YY3(1)=0;
DD(1)=0;
a=1;
while t<18000
D(i+1)=A*exp(-B*i*h);
k1=h*glucoz(x(:,i),Pn,Gd,Comande(i),D(i));
k2=h*glucoz(x(:,i)+k1'/2,Pn,Gd,Comande(i),D(i)); %the error in the + signe
k3=h*glucoz(x(:,i)+k2'/2,Pn,Gd,Comande(i),D(i));
k4=h*glucoz(x(:,i)+k3',Pn,Gd,Comande(i),D(i));
x(:,i+1)=x(:,i)+(1/6)*(k1+2*k2+2*k3+k4);
DD(i+1)=-A*B*exp(-B*i*h);
D2D(i+1)=A*B^2*exp(-B*i*h);
Food=0;
if i*h>Food
D(i+1)=2*A*exp(-B*(i*h-Food));
DD(i+1)=-A*B*exp(-B*(i*h-Food));
D2D(i+1)=A*B^2*exp(-B*(i*h-Food));
else
D(i+1)=D(i+1);
DD(i+1)=DD(i+1);
D2D(i+1)=D2D(i+1);
end
%%% tracking error %%%%%%%%%
e= x(1,i+1)-Gd;%0.1*sign(x(3,i+1)-Ib);
%%%%%%%%%%%%%%% First derivative %%%%%
edot=-x(1,i+1)*x(2,i+1)+D(i);
%%%%%%%%%%%% second derivative %%%%%%%%%%%
e2dot=-x(1,i+1)*x(2,i+1)^2+D(i+1)*x(2,i+1)+p2*x(1,i+1)*x(2,i+1)-p3*(x(3,i+1)-Ib)*x(1,i+1)+DD(i+1);
%%%%%%%%%%%%%%% Third Derivative %%%%%%%%%%%%%
%f2=[D(i+1)-x(1,i+1)*x(2,i+1)]*x(2,i+1)^2-2*p3*x(1,i+1)*x(2,i+1)*x(3,i+1)-3*p3*Ib*x(1,i+1)*x(2,i+1)-3*p2*x(1,i+1)*x(2,i+1)^2+x(2,i+1)*DD(i+1)+p3*x(3,i+1)*D(i+1)+p2*p3*x(1,i+1)*x(3,i+1)-p2*p3*Ib*x(1,i+1)-p2^2*x(1,i+1)*x(2,i+1)+D2D(i+1)+p3*x(3,i+1)*D(i+1)+p3*n*(x(3,i+1)-Ib)*x(2,i+1);
F=[D(i+1)-x(1,i+1)*x(2,i+1)]*[p2*x(2,i+1)-p3*(x(3,i+1)-Ib)+x(2,i+1)^2]-[p3*(x(3,i+1)-Ib)-p2*x(2,i+1)]*(D(i+1)+p2*x(1,i+1)-2*x(1,i+1)*x(2,i+1))+DD(i+1)*x(2,i+1)+D2D(i+1)+p3*n*x(1,i+1)*(x(3,i+1)-Ib);
%e3dot=F-p3*x(1,i+1)*U;
%%%%%%%%%%%%%%%%%%%%%%%%%%%% sliding surface %%%%%%%%%%
lambda1=0.01;%0.01;%0.01
lambda2=0.0001;%0.0001;%0.0001
QQ=.000;
KK=0.5;%0.5; 0.1 with Q=0.001, Patien 1
S=(q^2*e2dot+q*lambda1*edot+lambda2*e);%+0.001*sign(x(3,i+1)-Ib);KK=0.5;QQ=0.1;
surface(i)=S;
if KK>0
KK=KK+h*(abs(S)*sign(abs(S)-0.0001));
else
KK=KK;
end
%KK=0.9;
%KK=abs(p3*x(1,i+1)*10*F/(F^2+0.1));
YY=1.7159*[exp(a*S)-1]/[exp(a*S)+1];
g(i)=p3*x(1,i+1)*q^3;
GG=x(1,i+1)*p3;
U=((q^3)*F+(q^2)*lambda1*e2dot+q*lambda2*edot+KK*YY+QQ*S)/GG;
%___________________________________________________________
Comande(i+1)=U;
X=x(2,i+1);
I=x(3,i+1);
t(i+1)=i*h;
temps(i)=i*h;
i=i+1;
end
% Output
%torque inputs computation from the 7th,8th states inside ODE
%tt=0:(T(end)/(length(Comm)-1)):T(end);
%theta1 error plot
figure(1)
plot(t/60,x(1,:),'k')%,t/60,xob(1,:))
grid
title('G')
ylabel('error ')
xlabel('time (min)')
figure(2)
plot(t/60,Comande),
title('Commande')
figure(3)
plot(t/60,x(3,:),'k')
grid
title('X3')
ylabel('Insuline in plasma')
xlabel('time (min)')
figure(4)
plot(t/60,x(2,:),'k')
grid
title('X2')
ylabel('insuline effect')
xlabel('time (min)')
%theta2 error plot
figure(5)
plot(temps/60,surface)
grid
title('surfaces')
ylabel('insuline effect')
xlabel('time (min)')
%theta2 error plotsenadjki mohamed islamhttps://nl.mathworks.com/matlabcentral/profile/authors/17887361-senadjki-mohamed-islamtag:nl.mathworks.com,2005:Question/5591332020-07-03T18:46:42Z2020-07-03T20:50:50ZRemoving Unwanted data from a bunch of dataHey there everyone
I have a set of data of an eye digram (which I attached its .mat file) and clustered it by color as shown below. However, there are some data (lines) that are disturbing and out of range that makes the diagram too much clumsy and I intend to remove them (as I indicated in the second shape with black highlighter) but I do not know how to do it. I attached the code by the way to get the main output but removing those unwanted data and make the diagram looks clean is my problem
Can anyone help me do this?
Mahdi Khalili Hezarjaribihttps://nl.mathworks.com/matlabcentral/profile/authors/9641417-mahdi-khalili-hezarjaribitag:nl.mathworks.com,2005:Question/5589562020-07-03T11:44:32Z2020-07-03T20:45:10ZHistogram in App DesignerSo I have this excel file and i want to make an histogram or scatter in app desginer for smoke and non smoker, can someone help me out ? I can't figure it out, because in the excel Smoker is just one column, and i want to make a histogram with 2 bars (different colours), one is for the smokers, and the other one is for non smokers.Diogo Costahttps://nl.mathworks.com/matlabcentral/profile/authors/18370136-diogo-costatag:nl.mathworks.com,2005:Question/5591692020-07-03T20:43:43Z2020-07-03T20:43:43ZHow to make a structure to be input of a function and then its updated version to be output of the function?I want to make a structure to be input of a function and then do some analysis and add some fields to the structure and return the updated version of structure as the ouput of the function. I tried to use:
struct=function updatestruct(struct,...)
end
and it did not update the sruct and produced a new strucutre at the output loosing the previously stored data in the struct.Zeynab Mousavikhamenehttps://nl.mathworks.com/matlabcentral/profile/authors/14179884-zeynab-mousavikhamenetag:nl.mathworks.com,2005:Question/5577282020-07-01T11:52:17Z2020-07-03T20:43:26ZProgram working on one PC but not on otherIn a program to calculate value at risk. The for loop is stuck on a particular iteration 41 out of 50 iterations. But on some machines it is working fine.
Is there a problem of memory allocation or something else?
The error is coming is following function
function z2 = myfunction(r1,x1,x2)
warning('off', 'stats:gpfit:EvalLimit');
[bootstat,bootsam] = bootstrp(50,[],r1); %Sampling With Replacement from r1
Z=sort(r1(bootsam));% bootsam is the indices and Z1(bootsam) is 50 sample drawn
temp = [];
for k1 = x1:.1:x2
a5=0;
for i = 1:50
y5=Z(:,i);
[f12,x12]=ecdf(y5);
f12=f12(2:end);
x12=x12(2:end);
k11=k1;
k1 = min(k1,(y5(end-500))); % this is due to the possibility that the threshold could be greater than y(end-500)
% at least 500 observations are required to calculate Non-subjective Value-at-Risk
y5(y5<=k1)=[];
para = gpfit(y5-k1);
[h7, h8] = size (y5>k1);
h4=min(find(y5>k1));
[h5, h6] = size (y5);
s5=0;
clear F1 F2 F3 g;
for j5=h4:h5
F1=1-interp1q(x12,f12,y5(j5));
F2=1-interp1q(x12,f12,k1);
F3 = F1/F2;
g = 1-gpcdf(y5(j5)-k1,para(1), para(2), 0);
s5=s5+(g-F3)^2;
end
a5=a5+(s5/h7);
end
temp = [temp; [k1 a5]];
k1=k11;
end
[M,I]= min(temp(:,2));
z2=temp(I,1);
endNikhil Guptahttps://nl.mathworks.com/matlabcentral/profile/authors/18583886-nikhil-guptatag:nl.mathworks.com,2005:Question/5591422020-07-03T18:58:15Z2020-07-03T20:42:24ZHow to select the desired object in a certain region in an image?Hi all,
I have plenty images to process and calculate the frost area/ volume on a heat exchanger. First, I have some local images and I used matlab to crop them to a certain size that I have only two fins. Then, I want to calculte the triangle area between fins and tubes because I want to calculate the frost area = the difference of this trangle area between images. Thanks to this forum, I've been able to crop the images, deblur the images, covert them to binary image, find the closed area/ objects in the image, label the objects and calculate the areas.
However, there are about 30 objects in each image and I just need two of them in the central part (The green and yellow triangles, for example). How can I select and output the information, like shape, areas, centroids of those two objects? Can I achieve this based on the boundary limitation of the initial triangle region? Also, How can I plot the difference of image 1 and 2, so that I can show the frost thickness?
Thank you in advance!Wenying Zhanghttps://nl.mathworks.com/matlabcentral/profile/authors/18903883-wenying-zhangtag:nl.mathworks.com,2005:Question/5586982020-07-02T23:12:36Z2020-07-03T20:33:17ZHow do I set a seed to generate different random initial numbers and storing themfor kk = 1 : Iter
xD = rand(N,1)*2*pi; % Init Cond. Driver
endSamsonhttps://nl.mathworks.com/matlabcentral/profile/authors/14635796-samsontag:nl.mathworks.com,2005:Question/5591662020-07-03T20:28:09Z2020-07-03T20:28:09ZCorrecting drift in Euler angles, specifically yaw (z)I am collecting IMU data using Shimmer3 sensors in order to predict an individual's position when they are lying in bed. While testing the IMU by rotating it the following sequence: 0deg, +90deg, -90deg, 0deg in all respective axis, I obtained the correct output from roll and pitch (approx +90 and -90), but not yaw (approx +132, -51). The range between the max and min for yaw was still 180 which led me to believe the signal was drifting. I used the detrend function on the euler angle yaw output and it helped bring the values close to +90 nd -90 but they are still about 15 deg off. What are other possibilities to fix this drift.
Thank you!
The left image is the original output and the right image is after I used detrend on the euler angle output for yaw.
Nikola Pupichttps://nl.mathworks.com/matlabcentral/profile/authors/17063088-nikola-pupictag:nl.mathworks.com,2005:Question/5589292020-07-03T10:40:14Z2020-07-03T20:27:34Zstack up 3D images into a 4D matrixHello,
I have multiple 3D images and I should stack up these images into a 4D matrix and use it as an input for another code for feature extraction. I have tested this method : cat(4,im1,im2,im3) but it doesn't work well as input. How can I convert these images into 4D matrix ? SaHaRhttps://nl.mathworks.com/matlabcentral/profile/authors/11317038-sahartag:nl.mathworks.com,2005:Question/5589682020-07-03T12:28:09Z2020-07-03T20:22:08ZIs it possible that ode23 or ode45 could result in complex numbers instead of real ones? If Yes, what are the possible reasons for getting complex numbers once you would expect real ones?Hi, I perfromed ode23 for solving a differential equation, but after some timesteps I started to get complex numbers (i.e. the imaginary part) as result, instead of real numbers. Based on my equations/calculations, I should always get real numbers, and I do not understand if/why those solvers could give imaginary numbers.
Therefore, Is it possible that ode23 or ode45 could result in complex numbers instead of real ones?
If Yes, what are the possible reasons for getting complex numbers once you would expect real ones?
More info on the ODE here:
https://it.mathworks.com/matlabcentral/answers/558265-error-in-using-ode23t-to-solve-a-differential-equation-on-a-graph-network?s_tid=mlc_ans_email_ques
Thanks a lot!Simhttps://nl.mathworks.com/matlabcentral/profile/authors/14233052-simtag:nl.mathworks.com,2005:Question/5591302020-07-03T18:40:18Z2020-07-03T20:20:49ZWhy a figure window with a certain figure number cannot be opened? Hello.
Opening a figure window by typing ">figure;" in my startup.m leads to the following strange behavior:
Waiting 5-10sec after the start of Matlab and then executing >figure(2); does not produce a new figure window. Typing >figure will open Figure 3, but Figure 2 will now be missing completely from the session.
Interestingly, opening two figure windows in startup.m by executing ">figure; figure;" does open Figures 1 and 2 as expected. However, now Figure 3 is impossible to open!
Similarly, opening one figure in startup.m and then typing >figure as quickly as possible upon the start of the session opens Figure 2 successfully. So it seems that the "missing figure" is the first one which I try opening after some time interval following the opening of the first batch of figures. I.e. opening four figures via startup.m and waiting for 5-10 sec before opening another figure in the session will make Figure 5 inaccessible, not even after any of the open figures is closed.
Any help with recovering the "missing figure" will be appreciated.
Thanks,
Valery.Valery Milnerhttps://nl.mathworks.com/matlabcentral/profile/authors/227376-valery-milnertag:nl.mathworks.com,2005:Question/5590192020-07-03T14:52:13Z2020-07-03T20:20:16Zplot with string value in x axisI have a data
date temperate
----
'2020-01' 10
'2020-02' 10
'2020-03' 20
I tried
plot(date, temperature)
and got "invalid data argument"
Please advise. alpedhuezhttps://nl.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:nl.mathworks.com,2005:Question/5591602020-07-03T19:48:47Z2020-07-03T20:14:42Zsave matrix in loop to 3D matrix (storage all inkomming matrix)Hello,
I read multiple .mat-files with matrix M x-y-axis (5x2doubles) and have to save it. I think, the better way is to create a 3D-matrix - z-axis. Later, i have to make mean and std trow all z-axis elements. How can i do it?
Please think about - i get a matrix M in the loop, by load(MAT_File)
Thank you in advise!
Nik Rockyhttps://nl.mathworks.com/matlabcentral/profile/authors/7505467-nik-rocky