https://www.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-10-22T13:49:39Ztag:www.mathworks.com,2005:Question/4866992019-10-22T05:50:59Z2019-10-22T13:49:39ZIntegration via trapezoidal rule in various sections of the same arrayIf the signal S consists of several peaks as a function of time, is there a way to assign integration limits for the trapezoidal rule? Say, I would like to integrate peak 1 from 5 to 7 min, then there is another peak 2 which needs to be integrated from 7.5 to 9.5 minutes. The documentation for trapezoidal rule does not mention anything about limits. Assume we do not know the functional form of the peaks. Thanks.
https://www.mathworks.com/help/matlab/ref/trapz.htmlFWhttps://www.mathworks.com/matlabcentral/profile/authors/9766874-fwtag:www.mathworks.com,2005:Question/4867712019-10-22T12:33:49Z2019-10-22T13:49:22ZHow to revert run section keyboard shortcut behaviour change in MATLAB_R2019b Starting from MATLAB_R2019b, the "Evaluate Current Section" keyboard shortcut triggers even if the editor is not highlighted (e.g. when you work in Command Window). Previously, it only triggered when you used the shortcut while working in the editor. How can I revert to the previous behaviour in MATLAB_R2019b?Oscar Anghammarhttps://www.mathworks.com/matlabcentral/profile/authors/14004342-oscar-anghammartag:www.mathworks.com,2005:Question/4867872019-10-22T13:36:53Z2019-10-22T13:46:42Zhow to plot a defined function ?hi. i coded 2 functions. now i want to plot N(t) versus T. but it gives me errors. plz help me to do that.
clear;
T=0:0.1:14;
plot(T,N(t))
function pa = partialtranspos(T)
J=1;B=4;d=4;
s0=[1 0;0 1];
sx=[0 1;1 0];
sy=[0 -1i;1i 0];
sz=[1 0;0 -1];
H = 2*J*kron(sz,sz)+B*(kron(sz,s0)+kron(s0,sz))+d*(kron(sx,sy)-kron(sy,sx));
ro = expm(-H/T)/trace(expm(-H/T));
pa = [ro(1,1) ro(2,1) ro(1,3) ro(2,3);ro(1,2) ro(2,2) ro(1,4) ro(2,4);
ro(3,1) ro(4,1) ro(3,3) ro(4,3);ro(3,2) ro(4,2) ro(3,4) ro(4,4)];
end
function ne = N(T)
ne=0.5*(sum(abs(eig(partialtranspose(T))))-1);
endreza hamzehhttps://www.mathworks.com/matlabcentral/profile/authors/16618054-reza-hamzehtag:www.mathworks.com,2005:Question/4860692019-10-18T08:18:48Z2019-10-22T13:46:20ZHow to replace lines by bars of varying color in Tukey HSD plotIn multiple comparison test Tukey HSD is plotted as lines. I expect the following customizations:
1. Replace all Horizontal Lines by Horizontal Bars
2. Show Min, Max, Mean, Meadian as Vertical lines till horizontal bars.
3. Show these values, text aligned and along to vertical lines.
<</matlabcentral/answers/uploaded_files/243985/Matlab%20Result.png>>
<</matlabcentral/answers/uploaded_files/243986/Expected%20Result.png>>
Mukundhttps://www.mathworks.com/matlabcentral/profile/authors/8210225-mukundtag:www.mathworks.com,2005:Question/4867902019-10-22T13:45:38Z2019-10-22T13:45:38ZI don't find the run button on my simulink Model.I used the Matlab R2016 a version.
When working with simulink, I don't find the run button on my simulink Model.
I have restart Matlab but nothing happens.
Could anyone help me ?
Thanks in advanceMMSAAHhttps://www.mathworks.com/matlabcentral/profile/authors/8170340-mmsaahtag:www.mathworks.com,2005:Question/4867142019-10-22T07:30:19Z2019-10-22T13:44:35Z1)How MATLAB does LU decomposition? Which is MATLAB's buit-in function? How does it handle the pivoting case? Compare your obtained results with that of MATLAB.2)How to carry out LU decomposition for matrix A of increasing size n = 10; 20; 40; 80; 101)How MATLAB does LU decomposition? Which is MATLAB's buit-in function?
How does it handle the pivoting case? Compare your obtained results with that of
MATLAB.2)How to carry out LU decomposition for matrix A of increasing size n = 10; 20; 40; 80; 160. Plot
ashim sharmahttps://www.mathworks.com/matlabcentral/profile/authors/16435010-ashim-sharmatag:www.mathworks.com,2005:Question/4863972019-10-20T13:04:10Z2019-10-22T13:44:16ZReshaping 2d arraygreetings friends,
Problem Definition:
I had a variable named Interpreted_power_1st_column = 105120 X 1 ;
This is the power availablitiy data at a location collected at every 5 mins interval for whole year.( 8760*12=105120) (there are 12 5 mins intervals in 1 hour ,and 8760 hours in 365 days)
I want the data to be avaerged to 1 hour interval, so I used reshape function in matlab( code below) to sum the 12 consequtive data points multiply by 5 and then divide the whole summation by 60....this is actually good way to get average data for 1 hour interval.
hourly_wind_energy1=zeros(8750,1);
hourly_wind_energy1=((sum(reshape(Interpreted_power*5,12,8760)))/60); %Hourly Wind energy generated from intepretation of power curve KW-hr
hourly_wind_energy1=hourly_wind_energy1';%%Hourly Wind energy generated from intepretation of power curve KW-hr
Now I have to do the same but Interpreted_power = 105120 X 5 (5 columns)
I have be trying various ways like for loops but couldnot achieve my final result.
Possible solution 1 : any experts who are well aware of reshape function help me with a possible way to do the process I have done in problem definityin for an variable with several columns (for now 105120 X 5, 5 columns)
Possible solution 2:
to create 5 different variables (Interpreted_power_1st_column, Interpreted_power_2nd_column, Interpreted_power_3rd_column, Interpreted_power_4th_column, Interpreted_power_5th_column)
Interpreted_power_1st_column has 1st column of Interpreted_power = 105120 X 5
Interpreted_power_2nd_column has 2nd column of Interpreted_power = 105120 X 5
Interpreted_power_3rd_column has 3rd column of Interpreted_power = 105120 X 5
Interpreted_power_4th_column has 4th column of Interpreted_power = 105120 X 5
Interpreted_power_5th_column has 5th column of Interpreted_power = 105120 X 5
Now follow the same procedure used in Problem definition ( Use reshape function 5 times for 5 of these variables, then combine all the results into single variable with 8760 X 5 )
Problem with solution 2 : I am having trouble creating individual column variables,
Interpreted_power_1st_column=Interpreted_power(1:end);
Interpreted_power_1st_column=Interpreted_power_1st_column'; %% this is giving 1st column elements
Interpreted_power_2st_column=Interpreted_power(2:end);
Interpreted_power_2st_column=Interpreted_power_2st_column'; %% but all below are not exactly the required column elements
Interpreted_power_3st_column=Interpreted_power(3:end);
Interpreted_power_3st_column=Interpreted_power_3st_column';
Interpreted_power_4st_column=Interpreted_power(4:end);
Interpreted_power_4st_column=Interpreted_power_4st_column';
Interpreted_power_5st_column=Interpreted_power(5:end);
Interpreted_power_5st_column=Interpreted_power_5st_column';
Thanks in advancevenkat siddhartha ramahttps://www.mathworks.com/matlabcentral/profile/authors/12798231-venkat-siddhartha-ramatag:www.mathworks.com,2005:Question/4867862019-10-22T13:35:35Z2019-10-22T13:43:21ZHow to compute the partial derivative Compute the partial derivative of the following loss function with respect to θj:
J(θ0, θ1, θ2) = -1/m sum_{i = 1}^m [y(i) * log(hθ(x(i))) + (1 - y(i)) log(1 - hθ(x(i)))],
where hθ(x) = 1/(1 + exp(-(θ0 + θ1 x1 + θ2 x2)).
And I write the following ..
sysm x1 x2 theta0 theta1 theta2 y
h(theta0, theta1, theta2) = 1/(1+exp(-(theta0 + theta1*x1 + theta2*x2)));
I dont know how to differentiate the function using : diff (function, var)..Kumar Thapahttps://www.mathworks.com/matlabcentral/profile/authors/16250241-kumar-thapatag:www.mathworks.com,2005:Question/4867812019-10-22T13:16:24Z2019-10-22T13:42:03ZHow to compute the partial derivative Compute the partial derivative of the following loss function with respect to θj:
J(θ0, θ1, θ2) = -1/m sum_{i = 1}^m [y(i) * log(hθ(x(i))) + (1 - y(i)) log(1 - hθ(x(i)))],
where hθ(x) = 1/(1 + exp(-(θ0 + θ1 x1 + θ2 x2)).Kumar Thapahttps://www.mathworks.com/matlabcentral/profile/authors/16250241-kumar-thapatag:www.mathworks.com,2005:Question/4867892019-10-22T13:39:47Z2019-10-22T13:39:47Z"There are no compatible support packages available to install from this location"Greetings,
My name is Liron.
I’m using MATLAB R2017b, and trying to install an add-on called “Image Acquisition ToolBox Support Package for OS Generic Video Interface” *OFFLINE*.
When opening the .exe file (on Windows 7), MATLAB opens an error window, stating that *"There are no compatible support packages available to install from this location"*.
I’m the admin on this computer, so no permission issues should cause this error.
Does anyone know how to solve this?
Thank you!
Liron StettinerLiron Stettinerhttps://www.mathworks.com/matlabcentral/profile/authors/9247183-liron-stettinertag:www.mathworks.com,2005:Question/4867102019-10-22T06:54:08Z2019-10-22T13:39:38ZCreate a Matlab program to calculate the stoichiometric AFR for the following hydrocarbons: • Methane • Ethane • Propane • Butane • Pentane • Hexane • Octane • Decane and • Dodecane ....Plot their variation with carbon to hydrogen ratio.I have made a basic matlab programme for this code to run but plot is not generating.How should I approach for its plot generation?
%Stoichiometric air fuel ratio(AFR) by moles(a) and by mass(b)
r=[];
c= menu('Enter Carbon atoms= ',1,2,3,4,5,6,8,10,12);
h=(2*c)+2;
disp(['for ',num2str(c),' carbon atom,Hydrogen atoms= ',num2str(h)])
x=c;
y=h/2;
a=x+(y/4);
b=(a*4.76*29)/((12*c)+(h*1));
r=c/h;
disp(['Stoichiometric AFR by moles=', num2str(a)])
disp(['Stoichiometric AFR by mass=',num2str(b)])
plot(a,r)Parag Bendrehttps://www.mathworks.com/matlabcentral/profile/authors/15912846-parag-bendretag:www.mathworks.com,2005:Question/4867782019-10-22T12:59:38Z2019-10-22T13:39:21ZHow to create half cycle sine pulse trainclc;
clear all ;
close all;
%wt = 0:0.2:pi;
tp=2.2676*10^-3;
Ts=22.67*10^-6;
n=1:Ts:101;
fp=(1/tp);
w=2*pi*fp;
%p=sin(wt);
p=sin(w*n*Ts);
plot(n,p);
i tried this Durgaprasad Srinivasahttps://www.mathworks.com/matlabcentral/profile/authors/14504579-durgaprasad-srinivasatag:www.mathworks.com,2005:Question/4865632019-10-21T12:19:37Z2019-10-22T13:39:02ZUploading a value with a Matrix into MATLAB GUIHello Guys. I hope you are doing well. I have a question related to the uploading the value with a matrix. My code for the upload_ callback is working for all values except for the edit text box with a matrix and a value. How can I change the code below so that I can upload the value with the matrix as well? Any help will be greatly appreciated. I get the following errors when I use the pushbutton upload code shown below. These errors only come when I try to upload the value with the matrix edit box and not for the other edit text boxes.
Error using sprintf
Function is not defined for 'cell' inputs.
Error in GUI_ParametersFinal>pushbutton_Upload_Callback (line 149)
evalstr = sprintf('set(handles.%s,''%s'',''%s'')',uictagnames{i}, uicparams{j},tempval);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI_ParametersFinal (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI_ParametersFinal('pushbutton_Upload_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
The code is:
function pushbutton_Upload_Callback(hObject, eventdata, handles)
startingFolder = pwd
defaultFileName = fullfile(startingFolder, '*.mat');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a mat file');
if baseFileName == 0
return;
end
fullFileName = fullfile(folder, baseFileName)
temp = load(fullFileName);
data=temp.data;
uictagnames = fieldnames(data);
for i =1:numel(uictagnames)
uicparams = fieldnames(data.(uictagnames{i}));
for j = 1:numel(uicparams)
tempval = data.(uictagnames{i}).(uicparams{j});
if ~isnumeric(tempval)
evalstr = sprintf('set(handles.%s,''%s'',''%s'')',uictagnames{i}, uicparams{j},tempval);
else
evalstr = sprintf('set(handles.%s,''%s'',%d)',uictagnames{i}, uicparams{j}, tempval);
end
evalc(evalstr);
end
end
For edit callbacks, I am using this code:
str=get(hObject,'String');
tagname=get(hObject,'tag');
handles.mystructdata.(tagname).string = str;
guidata(hObject,handles)
The value in the edit text box is being generated from another GUI in the button down function. The value is getting saved, but once I click on the upload button, all the values get uploaded except for the value shown below because it is a value with matrix. You can see that below:
For all other structs, I have 1 fields. Only for this struct, I have 2 fields. Any help will be greatly admired as I am working on a big project. I had taken the help for uploading the values of the edit text boxes from this link. Therefore, you can see the link as well. I just need to upload the value with the matrix as shown above. Everthing else is done.
https://uk.mathworks.com/matlabcentral/answers/115235-store-permanently-data-taken-from-an-edit-text-box-of-gui
MHShttps://www.mathworks.com/matlabcentral/profile/authors/12763488-mhstag:www.mathworks.com,2005:Question/4866162019-10-21T17:03:47Z2019-10-22T13:35:05ZFirst colum of CSV-imported table has "x___" added to its nameI have a bunch of automatically-generated CSV files with headers, which I'd like to import into Matlab as a table. I used code such as
T = readtable('d:\test.csv', 'readvariablenames', true);
However, even though the name of the CSV's first column is runNr, the first column in the Matlab table gets named "x___runNr"
This clearly has something to do with the CSV files being in a slightly format different from that expected by Matlab. For instance, if I manually change the name of that first cell in Excel to something else, then reopen the CSV, the cell contents are all merged into a cell, on every row.
Still, I am not sure what to do to fix this, since I cannot change the format of the CSVs.
Any help?z8080https://www.mathworks.com/matlabcentral/profile/authors/8237042-z8080tag:www.mathworks.com,2005:Question/4867852019-10-22T13:33:37Z2019-10-22T13:33:37Zhow do I go about creating and storing data for a monte carlo simulation?Hi all,
This is my ham-fisted attempt to assign memory for the above. Let's say that I want my simulated data to be normally distributed random numbers (they're not, but right now I just care about having a structure in place) arranged in 3 series of 226 observations. So I create a cell that contains the 226x3 (empty, for now) arrays. Let's say I want 4 simulations, so 4 four of those (that's rubbish,but, again, just to keep things simple).
Then I create a 3 dimensional array of the right dimensions with said normal, random data. At this point I ought to extract each 226x3 lots of normal random data and shove it in the cell. Presumably, at that point, I can just put my model in that second loop and do what I need to do.
I do realise there surely are more direct ways to do this, but hey, I'm a beginner. Anyway, I can't seem to be able to do the extracting bit. M will only contain the last series from the 3 dimensional array.
clc;
clear;
par.muorig = 5; %mean
par.sigmaorig = 5; %stdev
Nsim = 4; % number of simulations
Lseries= 226;
M=cell(4,1);
%allocate memory for matrices-which perhaps I can store in cells
for imatrices=1:Nsim
M{imatrices}=zeros(Lseries,3);
end
for isim= 1:Nsimcreat
data(:,:,isim)=normrnd(par.muorig,par.sigmaorig,Lseries,3);
ff=1
for M M=data(:,:,isim); %pull out each array and shove it in the cells
ff=ff+1
%my model here
end
end
Any suggestions on how to do this? I look forward to hearing from you!Fede C 2018 Londonhttps://www.mathworks.com/matlabcentral/profile/authors/9117519-fede-c-2018-londontag:www.mathworks.com,2005:Question/3912762018-03-28T17:37:59Z2019-10-22T13:33:18ZInvalid Mex-files using 2018a Xcode 9.2
Hi,
While trying to run Matlab 2018a code using "BM3D" downloaded from from <http://www.cs.tut.fi/~foi/GCF-BM3D/>
(the file is <http://www.cs.tut.fi/~foi/GCF-BM3D/BM3D.zip> I'm getting this errors.
tried almost every solution suggested on Matlab Answers Community with no success.
I'm using Xcode 9.2.
Invalid MEX-file '/Users/ericelharar/Documents/MATLAB/Eric_Pedro/BM3D/bm3d_thr.mexmaci64': dlopen(/Users/ericelharar/Documents/MATLAB/Eric_Pedro/BM3D/bm3d_thr.mexmaci64,
6): Library not loaded: @loader_path/libmat.dylib
Referenced from: /Users/ericelharar/Documents/MATLAB/Eric_Pedro/BM3D/bm3d_thr.mexmaci64
Reason: image not found.
Error in BM3D (line 342)
y_hat = bm3d_thr(z, hadper_trans_single_den, Nstep, N1, N2, lambda_thr2D,...Eric Elharerhttps://www.mathworks.com/matlabcentral/profile/authors/12160309-eric-elharertag:www.mathworks.com,2005:Question/4867512019-10-22T10:45:47Z2019-10-22T13:32:57ZGet data from a CellstrHi
I have a Cellstr and I want to call the data from it 5 numbers at a time, so the user enters the text, and a binary value is stored in the cellstr depending on the ASKI value of the character entered, I want to call the binary values 5 at a time and use strrep to replce them with a character depending on the value of the binary number
Hopefully this makese sense!
Thanks
usertext = input('Enter your text message :','s');
usertext = usertext;
binary = cellstr(num2str(double(usertext) < 95));James Knighthttps://www.mathworks.com/matlabcentral/profile/authors/16428152-james-knighttag:www.mathworks.com,2005:Question/4867842019-10-22T13:32:18Z2019-10-22T13:32:56ZDice rolling & loopsHi! Im currently solving a task in which i have to simulate dice rolling. I'm supposed to generate 10 random numbers (between 1 and 6 of course, that part I've managed to do using a=rand(1,10) and then multiplying with 6 and rounding them). The next part is writing a loop which I'm struggling with. If 5 or 6 is gotten 7 or more times its supposed to display 'gain is 2',if 5 or 6 is gotten 4,5 or 6 times then display gain is 1 and if its gotten 4 or less times then gain is 0.
Any help or advice is appreciated Nina Helenahttps://www.mathworks.com/matlabcentral/profile/authors/16647397-nina-helenatag:www.mathworks.com,2005:Question/4867822019-10-22T04:00:00Z2019-10-22T13:32:07ZDisplay gets cut off when exporting Live Script to PDFI am working with and displaying rather large matrices in the Live Editor, then exporting this display to a PDF file. However, when exporting to a PDF, the matrices are so large that the display does not fit on the page and gets cut off on the right side of the screen.
MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/4867832019-10-22T13:31:33Z2019-10-22T13:31:33ZNot enough input argumentsSomebody help... this is my code:
% --- Estado Estable CIA --- %
function [f] = foc_cia(x)
global alpha beta delta eta psi fi theta_ss y_ss c_ss n_ss k_ss lambda_ss miu_ss i_ss r_ss
c_ss=x(1) ;
n_ss=x(2) ;
k_ss=x(3) ;
lambda_ss = x(4);
miu_ss = x(5) ;
%Condiciones de primer orden
f(1) = (c_ss^fi) - lambda_ss - miu_ss;
f(2) = psi*((1+n_ss)^eta) - lambda_ss*(1-alpha)*(y_ss/n_ss);
f(3) = -lambda_ss + beta*(1+r_ss)*lambda_ss;
f(4) = - miu_ss + i_ss*lambda_ss ;
f(5)= -lambda_ss + beta*((lambda_ss + miu_ss)/(1 + theta_ss));
...and the error
Not enough input arguments.
Error in foc_cia (line 5)
c_ss=x(1) Alessandro Caverzanhttps://www.mathworks.com/matlabcentral/profile/authors/13972193-alessandro-caverzantag:www.mathworks.com,2005:Question/4865972019-10-21T15:38:02Z2019-10-22T13:31:26ZCan i save excel files in app designerHello,
In my app i have push button and want the to save a 8 excel files with in the app. Reason for this is as the user makes his/her desired selection prior to using this push button (export) based on the users selection i want one the template(excel file) to be choosen which ever is assigned to the condition and selection made by the user. Please let me know if i could save excel files within an app?
Thanks
Sai Anand Gudlurhttps://www.mathworks.com/matlabcentral/profile/authors/8678603-anand-gudlurtag:www.mathworks.com,2005:Question/4862662019-10-19T09:54:52Z2019-10-22T13:23:47ZHow to change FontSize and FontWeight of labels using labeledge?How to change FontSize and FontWeight of labels using labeledge?
s = [1 1 2 2 3];
t = [2 3 3 4 4];
G = graph(s,t);
h = plot(G);
labelText = {'ABC' 'DEF' 'GHI'};
labeledge(h,[1 1 2],[2 3 3],labelText)
(I cannot see any mention of FontSize and FontWeight in the current labeledge's documentation)Simone Loretihttps://www.mathworks.com/matlabcentral/profile/authors/14233052-simone-loretitag:www.mathworks.com,2005:Question/2671702016-02-08T16:46:18Z2019-10-22T13:23:32ZHow can I control node label font size of a graph or digraph object?I want to plot a _graph_ or _digraph_ (R2015b). Unfortunately, the node labels are barely legible because the font size is too small.
*How can I change the font size of the node labels?*
My example code is from the Matlab documentation:
s = {'a' 'a' 'a' 'b' 'b' 'c' 'd' 'd' 'd'};
t = {'b' 'c' 'd' 'd' 'a' 'b' 'c' 'a' 'b'};
G = digraph(s,t);
labels = {'a/3' 'a/3' 'a/3' 'b/2' 'b/2' 'c' 'd/3' 'd/3' 'd/3'};
p = plot(G,'Layout','layered','EdgeLabel',labels);
highlight(p,[1 1 1],[2 3 4],'EdgeColor','g')
highlight(p,[2 2],[1 4],'EdgeColor','r')
highlight(p,3,2,'EdgeColor','m')
title('Page Rank Score Transfer Between Nodes')
I would expect p to have a property "NodeLabelFontSize" (or similar), but there is no property to control label appearance.
% get properties of p
get(p)
Jakob Nikolashttps://www.mathworks.com/matlabcentral/profile/authors/3730754-jakob-nikolastag:www.mathworks.com,2005:Question/4741322019-07-30T15:19:50Z2019-10-22T13:22:53ZManova(rm) Manova(rm) & manova1(Responses, GroupVar) can address the same data (if 1 group variable). Yet, they give different statistics. When I run the same data, I get a different probability of rejecting null hypothesis. are there differing null hypotheses? I there a method to tform stats of one to other?Michael Rossenhttps://www.mathworks.com/matlabcentral/profile/authors/13248738-michael-rossentag:www.mathworks.com,2005:Question/4867732019-10-22T12:41:14Z2019-10-22T13:16:37ZExtracting values from file names to arrayLet's say I have a directory "mydirectory" and in it, I have some files
file_234.txt
file_356.txt
file_567.txt
file_987.txt
and I want to form an array in Matlab out of the respective numbers.
234
356
567
987
How can I go into the directory, extract the information from the files, and put each value into the array?
Thanks!granthttps://www.mathworks.com/matlabcentral/profile/authors/12454507-granttag:www.mathworks.com,2005:Question/4855242019-10-15T19:19:21Z2019-10-22T13:15:23ZMATLABR2019b keeps on giving me this errors every second, please help me Macbook Pro 2017 13-inchjava.lang.IndexOutOfBoundsException: Invalid line index=1 >= lineCount=1
at org.netbeans.editor.LineRootElement.getElement(LineRootElement.java:91)
at sun.lwawt.macosx.CAccessibleText.getRangeForLine(CAccessibleText.java:338)
at sun.lwawt.macosx.CAccessibleText$11.call(CAccessibleText.java:189)
at sun.lwawt.macosx.CAccessibleText$11.call(CAccessibleText.java:187)
at sun.lwawt.macosx.LWCToolkit$CallableWrapper.run(LWCToolkit.java:597)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)Emin Oskayhttps://www.mathworks.com/matlabcentral/profile/authors/10884440-emin-oskaytag:www.mathworks.com,2005:Question/2903572016-06-16T18:00:04Z2019-10-22T13:14:33Zhow to design a denoising stacked autoencoderI see matlab add the stacked auto-encoder to its libraries.
Does any one know how I can make a denoising stacked auto-encoder.
isalirezaghttps://www.mathworks.com/matlabcentral/profile/authors/7967574-isalirezagtag:www.mathworks.com,2005:Question/4858702019-10-17T11:07:52Z2019-10-22T13:13:17ZGenerating vector and made it variable How i could generate a vector of equally likely 1 and -1 values and this vector has more than 1000 values. i want to make this vector variable that can be modified in the begining of the script
x = -1 : 0.001 : 1;sarah tariqhttps://www.mathworks.com/matlabcentral/profile/authors/16119445-sarah-tariqtag:www.mathworks.com,2005:Question/4867762019-10-22T12:54:07Z2019-10-22T13:11:08ZWhy edit copy of figure is inactive?Zeynab Mousavikhamenehttps://www.mathworks.com/matlabcentral/profile/authors/14179884-zeynab-mousavikhamenetag:www.mathworks.com,2005:Question/4866702019-10-22T00:44:06Z2019-10-22T13:10:49ZSimple Mars Landing FormulaWhat would be a simplistic formula for landing a 350 tonne rocket travelling at 11km/s on Mars safely and importing it into Matlabs? Riley McCullaghhttps://www.mathworks.com/matlabcentral/profile/authors/15911048-riley-mccullaghtag:www.mathworks.com,2005:Question/4863592019-10-20T02:52:01Z2019-10-22T13:10:01ZNaN from ptCloud.Location (Computer Vision toolbox required)Hello,
I have been following this example: https://www.mathworks.com/help/vision/examples/depth-estimation-from-stereo-video.html to reconstruct a 3D-scene from a pair of stereo cameras. My code and relevant files are attached, so if downloading and placing them all in one folder you should be able to run it and see what I am describing below.
When I wanted to extract xyz coordinates of the pixels in the reconstruction, I went to ptCloud.Location, which is an m-by-n-by-3 matrix that should store the xyz coordinates of the pixel, but I found only NaN's in this matrix. My ultimate goal would be to remove some points based on their locations. Is there a way to get valid xyz coordinates from this matrix or from elsewhere? Thanks Gesiren Zhanghttps://www.mathworks.com/matlabcentral/profile/authors/5559986-gesiren-zhangtag:www.mathworks.com,2005:Question/4867292019-10-22T09:16:32Z2019-10-22T13:09:23ZManage and produce subplots I have around 160 plots that are generated in a for loop. The number of plots might vary based on the inputs they are more than 100 so I need to manage them.
I was wondering if you have any suggestion managing/presenting this number of plots? If I want to use subplots (3*3 for example) how can I manage to do it automatically so I dont need to give the location of each subplot? since e.g. I want to have 9 plots in one subplot, I need to have 18 distinct subplot. e.g. when each loop is called, the plot is placed next to the previous plot.
The for loop that I use is:
for jjj=1:length(struct)
if jjj==1
rowidx = KsTable.k_name == KsTable.k_name(jjj) ;
x=KsTable.k_value(rowidx);
y=KsTable.Mean.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel(KsTable.k_name(jjj))
ylabel(strrep('Mean_Prolif','_','\_'))
%Plot derivative:
x=KsTable.deltax(rowidx);
y=KsTable.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel("delta x" + KsTable.k_name(jjj))
ylabel(strrep('prolif_mean','_','\_'))
elseif KsTable.k_name(jjj)~= KsTable.k_name(jjj-1)
rowidx = KsTable.k_name == KsTable.k_name(jjj) ;
x=KsTable.k_value(rowidx);
y=KsTable.Mean.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel(KsTable.k_name(jjj))
ylabel(strrep('Mean_Prolif','_','\_'))
%Plot derivative:
x=KsTable.deltax(rowidx);
y=KsTable.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel("delta x" + KsTable.k_name(jjj))
ylabel(strrep('prolif_mean','_','\_'))
end
endZeynab Mousavikhamenehttps://www.mathworks.com/matlabcentral/profile/authors/14179884-zeynab-mousavikhamenetag:www.mathworks.com,2005:Question/4867742019-10-22T12:43:18Z2019-10-22T13:08:25Zhow to reduce forloops and run time?? for rr = 1:25
for mm = 1:150
for nn = 1:300
[~,idx] = min(abs(var1(:,1) - tof(mm,nn,rr)));
voltage(mm,nn,rr) = bscan(idx,rr);
end
end
end
M.Prasanna kumarhttps://www.mathworks.com/matlabcentral/profile/authors/14364909-m-prasanna-kumartag:www.mathworks.com,2005:Question/4867682019-10-22T12:26:19Z2019-10-22T13:08:12ZObtain a specif value in a vectorHi guys, I'm having a problem; let's say I have a code like the following:
clear
g = ones(1,1);
serv = (randi([0, 10], [10,10])).*g;
meanserv = mean(serv);
At this point, what I need is a value of g such that meanserv(1,1) is equal to 0.3 and meanserv(1,10) is equal to 0.7; I was thinking to use an fsolve or a simple while/if but I can't figure out how to obtain those results.
Thanks in advance.Giuseppe Pintorihttps://www.mathworks.com/matlabcentral/profile/authors/11452821-giuseppe-pintoritag:www.mathworks.com,2005:Question/4867802019-10-22T13:04:02Z2019-10-22T13:04:02ZError with timer TimerFcnHi, am using an timer to plot my camera onto UIAxes. I am getting error everytime I stop the timer.
I am getting the error text below, were the i value in "timer-i" changes everytime.
Error while evaluating TimerFcn for timer 'timer-19'
Matrix dimensions must agree.
when I am using the following code
function CreatePlotTimer(app)
app.timerPlot = timer;
app.timerPlot.StartDelay=1;
app.timerPlot.ExecutionMode='singleShot';
app.timerPlot.TimerFcn = @(~, ~)PlotFunction(app);
end
I am calling the Timer at this location:
if strcmp(get(app.ButtonCamera,'Text'),'Start Camera')
start(app.timerPlot)
set(app.ButtonCaptureImages,'Enable','on');
set(app.ButtonCamera,'Text','Stop Camera') % sets button to 'Stop Camera'
else
%%Camera is off. Change button Text and 'start camera'.
stop(app.timerPlot)
CreatePlotTimer(app);
set(app.ButtonCaptureImages,'Enable','off');
set(app.ButtonCamera,'Text','Start Camera') % sets button to 'Start Camera'
end
Anyone knows what is going on?
Many thanks
Happy PhDhttps://www.mathworks.com/matlabcentral/profile/authors/12852222-happy-phdtag:www.mathworks.com,2005:Question/4861232019-10-18T11:35:23Z2019-10-22T13:03:39ZCurve fitting by Genetic AlgorithmHi everybody, I have a very simple theoric problem but I don't know how to resolve it.
I just wanna do a curve fitting like this:
I want the red line to fit the red dashed one as much as possible in the [0.3 - 0.6] interval.
The red line is a 100x1 vector (x-axis) and 100x1 vector (y-axis).
The red dashed curve is given by this equation (much longer, cropped here):
function [ d2 ] = d2_current( alpha,beta,phi,N,V )
d2 = (4903985730770845.*N.*(((exp(alpha.*(phi - V.*(beta - 1))) + 1).*((alpha.^2.*beta.^2.*exp(alpha.*...
end
Where V is the dependent variable, the previous 100x1 vector (x-axis) corresponding to the [0.3 - 0.6] interval.
The equation depends on 4 independent parameters, each one of them may be included in these intervals:
beta; from to a 1
alpha; from 0 to 15
N; from 0 to 300
phi; from 0 to 3
I have to vary these parameters in order to obtain the best fitting, note that the parameters value must be the same for one single fitting.
The first thing I did was 4 different 'for' loops for each parameter and try to compare each single result with the red curve my means of the euclidean distance. (simplified code):
cont = 0;
for beta = 0:0.01:1
for alpha = 0:0.01:15
for N = 0:1:300
for phi = 0:0.01:3
distance_euclidean(cont,1) = norm(current_red_curve - current_red_dashed_curve);
cont = cont + 1;
end
end
end
end
minim_eucl = min(distance_euclidean);
The minimum euclidean distance would be the best fitting. For the graph example:
beta = 1;
alpha = 15;
N = 300;
phi = 0.45;
Everything is fine until this point, but there's a big problem: the computing time is just huge when the step in the 4 intervals decreases (needed because of the poor fitting).
Looking for better solutions I found the possible way to go: the genetic algorithm. I've been trying it on the Matlab optimization tool, but with no results.
Could somebody help me out?
Thank you very much for your help.
Regards,Juan Castillohttps://www.mathworks.com/matlabcentral/profile/authors/12800191-juan-castillotag:www.mathworks.com,2005:Question/4739162019-07-29T12:13:55Z2019-10-22T13:03:17Zhow to compare ground truth image with segmented image?BW2=imread('C2.png'); %segmented image
figure,imshow(BW2)
BW=imread('001_mask.png'); %groundtruth-image
figure,imshow(BW)
% mask = false(size(BW2));
% mask(25:end-25,25:end-25) = true;
% BW = activecontour(BW2, mask, 300);
similarity = jaccard (BW2, BW)
figure
imshowpair(BW2, BW)
title(['Jaccard Index = ' num2str(similarity)])
I am trying to find accuracy but got an error.
Undefined function 'jaccard' for input arguments of type 'uint8'.
Error in Untitled (line 8)
similarity = jaccard (BW2, BW)
what will be changed in this code?tashu Dabariyahttps://www.mathworks.com/matlabcentral/profile/authors/10761538-tashu-dabariyatag:www.mathworks.com,2005:Question/1308512014-05-23T18:27:21Z2019-10-22T13:01:45ZHow to find "rectangular" corners?Hey,
I have this image:
<</matlabcentral/answers/uploaded_files/13201/recta.jpg>>
I want to find the 4 corners of the "rectangular", but I don't want to use the "corner" function.
What can I do?
Thanks.Morhttps://www.mathworks.com/matlabcentral/profile/authors/4285445-mortag:www.mathworks.com,2005:Question/4867792019-10-22T13:01:05Z2019-10-22T13:01:05ZIs there any way to speed up this 1D random walk?I'm a beginner at matlab and would like to know how to improve the computational speed of this script.
Sorry that my question is so poorly formated, but I am far too inexperienced to format it clearer.
I am supposed to investigate where one usually end up (dn) after making M one-dimensional random walks starting from the origin and taking N steps. I would appreciate any beginner tips on how I can improve my script so that it can run faster, as I would like to make M and Nvec as big as possible for this computation.
Nvec = 1:100
M = 100000;
dn = zeros(M,Nvec(end));
%{
This for-loop generates a M-by-Nvec(end) matrix of the results of M repeated 1D random walks (final positions)
with N(i) steps taken from the origin.
%}
for N = Nvec
dn(:,N) = sum(2*randi([0 1],N,M)-1,1);
end
%This results in a 1-by-Nvec(end) vector containing the root mean squares of the M random walks for each N(i).
dn = sqrt(sum(dn.^2)./M);
William Fritzonhttps://www.mathworks.com/matlabcentral/profile/authors/7891733-william-fritzontag:www.mathworks.com,2005:Question/4867022019-10-22T06:02:32Z2019-10-22T12:59:23ZTumor Segmentation using FCM in Matlab codeHi All,
I'm stuck in segmenting tumor from this Image. The output i expect is having tumor part Segmented.
I have completed with removal of outer skull layer for the input image. But when i try segmenting tumor im not able to get the exact tumor.
Can somebody help me with matlab code for segmenting this tumor?
Thanks in Advance !!Oviya ovhttps://www.mathworks.com/matlabcentral/profile/authors/15013391-oviya-ovtag:www.mathworks.com,2005:Question/4867772019-10-22T12:57:55Z2019-10-22T12:57:55Zcheckerboard background movie cameraFor a project I need to make a kind of movie of the camera moving through a landscape with a checkerboard background and wireframe cubes(3D). We have some code for the background and wireframe cubes, but I can't figure out how to get this done. How should I do this? Mainly the part how to get the camera angle 'inside' of the plot.Lars van Kasterenhttps://www.mathworks.com/matlabcentral/profile/authors/16350986-lars-van-kasterentag:www.mathworks.com,2005:Question/4863832019-10-20T10:25:49Z2019-10-22T12:52:27ZHow to convert 3D image to 1D data?I had the temperature temperature readings of a sensor which is 5002x1 double. I took the readings for different temperatures say 8 and made the temp as a 2D array of 5002x8 double. I converted it into a 3D image (.png) and did some processing. Now I want to convert this 3D image back to temp data. How can I do that?Viswanathan Shttps://www.mathworks.com/matlabcentral/profile/authors/9660711-viswanathan-stag:www.mathworks.com,2005:Question/4858322019-10-17T08:08:44Z2019-10-22T12:50:25ZHow Can I load N .txt files with different name in a for loop? Hi all,
I have to load some .txt files from different subdirectory. The files name is the same for all of them, only the subdirectory's name changes. I have wrote this code but I have a problem: at each cycle the for loop overwrite the imported matrix. How Can I rename differently the imported matrices? Thx a lot!
SS=string(ones(N,1)); %declare matrix
s=(pwd); %check path
for i=1:N
SS(i,1)= sprintf('Risultati%d', i);
ss(i)=strcat(s,{'\'},SS(i),{'\'},{'disp.out'});
importdata(ss(i)); %%i can use also load function
endGianmarco Manzohttps://www.mathworks.com/matlabcentral/profile/authors/11296683-gianmarco-manzotag:www.mathworks.com,2005:Question/4867752019-10-22T12:48:55Z2019-10-22T12:49:29ZHow to segment volume object Automatically ?How to segment volume object ?
Volume Object Sample:
300 X 400X 800
H W C
H-------->Height
W------->Width
C-------->Channel
Selva Karnahttps://www.mathworks.com/matlabcentral/profile/authors/4733665-selva-karnatag:www.mathworks.com,2005:Question/4120822018-07-25T13:09:52Z2019-10-22T12:42:34Zput a function inside loop and save as matrix and csvI have the following main script that pass value to a function.
I would like to import different csv using function within a loop and output as summarize all data as matrix to be printed in an xls file .
Here are my progress code so far, please help in matrix creationa and xls print.
Thanks
%%main script-reads diff csv
clc
clear all
km=csvread('Bus_Data1.csv');
A=0
[Result1,maxa]=csvimport(km)
km=csvread('Bus_Data2.csv');
A=4
[Result1,maxa]=csvimport(km)
km=csvread('Bus_Data3.csv');
A=5
[Result1,maxa]=csvimport(km)
km=csvread('Bus_Data4.csv');
A=9
[Result1,maxa]=csvimport(km)
Here is the function code
%%function to calculate output of main m
function [Result1,maxa]=csvimport(fileName)
A=fileName(1:5,1);
maxa=max(A);
Result1=A;
end
jomshttps://www.mathworks.com/matlabcentral/profile/authors/8535596-jomstag:www.mathworks.com,2005:Question/4867132019-10-22T07:07:34Z2019-10-22T12:41:21ZMatrix multiply with a functioni have two matrix with same columns and rows(matrix a and b). a is depth and b is land use index. each index value has a different equation and it is function of depth. i need to create a third matrix by substituting depth value to the functions.
depth d={2 3 4;7 2 5;1 2 5}
land use l={a b c;b c a;c b a}
a=0.5*depth+3
b=0.78*depth+4
c=0.1*depth+8
I really appreciate your cooperation. Thank youIndikatophttps://www.mathworks.com/matlabcentral/profile/authors/2105594-indikatoptag:www.mathworks.com,2005:Question/4867552019-10-22T11:21:54Z2019-10-22T12:41:15Zcontrast gain of an imageI have an image that from an hazy image model,a haze free image.I need to find the contrast gain of this image.How can I find that,please help me. Silpa Khttps://www.mathworks.com/matlabcentral/profile/authors/15760628-silpa-ktag:www.mathworks.com,2005:Question/4867722019-10-22T12:35:14Z2019-10-22T12:40:11ZRF Budget Analyzer - Variable element input parameterHello,
I have a question regarding the RF Budget Analyzer App. In my understanding I can specify element with only one of each parameter (Gain, NF, OIP3). But real components always have a non constant behaviour over frequecy.
Is it possible to model elements with variable input paramters.
For Example; I have an amplifier with
Gain = 12 dB, NF = 4, OIP3 = 42 @ 2GHz and the same amplifier with
Gain = 12.5 dB, NF = 3.8, OIP3 = 45 @ 5 GHz Gain.
Now I want to analyse the Output Power from 1GHz to 6 GHz.
Is there an easy way to do the RF Budget Analysis over frequency (with interpolated values)?
ThanksWaldemar Henrichhttps://www.mathworks.com/matlabcentral/profile/authors/10139586-waldemar-henrichtag:www.mathworks.com,2005:Question/4866512019-10-21T21:05:08Z2019-10-22T12:37:23ZCoordinates of corners of quadrilateral in binary maskI'm doing a project on computer vision in which I have to compute some homographies and perform image stitching. I also have to provide the coordinates of the corners of each image in the final panorama.
Essentially, what I need is to determine the [x,y] coordinates (or i,j indices) of the four corners of a quadrilateral in a binary mask (example in the image below).
I coded a pretty computationally inefficient function to do it. But it misses one of the corners whenever the quadrilateral is a trapezoid (which is most of the time). I tried fixing it but haven't managed to get it quite right. I have tried to detect edges and lines using the hough algorithm and then getting the intersections of those lines but the results aren't precise and looks like a complicated way of solving a somewhat simple problem. Any matlab functions or implementation ideas for this task?João Miguel Ribeirohttps://www.mathworks.com/matlabcentral/profile/authors/15399445-joao-miguel-ribeirotag:www.mathworks.com,2005:Question/4867702019-10-22T12:27:43Z2019-10-22T12:27:43ZMatlab R2019b unable to start installation, Unexpected error java.lang.IllegalArgumentException: Workflow must contain 1 or more stepsHi, im tring to install matlab after starting the installer with
./install
I get the following error prompt
Error: The application encountered an unexpected error and needs to close.
You may want to try re-installing your product(s).
More information can be found at /tmp/mathworks_exa.log
the log cotains the following
(Oct 22, 2019 14:05:16) ##################################################################
(Oct 22, 2019 14:05:16) #
(Oct 22, 2019 14:05:16) # Today's Date:
(Oct 22, 2019 14:05:16) Tue Oct 22 14:05:16 CEST 2019
(Oct 22, 2019 14:05:16)
(Oct 22, 2019 14:05:16) System Info
(Oct 22, 2019 14:05:16) OS: Linux 5.3.7-arch1-1-ARCH
(Oct 22, 2019 14:05:16) Arch: amd64
(Oct 22, 2019 14:05:16) Data Model: 64
(Oct 22, 2019 14:05:16) Language: en
(Oct 22, 2019 14:05:16) Java Vendor: Oracle Corporation
(Oct 22, 2019 14:05:16) Java Home: /tmp/mathworks_35617/sys/java/jre/glnxa64/jre
(Oct 22, 2019 14:05:16) Java Version: 1.8.0_202
(Oct 22, 2019 14:05:16) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Oct 22, 2019 14:05:16) Java Class Path: /tmp/mathworks_35617/java/config/professionalinstaller/pathlist.jar
(Oct 22, 2019 14:05:16) User Name: exa
(Oct 22, 2019 14:05:16) Current Directory: /tmp/mathworks_35617
(Oct 22, 2019 14:05:16) Input arguments:
(Oct 22, 2019 14:05:16) root /home/exa/Downloads/matlab_R2019b_glnxa64
(Oct 22, 2019 14:05:16) libdir /tmp/mathworks_35617
(Oct 22, 2019 14:05:16) standalone true
(Oct 22, 2019 14:05:18) java.lang.IllegalArgumentException: Workflow must contain 1 or more steps.
at com.mathworks.wizard.WizardFactoryImpl.createWorkflowSteps(WizardFactoryImpl.java:43)
at com.mathworks.wizard.WizardLauncher.startWizard(WizardLauncher.java:135)
at com.mathworks.wizard.WizardLauncher.start(WizardLauncher.java:66)
at com.mathworks.wizard.AbstractLauncher.launch(AbstractLauncher.java:31)
at com.mathworks.wizard.AbstractLauncher.launchStandalone(AbstractLauncher.java:21)
at com.mathworks.professionalinstaller.Launcher.main(Launcher.java:21)
(Oct 22, 2019 14:05:18) Error: The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at /tmp/mathworks_exa.log
(Oct 22, 2019 14:08:34) Exiting with status -2
(Oct 22, 2019 14:08:34) End - Unsuccessful.
especially the java exception stack trace doesn't seem to match any search results, so any help is very appreciated
Lukas Blockhttps://www.mathworks.com/matlabcentral/profile/authors/15205983-lukas-block