https://ch.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-12-14T00:15:37Ztag:ch.mathworks.com,2005:Question/4353052018-12-12T08:34:10Z2018-12-14T00:15:37Zi want to ask how to adjust image contrast,i want to adjust the image contrast, the problem is the when i used imread to read the image it appears as a black image although when i browse it using image viewer the image was good. i used imadjust command to adjust image contrast , but it become brighter in the middle , but at the edges the brigntness is lower, so i want a command to change the image brighness equally through out the image
in the first column of the attached image i am tracing powder inside pocket , so the problem is that the pixel values at the pocket boundries is lower than in the middle , so it is traced as black (no powder), i think that comes from imadjust commandkhalid Elserfyhttps://ch.mathworks.com/matlabcentral/profile/authors/11846776-khalid-elserfytag:ch.mathworks.com,2005:Question/4356112018-12-13T18:11:38Z2018-12-14T00:06:06ZHow to create a distance matrix in matlabHello,
I want to determine what the shortest route is to pick multiple items in a warehouse. However, I do not want to use a standard distance matrix, but I want to compute the distances between two items myself. Does anyone know how to create an distance matrix with the shortest distances between items in the same picking order? Lisa de Boerhttps://ch.mathworks.com/matlabcentral/profile/authors/10401444-lisa-de-boertag:ch.mathworks.com,2005:Question/4356502018-12-13T22:53:18Z2018-12-14T00:00:18ZComparing two input voltages?I'm attempting to build a ride by wire system, I've built a proof of concept in Simulink utilising an Arduino as the controller.
Now I've moved on to real hardware with a RBW throttle, it uses two hall effect sensors to give two voltages. On one it gives a range of 0.9 - 4.4v and the other is 0.4 - 2.2v. I've looked through various blocks but I'm struggling to see a way forward and would appreciate any guidance on this problem.Philip Harrishttps://ch.mathworks.com/matlabcentral/profile/authors/14178138-philip-harristag:ch.mathworks.com,2005:Question/4356052018-12-13T17:56:23Z2018-12-13T23:59:07ZMatrix dimensions must agree error Im trying to make a simple function in which you input the radius, centre of a circle and the intercept coordinates to output a plot with the circle, radius and tangent showing but I seem to be stuck here any help is appreciated
function circle2
x0=input('centre x-axis');
y0=input('centre y-axis');
r=input('radius');
xp=input('P x-coord');
yp=input('P y-coord');
%Parameters
th=0:0.01:2.*pi;
%Value for x
x=r.*cos(th)+x0;
%Value for y
y=r.*sin(th)+y0;
%Differentiation
dxdth = -r.*sin(th);
dydth = r.*cos(th);
%Gradient
dydx = dydth./dxdth;
%Calculate intercept
intcpt = yp - dydx.*xp;
%x vector for tangent
xt= linspace(xp-1,xp+1,2);
%Calculate tangent
yt = dydx.*xt+intcpt;
if yp~=yt
xt=xp-2<=xt<=xp+2
yt=dydx(xt-xp)+yp
elseif yp==y0
xt=xp
yt=yp-5<=yt<=yp+5
end
%Plot intercept
plot(x,y);
hold on
plot(xp, yp);
%Plot tangent
plot(xt, yt);
%Plot radius
plot ([x0 xp],[y0 yp])
%Axis limit values
axis ([-1.25*r 1.25*r -1.25*r 1.25*r]);
Alexandros Panagihttps://ch.mathworks.com/matlabcentral/profile/authors/14354122-alexandros-panagitag:ch.mathworks.com,2005:Question/4356542018-12-13T23:54:56Z2018-12-13T23:54:56ZHow to use linprog solver for some values of variables needs to have equal value How i could use linprog to solve this problem. My objective and constraint have this form.
Objective Pa - -> max
A x + B y = a
C x + Pa*D <= b
and Pa >=0
I don't want to use nonlinear constraint or need to know any other function (without using nonlinear constraint) to get the optimized value for Pa
A = [-1 1 0 0 0
1 -2 1 0 0
0 1 -2 1 0
0 0 1 -2 1
0 0 0 1 -1 ]
B = [-1 0; 0 0; 0 0; 0 0; 0 -1]'
a = [0 0 0 0 0]'
C = [ 1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
-1 0 0 0 0
0 -1 0 0 0
0 0 -1 0 0
0 0 0 -1 0
0 0 0 0 -1]
D = [4.50, 0.90, 2.70, 0.90, 4.50, 4.50, 0.90, 2.70, 0.90, 4.50]'
b = [3.00, 3.00, 3.00, 3.00, 3.00 6.00, 6.00, 6.00, 6.00, 6.00]'Abdulazizkhttps://ch.mathworks.com/matlabcentral/profile/authors/11856499-abdulazizktag:ch.mathworks.com,2005:Question/4356102018-12-13T18:09:02Z2018-12-13T23:54:02ZProblems in access on the MathWorks AccountHello dears, when I try to access my account of the my laptop a recieve the follow mensage: "Something unexpected occurred", but I can access using other computer. What could be happening?Ewerton Santoshttps://ch.mathworks.com/matlabcentral/profile/authors/14362850-ewerton-santostag:ch.mathworks.com,2005:Question/4355622018-12-13T13:28:06Z2018-12-13T23:47:29ZAny GPU implementation of k-nearest neighbor search? Hi, I am developing a SPH (smoothed particle hydrodynamic) code of solving fluid equations in Matlab. I have successfully vectorized and implemented the code on GPU. The speed up is astonishing, ~10 times faster than CPU code. In the process I got invaluable suggestions from Matt J and Joss Knight for speeding up the code. Thank them for their wonderful suggestions.
In SPH, one has to find the neighbor particles in a given radius for every particles in the domain. I use the matlab function knnsearch for this purpose. Now the other part of the code (except neighbor search but solving the fluid equations) is so fast that the limiting part now is the knnsearch, which uses kdtree algorithm runing on CPU. It takes 85% percent of the runtime (see the following code profiler results)
The function 'knnCPU_kdtree_func' uses the matlab built-in function knnsearch with kdtree algorithm runing on CPU. The other functions are solving the real fluid equations runing on GPU only consumes 10% of the total time.
I wonder is there any GPU implementation of k-nearest neighbor search that I can free download and using as a function call in my matlab code? Many thanks.Hao Zhanghttps://ch.mathworks.com/matlabcentral/profile/authors/2574469-hao-zhangtag:ch.mathworks.com,2005:Question/4356532018-12-13T23:46:07Z2018-12-13T23:46:07Zdisplay matrix with textHi,
I would like to display matrices in a command window as following:
A = [2 4;3 5];
B = [8 7;9 0];
C = A + B;
%part of code with solution to my question, which will result in displaying (in command window):
2 4 8 7 10 11
+ =
3 5 9 0 12 5
So notation feels very natural, like we would write it down on paper. Im curious to know if there is any possible solution without stringifying it to different lines like this?
'2 4 8 7 10 11'
' + = '
'3 5 9 0 12 5 'Anton Lipendinhttps://ch.mathworks.com/matlabcentral/profile/authors/14364146-anton-lipendintag:ch.mathworks.com,2005:Question/3087732016-10-24T03:00:53Z2018-12-13T23:43:26ZOpen .spf2Hello
I am trying to open a .spf2 file with matlab,but am having trouble. How can I do this?
Thank you
SamSamuel Yanghttps://ch.mathworks.com/matlabcentral/profile/authors/5960298-samuel-yangtag:ch.mathworks.com,2005:Question/4355762018-12-13T15:29:58Z2018-12-13T23:36:25ZHow to get the original Image matrix from the Integral Image of a N*N matrix?IF the original image matrix is represented by r=[ 1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]. Then it's integral image using the inbuilt 'integralImage' function is given by
0 0 0 0 0
0 1 3 6 10
0 6 14 24 36
0 15 33 54 78
0 28 60 96 136
Excluding first row and first column we get
1 3 6 10
6 14 24 36
15 33 54 78
28 60 96 136
My requirement is to obtain the original image from the given integral image provided.
Karthik Nagarajhttps://ch.mathworks.com/matlabcentral/profile/authors/11245659-karthik-nagarajtag:ch.mathworks.com,2005:Question/4356492018-12-13T22:35:13Z2018-12-13T23:33:43ZHow play wav files selected from a playlist/listboxI have created a GUI audio player that plays wav files. The player has an add button that selects a file from a folder and plays it.
I am able to populate the listbox/playlist with the appropiate wav files, but cant figure out how to actually play the selcted file. At the moment it just plays 1 audio file named 'handel.wav'. I would appreciate some input on how to make the player play more than just one song from the playlist. I have inlcuded the code for my player from the opening fcn and the code for the add button which puts the wav file in the listbox. There is no code in my listbox yet and just play, pause and stop buttons elsewhere.
Andrew Howehttps://ch.mathworks.com/matlabcentral/profile/authors/14056908-andrew-howetag:ch.mathworks.com,2005:Question/207382011-11-09T10:30:42Z2018-12-13T23:33:35Zbackward,forward, and central DifferenceCan any body help me understand how to do numerical differentiation? example:
t = 0:5:100; Z = cos(10*pi*t)+sin(35*pi*5);
how can I find the backward,forward and central difference at t = 99?Abra doghttps://ch.mathworks.com/matlabcentral/profile/authors/3080357-abra-dogtag:ch.mathworks.com,2005:Question/4356482018-12-13T22:29:19Z2018-12-13T23:26:53ZRound elements in a table while simultaneously having titles?I want to simultaneously have tables were the elements inside are rounded, while also having a title and labels for the rows.
'title' | var1 | var2 | var3
'row1' | .123 .421 .021
'row2' | .321 .231 .231
Without rounding I can create a table with the following syntax:
TableName = ['row1','row2'];
T = table(var1, var2, var3, 'RowNames',TableName)
But to round, it seems like I need to use the function varfun:
TableName = ['row1','row2'];
T = table(var1, var2, var3, 'RowNames',TableName)
LOGtable = varfun(@(var) round(var, 4), T)
But in doing so I lose the 'RowNames' and title options in the previous table.
How should I solve this? Steven Sagonahttps://ch.mathworks.com/matlabcentral/profile/authors/7111331-steven-sagonatag:ch.mathworks.com,2005:Question/4356522018-12-13T23:23:54Z2018-12-13T23:23:54Zhow to install the SPM 12 into Matlab?I have downloaded spm 12,(files from UCL) but I cant use it in matlab.
I dont know what to do and I have tried several times and no use. Could you please give me instructions on how to use SPM to carry out my analysis
Catarina Gaglianonehttps://ch.mathworks.com/matlabcentral/profile/authors/14189320-catarina-gaglianonetag:ch.mathworks.com,2005:Question/1630792014-11-17T14:59:51Z2018-12-13T23:20:00ZUnable to open file "binaryeye.jpg" for writing. You may not have write permission.Hi, i am trying to run this program but i keep getting this error "Unable to open file "binaryeye.jpg" for writing. You may not have write permission. "
The code which i am trying is:
im=imread('2.jpg');
imgray=rgb2gray(im);
imgray=double(imgray);
[imgx,imgy]=gradient(imgray);
imggra=sqrt(imgx.^2+imgy.^2);
imedge=uint8(imggra);
imedge=imadjust(imedge);
imedge=im2bw(imedge);
imwrite(imedge,'binaryeye.jpg');
[imr,imc]=size(imgray);
maxvalue=eps;
maxr=0;
maxx=1;
maxy=1;
for radius=9:13
for i=radius+1:imr-radius
for j=radius+1:imc-radius
maxcount=0;
for theta=0:pi/60:2*pi
y=floor(radius*sin(theta))+i;
x=floor(radius*cos(theta))+j;
if imedge(y,x)==true
maxcount=maxcount+1;
end
% y=floor((radius-1)*sin(theta))+i;
% x=floor((radius-1)*cos(theta))+j;
% if imedge(y,x)==true
% maxcount=maxcount+1;
% end
if maxcount>maxvalue
maxvalue=maxcount;
maxr=radius;
maxx=j;
maxy=i;
end
end
end
end
end
maxr,maxx,maxy
imgray=uint8(imgray);
figure,imshow(imgray)
hold on;
for theta=0:pi/50:2*pi
x=floor(maxr*cos(theta))+maxx;
y=floor(maxr*sin(theta))+maxy;
plot(x,y,'b*-');
end
However i keep getting this error
Error using imwrite (line 455)
Unable to open file "binaryeye.jpg" for writing. You may not have write
permission.
what can i do to solve it? i already change the setting of the folder containing binaryeye.jpg to be written.
Thanks.Jia Zhenhttps://ch.mathworks.com/matlabcentral/profile/authors/5702831-jia-zhentag:ch.mathworks.com,2005:Question/4356512018-12-13T23:06:53Z2018-12-13T23:18:15ZHow to Index Substructure I am trying to index a field in a substructure of a structure. The main structure is supermarket
the next structure is produceList
the field i wish to call from produceList is minNumber
I tried supermarket.produceList{i}.minNumber
I need the {i} to allow the for loop to work
for i = 1:length(supermarket.produceList)
It gives me the error Dot indexing is not supported for this type of variable.
I know i can index with specific elements in the structure such as supermarket.Apples.minNumber. However, this prevents me from testing it for each element of substructure produceListJoshua Konzelmanhttps://ch.mathworks.com/matlabcentral/profile/authors/13451865-joshua-konzelmantag:ch.mathworks.com,2005:Question/4356362018-12-13T20:32:39Z2018-12-13T23:02:38Zhow to have a line marking in 3d image?have done a 3d plot, and want to get a line marking to mark a specific plot?
which code can i use?
Jia Yuhttps://ch.mathworks.com/matlabcentral/profile/authors/13764745-jia-yutag:ch.mathworks.com,2005:Question/1555712014-09-20T12:58:18Z2018-12-13T23:00:15ZMAKING SUBJECT OF FOMULARHOW DO I MAKE X SUBJECT OF FOMULAR IN THIS EQUATION x = exp(x+y).
I have tried the following code
syms x y
solve('x = exp(x+y)',x)
and this give me
*
[sym empty].*
How best can I do it.lloyd mukunzahttps://ch.mathworks.com/matlabcentral/profile/authors/4027519-lloyd-mukunzatag:ch.mathworks.com,2005:Question/4354322018-12-12T19:18:57Z2018-12-13T22:50:23ZCreating the Snake Game using a classI'm having trouble making the Snake game using a class def, my code just continously loops & keeps recreating the graph. I'm stuck & don't know what I need to do to be able to stop the the graph from constantly remaking itself & make the snake move.
classdef snake < handle
properties
gameinput = 'k';
player1 = [];
board = [];
lose = [];
character = 1;
ex = 0;
end
methods
%constructor
function self = snake(varargin)
if ~isempty(varargin)
self.gameinput = varargin{1}
if nargin > 1
self.player1 = varargin{2};
end
end
end
%controls game flow
function play(self)
if isempty(self.lose)
draw_board(self)
end
end
%creates game board
function draw_board(self)
axis_limit = 16;
d = 0;
ate = 0;
x = round(axis_limit/2); %starting point
y = round(axis_limit/2); %starting point
a =randi([1 axis_limit-1],1);%generates random x coordinate for food
b =randi([1 axis_limit-1],1);%generates random y coordinate for food
d =randi([1,4]);% generates random direction to start in for snake
snake(1,1:2)=[x y];%defines the snake for x and y coordinates
size_snake=size(snake);
size_snake=size_snake(1);
food = [a b]; %defines coords for the food
test
while (self.ex~=1)%runs the snake as long as q is not pressed
size_snake=size(snake);
size_snake=size_snake(1);
for l=size_snake+ate:-1:2
snake(l,:)=snake(l-1,:);
end
switch d %calling callback function
case 1
snake(1,2)=snake(1,2)+1;%add value of 1 to y position
case 2
snake(1,2)=snake(1,2)-1;%subtract value of 1 to y position
case 3
snake(1,1)=snake(1,1)+1;%add value of 1 to x position
case 4
snake(1,1)=snake(1,1)-1;%subtracts value of 1 to x position
end
draw_snake(self)
if snake(1,1)==food(1) && snake(1,2)==food(2)%if the snake and food are in the same position
ate=1;
food(1) = randi([1 axis_limit-1]);%creates a new x position for the food
food(2) = randi([1 axis_limit-1]);%creates a new y position for the food
else
ate=0;
end
snake=snake-((snake>axis_limit).*(axis_limit+1));
snake=snake+((snake<0).*(axis_limit+1));
end
end
function draw_snake(self)
axis_limit = 8;
d = 0;
ate = 0;
x = round(axis_limit/2); %starting point
y = round(axis_limit/2); %starting point
a =randi([1 axis_limit-1],1);%generates random x coordinate for food
b =randi([1 axis_limit-1],1);%generates random y coordinate for food
d =randi([1,4]);% generates random direction to start in for snake
snake(1,1:2)=[x y];%defines the snake for x and y coordinates
food = [a b]; %defines coords for the food
size_snake=size(snake);
size_snake=size_snake(1);
for p = 1:size_snake
plot(snake(p,1),snake(p,2), 'wo')
hold on
end
plot(food(1,1),food(1,2), 'rs')%creates the vectors for the food and snake and plots them
drawnow
whitebg([0 0 0])%creates black background
axis([0, axis_limit, 0, axis_limit])%creates the axis for gameplay
hold off
end
%controls the movement of the snake
function move_snake(self)
switch self.character
case 'q'
self.ex=1;
case 30 % arrow direction
if(d~=2)
d = 1; %up d=1
end
case 31
if(d~=1)
d = 2; %down d=2
end
case 29
if(d~=4)
d = 3; %right d=3
end
case 28
if(d~=3)
d = 4; %left d=4
end
end
end
end
endLandon Dukehttps://ch.mathworks.com/matlabcentral/profile/authors/10269981-landon-duketag:ch.mathworks.com,2005:Question/4356352018-12-13T20:14:09Z2018-12-13T22:49:42ZHow to run encoder.m file .following message appears: Undefined function or variable 'raw_message'? appears as i press run buttonHow to run encoder.m file downloaded from the matlab website .
Undefined function or variable 'raw_message'? appears as i press run buttonsami ullahhttps://ch.mathworks.com/matlabcentral/profile/authors/14103506-sami-ullahtag:ch.mathworks.com,2005:Question/4356452018-12-13T21:53:56Z2018-12-13T22:47:16ZObjective function for projectile I have a function to calculate projectile's distance and velocity in both x and y direction. I need to write a function, which defines the objective function to be minimised. objective should take as arguments: the two variables being optimised (i.e. the initial velocity and angle), and the target coordinates tx and ty. It should call my function mentioned earlier with the initial conditions and return the shortest distance between the computed trajectory and (tx, ty). I've not dealt with optimization before so I don't know where to start.
Many thanksZivile Dailidonytehttps://ch.mathworks.com/matlabcentral/profile/authors/13638220-zivile-dailidonytetag:ch.mathworks.com,2005:Question/4355412018-12-13T11:16:33Z2018-12-13T22:46:26ZHow to convert text to time and merge two seperate date and time columns in readtable Hi,
Before I ask my question I have to state that I have searched forums a lot and can not compile all the information I need.
I have attached a sample of my file which has date and hour as the first and second columns. I will be needing these timestamps combined for my analysis.
I need to first convert that time data which reads as Hour with date information. but I think matlab does not see it in a date format as I attached how data shows when I use timetable, as u can see it reads hour with extra '' . I was not successful converting that column to a time information..
Si first I need to make sure readtable reads that second column in time format.
Then I need to merge these two date and time information in seperate colums so I can have something in the following format:
dd/mm/yyyy hh:mm
After that I need to add 7 hours to each of the timestamp data (Maybe this is another question)
I need to have a table2timetable in the end so I can aggregate data.
Below is my code.
I have multiple files like this and each file has around 300K rows and 10 columns so import data is out of question for me as well
I am using matlab 2017b.
filename='AUDUSD.csv';
aud = readtable(filename);
newaud=datetime (aud{:,2},'InputFormat','yyyy/MM/dd/HH:mm');
audtry = table2timetable(newaud);
Error using datetime (line 616)
Unable to parse date/time text using the format 'yyyy/MM/dd/HH:mm'.
Error in Untitled8 (line 4)
newaud=datetime (aud{:,2},'InputFormat','yyyy/MM/dd/HH:mm');
Stephhttps://ch.mathworks.com/matlabcentral/profile/authors/12971362-stephtag:ch.mathworks.com,2005:Question/4356472018-12-13T22:18:14Z2018-12-13T22:40:58ZA function to compare pricesI have completed most of this question but am struggling to complete.
%This is the script/function for Q.2a of Assignment 4
function a = MPR_Asgn4_Q2a_26024405(modnam,man,prc) %modnam is the model name, man is the manufacturer, prc is the price
a = cell(3, 1);
a{1, 1} = modnam;
a{2, 1} = man;
a{3, 1} = prc;
end
%This is the script/function for Q.2b of Assignment 4
p1 = MPR_Asgn4_Q2a_26024405('Iphone X 64 GB','Apple',899);
p2 = MPR_Asgn4_Q2a_26024405('Xperia XZ2 64GB','Sony',399);
p3 = MPR_Asgn4_Q2a_26024405('Galaxy J6 Plus 32GB', 'Samsung',209);
p4 = MPR_Asgn4_Q2a_26024405('Mate 10 Pro 64GB', 'Huawei', 429);
p5 = MPR_Asgn4_Q2a_26024405('Pixel 3 64GB', 'Google', 739);
P=[p1,p2,p3,p4,p5];
for
It's sorting by price and using double nested loops which I can't do.Jack Bushhttps://ch.mathworks.com/matlabcentral/profile/authors/13883834-jack-bushtag:ch.mathworks.com,2005:Question/2772062016-04-05T07:00:30Z2018-12-13T22:35:08ZSimulink tutorials/ examples for ZynqHello,
I have searched the internet and don't find sufficient examples of simulink for zynq (VHDL code generation). Kindly give me some tutorials/ examples from where I can learn this. I need a supporting document which explains interfacing matlab with vivado as well as I encountering some errors while doing this.sunayana chakradharhttps://ch.mathworks.com/matlabcentral/profile/authors/7970922-sunayana-chakradhartag:ch.mathworks.com,2005:Question/4354652018-12-13T00:22:47Z2018-12-13T22:33:53ZHow do I identify subsets of data and divide the data into the subsetsRight now I have code that takes data from two IMU's attached to each side of a knee joint and finds the angle in the knee while someone performs a squat. The Output is the angle on each plane between the two IMUs (the main one I am concerned with is the blue line which is the angle assuming the knee can only rotate on one axis). Plot attached.
I am wondering how I can identify and divide the data so I can analyze each "Repitition" of the exercise on its own. In the plot attached there would be three seperate repetitions I would want to look at.
Bill Phttps://ch.mathworks.com/matlabcentral/profile/authors/6992148-bill-ptag:ch.mathworks.com,2005:Question/4354522018-12-12T22:27:51Z2018-12-13T22:32:07ZChoosing bin size to include equal number of data pointsI have 'time' of certain event to happen in first column and the 'probability of event to happen' in the second column. If i want to plot the data with each bin containing equal number of visits based on the time of visit, how should i decide the bin size?Hari krishnanhttps://ch.mathworks.com/matlabcentral/profile/authors/13142902-hari-krishnantag:ch.mathworks.com,2005:Question/4356312018-12-13T19:43:21Z2018-12-13T22:29:35ZHow to add multiple suggestions to the automatic pop-up help boxes when typing a function?I have some functions that can accept variable amounts of inputs and I want to better document them by adding appropriate suggestions to the box that pops up when you begin typing the function name, like this:
Most built-in Matlab functions display help boxes like this but when I write a function from scratch, it either displays the inputs I specifically have listed, or it shows (...) if the function accepts "varargin", like so:
Those functions of course already handle the inputs properly, but I want to display the various acceptable ways of calling the function in the displayed suggestions here. Is there a way to customize this feature?Nathanhttps://ch.mathworks.com/matlabcentral/profile/authors/5734014-nathantag:ch.mathworks.com,2005:Question/3718782017-12-08T10:51:05Z2018-12-13T22:29:21ZCan Polyspace prove recursion to be impossible?We have a statemachine implementation in C for an embedded automotive product, using a table-approach. The table contains pointers to functions handling the transition and during actions for states. As these functions can call the table again, there is a chance on recursion (reported by another 3rd party static code analysis tool).
From the code design we 'know' it is not possible to have recursion, but we need proof for that as we're following ISO26262-6 (ASIL-C) and MISRA-2012 rules. From these norms, recursion in the implementation is not allowed.
Can polyspace bugfinder/codeprover report on the recursion of this tabular approached state machine implementation? If yes, how?Stein Heselmanshttps://ch.mathworks.com/matlabcentral/profile/authors/8107921-stein-heselmanstag:ch.mathworks.com,2005:Question/4322992018-11-27T15:10:49Z2018-12-13T22:26:51ZWhy importing ascii file and doing differentiation on it by GUI MATLAB shows this error 'Undefined operator '<=' for input arguments of type 'cell'.' ?Dears,
I come to my first Matlab code and I have no previous experience with Matlab so I need your help. I wrote the following code in order to load an ascii file of different rows and columns by push_callback in GUI Matlab. Before loading the file I entered value to define the column of interest and I loaded the desired 'tauD'. Afterwards, I need this code to do some differentiations, save the results, and finally to draw the ouput. But, I got the following message
'
' Undefined operator '<=' for input arguments of type 'cell'.
Error in PSD>pushbutton1_Callback (line 128)
I=imp(tauD(1,1)<=imp(:,1)&imp(:,1)<=tauD(end,1),col+1);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in PSD (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)PSD('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback''
So, could you please help me to fix this errors?
Your efforts and time are deeply appreciated in advance!
tauD_file='myOptions';
col=getappdata(0,'edit1');
load(tauD_file);
tauD=myOptions;
[fnames,fpath]=uigetfile({'*.dat;*.txt','ASCII Files';'*.*','All Files' },'Select data file','MultiSelect','on');
if ~iscell(fnames)
fnames={fnames};
end
for k=fnames
X1 = cell2mat(k)
imp=importdata([fpath,char(X1)]);
I=imp(tauD(1,1)<=imp(:,1)&imp(:,1)<=tauD(end,1),col+1);
[~,fname]=fileparts(char(X1));
dtau=gradient(tauD(:,1));
dtaudD=gradient(tauD(:,1),tauD(:,2));
dtaudlogD=gradient(tauD(:,1),log(tauD(:,2)));
dVdD=I.*dtaudD./dtau;
dVdlogD=I.*dtaudlogD./dtau;
result=[tauD(:,2),dVdD,dVdlogD];
save([fpath,'dVdD(C8)_cyl_0.193_6_',fname,'.dat'],'result','-ascii')
end
set(handles.pushbutton1,'String',filename);
a = get (handles.pushbutton1,'String',dVdlogD(:,1));
b= get (handles.pushbutton1,'String',dVdlogD(:,3));
axes(handles.axes1);
plot(eval(a), eval(b))
Ahmed Elsherifhttps://ch.mathworks.com/matlabcentral/profile/authors/13979717-ahmed-elsheriftag:ch.mathworks.com,2005:Question/4356322018-12-13T19:44:48Z2018-12-13T22:23:09ZProblems with plotting multiple objects
Hi! I have a question. There are the label of contour on the rectangle. Can I delete this for a better reading? Thank you
This is the code for the graphic part.
[c,cc]=contour(x,y,u',[13.1,13.5,14,14.5,15,15.5,15.9]);
clabel(c,cc,'LabelSpacing',72,'Color','r','FontWeight','normal');
rectangle('position',[0,0,Lx,Ly])
rectangle('position',[x(6),y(4),d,3*d],'FaceColor',[0.5 0.5 0.5],'LineWidth',1)
axis('equal');
set(cc,'ShowText','on');
colormap cool;
axis([0 Lx 0 Ly]);
hold on;
streamline(x,y,qx,qy,[x(2:4),x(9:nx)], y(ny+1)*ones(1,6));
quiver(x(2:5),y(2:ny),qx(2:ny,2:5),qy(2:ny,2:5),'b');
quiver(x(8:nx),y(2:ny),qx(2:ny,8:nx),qy(2:ny,8:nx),'b');
quiver(x(6:7),y(2:3),qx(2:3,6:7),qy(2:3,6:7),'b');
trimesh(T,P(:,1),P(:,2),hh);
title('Sheet pile wall');
xlabel('x');ylabel('y');zlabel('z');MICHELA VOLGAREhttps://ch.mathworks.com/matlabcentral/profile/authors/13760896-michela-volgaretag:ch.mathworks.com,2005:Question/4350492018-12-10T22:22:47Z2018-12-13T22:19:07ZPlease help me create Decimal to Two's Complement/ Two's Complement to Decimal function without using the built-in function in MatlabHello Everyone,
My goal here is to create the Decimal to Two's Complement/ Two's Complement to Decimal function without using the built-in function in Matlab , aslo to create hexadecimal number to decimal number and vise versa. without using hex2dec & dec2hex.
Your input is much appreciated.
Thank you.Irwin2000https://ch.mathworks.com/matlabcentral/profile/authors/12752529-irwin2000tag:ch.mathworks.com,2005:Question/4262002018-10-26T05:07:37Z2018-12-13T22:14:59ZHow to resolve the error "Expected audioIn to be a column vector."Hi,
I am using the "Speech Command Recognition Using Deep Learning " to detect words from my own database. The length of each clip in my database is 4 seconds. I am using the default parameters for creating histograms only changing the segmentDuration to the duration in my clips. What wrong I might be doing here?
segmentDuration = 3;
frameDuration = 0.025;
hopDuration = 0.010;
numBands = 40;
The problem is whenever I am trying to run the code, its throwing an error
"Computing speech spectrograms...
Error using auditorySpectrogram
Expected audioIn to be a column vector.
Error in auditorySpectrogram>validateRequiredInputs (line 196)
validateattributes(x,{'single','double'},...
Error in auditorySpectrogram (line 66)
validateRequiredInputs(x,fs)
Error in speechSpectrograms (line 24)
spec = auditorySpectrogram(x,fs, ...
Error in Speech (line 30)
XTrain = speechSpectrograms(adsTrain,segmentDuration,frameDuration,hopDuration,numBands);"
What could be the possible reason and a solution for this. ThannksMohammed Faridul Haque Siddiquihttps://ch.mathworks.com/matlabcentral/profile/authors/7702407-mohammed-faridul-haque-siddiquitag:ch.mathworks.com,2005:Question/4356462018-12-13T22:14:50Z2018-12-13T22:14:50ZPlotting a function based of a vectorThis is the question I've been posed
%This is the script/function for Q.3a of Assignment 4
function y = MPR_Asgn4_Q3a_26024405(x)
y = 4.*exp(x/(5*3))*sin(5.*x); % a=4, b=0 but we will change it to 3 so b=0, c=5
end
%This is the script/function for Q.3b of Assignment 4
clear all
close all
x = linspace(0, 4.*pi);
y = MPR_Asgn4_Q3a_26024405(x);
plot(x,y,'-b','LineWidth',2)
hold on
n = [0:1:20]; % 4*c=20
f = @MPR_Asgn4_Q3a_26024405;
s = (n*pi)./5;
m = f(s);
x = fzero(f,x0);
plot(x,s,'^r')
title('A plot of the function y=4*e^(x/5*3)*sin(5x)'
xlabel('Inputting a vector')
ylabel('The Vector Returned for each given Vector')
I haven't completely finished the code yet but have reached a brick wall, can anyone offer assistance?Jack Bushhttps://ch.mathworks.com/matlabcentral/profile/authors/13883834-jack-bushtag:ch.mathworks.com,2005:Question/4356432018-12-13T21:17:27Z2018-12-13T22:08:56ZHello, how I can represent a imaginary part in curve fitting exponential mode? Thank you very much.Hello, how I can represent a imaginary part in curve fitting exponential mode? Thank you very much.CRISTINA SANCHEZhttps://ch.mathworks.com/matlabcentral/profile/authors/11443517-cristina-sancheztag:ch.mathworks.com,2005:Question/4356402018-12-13T21:05:52Z2018-12-13T22:07:55ZDoes anyone know what these lines of code are doing? Thanks
ma=RandChooseN(probs,M); %function probs with the argument m
pa=RandChooseN(probs,M);
xp=ceil(rand(1,M)*(Nt-1));
pop(1:2:popsiz*e,:)=[pop(ma,1:xp(1)) pop(pa,xp(1)+1:Nt)];
pop(2:2:popsize,:)=[pop(pa,1:xp(1)) pop(ma,xp(1)+1:Nt)]; Ifeatu Ezenwehttps://ch.mathworks.com/matlabcentral/profile/authors/11167739-ifeatu-ezenwetag:ch.mathworks.com,2005:Question/4355082018-12-13T07:21:55Z2018-12-13T22:04:08ZHow can I get proper length of FFTI'm trying to transforming an already know signal from time domain to frequency domain using fftfunction in MATLAB.
And I got different values of amplitude whenever I change the value(nfft) of length of signal.
I'm therefore wondering if there is a rule to choose the length of signal when calculating FFT.
From I understand the amplitude of signal should be same when it is on the time domain and frequency doamin.
am I wrong?
I have an acoustic signal got from a sensor and need to analyze it particularly SPL
I want to transform it into frequency domain using fftfunction in MATLAB. And I don't know how can I choose the length of signal.
Could somebody please help?
This is my code below
[y,Fs] = audioread('AA.wav')
%% Implementation FFT
t=linspace(0,length(y)/Fs,length(y));
nfft=512;
f=linspace(0,Fs,nfft);
g=abs(fft(y,nfft));
F2=f(1:nfft/2)
G2=g(1:nfft/2)
%% ploting FFT
figure(1)
plot(F2,G2)
xlabel('Frequency')
ylabel('Amplitude')
legend('FFT for SPL');Byeongoh Minhttps://ch.mathworks.com/matlabcentral/profile/authors/13597284-byeongoh-mintag:ch.mathworks.com,2005:Question/4354152018-12-12T17:15:33Z2018-12-13T22:02:31ZMatrix construction from base n indicesI'm looking for an efficient way to construct the following matrix
where and are indexed from 0 to as they would be in a base number system i.e. 000,001,...,00N,010,...,01N,...,0NN,...NNN. These indices are then 'split up' across the different functions . Written out this looks like
.
So, for example if then the final matrix is the following 27x27 matrix:
.
In practise will probably be around 15 and the functions can be quite costly so ideally I'd like to implement a vectorised method.
Thanks in advance,
Andrew
Andrewhttps://ch.mathworks.com/matlabcentral/profile/authors/10589180-andrewtag:ch.mathworks.com,2005:Question/4356372018-12-13T20:35:12Z2018-12-13T21:59:07Zhow could i animate a series as an animation ?a function like :
just with loop
HADIMARGOhttps://ch.mathworks.com/matlabcentral/profile/authors/14322242-hadimargotag:ch.mathworks.com,2005:Question/4356062018-12-13T17:59:08Z2018-12-13T21:55:34ZThere is a Java Error in the File Explorer in MATLAB 2018b on MacOS Mojave This was the error output:
Exception in thread "Explorer NavigationContext request queue": java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at com.mathworks.matlab.api.explorer.FileLocation.<init>(FileLocation.java:91)
at com.mathworks.matlab.api.explorer.FileLocation.getParent(FileLocation.java:126)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.resolveLocation(VirtualFileSystem.java:285)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.getTarget(VirtualFileSystem.java:276)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.resolveLocation(VirtualFileSystem.java:285)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.getTarget(VirtualFileSystem.java:276)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.resolveLocation(VirtualFileSystem.java:285)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.getTarget(VirtualFileSystem.java:276)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.resolveLocation(VirtualFileSystem.java:285)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.getTarget(VirtualFileSystem.java:276)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.isMountPoint(VirtualFileSystem.java:239)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem.toExternalEntry(VirtualFileSystem.java:324)
at com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileList.getLocationEntry(VirtualFileList.java:47)
at com.mathworks.mlwidgets.explorer.model.table.UiFileList$PollingNotificationMacPathsWorkaround.<init>(UiFileList.java:545)
at com.mathworks.mlwidgets.explorer.model.table.UiFileList.diffAndSendEvents(UiFileList.java:418)
at com.mathworks.mlwidgets.explorer.model.table.UiFileList.updateCache(UiFileList.java:396)
at com.mathworks.mlwidgets.explorer.model.table.UiFileList.readAndUpdateCache(UiFileList.java:372)
at com.mathworks.mlwidgets.explorer.model.table.UiFileList.access$500(UiFileList.java:45)
at com.mathworks.mlwidgets.explorer.model.table.UiFileList$6.run(UiFileList.java:325)
at com.mathworks.util.RequestQueue.execute(RequestQueue.java:129)
at com.mathworks.util.RequestQueue.access$000(RequestQueue.java:25)
at com.mathworks.util.RequestQueue$2.run(RequestQueue.java:79)
at java.lang.Thread.run(Thread.java:748)Khambrel Simpsonhttps://ch.mathworks.com/matlabcentral/profile/authors/10818827-khambrel-simpsontag:ch.mathworks.com,2005:Question/4356442018-12-13T21:50:22Z2018-12-13T21:50:22ZHow to represent data as a table in SimulinkI have a subsystem with inputs of a, b, t and output of Q(t). In the subsystem, I have 3 2D tables, each table a func( a, b ) --> i.e., Q1 = f1( a, b ), Q2 = f2( a, b ), and Q3 = f3( a, b ) where Q1, Q2, Q3 are the interpolated values from each of the three tables. Now, Q1 represents the interpolated value at a specifc temperature, t1; Q2 at t2; and Q3 at t3. I am trying to construct a Simulink model such that when I pass in a, b, and t (temperature), I get a final interpolated value of Q(t) at the temperature, t.
Can you tell me how to do that? I am in Matlab 2015a. No offense, but the documentation on how to use the tables in Simulink doesn't help me at all. I would prefer to see detailed examples. Anyway, hope you can help.Mark Pyclikhttps://ch.mathworks.com/matlabcentral/profile/authors/395626-mark-pycliktag:ch.mathworks.com,2005:Question/3199292017-01-11T07:04:36Z2018-12-13T21:48:12Zknnsearch(trainingset, testingset, 'K', neighborsvalue) on GPU matlab using parallel processing how to apply knnsearch builtin function of searching the neighbors in GPU using parallel processing , having problem in knnsearch function with Cuda. Aysha Ashrafhttps://ch.mathworks.com/matlabcentral/profile/authors/7735742-aysha-ashraftag:ch.mathworks.com,2005:Question/4356422018-12-13T21:12:14Z2018-12-13T21:42:06ZMutli Degree of freedom questionHi there!
Im trying to use the following code to solve a problem. Yet I keep getting an error code on Line 9: ydot(1) = y(2); stating not enough input arguments.
This is for a multi degree of freedom analysis. What am i doing wrong?
Thanks in advance!
function ydot = Assignment_Q2_D(t,y,m,c,k)
m = 0.5;
c = 0.5;
k = 200;
omega = 33;
ydot = zeros(6,1);
ydot(1) = y(2);
ydot(2) = (1/2*m) *( -c*y(2) - 4*k*y(1) + k*y(3) + 2*k*y(5) );
ydot(3) = y(4);
ydot(4) = (1/2*m) * (-3*c*y(4) + c*y(6) + 2*k*y(1) +k*y(3) - 4*k*y(5) +( 50*sin(omega*t)));
ydot(5) = y(6);
ydot(6) = (1/m) * ( c*y(4) - 2*c*y(6) + 2*k*y(1) + k*y(3) - 4*k*y(5) );
endKyle Spencerhttps://ch.mathworks.com/matlabcentral/profile/authors/14146242-kyle-spencertag:ch.mathworks.com,2005:Question/3765102018-01-10T16:32:16Z2018-12-13T21:41:28ZWhy is gpuArray\knnsearch so slow?I want to accelerate my code using the GPU. In my case, using knnsearch with a gpuArray is very slow.
Here is a code-snippet to test:
%% sample data
ptCloud = pcread('teapot.ply');
%% Option 1: CPU
points = ptCloud.Location;
k = 50;
tic
[idxCPU, distCPU] = knnsearch(points, points, 'K', k);
tCPU = toc;
disp(tCPU);
%% Option 2: GPU
pointsOnGPU = gpuArray(ptCloud.Location);
kOnGPU = gpuArray(50);
tic
[idxGPU, distGPU] = knnsearch(pointsOnGPU, pointsOnGPU,'K',kOnGPU);
wait(gpuDevice);
tGPU = toc;
disp(tGPU);
%% Option 3: ptCloud.findNearestNeighbors in a for loop
tic
ind = zeros(k, ptCloud.Count);
dists = zeros(k, ptCloud.Count);
for i=1:ptCloud.Count
[ind(:,i), dists(:,i)] = findNearestNeighbors(ptCloud, ptCloud.Location(i,:), k);
end
tOption3 = toc;
disp(tOption3);
My result:
0.4188
2.9700
5.9763
I use Matlab R2017b on Ubuntu 16.04.
CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
gpuDevice:
CUDADevice with properties:
Name: 'Quadro M1000M'
Index: 1
ComputeCapability: '5.0'
SupportsDouble: 1
DriverVersion: 9
ToolkitVersion: 8
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 2.0978e+09
AvailableMemory: 1.5902e+09
MultiprocessorCount: 4
ClockRateKHz: 1071500
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
I expected that Option 2 is the fastest. Can anyone explain me why this is not the case?
Actually, my point cloud contains much more points and the difference is considerably greater.
Markus Hillemannhttps://ch.mathworks.com/matlabcentral/profile/authors/7774726-markus-hillemanntag:ch.mathworks.com,2005:Question/3528522017-08-15T18:45:47Z2018-12-13T21:38:03Z[Audio System Toolbox] Changing properties bound to Interface ParametersWhile programming an audioPlugin with Audio System Toolbox, I stumbled across this problem: it doesn't seem possible to *change from code the value of a property that has been bound to an interface* (audioPluginInterface) *parameter*.
I'll show a simple example of what I mean. Let's say I want to have a boost that decreases its gain of 3dB when clipping happens. I'd have
classdef safeBoost < audioPlugin
properties
gain = 1;
end
properties (Access = private)
update = 10^(-3/20);
end
properties (Constant)
PluginInterface = audioPluginInterface( ...
audioPluginParameter( 'gain' , ...
'DisplayName' , 'Boost' , ...
'Mapping' , { 'log' , 10^(-120/20) , 10^(120/20) } ) );
end
methods
function out = process(plugin, in)
out = in*plugin.gain;
if max(out(:)) > 1
plugin.gain = plugin.gain*plugin.update; % <-- Running plugin changed parameter 'gain' from 1e+06 to 707946.
end
end
end
end
As you can read in the comment, the validation is unsuccessful due to the error " *Running plugin changed parameter 'gain'* ".
I guess there is a way of assigning a value to a property when it's bound to a parameter (assignment to a property not bound to a parameter doesn't seem to cause any trouble).
I went through the documentation ( <https://it.mathworks.com/help/audio/ref/audioplugininterface.html here> and <https://it.mathworks.com/help/audio/ref/audiopluginparameter.html here> ), but didn't find anything about it.
Anyone encountered the same problem or knows how to do this kind of assignments?Marco Tiraboschihttps://ch.mathworks.com/matlabcentral/profile/authors/7053014-marco-tiraboschitag:ch.mathworks.com,2005:Question/4353942018-12-12T15:46:54Z2018-12-13T21:34:56ZCorrelate a 3d array into n times 2d rowsHi
Was just wondering if there was a simple way to flatten a 2d array into correlation rows. Ok so here's an example:
I have n numbers of a 2d array as such:
a b c d e f
1 1.771 1.771 1.771 1.771 2.314 2.314
2 1.802 1.802 1.802 1.802 2.288 2.288
3 2.071 2.071 2.071 2.071 2.184 2.184
4 1.961 1.961 1.961 1.961 2.086 2.086
5 1.94 1.94 1.94 1.94 2.649 2.649
6 1.924 1.924 1.924 1.924 2.458 2.458
7 2.065 2.065 2.065 2.065 2.211 2.211
8 1.981 1.981 1.981 1.981 2.066 2.066
9 1.752 1.752 1.752 1.752 2.108 2.108
10 1.907 1.907 1.907 1.907 2.153 2.153
So say example here a 3d (6x10x n)
How can i correlate a1:a10, b1:b10 till f1:f10 so call them feature a1,a2,a3....f8,f9,f10 and do this for n rows. N rows of 60 features (a1,a2,a3...). Is there a simple matlab function ? Thank you for any help.
Answer for n rows is:
a1 a2 a3 a4 a5 … f8 f9 f10
n1 1.771 1.802 2.071 1.961 1.94 2.066 2.108 2.153
n2
n3
….
Kevin
Kevin Tehhttps://ch.mathworks.com/matlabcentral/profile/authors/856093-kevin-tehtag:ch.mathworks.com,2005:Question/4344802018-12-07T17:35:01Z2018-12-13T21:31:23ZHow do I solve this error: Error using matlab.io.datastore.ImageDatastore/readimage (line 32)?I am trying to use feature extraction to recognise faces, however when I run the code these errors come up:
Error using matlab.io.datastore.ImageDatastore/readimage (line 32)
Expected input number 2, INDEX, to be a scalar with value <= 8.
Error in Alexnet_Feature_Test (line 31)
I = readimage(imdsTest,idx(i));
Below is my code, I have tried using vgg19 and Alexnet and get the same errors for both
%Load zipped images
unzip('ATTDatabase.zip');
imds = imageDatastore('ATTDatabase','IncludeSubfolders',true,'LabelSource','foldernames');
[imdsTrain,imdsTest] = splitEachLabel(imds,0.7,'randomized');
%Display sample images from zip file
numTrainImages = numel(imdsTrain.Labels);
idx = randperm(numTrainImages,10);
figure
for i = 1:10
subplot(2,5,i)
I = readimage(imdsTrain,idx(i));
imshow(I)
end
%Load pretrained network (AlexNet)
net = vgg19();
net.Layers
inputSize = net.Layers(1).InputSize;
%Extracting image features
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain);
augimdsTest = augmentedImageDatastore(inputSize(1:2),imdsTest);
layer = 'fc7';
featuresTrain = activations(net,augimdsTrain,layer,'OutputAs','rows');
featuresTest = activations(net,augimdsTest,layer,'OutputAs','rows');
%Extracting class labels
YTrain = imdsTrain.Labels;
YTest = imdsTest.Labels;
%Image classifier
classifier = fitcecoc(featuresTrain, YTrain);
%Classification from test
YPred = predict(classifier,featuresTest);
%Showing 4 images with labels
idx = [1 5 10 15];
figure
for i = 1:numel(idx)
subplot(2,2,i)
I = readimage(imdsTest,idx(i));
label = YPred(idx(i));
imshow(I)
title(char(label))
end
%Accuracy of model
accuracy = mean(YPred == YTest)
The majority of the code can be found here: https://uk.mathworks.com/help/deeplearning/examples/feature-extraction-using-alexnet.html
I am not sure why this is coming up, please help!Sujit Mistryhttps://ch.mathworks.com/matlabcentral/profile/authors/9077628-sujit-mistrytag:ch.mathworks.com,2005:Question/868592013-09-11T07:49:17Z2018-12-13T21:28:57ZIs it possible to get a worst case stack size with polyspaceHello everybody,
i would like to know a worst case value of stack usage for my embedded application.
Is this information somehow avaliable with polyspace?
thanks
OlafOlafhttps://ch.mathworks.com/matlabcentral/profile/authors/2985515-olaftag:ch.mathworks.com,2005:Question/2705552016-02-29T06:48:46Z2018-12-13T21:21:56ZHow to return value from an axes ?Hello all,
How to return value of an axes in GUI, which is typically a numeric value. That value can be used to handle the axes outside the axes function also.
thank youyogesh jainhttps://ch.mathworks.com/matlabcentral/profile/authors/6915692-yogesh-jaintag:ch.mathworks.com,2005:Question/4352002018-12-11T17:02:17Z2018-12-13T21:19:40Zreadtable changing range (not all contents)Hello,
Manually Importing an XLS file (right click import data) the window by default highlights a matrix, say C10:X90
If I manually change the default "column vectors" to "table" and then click import, then it imports the matrix I need.
I need to do this for many files. However, using readtable('file1.xls') it imports all contents, beyond that matrix.
The matrix range changes from file to file so I cannot fix it to C10:X90, so file2.xls can be C15:X80, etc
How can I import the highlighted matrix (which changes from file to file) in a loop?Davehttps://ch.mathworks.com/matlabcentral/profile/authors/5686285-davetag:ch.mathworks.com,2005:Question/4356412018-12-13T21:09:54Z2018-12-13T21:18:08ZStrange sparse matrix error on GPUI have a sparse matrix with a relatively small (16 MB) memory footprint
>> Whos A
Name Size Kilobytes Class Attributes
A 100000x100000 16406 double sparse
When I send it to the GPU and add the scalar 0, I get a puzzling error
>> gpuArray(A)+sparse(0);
Error using +
Maximum variable size allowed on the device is exceeded.
I really cannot see why this operation would cause any excessively large memory allocations. This is in Matlab version R2018a and the following GPU details. Does anyone have any insights as to why this occurs?
>> gpuDevice
ans =
CUDADevice with properties:
Name: 'GeForce GTX TITAN X'
Index: 1
ComputeCapability: '5.2'
SupportsDouble: 1
DriverVersion: 9.2000
ToolkitVersion: 9
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 1.2885e+10
AvailableMemory: 1.2259e+10
MultiprocessorCount: 24
ClockRateKHz: 1076000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 0
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1Matt Jhttps://ch.mathworks.com/matlabcentral/profile/authors/1440443-matt-j