https://se.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2019-02-17T20:11:08Ztag:se.mathworks.com,2005:Question/4454582019-02-17T20:08:37Z2019-02-17T20:08:37ZHow do I type 50 million on the command windowAnshoo Mehrahttps://se.mathworks.com/matlabcentral/profile/authors/14805186-anshoo-mehratag:se.mathworks.com,2005:Question/4450692019-02-15T00:21:07Z2019-02-17T20:07:07ZHow to plot Date time series in MATLAB?I am facing difficulties in plotting my time series data.The data file is also attached.I write code like this but doesnt work.
data3=readtable ('PRICE_AND_DEMAND_Jan.csv')
Date_Time = data3(:,2);
datecell=table2cell(Date_Time);
load = data3(:,3);
A = table2array(load)
p=datenum(datecell);
plot(datenum(datecell), A)
datetick('x', 'dd-mmm-yyyy HH:MM:SS')
% datetick('x', 'dd-mmm-yyyy HH:MM:SS')
Alihttps://se.mathworks.com/matlabcentral/profile/authors/14555415-alitag:se.mathworks.com,2005:Question/4454572019-02-17T20:05:15Z2019-02-17T20:05:15ZHow to install and enable Symbolic Math ToolboxHello! I am new to MatLab. How do I install and enable Symbolic Math Toolbox? I am currently getting the following error when I try to use the "syms" syntax:
To use 'syms', the following product must be licensed, installed, and enabled:
Symbolic Math ToolboxAnthony Bamugohttps://se.mathworks.com/matlabcentral/profile/authors/2846945-anthony-bamugotag:se.mathworks.com,2005:Question/4454532019-02-17T19:05:21Z2019-02-17T20:01:52ZIs there any way to separate the terms of a product?Hello,
Let's say I have this function_handle: f = @(x) exp(x-2)*log(x)
Is it possible to assign each function that comprises this product to its own seperate variable i.e:
g = exp()
h = x-2
j = log()
k = x
Thank you!Panagiotis Panagopoulos Papageorgiouhttps://se.mathworks.com/matlabcentral/profile/authors/14804881-panagiotis-panagopoulos-papageorgioutag:se.mathworks.com,2005:Question/4454512019-02-17T18:58:21Z2019-02-17T19:59:27ZWith 2 rectangles create a point in one that shows up in the otherI have this code where it creates 2 random sized rectangles.
But what I want to do is when I click within one of the rectangles it shows up in the other rectangles similar location based off of the size.
I think how I want to do it is calculate the area of both rectangles and then when I click within one of the rectangles it does some calculation dependent on the rectangle size to determine where to place the point in the other rectangle.
I'm just not sure on the math needed or maybe matlab has some easy functions to do something similar to what I'm wanting?
Edit:
This is what I have so far. xp1/yp1 and xp2/yp2 are the points of the 2 rectangles.
function drawPoint(xm1,ym1,xM1,yM1,xm2,ym2,xM2,yM2)
key = get(gcf,'CurrentKey');
xp1 = [xm1, xM1];
yp1 = [ym1, yM1];
xp2 = [xm2, xM2];
yp2 = [ym2, yM2];
while (~(key=='return'))
[x,y] = ginput(1);
if (inpolygon(x,y,xp1,yp1))
plot(x,y,'b*');
end
if (inpolygon(x,y,xp2,yp2))
plot(x,y,'r*');
end
key = get(gcf,'CurrentKey');
end
end
Jake Younghttps://se.mathworks.com/matlabcentral/profile/authors/14804848-jake-youngtag:se.mathworks.com,2005:Question/4454132019-02-17T13:44:23Z2019-02-17T19:56:40ZSave output data in a vector format while loopHi all,
I would like to export the output of the while loop in a vector format but it is not working for me... below is the code please advise.
Thanks
function [Q,h,t,v]= func (h0,D,d,dt)
g=9.81;
rho=1000;
h=h0;
t=0;
j=0;
% v=sqrt(2*g*h)
% h=(sqrt(h0)-1/2*d^2/D^2*sqrt(2*g)*t)^2
% Q=sqrt(2*g*h)*pi*d^2/2
while (t<228)
j=j+1;
t=t+dt;
h=((sqrt(h0))-((1/2)*(d^2)/(D^2)*(sqrt(2*g))*t))^2;
v=sqrt(2*g*h);
Q=sqrt(2*g*h)*pi*(d/2)^2;
a(j)=Q;
b(j)=h;
c(j)=t;
d(j)=v;
endAhmad Sayahhttps://se.mathworks.com/matlabcentral/profile/authors/7802665-ahmad-sayahtag:se.mathworks.com,2005:Question/4454182019-02-17T14:44:37Z2019-02-17T19:55:40ZIssue regarding mahalanobis distance functionHi, i am currently working on my thesis and i am trying the mahalanobis distance function to get the answer. The problem is i have a matrix of 242 lines and 2 colums and. In the first columns i have different mean values and in second column i have the standard deviation. What i want is at each line(in a for loop) i want to compare the line standard deviation and mean with the first line. Ultimately having a vector of 1 column and 242 lines. Can someone tell me how this can be done.
I tried using the 'mahal(X,Y)' but it does not work when dimension of both vectors are the same.
Marc Saadehttps://se.mathworks.com/matlabcentral/profile/authors/10846849-marc-saadetag:se.mathworks.com,2005:Question/4453702019-02-17T04:56:28Z2019-02-17T19:51:42ZNewtons Method, help calling anon function inside of function file Ok so I have been tasked with writing a file myNewton which finds the root of any function given the listed inputs. I am maybe misunderstanding how to implement the method in general, but my matlab related question pertains more to the nature of calling anony functions inside of function files. I do not do this here but I anticipate that the best way to solve this problem is to do that. I am basically confused! Any help is appreciated, here is what I have so far.
function p = myNewton(f,fprime,x0,tol)
%input f, anonymous function for root finding problem
%input fprime, anonlymous function, the derivative of f
%input x0, an initial guess
%input tol, a tolerance (method will stop when successive iterates are within tol of each other)
%output p, a root f(p) = 0
x(1) = x0 - (f(x0)/fprime(x0));
k = 2;
ex(1) = abs(x(1)-x0);%error
while (ex(k-1) >= tol) %while my error is greater than tolerance
x(k) = x(k-1) - (f(x(k-1))/fprime(x(k-1)));
k = k+1;
end
end
code to call function;
%As a test, the root of f(x) = x+2^x is -0.64118574
% define f, fprime, an initial guess (you can use 1), and use a tolderance of 1e-6
% send these into the function and store the result as the variable p
format long % to display more digits
x0=1;
tol=1e-6;
myNewton('x+2^x','diff(x+2^x)',x0,tol)
Peter M Hoganhttps://se.mathworks.com/matlabcentral/profile/authors/14581397-peter-m-hogantag:se.mathworks.com,2005:Question/4451182019-02-15T09:31:39Z2019-02-17T19:48:41ZExtracting Frames and resizing each frameHy, i convert YUV video file to frames but now i want to change size of every frames , how can i do that?
My code is:
clc; clear; close all;
VideoSequence = 'sampleQCIF.yuv';
width = 176;
height = 144;
nframes = 300;
[Y,U,V] = yuvRead(VideoSequence, width, height, nframes);
figure;
c = 0; % counter
for iFrame = 1:10
c = c + 1;
subplot(4,5,c),
imshow(Y(:,:,iFrame));
title(['frame #', num2str(iFrame)]);
endIqra Saleemhttps://se.mathworks.com/matlabcentral/profile/authors/11869957-iqra-saleemtag:se.mathworks.com,2005:Question/4454412019-02-17T18:13:49Z2019-02-17T19:48:19ZDouble vs Single Precision, Matlab in 2019Matlab defaults to double precision, but single precision is sufficient for many computational problems. In addition, single precision uses half the memory, and is generally twice as fast.
To convert from double to single precision is easy, in that all that is needed is to define the starting variables as single, and then all subsequent variables will default to the variable in each calculation with the lowest precision.
The best approach to define type single is:
X = zeros(10,10, 'single');
The construction: X = single(zeros(10,10)); is four times slower!!
Note that there is no difference between these two constructions for type double given that double precision is the default.
PROBLEMS
I ran into two problems that dimmed my enthusiasm for single precision.
1) Some Matlab functions will only work with double precision. The interpolation functions are the main examples that I have come across. (It would be great to have some documentation, either informal or formal, listing those Matlab functions that have type limitations. I have yet to find this information on the web.) To use the interpolation functions, you have to convert the input arguments to double, and then convert the output arguments back to single, which is cumbersome, and perhaps troublesome as well, as noted below.
2) A second problem is that the transition back and forth between single and double can cause errors in the limits for the interpolation. I ran across an error where the interpolation started to return nans after conversion to single precision. This problem would not have occured if the interpolation functions were able to work with single precision. That said, it might be possible to set the extrapolation option to "nearest" in order to navigate around the small round-off errors associated with the transition between single and double precision. Of course, this option could only be trusted when the algorithm was known to be fully functional.
For now, I have decided to stick with double precision.
I found very little discussion of this issue on the web. Surely there are others out there with experiences and recommendations about single precision.
Best,
Mark
Mark Brandonhttps://se.mathworks.com/matlabcentral/profile/authors/72436-mark-brandontag:se.mathworks.com,2005:Question/4454482019-02-17T18:45:28Z2019-02-17T19:45:31Zoptmization problem in hybrid energy storage system.how to solve time varying optimization problem in matlab, I have to perform optimizaiton in optimal power sharing in hybrid energy storage system where objective function is cost function which is needed to be minimized while constraints include time varying quantities such as output power constraint which is different at each second.vinodkumar wadhwanihttps://se.mathworks.com/matlabcentral/profile/authors/10837456-vinodkumar-wadhwanitag:se.mathworks.com,2005:Question/4454452019-02-17T18:29:27Z2019-02-17T19:45:26ZApp designer:Please help me with the table, im not able to add another row with new dataclassdef AquaSips < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
CustomerTable matlab.ui.control.Table
CompanyName matlab.ui.control.EditField
CustomerNameEditFieldLabel matlab.ui.control.Label
CustomerName matlab.ui.control.EditField
MobileNumberEditFieldLabel matlab.ui.control.Label
MobileNumber matlab.ui.control.NumericEditField
SubmitButton matlab.ui.control.Button
AddressEditFieldLabel matlab.ui.control.Label
AddressEditField matlab.ui.control.EditField
MeltonEditFieldLabel matlab.ui.control.Label
MeltonEditField matlab.ui.control.NumericEditField
BubbleEditFieldLabel matlab.ui.control.Label
BubbleEditField matlab.ui.control.NumericEditField
DueEditFieldLabel matlab.ui.control.Label
DueEditField matlab.ui.control.NumericEditField
OweEditFieldLabel matlab.ui.control.Label
OweEditField matlab.ui.control.NumericEditField
DepositEditFieldLabel matlab.ui.control.Label
DepositEditField matlab.ui.control.NumericEditField
RemarkEditFieldLabel matlab.ui.control.Label
RemarkEditField matlab.ui.control.EditField
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
data = {'','','','','','','','',''};
app.CustomerTable.Data = data;
end
% Button pushed function: SubmitButton
function SubmitButtonPushed(app, event)
data = {app.CustomerName.Value,num2str(app.MobileNumber.Value),app.AddressEditField.Value,num2str(app.MeltonEditField.Value), num2str(app.BubbleEditField.Value),num2str(app.DueEditField.Value),num2str(app.OweEditField.Value),num2str(app.DepositEditField.Value),app.RemarkEditField.Value};
app.CustomerTable.Data = data;
RowAdd = size(data,1);
RowAdd = RowAdd + 1;
data(RowAdd,:) = {''};
app.CustomerTable.Data = data;
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 1095 616];
app.UIFigure.Name = 'UI Figure';
% Create CustomerTable
app.CustomerTable = uitable(app.UIFigure);
app.CustomerTable.ColumnName = {'Name'; 'Mobile Number'; 'Address'; 'Melton'; 'Bubble'; 'Due'; 'Owe'; 'Deposit'; 'Remark'};
app.CustomerTable.RowName = {};
app.CustomerTable.ColumnEditable = false;
app.CustomerTable.Position = [42 291 1014 230];
% Create CompanyName
app.CompanyName = uieditfield(app.UIFigure, 'text');
app.CompanyName.HorizontalAlignment = 'center';
app.CompanyName.FontSize = 20;
app.CompanyName.Position = [401 534 295 47];
app.CompanyName.Value = 'New Aqua Sips';
% Create CustomerNameEditFieldLabel
app.CustomerNameEditFieldLabel = uilabel(app.UIFigure);
app.CustomerNameEditFieldLabel.HorizontalAlignment = 'center';
app.CustomerNameEditFieldLabel.Position = [58 238 91 22];
app.CustomerNameEditFieldLabel.Text = 'Customer Name';
% Create CustomerName
app.CustomerName = uieditfield(app.UIFigure, 'text');
app.CustomerName.HorizontalAlignment = 'center';
app.CustomerName.Position = [164 238 220 22];
% Create MobileNumberEditFieldLabel
app.MobileNumberEditFieldLabel = uilabel(app.UIFigure);
app.MobileNumberEditFieldLabel.HorizontalAlignment = 'center';
app.MobileNumberEditFieldLabel.Position = [58 199 83 22];
app.MobileNumberEditFieldLabel.Text = 'Mobile Number';
% Create MobileNumber
app.MobileNumber = uieditfield(app.UIFigure, 'numeric');
app.MobileNumber.Limits = [0 Inf];
app.MobileNumber.ValueDisplayFormat = '%.0f';
app.MobileNumber.HorizontalAlignment = 'center';
app.MobileNumber.Position = [164 199 220 22];
% Create SubmitButton
app.SubmitButton = uibutton(app.UIFigure, 'push');
app.SubmitButton.ButtonPushedFcn = createCallbackFcn(app, @SubmitButtonPushed, true);
app.SubmitButton.Position = [578 25 100 22];
app.SubmitButton.Text = 'Submit';
% Create AddressEditFieldLabel
app.AddressEditFieldLabel = uilabel(app.UIFigure);
app.AddressEditFieldLabel.HorizontalAlignment = 'center';
app.AddressEditFieldLabel.Position = [58 160 48 22];
app.AddressEditFieldLabel.Text = 'Address';
% Create AddressEditField
app.AddressEditField = uieditfield(app.UIFigure, 'text');
app.AddressEditField.HorizontalAlignment = 'center';
app.AddressEditField.Position = [164 160 220 22];
% Create MeltonEditFieldLabel
app.MeltonEditFieldLabel = uilabel(app.UIFigure);
app.MeltonEditFieldLabel.HorizontalAlignment = 'center';
app.MeltonEditFieldLabel.Position = [58 121 39 22];
app.MeltonEditFieldLabel.Text = 'Melton';
% Create MeltonEditField
app.MeltonEditField = uieditfield(app.UIFigure, 'numeric');
app.MeltonEditField.HorizontalAlignment = 'center';
app.MeltonEditField.Position = [164 121 220 22];
% Create BubbleEditFieldLabel
app.BubbleEditFieldLabel = uilabel(app.UIFigure);
app.BubbleEditFieldLabel.HorizontalAlignment = 'center';
app.BubbleEditFieldLabel.Position = [58 82 41 22];
app.BubbleEditFieldLabel.Text = 'Bubble';
% Create BubbleEditField
app.BubbleEditField = uieditfield(app.UIFigure, 'numeric');
app.BubbleEditField.HorizontalAlignment = 'center';
app.BubbleEditField.Position = [164 82 220 22];
% Create DueEditFieldLabel
app.DueEditFieldLabel = uilabel(app.UIFigure);
app.DueEditFieldLabel.HorizontalAlignment = 'center';
app.DueEditFieldLabel.Position = [466 238 27 22];
app.DueEditFieldLabel.Text = 'Due';
% Create DueEditField
app.DueEditField = uieditfield(app.UIFigure, 'numeric');
app.DueEditField.HorizontalAlignment = 'center';
app.DueEditField.Position = [526 238 152 22];
% Create OweEditFieldLabel
app.OweEditFieldLabel = uilabel(app.UIFigure);
app.OweEditFieldLabel.HorizontalAlignment = 'center';
app.OweEditFieldLabel.Position = [466 199 30 22];
app.OweEditFieldLabel.Text = 'Owe';
% Create OweEditField
app.OweEditField = uieditfield(app.UIFigure, 'numeric');
app.OweEditField.HorizontalAlignment = 'center';
app.OweEditField.Position = [526 199 152 22];
% Create DepositEditFieldLabel
app.DepositEditFieldLabel = uilabel(app.UIFigure);
app.DepositEditFieldLabel.HorizontalAlignment = 'center';
app.DepositEditFieldLabel.Position = [466 160 45 22];
app.DepositEditFieldLabel.Text = 'Deposit';
% Create DepositEditField
app.DepositEditField = uieditfield(app.UIFigure, 'numeric');
app.DepositEditField.HorizontalAlignment = 'center';
app.DepositEditField.Position = [526 160 152 22];
% Create RemarkEditFieldLabel
app.RemarkEditFieldLabel = uilabel(app.UIFigure);
app.RemarkEditFieldLabel.HorizontalAlignment = 'right';
app.RemarkEditFieldLabel.Position = [466 121 47 22];
app.RemarkEditFieldLabel.Text = 'Remark';
% Create RemarkEditField
app.RemarkEditField = uieditfield(app.UIFigure, 'text');
app.RemarkEditField.Position = [526 121 152 22];
end
end
methods (Access = public)
% Construct app
function app = AquaSips
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
Abdul Basithhttps://se.mathworks.com/matlabcentral/profile/authors/8538170-abdul-basithtag:se.mathworks.com,2005:Question/4453592019-02-17T02:16:38Z2019-02-17T19:45:22ZIf else statement for pixel intensityHow would you go about writing a function to create a contrasted image of matrix A. Then display the contrasted image using a tolerance of 100 and then 150 in two separate figures. I'm pretty sure that I have to do a if else statement but I'm not sure about everything else.Merranda Schmidhttps://se.mathworks.com/matlabcentral/profile/authors/14619508-merranda-schmidtag:se.mathworks.com,2005:Question/3917332018-03-30T22:09:04Z2019-02-17T19:44:46ZHow do I separate date and time of a raw date? >> a = untitled.startDate(1:10)
a =
10×1 categorical array
2013-07-10 00:01:00.0
2013-07-17 00:01:00.0
2013-06-29 00:01:00.0
2013-07-17 00:01:00.0
2013-05-11 00:01:00.0
2013-05-31 00:01:00.0
2013-06-06 00:01:00.0
2013-08-31 00:01:00.0
2013-05-21 00:01:00.0
2013-08-06 00:01:00.0
>> a.Format = 'dd-MMM-yyyy'
Error using categorical/subsasgn (line 87)
Attempt to assign field of non-structure array.aishahhttps://se.mathworks.com/matlabcentral/profile/authors/10462330-aishahtag:se.mathworks.com,2005:Question/3202982017-01-13T15:26:40Z2019-02-17T19:42:24ZCombine date vector into single columnI have a n X 6 matrix, with time data:
1st col = yyyy (e.g. 2016)
2nd col = mm (e.g. 10 for Oct)
3rd col = day (e.g. 1)
4th col = hour
5th col = min
6th col = seconds
I need to combine them into a n X 1 (e.g. 1-Oct-2016 00:00:00). How can I do that?
My initial data comes in the form of serial date (e.g. 4.264400001156250e+04 for 1-Oct-2016 00:00:00)
I used this function to convert into a date vector, but am stuck from here:
date_vec = datevec(datestr(x2mdate(raw_data)));
Should I be doing this? My goal is to export to excel for it to be read properly (need to plot a time series). Currently when it goes to the next day, instead of showing up the date of the next day, it simple wraps back to AM of the same day.
e.g.
42644.99999
42644.99999
42645
42645
BenLhttps://se.mathworks.com/matlabcentral/profile/authors/3963340-benltag:se.mathworks.com,2005:Question/4453642019-02-17T03:51:50Z2019-02-17T19:40:34ZHow to run optmization on vectors?Hello,
Please, I would like to ask for some help on a procedure that I'm running.
I have some large vectors that are input for a model that is solved through Least Squares Method. The model is a function of 6 parameters (the vectors v1[], v2[], v3[] and v4) and the 2 vectors to be optmized (x1[] and x2[]). The function dOptTgt is the quadratic sum of the errors of the model.
function dOptT = dOptTgt(x1,v1,v2,x2,v3,v4)
t1=f1(x1,v1,v2,x2,v3,v4) %math only
t2=f2(x1,v1,v2,x2,v3,v4) %math only
a1=(t1-v3)./v3
a2=(t2-v4)./v4
dOptT=(a1.^2+a2.^2)*10000
end
I have tried to use fminsearch() on the vectors,
x1=...
x2=...
fun=@(x) dOptTgt(x(:,1),v1,v2,x(:,2),v3,v4)
x0=[x1,x2]
Y=fun(x0)
x=fminsearch(fun,x0)
but got an error message. As it seems, fminsearch cannot be run on vectors:
Attempt to execute SCRIPT fminsearch as a function
Error in fminsearch (line 22)
x=fminsearch(fun,x0)
Also tried lsqnonlin(), not sure if the problem was correctly setup; the outputs afer fitting do not make the residuals zero, but just a good approximation.
x1=...
x2=...
fun=@(x) dOptTgt(x(:,1),v1,v2,x(:,2),v3,v4)
x0=[x1,x2]
options = optimoptions('lsqnonlin','Display','iter')
[x,resnorm] =lsqnonlin(fun,x0,[],[],options)
The solution I put in place was a loop selecting the elements i of each vector and using fminsearch().
x1=...
x2=...
for i=1:size(...)
fun=@(x) dOptTgt(x(1),v1(i),v2(i),x(2),v3(i),v4(i)))
x0=[x1(i),x2(i)]
a =fminsearch(fun,x0)
end
It works, but takes a lot of time to run, and doesn't seem to be the most efficient way to do that.
Please, is there a way to run this problem more efficiently?
Thank you,
G
Guilherme Candidohttps://se.mathworks.com/matlabcentral/profile/authors/9354961-guilherme-candidotag:se.mathworks.com,2005:Question/4448112019-02-13T17:58:22Z2019-02-17T19:36:37ZProblem when importing a TXT file into MATLAB with "readtable". Text and numbers are between single quotes...Hello everyone,
I am facing a big issue when trying to read a table from a TXT file. The data appears to be normal in Excel and in Wordpad but not in Matlab. Why does not Matlab recognize numerical data and import it as so?
So far I have the following sequence:
data=readtable('example.txt);
And then I get the following (see picture).
How can I get rid of the single quotes and treat the numerical data (from column 3 on) normally?
I would really appreciate your help in this regard.
Best,
JosebaJoseba Morenohttps://se.mathworks.com/matlabcentral/profile/authors/9678177-joseba-morenotag:se.mathworks.com,2005:Question/4394232019-01-12T02:05:08Z2019-02-17T19:36:19Zsum first matrix and second matrix I want to collect the first function and the second function but there is an error there is no help ('Xf ').
x=[-1 8 2 -3 -5 6 -4 5 -8 7 -9 4 5 -10 -6 -11 8 3 7 1 -5 -20 14 18 19 -16 8 16 -17 -15];
Xp=x(x>0);
Xn=x(x<0);
figure(1)
stem(Xn);
title('negative signal');
Xn=abs(Xn);
figure(2)
stem(x);
title('orginal signal');
figure(3)
stem(Xp);
title('positive signal');
figure(4)
stem(Xn);
title('abs negative signal');
Xf=Xp+Xn;
abdullah qasimhttps://se.mathworks.com/matlabcentral/profile/authors/12485153-abdullah-qasimtag:se.mathworks.com,2005:Question/4339342018-12-05T08:23:18Z2019-02-17T19:35:13ZHow to pix the syntax error?Hi,
I have proplem with syntax:
function [TDOA, FDOA] = CAF(S1, S2;1500;1e6; 10e-4);
The error is:
Invalid syntax at ';' . possibly ,a ')' is missing
Parse error at ')': usage might be Invalid MATLAB syntax
How to pix them, thank you so much
Hai Ninhhttps://se.mathworks.com/matlabcentral/profile/authors/14302530-hai-ninhtag:se.mathworks.com,2005:Question/4450132019-02-14T17:28:31Z2019-02-17T19:32:27ZIs there a way to extract data from surface graphics in the curvefitting toolbox?Hello to all
I'm doing some interpolation problems using curve fitting toolbox.
I would like to know if there is any way to extract the x, y z of the surface graphic that appear in the curve fitting window?
Thank you
PedroPedro Pintohttps://se.mathworks.com/matlabcentral/profile/authors/14086409-pedro-pintotag:se.mathworks.com,2005:Question/4453892019-02-17T10:16:00Z2019-02-17T19:31:31ZIssue with DisplayName plot function in a loopHello all,
I am having an issue when trying to plot the display for specific vectors in a loop. Here is my code:
clf;
cc = jet(32);
for i=1:31
check_NaN=~isnan(CN0_Plot_GPA_L1CA4(i,:));
val_index=find(check_NaN);
if ~isempty(val_index)
p(i)=plot(Time(1:N_Packet)-fix(Time(1)),CN0_Plot_GPA_L1CA4(i,:),'color',cc(i,:), 'marker','+','DisplayName',['SV=' num2str(i)]);
hold on
end
end
legend(gca,'show')
grid on;
datetick('x','HH:MM');
xlabel(datestr(fix(Time(1))));
ylabel('CN0(dBHz)');
title('GPS CN0 for L1CA modulation ');
With this code I am getting a plot with all indexes i plotted.
Now, when I am doing a very similar algorithm but this time removing the abscissa in the plot (no more Time(1:N_Packet) in the plot) it is working as expected:
clf;
cc = jet(32);
for i=1:31
check_NaN=~isnan(CN0_Plot_GPS_L1CA4(i,:));
val_index=find(check_NaN);
if ~isempty(val_index)
%
p(i)=plot(CN0_Plot_GPS_L1CA4(i,:),'color',cc(i,:), 'marker','+','DisplayName',['SV=' num2str(i)]);
%
hold on
%
end
end
legend(gca,'show')
grid on;
ylabel('CN0(dBHz)');
title('GPS CN0 for L1CA4 modulation ');
Any idea on how to solve this will be much welcome!
Best regardsFranck Bordehttps://se.mathworks.com/matlabcentral/profile/authors/1804233-franck-bordetag:se.mathworks.com,2005:Question/2612192015-12-21T17:36:06Z2019-02-17T19:30:38ZFind column names with particular names in MATLAB tableHi there,
I have a massive table with 408 columns in MATLAB. I want to get rid of columns that start with the word "connected". Instead of having to manually check the table and do something like
finalnbs(:,212:364) = [];
Where
finalnbs
is the table, how do I find all columns in finalnbs which start with connected e.g.
connected*
And then remove those?Dhruv Ghulatihttps://se.mathworks.com/matlabcentral/profile/authors/7100428-dhruv-ghulatitag:se.mathworks.com,2005:Question/4453312019-02-16T19:40:26Z2019-02-17T19:28:16Zinnerjoin two tables based on the first word in the key columns in Matrix A I have the following columns:
Date AcquirorName TargetName
_____ ________________ _________________________________
41640 "Investor Group" "Audio Visual Services Group Inc"
In Matrix B I have the following columns:
Date AcquirorName TargetName
_____ ________________ _________________________________
41640 "Investor Group Ltd" "Audio Visual Svcs Group Inc"
I tried to match them using innerjoin function
Akeys={'Date','AcquirorName','TargetName'};
Bkeys={'Date','AcquirorName','TargetName'};
C=innerjoin(A,B,'LeftKeys',Akeys, 'RightKeys',Bkeys);
However, I received no match simply because the names in A and B differ a bit for instance, Ltd is added to the AcquirorName in column 2 of Matrix B and Services is abbreviated to Svcs in Target name in Matrix B
I have more than 300,000 rows so judging visusally is not option although clearly the two rows in A and B match. I am wondering if there is a way to match based on the first word in each column. In this case the date is the same," Investor" under acquiror name is the same and "Audio" under target name is the same. I noticed that almost always the first words are the same. Wessohttps://se.mathworks.com/matlabcentral/profile/authors/7645583-wessotag:se.mathworks.com,2005:Question/4454542019-02-17T19:07:32Z2019-02-17T20:11:08ZOutputting solutions to symbolic variables in a matrix.I created a system of 22 symbolic varriables for a rather large system of euqation I was solving. I was able to solve for all the varriables and file them into a 22x1 matrix. However, now I need to extract the solve values of those matrix elements. When I try to use an element like Matrix(7,1) it simply outputs 'x7', and I cant use the 'sol.' on the matrix or its elements to get these numbers. Is there an efficent way to get the solved values from all the matrix elements?Joe Turnerhttps://se.mathworks.com/matlabcentral/profile/authors/9207381-joe-turnertag:se.mathworks.com,2005:Question/4454562019-02-17T19:25:20Z2019-02-17T19:25:20ZMATLAB takes forever to openWhen I click on MATLAB to open it on my desktop it doesn't open. The icon momentarily pops up and disappears in the task bar and then 10-15 minutes later I have 55 MATLAB windows open that arent working and I cant close them. Please help, this is so annoying and a huge waste of time.Alexandre Dugashttps://se.mathworks.com/matlabcentral/profile/authors/10788331-alexandre-dugastag:se.mathworks.com,2005:Question/4453972019-02-17T11:31:47Z2019-02-17T19:23:55ZChange table variable dimensionI have two multi-diemnsional array to be merged into a Table.
A : K x M x N x L array
B : K x M x N array
If I do table(A,B), it resulted in two columns with K rows as follows
Var1 Var2
--------------------- -------------------------
[1xMxNxL single] [1xMxN categorical]
...
I want to reduce the first dimension of each table element like
Var1 Var2
--------------------- -------------------------
[MxNxL single] [MxN categorical]
...
How to get the table?Soo Mee Kimhttps://se.mathworks.com/matlabcentral/profile/authors/11514883-soo-mee-kimtag:se.mathworks.com,2005:Question/4453882019-02-17T09:26:47Z2019-02-17T19:21:28ZLittle Bit Help Required Regarding LoopHi EveryOne
I am currently working on this code
a=[1 2 3]
b=[3 4 5]
c=[34 5 6 ]
for i=1:1:3;
C = {[a];[b];[c]};
d= cellfun(@(v)v(i),C)
end
And the output is
d =
1
3
34
d =
2
4
5
d =
3
5
6
Every time loop runs it updated the last results.
I just want to save all the values means every time when loop run it keep save the last results and save the new results in the new coloumn
When I use
d(i)= cellfun(@(v)v(i),C)
The code give error
In an assignment A(I) = B, the number of elements in B and I must be the same.
Please help in this matter
Thanks
Regards
John Hockhttps://se.mathworks.com/matlabcentral/profile/authors/11079478-john-hocktag:se.mathworks.com,2005:Question/4453782019-02-17T06:51:00Z2019-02-17T19:20:07ZBisectional method Not always giving correct rootsMy code sometimes does not give correct roots? Sometimes it will and other times it wont depending on the boundaries, please let me know if you guys know what is causing it.
clc
clear all
close all
f=@(x)(x.^3+7*x.^2-33*x-135);
yl = input('type approximated lower boundary:');
yu = input('type approximated upper boundary:');
err=input('Type desired approximate error limit:');
if(f(yl)*f(yu)) > 0
disp('TRY NEW BOUNDARIES');
return
%if values do not produce a negative number give better boundaries
end
while abs(yu-yl) >= err %basically how close do you want the boundaries to go
ynew=(yl+yu)/2;
if (f(yl)*f(yu) < 0)
yu=ynew;
else
yl=ynew;
end
end
fprintf('The root of this equation given your error limit is=%f', ynew);
Anthony Minghttps://se.mathworks.com/matlabcentral/profile/authors/14562039-anthony-mingtag:se.mathworks.com,2005:Question/4454552019-02-17T19:15:07Z2019-02-17T19:15:07ZHow can I make this code more efficient?close; clear all; clc;
global cp1 vp1 cp2 vp2 value gk;
A=1; % aggregate productivity
a=0.36; % capital share of output (alpha)
b=0.96; % subjective discounting (beta)
d=0.069;% depreciation
klow=0.1;
khigh=6;
knum=250;
kgrid = linspace(klow,khigh,knum);
uf = @(x)log(x);
pf = @(x)(A*(x.^a));
cp2=[cp2,pf(kgrid(1:knum))+((1-d)*kgrid(1:knum))]; %period 2
vp2=[vp2,uf(cp2(1:knum))];
for i=1:knum %period 1
for j=1:knum
cp1(i,j)=max(pf(kgrid(i))+(1-d)*kgrid(i)-kgrid(j),0);
vp1(i,j)= log(cp1(i,j))+(b*vp2(j));
end
value=[value,max(vp1(i,:))];
[val,loc] = max(vp1(i,:));
gk=[gk,kgrid(loc)];
end
figure
subplot(211)
plot(kgrid, value)
hold on
title ( ' the value function ' )
subplot(212)
plot(kgrid, kgrid)
hold on
plot(kgrid, gk, '*')
title ( ' the decision rule ' )
saveas(gcf,'optimal2.png')
What can I do to make this code take up less lines or compute faster?Kai Jensenhttps://se.mathworks.com/matlabcentral/profile/authors/14275901-kai-jensentag:se.mathworks.com,2005:Question/4454492019-02-17T18:46:59Z2019-02-17T19:13:39ZAttempt to grow array along ambiguous dimension.Hi :)
I'm having trouble with a function becasue there's this kind of error:"Attempt to grow array along ambiguous dimension.
the error is present at the line 47.
Can anybody help me?ROBERTA NOCERINOhttps://se.mathworks.com/matlabcentral/profile/authors/14362062-roberta-nocerinotag:se.mathworks.com,2005:Question/4454522019-02-17T19:05:17Z2019-02-17T19:05:17ZPlease help me make this function periodicThank you very much for all the help!
T = 1 millisecond
Vm = 1 volt (amplitude voltage)
t = linspace(-T, 2*T, 3001)
The following pararameter is given
v(t) = Vm - (Vm/T)t for 0<= t <= T
0 elsewhere
I need to modify the vector v so that is represents a periodic function with a period T over this time period
(hint: it should look like a sawtooth), and plot v vs t over the range from -T to 2T.
So far I have this:
T = 1;
Vm = 1;
t = linspace(-T,2*T,3001);
for i = 1:length(t)
if (t(i) >= 0) && (t(i) <= T)
v(i) = Vm - (Vm/T)*t(i);
else
v(i) = 0;
end
end
plot(t,v)
Vinh Lehttps://se.mathworks.com/matlabcentral/profile/authors/13150110-vinh-letag:se.mathworks.com,2005:Question/4447942019-02-13T16:34:37Z2019-02-17T19:00:51ZHow to extrapolate to the point of intersection i have the following data :
x=[5 6 7 8 9 10 11 12 13 14 15 16 16.5 17 17.5 18 18.5 19 19.5 20 20.5 21 21.5 22 23 24 25 26 27 28 29 30]
y=[110.515 148.485 139.68 218.925 352.41 441.755 490.11 518.295 521.32 515.825 499.51 499.345 471.685 666.715 1100.35 936.625 484.64 568.875 1444.015 1859.38 1478.71 383.84 352.75 324 282.6 239.2 215.5 189.1 165.95 142.8 137.85 128.7]
i would like to find the x value for the intersection point with the x axis (y=0)
using extrapolation by an approximate function and how i show the equation of that function
zerguine nafissahttps://se.mathworks.com/matlabcentral/profile/authors/14771535-zerguine-nafissatag:se.mathworks.com,2005:Question/4454502019-02-17T18:57:18Z2019-02-17T18:57:18ZTaking symbolic variables out of txt file and making a matrixI have a txt file containing following characters.
theta1 , l1 and others are symbolic variables.( Don't mind about it)
M=[theta1 + (l1^2*m1)/4 + l1^2*m2 (l1*l2*m2*cos(fi1 - fi2))/2 ;
(l1*l2*m2*cos(fi1 - fi2))/2 theta2 + (l2^2*m2)/4 ]
I need to take it out and make it a symbolic matrix. As you can see txt file is already fine for making matrix but I don't want to copy paste the whole thing to script, I rather want to do it automatically.
fid = fopen('a.txt');
MMatrix=textscan(fid,'%s');
fclose(fid);
I tried the code above but it turn out to be not useful. What do you think is the way to copy the whole thing and use it for matrix making?
Mirroyal Ismayilovhttps://se.mathworks.com/matlabcentral/profile/authors/12161799-mirroyal-ismayilovtag:se.mathworks.com,2005:Question/4454362019-02-17T17:40:33Z2019-02-17T18:55:36ZWrite a MATLAB function MyTrapezoid Xiang Chenhttps://se.mathworks.com/matlabcentral/profile/authors/13513717-xiang-chentag:se.mathworks.com,2005:Question/4051862018-06-12T03:47:10Z2019-02-17T18:50:29ZFill area with random circles having different diametersI should fill the area of a 500x500 square with random circles having random diameters between 10 and 50 (without overlap). Then, I need the output file of the generated coordinates. Can someone help me, please?mikymike89https://se.mathworks.com/matlabcentral/profile/authors/9069597-mikymike89tag:se.mathworks.com,2005:Question/4454332019-02-17T17:15:37Z2019-02-17T18:39:23ZHow can I stretch a line of best fit to the limits of my axes?Hello,
For a Geophysics assignment we have been asked to interpret a set of seismic data by plotting the first arrivals (the picks) onto a graph and estimating the velocities of the layers which the waves interact with from the data provided. For the direct wave this is straightforward, but for the refracted wave it requires an unknown called the 'Intercept Time' which is where the line of best fit for the refracted wave picks intersects the Y axis (t, time).
I have managed to apply a line of best fit to the data I've chosen that represents the refracted wave, but I can't make it extend all the way to the Y-axis, seen below:
Using the following code...
xpicks = [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115]
tpicks = [0,3,6,9,12,15,18,21,22,24,26,28,28,28,29,29,30,32,34,35,34,34,35,35]
% Specify the raw data for the first wave arrival picks.
xdirect = [0,5,10,15,20,25,30,35]
tdirect = [0,3,6,9,12,15,18,21]
% Specify the picks referring to the Direct Seismic Wave.
xrefract = [40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115]
trefract = [22,24,26,28,28,28,29,29,30,32,34,35,34,34,35,35]
% Specify the picks referring to the Refracted Seismic Wave.
poly = polyfit(xrefract,trefract,1)
lobf = polyval(poly,xrefract)
% Calculating a line of best fit for the disparate Refracted Wave data.
co = get(gca,'ColorOrder')
set(gca, 'ColorOrder', [0 0.5 0; 0 0 0.7; 0.7 0 0], 'NextPlot', 'replacechildren');
co = get(gca,'ColorOrder')
scatter(xpicks,tpicks,'filled','^')
% Displaying the raw scattered data.
hold on
plot(xdirect,tdirect,xrefract,lobf,'Linewidth',1)
% Displaying the t-x plot for the direct wave and the refracted wave.
title('T-X Plot for Refraction Survey Arrivals')
xlabel('Source - Receiver Offset (m)')
ylabel('Time (ms)')
legend('Arrival Picks','Direct Wave','Head Wave')
Granted I could just use an image editor to add the remainder of the lines, but I have enough time that I would prefer a more elegant method!
Is there any way to extend the lines for the Refracted Wave + Direct Wave across the entire graph without assuming data I don't have?
Thanks in advance for any assistance.Mark Gaigerhttps://se.mathworks.com/matlabcentral/profile/authors/11947957-mark-gaigertag:se.mathworks.com,2005:Question/4453332019-02-16T20:22:52Z2019-02-17T18:39:12ZCommand window showing the errror 'Index exceeds matrix dimensions'. How to resolve it? Following is my code if possible resolve the code.layers=[ ...
imageInputLayer([566 804 3])
convolution2dLayer([50 50],10,'stride',[6 6],'padding',[0 0])
reluLayer
crossChannelNormalizationLayer(3)
maxPooling2dLayer(5,'stride',[4 4],'padding',[0 0])
convolution2dLayer([50 50],10,'stride',[6 6],'padding',[0 0])
reluLayer
crossChannelNormalizationLayer(3)
maxPooling2dLayer(5,'stride',[4 4],'padding',[0 0])
convolution2dLayer([50 50],10,'stride',[6 6],'padding',[0 0])
reluLayer
crossChannelNormalizationLayer(3)
maxPooling2dLayer(5,'stride',[4 4],'padding',[0 0])
convolution2dLayer([50 50],10,'stride',[1 1],'padding',[1 1])
reluLayer
convolution2dLayer([50 50],10,'stride',[1 1],'padding',[1 1])
reluLayer
convolution2dLayer([50 50],10,'stride',[1 1],'padding',[1 1])
reluLayer
maxPooling2dLayer(5,'stride',[4 4],'padding',[0 0])
fullyConnectedLayer(2)
softmaxLayer
classificationLayer()]GUDIVADA ROKESH KUMARhttps://se.mathworks.com/matlabcentral/profile/authors/13518531-gudivada-rokesh-kumartag:se.mathworks.com,2005:Question/4454292019-02-17T16:23:11Z2019-02-17T18:38:54Zhow to keep waitbar on the application i tried to use waitbar in an apllication and want it to be built up in the application not seperate. Thank you
f = waitbar(0,'1','Name','Optmization Process...',...
'CreateCancelBtn','setappdata(gcbf,''canceling'',1)');
setappdata(f,'canceling',0);
steps = gen;
for step = 1:0.01:steps
% Check for clicked Cancel button
if getappdata(f,'canceling')
break
end
% Update waitbar and message
waitbar(step/steps,f,sprintf('%12.1f',step))
end
delete(f)
Gali Musahttps://se.mathworks.com/matlabcentral/profile/authors/6726361-gali-musatag:se.mathworks.com,2005:Question/4454352019-02-17T17:30:34Z2019-02-17T18:35:35ZHow can I group column of data with the same time stamp and get the row mean of each group?
from this table to this image where
x = Height
t = time
u = zonal wind
Teddy2018https://se.mathworks.com/matlabcentral/profile/authors/14804435-teddy2018tag:se.mathworks.com,2005:Question/4453382019-02-16T20:53:19Z2019-02-17T18:33:04ZWriteing a stings using Matlab 2015Hello All
i am working on algorithm that has the ability to creat a text file and write on it depending on specific commands.
i am in need to write words using matlab and the results should be showed simultaneously in the text file (no need to re-open the text file again).
i am looking for something like attached photo.
Any suggestions?
regards
Hassan Qassimhttps://se.mathworks.com/matlabcentral/profile/authors/10890700-hassan-qassimtag:se.mathworks.com,2005:Question/4454462019-02-17T18:32:17Z2019-02-17T18:32:17ZHow to vectorize these nested for loopsfor i=1:knum
for j=1:knum
cp1(i,j)=max(pf(kgrid(i))+(1-depreciation)*kgrid(i)-kgrid(j),0);
vp1(i,j)= log(cp1(i,j))+(beta*vp2(j));
end
end
How can I vectorize these 2 nested for loops?
Kai Jensenhttps://se.mathworks.com/matlabcentral/profile/authors/14275901-kai-jensentag:se.mathworks.com,2005:Question/4452742019-02-16T08:58:13Z2019-02-17T18:32:10ZFFT from CSV fileI'm trying to perform FFT on the 2nd data column of a .csv file. The .csv file is quite large and the zipped version can be found here: https://www.dropbox.com/s/87l5vtxdqfbtt6x/Tridral_1m_1ms.7z?dl=0
The signal is 10 milliseconds long, and is sampled 1 million times over that time period. I've tried following the FFT example provided by the help file, but the frequency domain signal does not come out right. The FFT output gives a strong DC signal (that could be right), and a signal at 50 KHz. Based on the time domain signal, i should expect approximately a 1 KHz fundamental with recurrent harmonics at 2, 3, 4 KHz..., but it comes out empty... am i doing something wrong in my code?
Ray Fanghttps://se.mathworks.com/matlabcentral/profile/authors/14791516-ray-fangtag:se.mathworks.com,2005:Question/4454062019-02-17T12:53:36Z2019-02-17T18:30:07Zhow to import data from workspace to gui?Hello folks
I'm in a process of making an application using app designer,
I'm wondering how can I create an object such as list box or anything else which allow me to bring (import) data from workspace, as used in cftool as shown in the picture bellow; so that when the user enter some arguments (vector, matrix....etc) in the workspace it will show-up automatically in the object created. and use it later for it's own purposes.Abdelmalek Benaimeurhttps://se.mathworks.com/matlabcentral/profile/authors/14803137-abdelmalek-benaimeurtag:se.mathworks.com,2005:Question/4453812019-02-17T07:03:58Z2019-02-17T18:27:21ZHello, a error has come in my s-function kindly help me....error
An error occurred while running the simulation and the simulation was terminated Caused by: Error in 'untitled/S-Function' while executing MATLAB S-function 'chap1_1ctrl', flag = 3 (output), at time 0.0. Too many input arguments.
--------------------------------------------------------------------------------------------------------------------------------
function [sys, x0, str, ts]=chap1_1ctrl(t,x,u,flag)
switch flag,
case 0,
[sys, x0, str, ts]=mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u,J);
case 3,
sys=mdlOutputs(t,x,u,J);
case{2,4,9}
sys=[];
otherwise
error(['Unhandled flag=',num2str(flag)]);
end
function[sys, x0, str, ts]= mdlInitializeSizes
sizes=simsizes;
sizes.NumContStates=0;
sizes.NumDiscStates=0;
sizes.NumOutputs=1;
sizes.NumInputs=3;
sizes.DirFeedthrough=1;
sizes.NumSampleTimes=0;
sys=simsizes(sizes);
x0=[];
str=[];
ts=[];
function sys=mdlOutputs(t,x,u)
J=2;
thd=u(1);
th=u(2);
dth=u(3);
e=th-thd;
de=dth;
c=10;
s=c*e+de;
xite=1.1;
k=0;
%k=10;
ut=J*(-c*dth-1/J*(k*s+xite*sign(s)));
sys(1)=ut;ABDUL KHALIQUEhttps://se.mathworks.com/matlabcentral/profile/authors/6560142-abdul-khaliquetag:se.mathworks.com,2005:Question/4454442019-02-17T18:23:29Z2019-02-17T18:23:29Zhow to run pe_hv_battery_charge_discharge on command window? Kindly i want to run this example on matlab but i got that >> pe_hv_battery_charge_discharge
Undefined function or variable 'pe_hv_battery_charge_discharge'. on command window
please let me know the steps to start run this example
thanksAmani Al-Shaibanhttps://se.mathworks.com/matlabcentral/profile/authors/12059640-amani-al-shaibantag:se.mathworks.com,2005:Question/4454312019-02-17T16:42:13Z2019-02-17T18:22:55ZHow can I crop a graphHow can i crop a graph using GUI and then do further mathematical actions on the cropped data?
if my graph has parts of irrelevant data in the beginning and end and i want to look at the graph and use only the relevant partIlan Prilutskihttps://se.mathworks.com/matlabcentral/profile/authors/12732157-ilan-prilutskitag:se.mathworks.com,2005:Question/4454422019-02-17T18:18:38Z2019-02-17T18:18:38ZNo logging of "mat" file-parrot mini droneHello,
I configured the parrot mini drone with MATLAB R2018b. The drone operates correctly but when I try to get the MAT file after stopping the program, it displays the following error, "MAT-File not found on mini drone. Ensure that MAT-File logging is enabled and build the model again. Note that MAT-File logging is only available if you have Simulink Coder."
I have already checked that I have a liscenced version of Simulink Coder and also, before uploading my flight control system on the drone, I run "set_param('FlightControlSystem','MatFileLogging','on')" command. However, still, the MAT file is not logged. The "Flight log" file is getting created.
Please could you help on this issue.Jasvir Virdihttps://se.mathworks.com/matlabcentral/profile/authors/14397810-jasvir-virditag:se.mathworks.com,2005:Question/4454042019-02-17T12:45:43Z2019-02-17T18:18:02ZHow to call an array by its indiceHello,
I have some number of arrays with diffrent dimensions
For example :
d1=[[1,2,3];[11,22,33];[111,222,333]]
d2=[[4,5,6];[44,55,66]]
d3=[[7,8,9]]
SO after i would like to call the above arrays by their indices:
for u=1:3
s=d{u )
end
How could I do that.
thanks
regaieg rymhttps://se.mathworks.com/matlabcentral/profile/authors/7660479-regaieg-rymtag:se.mathworks.com,2005:Question/4454402019-02-17T18:06:09Z2019-02-17T18:16:38Zundefined function or variable matlab for loop outsideDear All, i have yhis problem the program does not recognize the variable A outside the loop. How can I make the code recognize Thank you very much
this is the error message
Undefined function or variable 'A'.
Error in TT (line 25)
df=(sum(sum(A))^-1);
this is the function
function [teta1,teta2,teta3,]=TT(X)
global n m
p1=1;
p2=2;
t=1;
for i=2:n
for j=2:m
k=1;
vect=zeros(4,1);
for h=0:p1
for l=0:p2
vect(k)=X(i-h,j-l);
k=k+1;
end
end
f(t,:)= vect(2:4)
A(t)= vect(2:4)'*vect(2:4)
t=t+1;
end
end
df=(sum(sum(A))^-1);
t=0;
for i=2:n
for j=2:m
t=t+1;
g(t,:)=f(t,:)*X(i,j);
end
end
teta=df*sum(g);
% teta=df*sum(g);
% teta1=teta(1);
% teta2=teta(2);
% teta3=teta(3);
end
this is the main programme
C=imread('D29.gif');
x2=im2double(C);
[m,n]=size(x2);youbaa maahttps://se.mathworks.com/matlabcentral/profile/authors/14804606-youbaa-maatag:se.mathworks.com,2005:Question/3914062018-03-29T10:38:50Z2019-02-17T18:15:29ZIs there a way to show output directly on ui figure with App Designer?I'm creating an user interface with App Designer and I'd like to insert output (like answer of prompt) directly on UI Figure and not in the Command Window. Is this possible?schttps://se.mathworks.com/matlabcentral/profile/authors/9860915-sc