https://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-02-21T09:19:50Ztag:de.mathworks.com,2005:Question/3834582018-02-19T08:39:30Z2018-02-21T09:19:50ZHow to scan an image to find out the row or column that will be the first background pixel?<p>I have a binary image. I have to scan the image from centroid to its right to find out row consisting of first background pixels ,then centroid to left side and from centroid to top. in each case I have to find out the distance between two columns and rows and find out the max distance.</p>Zara Khanhttps://de.mathworks.com/matlabcentral/profile/authors/10893209-zara-khantag:de.mathworks.com,2005:Question/3839162018-02-21T08:44:31Z2018-02-21T09:16:55ZFor loop problem (Help)<p>Hi guys , anyone can help me to check my coding ...</p><img src = "/matlabcentral/answers/uploaded_files/105637/1.JPG"><p>Current result, something wrong ...</p><img src = "/matlabcentral/answers/uploaded_files/105640/2.JPG"><p>Desire result ,
How to get table like this? I'm trying to create an auto data collection software by using GUI.</p><img src = "/matlabcentral/answers/uploaded_files/105639/3.JPG">zhixuan honghttps://de.mathworks.com/matlabcentral/profile/authors/12101438-zhixuan-hongtag:de.mathworks.com,2005:Question/3779102018-01-19T09:21:19Z2018-02-21T09:15:56Zfind the best slice from a volume<p>hello. i have a 2D image of echo which consist of LV contour. and also i have a volume of cardiac ct that i want to find the best slice of it that best matches to my 2D image.
if i start to slice the volume with different points and normal vectors(https://www.mathworks.com/matlabcentral/fileexchange/32032-extract-slice-from-volume) it will be infinit situations
does any body know how can i find the best maching slice to my 2D image from my 3D volume?</p>talahttps://de.mathworks.com/matlabcentral/profile/authors/8858317-talatag:de.mathworks.com,2005:Question/3839132018-02-21T08:32:37Z2018-02-21T09:15:29ZHow to display a plot going to infinity?<p>I am meant to plot the Dirac Delta function:</p><img src = "https://i.imgur.com/KBNvQU4.png"><p>my attempt:</p><pre class="language-matlab">x = -30:1:30;
y = zeros(1,numel(x)); %sets all values initially to zero
y(x==0)= inf; % the point corresponding to x=0 is set to inf
plot(x,y,'d')
axis([-40 40 0 inf])
</pre><img src = "https://i.imgur.com/2bdzeSQ.png"><p>How can I get it to visually show it going up to infinity?</p>Natasha Simonehttps://de.mathworks.com/matlabcentral/profile/authors/12054635-natasha-simonetag:de.mathworks.com,2005:Question/3184952016-12-29T10:45:51Z2018-02-21T09:15:28ZDeactivation switch for implicit expansion<p>Does anyone know if there is a way to disable the <a href = "http://blogs.mathworks.com/loren/2016/10/24/matlab-arithmetic-expands-in-r2016b/#ff37e349-b21d-48a5-b89d-453215d69fc7">implicit expansion</a> feature introduced in R2016b?</p>Matt Jhttps://de.mathworks.com/matlabcentral/profile/authors/1440443-matt-jtag:de.mathworks.com,2005:Question/2531972015-11-05T16:01:41Z2018-02-21T09:10:44ZHow to get simulink block diagram's width and height in pixel?<p>How to get simulink block diagram's width and height in pixel?</p>Ami Shahhttps://de.mathworks.com/matlabcentral/profile/authors/7026286-ami-shahtag:de.mathworks.com,2005:Question/3839192018-02-21T09:06:01Z2018-02-21T09:09:35Z how to solve timing problem with laser scan (synchronizing with odometry) in MATLAB with bag file <p>hello guys,
I want to simulate the bag data that I got from ROS in MATLAB and I wrote a script to plot the laser data and build a map (I assumed that my poses are correct).
my problem is related to synchronization and I match the wrong pose to the scan data. after some research I found that I should use the \tf data but I dont know how to use them. do you have any idea how to get the robot pose at the time of sensor reading?</p>fereydoon jafarihttps://de.mathworks.com/matlabcentral/profile/authors/7209173-fereydoon-jafaritag:de.mathworks.com,2005:Question/3838352018-02-20T23:30:48Z2018-02-21T09:07:24Zget the table from uitable into a matrix A<pre class="language-matlab">tableData = get(handles.uitable1, 'Data')
tableData =
'99' [41]
'77' [13]
</pre><p>can i convert it to a normal matrix so i can do a function on it</p>Amjad Greenhttps://de.mathworks.com/matlabcentral/profile/authors/12204813-amjad-greentag:de.mathworks.com,2005:Question/3838882018-02-21T05:50:18Z2018-02-21T09:01:33Zhow to create matrix with multiple column vectors?<p>I have to create channel matrix for 16 users. each column contains information about channel of particular user.my matrix size will be 128x16</p>prabhabathi devi chandrasekaranhttps://de.mathworks.com/matlabcentral/profile/authors/11919498-prabhabathi-devi-chandrasekarantag:de.mathworks.com,2005:Question/3838972018-02-21T06:31:38Z2018-02-21T09:00:32ZHow to make a for loop run consecutively?<p>I have column vectors imported numerically that sometimes have NaN. This data corresponds to the position of an animal in a pool, where the NaN values at the beginning are not significant and need to be discarded, whereas there could be NaN values elsewhere (ie. after the first numerical value) that need to be addressed in a different manner. I'm not sure if this is the best way to approach this, but I envision using a while and for loop to evaluate the first row of the TF, if 1 delete row 1 in the associated column vectors, and then evaluate the new row 1 until row 1 is no longer a 1/NaN.</p><pre class="language-matlab">TF = isnan(X);
for m = 1
if TF(m) == 1
X(m) = [];
Y(m) = [];
Z(m) = [];
end
end
</pre><p>This is what I have so far. The only method I have found that works as intended is to copy and paste this for loop consecutively hundreds of times. However, I feel as if there must be a better way. Thanks for your help.</p>Rameen Forghanihttps://de.mathworks.com/matlabcentral/profile/authors/11852163-rameen-forghanitag:de.mathworks.com,2005:Question/3838562018-02-21T05:00:00Z2018-02-21T08:59:06ZMATLAB Answers とMathWorksサポート窓口の使いどころのガイドラインはありますか。<p>MATLAB Answers とMathWorksサポート窓口の２つのサービスがあるようですが、</p><p>それぞれはどのように使えばいいでしょうか。何かガイドラインがあれば教えてください。</p>MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/3839172018-02-21T08:56:52Z2018-02-21T08:56:52ZHow to build auxiliary control inputs in Simulink <p>How to build the auxiliary control inputs when I am given this equations in Simulink</p><p>Thank you</p>Ian Cheonghttps://de.mathworks.com/matlabcentral/profile/authors/12146452-ian-cheongtag:de.mathworks.com,2005:Question/3837852018-02-20T19:39:33Z2018-02-21T08:49:35Zhow to find mean absolute deviation image?<p>I want to display mean absolute deviation image from a given input jpg Image. MAD is an energy measure that represents regularity of texture.</p>Khushal Gumgaonkarhttps://de.mathworks.com/matlabcentral/profile/authors/3243335-khushal-gumgaonkartag:de.mathworks.com,2005:Question/3839152018-02-21T08:44:21Z2018-02-21T08:44:21ZHow to generate synthetic image according to parameters of size ?<p>Perform segmentation using Otsu algorithm</p>Nor Syafina Md Shariffuldinhttps://de.mathworks.com/matlabcentral/profile/authors/12207304-nor-syafina-md-shariffuldintag:de.mathworks.com,2005:Question/3839142018-02-21T08:36:14Z2018-02-21T08:36:14ZHOW TO SOLVE .dll ERROR?<p>Warning: The library name case did not match the file name.
The library will be named "thinkgear".
> In loadlibrary at 175
In bcr_eyeblink at 21
Index exceeds matrix dimensions.</p><p>Error in loadlibrary>getLoadlibraryCompilerConfiguration (line 497)
compilerConfiguration=compilerConfiguration(1); %unix machines return c and cpp compilers here</p><p>Error in loadlibrary (line 253)
[thunk_build_fn,preprocess_command]=getLoadlibraryCompilerConfiguration(ccinclude,header,headername,compilerConfiguration);</p><p>Error in bcr_eyeblink (line 21)
loadlibrary('Thinkgear.dll');</p><p>>> this error occuring while running the below code:</p><p>%Clear Screen
clc;
%Clear Variables
clear all;
%Close figures
close all;
a=imread('blink.jpg');
%Preallocate buffer
data_blink = zeros(1,256);
%Comport Selection
portnum1 = 7;
%COM Port #
comPortName1 = sprintf('\\\\.\\COM%d', portnum1);
% Baud rate for use with TG_Connect() and TG_SetBaudrate().
TG_BAUD_115200 = 115200;
% Data format for use with TG_Connect() and TG_SetDataFormat().
TG_STREAM_PACKETS = 0;
% Data type that can be requested from TG_GetValue().
TG_DATA_BLINK_STRENGTH = 37;
%load thinkgear dll
loadlibrary('Thinkgear.dll');
%To display in Command Window
fprintf('Thinkgear.dll loaded\n');
%get dll version
dllVersion = calllib('Thinkgear', 'TG_GetDriverVersion');
%To display in command window
fprintf('ThinkGear DLL version: %d\n', dllVersion );
% Get a connection ID handle to ThinkGear
connectionId1 = calllib('Thinkgear', 'TG_GetNewConnectionId');
if ( connectionId1 < 0 )
error( sprintf( 'ERROR: TG_GetNewConnectionId() returned %d.\n', connectionId1 ) );
end;
% Attempt to connect the connection ID handle to serial port "COM3"
errCode = calllib('Thinkgear', 'TG_Connect', connectionId1,comPortName1,TG_BAUD_115200,TG_STREAM_PACKETS );
if ( errCode < 0 )
error( sprintf( 'ERROR: TG_Connect() returned %d.\n', errCode ) );
end
fprintf( 'Connected. Reading Packets...\n' );
if(calllib('Thinkgear','TG_EnableBlinkDetection',connectionId1,1)==0)
disp('blinkdetectenabled');
end
i=0;
j=0;
%To display in Command Window
disp('Reading Brainwaves');
while i < 20
if (calllib('Thinkgear','TG_ReadPackets',connectionId1,1) == 1) %if a packet was read...
if (calllib('Thinkgear','TG_GetValueStatus',connectionId1,TG_DATA_BLINK_STRENGTH) ~= 0)
j = j + 1;
i = i + 1;
%Read attention Valus from thinkgear packets
data_blink(j) = calllib('Thinkgear','TG_GetValue',connectionId1,TG_DATA_BLINK_STRENGTH );
%To display in Command Window
disp(data_blink(j));
%Plot Graph
figure;
imshow(a);
title('Blink Strength');
%Delay to display graph
pause(1);
close all;
end
end
end
%To display in Command Window
disp('Loop Completed')
%Release the comm port
calllib('Thinkgear', 'TG_FreeConnection', connectionId1 );</p>JOMISH JAMEShttps://de.mathworks.com/matlabcentral/profile/authors/12207231-jomish-jamestag:de.mathworks.com,2005:Question/3746122017-12-27T04:07:59Z2018-02-21T08:32:39ZWants to execute matlab file with php <p>how to pass php dynamic file path to matlab(any function where I can execute matlab file code). Want to show the output on browser. SO, how can I code for this.</p>Pramod Amrutkarhttps://de.mathworks.com/matlabcentral/profile/authors/11805634-pramod-amrutkartag:de.mathworks.com,2005:Question/3839122018-02-21T08:29:06Z2018-02-21T08:29:06Zextract single object with a particular area from binary image<p>After segmentation i computed the area of the objects in the segmented image, and got all areas in the variable named "allAreas"</p><p>if wanted to selected only one object, which has the area with value 50, If there is no exact value with 50, object with nearest to value 50 needs to be extracted from the binary image</p><p>Please can someone help me solve this</p>Elysi Cochinhttps://de.mathworks.com/matlabcentral/profile/authors/3625227-elysi-cochintag:de.mathworks.com,2005:Question/3836792018-02-20T11:04:07Z2018-02-21T08:28:59ZHow to effectively run loops and save time in computation? I have a matrix of size 'm' and run five loops from 1 to m. The logic is explained below. How to optimize the code and save time of calculation.<p>I need to find projection statistics for my matrix of size 'm' by initially calculating the sum of all possible observations (using logic as in code-Rousseuuw and Croux method). This needs a quite a large number of iterations. When my matrix size is 1000x1000, it takes close to 250seconds for this code to complete. Can someone help me in optimizing the code below thereby reducing the operation time.</p><pre> m=1000;
H=rand(m);
rng default;</pre><pre> x=zeros(m,1);
y=zeros(m,1);
output1 = zeros(m,1);
output = zeros(m,1);
PS = zeros(m,1);</pre><pre> for k=1:m
for i=1:m
for j=1:m
if j~=i
x(j)=abs(H(i,k)+H(j,k));
end
end
mask=x~=0; % mark the non-zero elements
x=x(mask); % keep the non-zero elements
y(i)=median(x);
x=zeros(m,1); %Clearing x after calculating median and proceed to next iter
end
y(y==0)=NaN;
output1(k)=1.1926*nanmedian(y);
end
for k=1:m
for i=1:m
output(i)=abs(H(k,i))/output1(i);
end
PS(k,1)=max(output);
end</pre><p>Even after making the suggestions in comments, the computation time is still high.
Without pre-initialising, - 250s
With pre-initialising - 250s
After changing namedian to median - 200s (recent)</p>SanthoshKumar Chttps://de.mathworks.com/matlabcentral/profile/authors/10543176-santhoshkumar-ctag:de.mathworks.com,2005:Question/3836852018-02-20T11:39:11Z2018-02-21T08:26:26ZHow to add additional constraint to lsqlin?<p>Hey,</p><p>I want to add 2 constraints in the form:</p><pre class="language-matlab">Ax <= b
</pre><p>but there is only one option to do it.</p><p>specifically, I want to make constraint for the absolute value,
so I need to constraint</p><pre class="language-matlab">-b < Ax < b
</pre><p>Is it possible?</p>Kalonymushttps://de.mathworks.com/matlabcentral/profile/authors/6894578-kalonymustag:de.mathworks.com,2005:Question/3837502018-02-20T16:14:53Z2018-02-21T08:23:46ZNeed help for a nonlinear constraint optimization problem<p>Dear all,</p><p>I am going to solve the following nonlinear constraint optimization problem using MATLAB. I was wondering if you could please help me how to do that,</p><pre class="language-matlab">minimize -trace(W^-1)
subject to
(A-B1*k)W+W*(A-B1*k)'=-B2*B2';
sqrt(trace(C'*W*C)) <= 1;
max(eig(A-B1*k)) <= -1;
</pre><p>A, B1 and B2 are known matrices and k is the unknown 2*2 matrix. (W is also a 2*2 matrix).</p><p>I wrote the following code but got error,</p><pre class="language-matlab">function [c,ceq] = constr(k)
</pre><pre class="language-matlab">c(1) = (A-B1*k)*W+W*(A-B1*k)'+B2*B2';
c(2) = sqrt(trace(C'*W*C))-1;
c(3) = max(eig(A - B1*k))+1;
ceq = [];
end
</pre><pre class="language-matlab">clc
clear
close all
</pre><pre class="language-matlab">A = [-1 0
0 -2];
B1 = eye(2);
B2 = eye(2);
C = eye(2);
g2 = 3; g3 = -1;
</pre><pre class="language-matlab">x0=[1;1];
A=[];
b=[];
Aeq=[];
beq=[];
lb=[];
ub=[];
</pre><pre class="language-matlab">nonlcon = @constr;
fun = @(k)(-trace(inv(W)));
k = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
</pre><p>Thanks a lot.</p>Mohammadhttps://de.mathworks.com/matlabcentral/profile/authors/4437557-mohammadtag:de.mathworks.com,2005:Question/3839112018-02-21T08:19:25Z2018-02-21T08:19:25Zhow to convert the x axis of a time series autocorrelation from time lags to real time?<p>Hi all, I have a time series with 32000 samples. I have plotted the autocorrelation of the time series by autocorr(x,n) syntax. where n is its lag. it plots the autocorrelation which its x axis is based on the time step, but I want to convert the x axis to real time which totally is 0.16 sec.
any help would be appreciated.</p>ramin asadihttps://de.mathworks.com/matlabcentral/profile/authors/7396120-ramin-asaditag:de.mathworks.com,2005:Question/3836722018-02-20T10:33:48Z2018-02-21T08:19:20ZIn a Matlab plot(x,y) having both negative and positive 'y' values, how to display the xtick labels at zero(0) line too<p>In the sample image, I would like to have xtick labels at 0 line too.</p>Anjana Krishnanhttps://de.mathworks.com/matlabcentral/profile/authors/9234736-anjana-krishnantag:de.mathworks.com,2005:Question/3839102018-02-21T08:17:48Z2018-02-21T08:17:48ZWrite loop for read then write multiple files<p>Hi!</p><p>I've wrote a script for read a binary float32 file, then write it into a txt file. I works for one file, but i have several binary files. The file names are 001001.bin,001002.bin...etc.</p><p>Here is the original loop:</p><pre class="language-matlab">fname='D:\001001.bin';
fid = fopen(fname);
data = fread(fid,'float32');
dlmwrite('001001.bin.txt',data,'precision','%10.5f','newline','pc')
</pre><p>I tried to make a loop, but it has an error message:
"In an assignment A(:) = B, the number of elements in A and B must be the same."</p><p>Here is the loop:</p><pre class="language-matlab">v=dir('*.bin')
for i=1001:v
fname(i)='D:\00(i).bin';
fid(i) = fopen(fname(i));
data(i) = fread(fid(i),'float32');
dlmwrite('00(i).bin.txt',data(i),'precision','%10.5f','newline','pc')
end
</pre><p>Thanks for helping!</p>Richard Hardihttps://de.mathworks.com/matlabcentral/profile/authors/12207073-richard-harditag:de.mathworks.com,2005:Question/3839092018-02-21T08:16:47Z2018-02-21T08:16:47ZHow Can I merge R,G,B Components of an image into a single RGB image ?<p>I am using 'V4L2 Video Capture' block for interfacing my Raspberrypi Camera with my laptop. I need a single multidimensional signal instead of three separate R, G, B components. Please suggest me any solution for this. <b>It should be compatible with code generation</b>.
Thanks in advance.</p>Omkar Bhanaphttps://de.mathworks.com/matlabcentral/profile/authors/9528744-omkar-bhanaptag:de.mathworks.com,2005:Question/3839072018-02-21T08:12:43Z2018-02-21T08:12:43ZDAQ with raspberry Pi<p>Hi,</p><p>After researching the possibilities I’m left with some questions.
I would like to run Data acquisition (DAQ) on my raspberry Pi to receive and later transmit data. The idea is to receive a vibration and send out, actuator movement to counter measure the effect.</p><p>While the Pi is doing this, I would like occasionally to connect the Pi to Matlab (while it’s still running) and receive the data of the in/out-going signals and be able to control the Pi.</p><p>According to the website: “MATLAB communicates with the Raspberry Pi hardware by connecting to a server running on Raspberry Pi “
I don’t fully understand this part. I’m I able to connect to the Raspberry Pi directly with Ethernet or is there another server needed?</p><p>Is it possible to connect to the Pi and analyze/control the data?</p><p>Hope someone can answer both questions,
Thank you,</p><p>Luc</p>Luc Meijerhttps://de.mathworks.com/matlabcentral/profile/authors/6447956-luc-meijertag:de.mathworks.com,2005:Question/3838822018-02-21T04:55:34Z2018-02-21T08:06:27Zhow to create a square matrix with unique real values?<p>Hello,
I want a random square matrix of size 10*10, where each row must contain random values from 1 to 10...</p>Jyothi Alugoluhttps://de.mathworks.com/matlabcentral/profile/authors/9669677-jyothi-alugolutag:de.mathworks.com,2005:Question/3838932018-02-21T06:01:13Z2018-02-21T08:00:42ZI want to create a two axis y plot which is only dependent on a single x variable. How is this possible? <p>Hi,</p><p>I have one variable x. This variable x has two different outputs such that there is (x,y1) and (x,y2). To fully understand the effect that x has it is important to simultaneously consider y1 and y2 in the same curve. Using a two y-axis plot usually generates two different curves. I want to generate a single curve. A hypothetical code would be like</p><p>plotyy(x,y1,y2).</p><p>I know that plotyy is no longer supported but is there something similar in yyaxis?</p>New to Matlabhttps://de.mathworks.com/matlabcentral/profile/authors/3527003-new-to-matlabtag:de.mathworks.com,2005:Question/3839052018-02-21T07:51:26Z2018-02-21T07:58:54ZCan I save my outputs in a way to use them as my inputs for the next run?<p>Hi
suppose I have:</p><pre class="language-matlab">[D C] = function(A,B)
C = A*B;
D = A+B;
end
</pre><p>A and B are my inputs,so after I run the function I can calculate C and D. the second time I am running the function, I want to have my input as this way: A = C and B = D. but I don’t want to change the inputs manually every time. In other words every time I run the function, I want to have A and B replaced by C and D and then running the function without any needs to change my inputs manually every time.
Is there anyway I can do this in Matlab?
Thanks,</p>K.Ghttps://de.mathworks.com/matlabcentral/profile/authors/8236153-k-gtag:de.mathworks.com,2005:Question/3837832018-02-20T19:13:42Z2018-02-21T07:53:46Zdr/dt* ln(a*r*dr/dt)=b/r^7 how to solve this equation<p>kindly help me to solve this equation a = 0.5, b=2, r(0)=1.2</p>vishal vyashttps://de.mathworks.com/matlabcentral/profile/authors/8217805-vishal-vyastag:de.mathworks.com,2005:Question/3839042018-02-21T07:43:32Z2018-02-21T07:43:32ZI have an hourly meteorological data screenshot attached which i need to convert to average daily data. Since I have a long period of data it is difficult to do it in excel. If anyone knows how to code it in matlab pls let me know<img src = "/matlabcentral/answers/uploaded_files/105636/rain.PNG">Jeffrey Marakhttps://de.mathworks.com/matlabcentral/profile/authors/3587598-jeffrey-maraktag:de.mathworks.com,2005:Question/3839032018-02-21T07:42:29Z2018-02-21T07:42:29ZHow to run "Train a Convolutional Neural Network for Regression" example in single precision on laptop with NVIDIA GPU?<p>Attempt 1:
Use nndata2gpu: error only works for 2D array
>> trainImagesSingle = nndata2gpu(trainImages,'single');
Error using nnsize (line 32)
Data{1,1} is not two-dimensional.</p><p>Error in nndata2gpu (line 76)
[N,Q,TS,M] = nnsize(x);</p><p>Attempt 2:
Use 'single': runs but no improvement in training time
>> trainImagesSingle = single(trainImages);
>> trainAnglesSingle = single(trainAngles);
>> net = trainNetwork(trainImagesSingle,trainAnglesSingle,layers,options);</p><p>It seems like it would be a fairly common thing to do since most laptop Nvidia gpu's (mine is Quadro M1200) have slow double precision.</p><p>Any idea?</p>Kenneth Yiphttps://de.mathworks.com/matlabcentral/profile/authors/702528-kenneth-yiptag:de.mathworks.com,2005:Question/3838732018-02-21T04:25:29Z2018-02-21T07:39:25ZDetermine if valid initial guess for closed numerical method<p>If I'm given a function f(x), how can I determine whether say [0 1] or [1,2 ] are valid initial guesses for a closed numerical method, of solving f(x)=0.</p>Rachel Dawnhttps://de.mathworks.com/matlabcentral/profile/authors/11963433-rachel-dawntag:de.mathworks.com,2005:Question/3838782018-02-21T04:54:05Z2018-02-21T07:34:49Zdsolve and heaviside (unit step response)<p>Hi, I'm trying to understand the behaviour of dsolve and heaviside for solving a simple ODE.</p><pre class="language-matlab">syms y(t)
Y = dsolve(diff(y)+y == 1, y(0) == 0)
ezplot(Y,[0,5])
</pre><p>Gives the desired response of a first order LTI ODE to a step, i.e.
Y = 1 - exp(-t)
(not too worried about negative time). However,</p><pre class="language-matlab">sympref('HeavisideAtOrigin', 1)
Y = dsolve(diff(y)+y == heaviside(t), y(0) == 0)
ezplot(Y,[0,5])
</pre><p>Produces
Y = sign(t)/2 - exp(-t)/2 + 1/2
so the value at Y(0) is 0.5, rather than starting from Y(0)=0.</p><p>Given the same initial value and forcing function 1 for t>=0, they should produce the same result? Obviously, the first result is the one I was expecting.</p>Martin Brownhttps://de.mathworks.com/matlabcentral/profile/authors/6555163-martin-browntag:de.mathworks.com,2005:Question/3838642018-02-21T02:57:39Z2018-02-21T07:29:25ZHow to export ASCII-delimited file to Excel file or csv.file?<p>Hi guys , is it possible export ASCII-delimited file to excel file?</p><p>I used dlmwrite() function to get the table.</p><img src = "/matlabcentral/answers/uploaded_files/105596/Capture.JPG">zhixuan honghttps://de.mathworks.com/matlabcentral/profile/authors/12101438-zhixuan-hongtag:de.mathworks.com,2005:Question/242732011-12-19T08:26:19Z2018-02-21T07:27:54ZPupil Detection using Hough Transform<p>Hi guys,</p><p>I would like to ask is there an accurate Hough transform source code available that can detect pupil/circle and draw a circle around the pupil and return the radius as well?</p><p>I have tried several methods but they cannot detect the pupil accurately, which results in more than one circle being drawn.</p><p>Looking forward to your experienced help. Thank you!</p>Ivanhttps://de.mathworks.com/matlabcentral/profile/authors/3093421-ivantag:de.mathworks.com,2005:Question/3838682018-02-21T03:34:21Z2018-02-21T07:26:58ZHello, please can anyone help me with a pseudocode for a classic beamforming scheme?<p>I need help with a pseudo-code for a classic beamforming scheme for cellular systems</p>Tolulope Olabisihttps://de.mathworks.com/matlabcentral/profile/authors/11232845-tolulope-olabisitag:de.mathworks.com,2005:Question/3838992018-02-21T06:55:46Z2018-02-21T07:20:31ZArray and Matrix question<p>How would I go about creating a 4x3 array/matrix and use some of its values to create another array/matrix that is 2x2? I have to use 'x=y(a:b:c,d:e:f)', where y is my initial 4x3 and x would be my 2x2, in order to create my second array. I keep getting 'Index exceeds matrix dimensions.' No matter what I try. This is what my code looks like:</p><p>y=[1 2 4;3 2 -1;2 4 5; -2 -1 10]</p><p>x=y(12:-8:4,10:-8:3)</p>Fred Umbachhttps://de.mathworks.com/matlabcentral/profile/authors/12196760-fred-umbachtag:de.mathworks.com,2005:Question/3839012018-02-21T07:02:22Z2018-02-21T07:14:02ZWrite permission error while creating instrument driver-using makemid (line 155)<p>I am trying to generate a MATLAB instrument driver for Keithley 2450. When I use makemaid it gives an error and I couldn't understand what causes this error. The Error is:
"Error using makemid (line 155)
The driver file could not be written. Verify that you have write permissions in the output file or directory."</p>Rawdha Ameenhttps://de.mathworks.com/matlabcentral/profile/authors/10689272-rawdha-ameentag:de.mathworks.com,2005:Question/3831252018-02-16T16:51:09Z2018-02-21T07:13:24Zvector length different interval problem<p>I am having trouble making two equations vary over different intervals. I need v to go up to 950 i know why its not working i just dont know how to fix it. M on the x axis should go up to about 0.9.</p><p>What i am wondering is how would i make a for loop for both the height h and the velocity with when both are changing?</p><pre> clc,clear</pre><p>T0=46500;
a=994.71;
T_SSL=518.69;
rho_SSL=0.002377;
m=0.6;
g=32.2;
R=1716;
aL=-0.003563;
x = g./(a.*R);
h0=0.0;</p><p>Z=h0:5000:45000;
W=50:10:950;
for i = 1:numel(Z)
h(i) = Z(i);
v(i) = W(i);</p><pre> T(i) = T_SSL+aL*h(i);
rho(i) = rho_SSL*((T(i)/T_SSL)^-(x+1));
TH2(i)=T0*(rho(i)/rho_SSL)^m;</pre><pre> M(i) = v(i)/a;
end</pre><p>plot(M,TH2);</p><p>xlabel('Mach Number');
ylabel('Thrust Available (lb)');
title('Thrust Available vs Mach Number');</p>Austen Thomashttps://de.mathworks.com/matlabcentral/profile/authors/9233302-austen-thomastag:de.mathworks.com,2005:Question/3813752018-02-07T21:38:10Z2018-02-21T07:06:47ZX is an array of x coordinates of a sine wave which is a function of time(t). X contains data points that are not equally spaced like t. How do I convert the X array to equally spaced array and find corresponding (t) for new points?<p>angle=0:2*pi/20:2*pi;
t=0:2/20:2;
X=(5*sin(angle)+2*t);</p><p>Using the data obtained from X, I want to modify the array to equally spaced x values. Using those x values, I want to find new times of those each equally spaced x values.</p>Akshay Patelhttps://de.mathworks.com/matlabcentral/profile/authors/11012491-akshay-pateltag:de.mathworks.com,2005:Question/1559762014-09-24T04:16:06Z2018-02-21T06:50:46ZHow to remove background from an image?<p>I want to know how to remove background from an image and edge detection of the rest of the image</p>Opencvhttps://de.mathworks.com/matlabcentral/profile/authors/5653397-opencvtag:de.mathworks.com,2005:Question/3811392018-02-06T18:05:29Z2018-02-21T06:48:53ZNon linear fit & error propagation<p>Dear Mathworks community,</p><p>I am currently facing the following problem :
I have a set of data, X, and Y. I know that the uncertainty on Y is given by its square root.
I want to use possibly a non linear fit to fit a gaussian function to it. I would like to propagate the error through the fit and take into account the fact that I know that there is an uncertainty on the measurement.</p><p>How is this possible with matlab ?</p><p>Cheers</p>Virgile Favrehttps://de.mathworks.com/matlabcentral/profile/authors/3708252-virgile-favretag:de.mathworks.com,2005:Question/1207372014-03-09T06:08:27Z2018-02-21T06:37:46ZHow to set default aspect ratio of 2D-3D plot in Matlab<p>Hi ,</p><pre> How can I set pbaspect([2.5 3.5 1]) in the startup.m file for every plot?
Thanks,</pre>John Aunghttps://de.mathworks.com/matlabcentral/profile/authors/3169386-john-aungtag:de.mathworks.com,2005:Question/3834472018-02-19T07:06:30Z2018-02-21T06:37:29ZCombine multiple if statements for something more compact<p>Friends,</p><p>I'm trying to refine my code.It works fine but I have four if conditions which I want to make more efficient. Is there an alternative way to do it?</p><pre class="language-matlab">i=1;
while (VMPH<=60)
% Vehicle speed
t(i+1) = t(i)+delt;
Vmps(i+1) = Vmps(i)+((delt*(Facc(i)))/Vm);
VMPH(i+1) = Vmps(i+1)/0.44704;
% Vehicle forces
Fr(i+1) = Fr(1);
Fd(i+1) = 0.5*Af*Cd*(Vmps(i+1))^2;
% Speed conditions
ig(i+1) = 3.78;
N(i+1) = Vmps(i+1)*io*ig(i+1)*60/(pi*Dt);
if N(i+1) > 2150
ig(i+1) = 2.06;
N(i+1) = Vmps(i+1)*io*ig(i+1)*60/(pi*Dt);
end
if N(i+1) > 2150
ig(i+1) = 1.58;
N(i+1) = Vmps(i+1)*io*ig(i+1)*60/(pi*Dt);
end
if N(i+1) > 2150
ig(i+1) = 1.21;
N(i+1) = Vmps(i+1)*io*ig(i+1)*60/(pi*Dt);
end
if N(i+1) > 2150
ig(i+1) = 0.82;
N(i+1) = Vmps(i+1)*io*ig(i+1)*60/(pi*Dt);
end
</pre><pre> % Power and performance
Tao_b(i+1) = interp1(Speed,Torque,N(i+1));
Tao_w(i+1)= Tao_b(i+1)*io*ig(i+1)*etadrive;
Ft(i+1) = Tao_w(i+1)/Dt*2;
Pb(i+1) = 2*pi*Tao_b(i+1)*N(i+1)/60;
% Acceleration force
Facc(i+1) = Ft(i+1)-Fd(i+1)-Fr(i+1);
i=i+1;
end</pre><p>Thank You!</p>DIPhttps://de.mathworks.com/matlabcentral/profile/authors/7881208-diptag:de.mathworks.com,2005:Question/3838942018-02-21T06:06:34Z2018-02-21T06:30:53ZHow to create a vector of randomly selected elements from a matrix?<p>I am trying to create a one dimensional vector of size n from randomly selected elements of a matrix. I am not trying to select a random row or a random column from the matrix. I am just trying to create a vector from random matrix elements and have the size of my vector determined. For example:</p><p>A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15];</p><p>And I'm looking for something like the following if I wanted a vector of size 6:</p><p>B = [15 2 13 8 1 10]</p><p>I tried using "datasample" but that just created another 2D matrix instead of a one dimensional vector. Any ideas?</p><p>Thanks for the help!</p>virkuz000https://de.mathworks.com/matlabcentral/profile/authors/7669973-virkuz000tag:de.mathworks.com,2005:Question/3838962018-02-21T06:19:36Z2018-02-21T06:21:19Zdifficulty in printing for 'cell' inputs. <p>I have a text file having sentences.I want to edit and print each sentence in a new line .I successfully edited but find difficulty in printing</p><pre class="language-matlab">fid1=fopen('edited_sentences_program3.txt','r');
fid2=fopen('edited_sentences_program4','w');
while ~ feof(fid1)
new_line = fgetl(fid1);
a=new_line;
b=strsplit(a);
c=[b(end) b];
c(end)=[];
fprintf(fid2,'%s\n',c)
end
fclose(fid1);
fclose(fid2);
</pre><p>when I run the code ;error is</p><pre class="language-matlab">"Function is not defined for 'cell' inputs." for line fprintf(fid2,'%s\n',c)
</pre>muaz shaikhhttps://de.mathworks.com/matlabcentral/profile/authors/11945048-muaz-shaikhtag:de.mathworks.com,2005:Question/3838952018-02-21T06:08:15Z2018-02-21T06:08:15Zhow to build a gui that upload excel file and then calculate trendline acording to dates that the user wants<p>i got a small task for college to build a gui that upload excel file . then calculat trendline acording to specific dates the the user put in in the gui plus i need to put an option of time there...short tem lets sey a month or long term lets sey a year. so pleas can some one help me ? i need to do it in 3 days.</p>rayen chausohttps://de.mathworks.com/matlabcentral/profile/authors/9926506-rayen-chausotag:de.mathworks.com,2005:Question/3838722018-02-21T04:25:03Z2018-02-21T06:05:05ZMatrix Dimensions must agree using integral<p>Hello all,</p><p>I am trying to integrate over a function.</p><pre class="language-matlab">% calculation of f(b)
b = exp((-q*Vj)/(2*kB*Temp))*cosh((Et-Ei)/((kB*Temp)+0.5*(log(tau_p0/tau_n0))));
% integrate over x while varying b
fcn_b = zeros(1,length(b));
fcn = @(x)1./((x.^2)+(2.*b.*x)+1);
fcn_b = integral(fcn,0,Inf);
end
</pre><p>But I receive an error after the fcn = @x line saying matrix dimensions must agree.</p><p>The size of b => 1 x 141. Any help would be appreciated.</p>atsprinkhttps://de.mathworks.com/matlabcentral/profile/authors/3264689-atsprinktag:de.mathworks.com,2005:Question/3838862018-02-21T05:37:03Z2018-02-21T06:02:53ZCNN with data_set<p>Hi,</p><p>I want to train CNN with 2 channel data set which is stored in a cell array in a .mat file. have 4 such mat files in 4 folders which are used for labelling. I want to read those cellarray data from the mat files using imageDatastore. I was able to read the entire mat file, but I am having trouble reading the cell array data, which are actually the inputs for my training.
Would anyone able to help me regarding this.</p><p>Thanks in Advance.</p>SRUTHY SKARIAhttps://de.mathworks.com/matlabcentral/profile/authors/9895132-sruthy-skariatag:de.mathworks.com,2005:Question/3497962017-07-21T22:52:08Z2018-02-21T06:01:28Zhow to simulate radar echo signal with time delay and doppler shift without using phased array toolbox if the direct signal is 16-ary QAM modulated<p>simulation of radar echo signal without using matlab toolbox</p>Siva Priya Radha Lakshmindranhttps://de.mathworks.com/matlabcentral/profile/authors/9354798-siva-priya-radha-lakshmindran