https://au.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-01-23T04:05:51Ztag:au.mathworks.com,2005:Question/3782492018-01-22T01:27:19Z2018-01-23T04:04:09ZHelp search index not found<p>Being a novice I have been using the help documentation frequently as I learn how to do what I want!</p><p>Suddenly, I started getting the error:</p><p><i>Search index not found</i></p><p>when searching the documentation on my laptop installation.
I started using my PC installation instead to search the help pages but since today get the same error message! In both cases I can still browse the documentation - I just can't search it anymore.</p><p>I have no idea what could have caused this on both systems. Maybe there was a Windows update that causes problems?</p><p>I have Matlab R2017b (9.3.0.713579) on both machines running Windows 7 with an academic license.</p><p>Does anyone know how to restore the search index?</p><p>Thanks</p>Gareth Jenkinshttps://au.mathworks.com/matlabcentral/profile/authors/2097363-gareth-jenkinstag:au.mathworks.com,2005:Question/3780992018-01-20T10:49:34Z2018-01-23T03:59:26ZI am having problem in login page when connected with database and the error is Cell contents reference from a non-cell array object.<p>the below code is of login page.</p><p>//x and y are the information that the user will enter i.e login id and password</p><pre class="language-matlab">global x;
</pre><pre class="language-matlab">global y;
</pre><pre class="language-matlab">x = get(handles.edit1,'String');
</pre><pre class="language-matlab">y = get(handles.edit2,'String');
</pre><pre class="language-matlab">if isempty(x)
</pre><pre> msgbox(sprintf('Enter Email id first'),'Error','Error');</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">if isempty(y)
</pre><pre> msgbox(sprintf('Enter passsword'),'Error','Error');</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">conn = database('watermar_db','root','');
</pre><pre class="language-matlab">sqlquery = 'select uname,pwd from user';
</pre><pre class="language-matlab">curs = exec(conn,sqlquery);
</pre><pre class="language-matlab">setdbprefs('DataReturnFormat','structure');
</pre><pre class="language-matlab">curs = fetch(curs);
</pre><pre class="language-matlab">usernamePwdData = curs.Data;
</pre><pre> validUser = false;</pre><pre> for k=1:length(usernamePwdData)</pre><pre> uname = usernamePwdData{k,1}; //the error is coming while executing this line.</pre><pre> pwd = usernamePwdData{k,2};</pre><pre> if strcmp(uname,x) && strcmp(pwd,y)</pre><pre> validUser = true;</pre><pre> break;</pre><pre> end</pre><pre> end</pre><pre> if validUser == true</pre><pre> Option</pre><pre> else</pre><pre> msgbox('wrong pwd');</pre><pre> end</pre>Ujwal Kumarhttps://au.mathworks.com/matlabcentral/profile/authors/10602099-ujwal-kumartag:au.mathworks.com,2005:Question/3635592017-10-27T06:42:27Z2018-01-23T03:59:04Zparfor fails with loop indices being uint64<p><a href = "https://www.mathworks.com/help/distcomp/parfor.html#bvi_72t-3">Documentation on <tt>parfor</tt></a> says that the loop indices can be of type <tt>uint64</tt>.</p><p>But with the following code, parfor fails. Either setting N to <tt>uint64(100)</tt> or changing the type of N to <tt>double/uint32</tt> makes the code work. <b>Is this a bug?</b></p><pre class="language-matlab">N = uint64(50);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% fail
</pre><pre class="language-matlab">N = uint64(100);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% work
</pre><pre class="language-matlab">N = uint32(50);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% work
</pre><pre class="language-matlab">N = 50;
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% work
</pre><p>The error report is</p><pre class="language-matlab">An UndefinedFunction error was thrown on the workers for 'A'.
This might be because the file containing 'A' is not
accessible on the workers. Use addAttachedFiles(pool, files)
to specify the required files to be attached. See the
documentation for 'parallel.Pool/addAttachedFiles' for more
details.
</pre><pre class="language-matlab">Caused by:
Undefined function or variable 'A'.
</pre>Eli4phhttps://au.mathworks.com/matlabcentral/profile/authors/7740610-eli4phtag:au.mathworks.com,2005:Question/1027872009-06-27T01:12:00Z2018-01-23T03:53:31ZHow do I save the output of a Maple command for subsequent usage in the Symbolic Math Toolbox 3.2.3 (R2008a)?<p>I am calling the 'minimax' Maple function using the MAPLE command in the Symbolic Math toolbox as follows:</p><pre class="language-matlab">result = maple('minimax(x -> exp(x), 0..1, [3,3], x -> 1/exp(x), ''maxerror'')')
</pre><p>The MAPLE function returns the following string in variable 'result':</p><pre> result =</pre><pre> f := x -> (1.2602800445888353170924366790497+(.66158210209444427227482310507910+(.14246093837255028787615147350931+.13527434224563229808331124195992e-1*x)*x)*x)/(1.2602800461150506916370546709863+(-.59869809320400732192202261234153+(.11102133762163519871251090606741-.82048035877127366183518546907472e-2*x)*x)*x) </pre><p>I would like to be able to retrieve the symbolic result of the call to 'minimax' in Maple and evaluate the resulting rational polynomial function in MATLAB without resorting to a cut-and-paste operation.</p>MathWorks Support Teamhttps://au.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:au.mathworks.com,2005:Question/3350922017-04-12T04:00:00Z2018-01-23T03:53:14ZCan I use Microsoft Visual Studio 2017 with MATLAB?<p>Can I use Microsoft Visual Studio 2017 compilers with MATLAB R2017a or R2016b?</p>MathWorks Support Teamhttps://au.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:au.mathworks.com,2005:Question/3784792018-01-23T03:44:44Z2018-01-23T03:52:34ZI have this script I am doing iteration for x(i) and f(i) but did not work <pre class="language-matlab">i=1
x(i)=4.6*20/2
error(i)=9999
f(i)=789
while error(i) <0.1
u(i)=f(i)*18
g(i)=f(i)*19/x(i)
f(i+1)=u(i)/(28888^2)
x(i+1)=g(i)*20/2
error(i+1)=abs((((x(i+1)-x(i))/x(i+1))*100))
i=i+1
end
x
</pre>Osama Brinjihttps://au.mathworks.com/matlabcentral/profile/authors/1943412-osama-brinjitag:au.mathworks.com,2005:Question/3784822018-01-23T03:50:54Z2018-01-23T03:50:54Zhow to clear this error?<p>Error: File: file.m Line: 103 Column: 1</p><p>Function definitions are not permitted in this
context.</p><pre class="language-matlab">if true
103.function z = myfunction(Ns,8)
104.c = Ns;
105.d= 8;
106.z =f(c, d)
107.end
108.function z = f(c,d)
109. if ~mod(c,d)
110. z=0
111. else
112. z=d-mod(c,d);
113. end
114. end
</pre><p>115. end</p>PLACEIUS NISHIGA Ghttps://au.mathworks.com/matlabcentral/profile/authors/11796944-placeius-nishiga-gtag:au.mathworks.com,2005:Question/3784602018-01-23T00:46:40Z2018-01-23T03:50:32ZHow can I get gif images from the 300 by 300 raw pixels .txt files?<p>Hi I am trying to make a gif files from the amount of 500 text files.
text files are saved like matrices such as
1.023000000000000000e+03 9.000000000000000000e+00 1.300000000000000000e+01
9.420000000000000000e+02 9.270000000000000000e+02 8.600000000000000000e+01
7.620000000000000000e+02 7.680000000000000000e+02 7.590000000000000000e+02
and I want to make only one gif files included 500 txt files.
Also, I want to make scale bar and automatic range(find minimum and maximum value and set that the minimum and maximum during the play.</p><p>Please start at opening the text files!</p>Jungbae Yoonhttps://au.mathworks.com/matlabcentral/profile/authors/9721324-jungbae-yoontag:au.mathworks.com,2005:Question/3784612018-01-23T00:47:18Z2018-01-23T03:49:13ZHow to sum specific values from a loop and create a new vector?<p>If I have this matrix M:</p><pre> a=1:1:20;
b=[0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 2 0 0];</pre><pre> M=[a,b];</pre><p>How could I find the i values where M(:,b)>0 (where the second column "b">0), and then take the values of the same row but the first column "a" M(a,:) and make a summation from that row i and i-2, i,e, [i + (i-1)+(i-2)].. like this:</p><pre> X=[(5+6+7) (12+13+14) (18+17+16)] = [18 39 51]</pre><p>Besides a vector Y which contains the summation from i-5 until i-3 like this:</p><pre class="language-matlab">Y=[(2+3+4) (9+10+11) (13+14+15)] = [9 30 42]
</pre><p>Both of them for all i values in a vector b of a matrix.</p>Philippe Cornerhttps://au.mathworks.com/matlabcentral/profile/authors/7103813-philippe-cornertag:au.mathworks.com,2005:Question/3784672018-01-23T01:21:42Z2018-01-23T03:47:36ZHi, I want to plot a 2D graph and make it look like a 3D graph. my 2 XY variables are vectors of the same length, I'm varing my 3D variable( length different from the X and Y vectors length) is that any way to do that ? <p>Hi, I want to plot a 2D graph and make it look like a 3D graph. my 2 XY variables are vectors of the same length, I'm varing my 3D variable( length different from the X and Y vectors length). plot3 or mechgrid can not be applicable to my applicaton, is that any way to do that ?
Thank you</p>Khedidja Ayache https://au.mathworks.com/matlabcentral/profile/authors/6753588-khedidja-ayachetag:au.mathworks.com,2005:Question/3784812018-01-23T03:46:12Z2018-01-23T03:46:12ZHow do I plot the different force values that get calculated in the loop? (This is an equation for the charge of a uniformly charged hoop)<p>x = [0:100]
r = 10;
X = r * x
Ef = zeros(length(X),1);
% defines Coulomb's constant
k = 8.99*10^9;
% defines the points
Q = (2*pi*r);
for n = [X]
Ef = [((k*n)/(n^2+r^2).^(3/2))];
force1 = Ef * Q
end
force1
Y=[force1]
semilogx(X,Y,'b*')</p>Julian Quinterohttps://au.mathworks.com/matlabcentral/profile/authors/9537707-julian-quinterotag:au.mathworks.com,2005:Question/3784712018-01-23T02:17:04Z2018-01-23T03:45:46ZPlot two outputs (or two columns of one output) of a function against each other using only one line of script in an anonymous function<p>I have the following anonymous functions (this is a much-simplified version for the sake of asking this question) that both produce a new x and y array, which I'd like to plot in a single command (so it can be called within another anonymous function). Function @xy1 outputs two arrays (x and dy), while function @xy2 outputs a single array with x and dy as columns. It doesn't matter which approach is used, they're just the two methods I can come up with and I'm hoping one of them is do-able.</p><pre class="language-matlab">x=[1:10]';
y=rand(10,1);
</pre><pre class="language-matlab">xy1=@(x,y) deal(diff(y)./diff(x), x(1:end-1)+diff(x)./2);
xy2=@(x,y)[diff(y)./diff(x) x(1:end-1)+diff(x)./2];
</pre><pre class="language-matlab">[xnew,dy]=xy1(x,y);
xy=xy2(x,y);
</pre><p>I'd like to get the new x and dy arrays to plot as they would if you used plot(xnew,dy), but I need them to plot directly from the function call, something like:</p><pre class="language-matlab">newfunction1=@(x,y) plot(xy1(x,y));
</pre><p>or</p><pre class="language-matlab">newfunction2=@(x,y) plot(xy2(x,y)(:,1),xy2(x,y),(:,2));
</pre><p>Obviously these don't work, but I'm looking for a way to do something similar. Any suggestions would be appreciated. Thanks!</p>dandanhttps://au.mathworks.com/matlabcentral/profile/authors/6445507-dandantag:au.mathworks.com,2005:Question/3784802018-01-23T03:45:04Z2018-01-23T03:45:04ZError in port widths or dimensions <p>I am using Robotics System toolbox to publish direct motor commands (Angular velocities=[v1,v2,v3,v4]) for a quadrotor (rotors simulator) as following</p><img src = "/matlabcentral/answers/uploaded_files/102133/1.png"><p>I got the following error</p><p>Error in port widths or dimensions. Output port 1 of 'pelican/Command Velocity Publisher/Mux' is a one-dimensional vector with 4 elements.
Component: Simulink | Category: Model error
Error in port widths or dimensions. Input port 2 of 'pelican/Command Velocity Publisher/Bus Assignment1' is a one-dimensional vector with 128 elements.</p><p>when I publish through the terminal using rospub it works fine</p><p>rostopic pub /pelican/command/motor_speed mav_msgs/Actuators '{angular_velocities: [100, 100, 100, 100]}'</p><p>I tried to manage the array sizes for ROS msgs in Simulink from 128 to 4 :</p><img src = "/matlabcentral/answers/uploaded_files/102134/2.png"><p>in this case, Simulink running without error, but I got a new error and gazebo simulator shutdown,</p><img src = "/matlabcentral/answers/uploaded_files/102135/3.png"><p>Thanks in advance</p>oualid doukhihttps://au.mathworks.com/matlabcentral/profile/authors/8762223-oualid-doukhitag:au.mathworks.com,2005:Question/3784732018-01-23T02:45:42Z2018-01-23T03:43:05ZHow to get maxima that are not on a current datapoint?<p>Hi all,</p><p>I am trying to find the position of major infliction points in a signal. I know there are 2 main infliction points in the signal within the range I am looking at. I am writing a function that pulls these out, which in itself finds them (see below). However, these points are always located on one of the X-values in the dataset. I would like to find them on the actual position if one where to have a continuous line through the data.</p><p>I tried using the <i>interpo1</i> function, on the signals using method <i>pchip</i>, creating 10 times as many points. But when I run that data through the routine, still the calculated maxima are located on the original datapoint location.</p><p>What could I be doing wrong?</p><pre class="language-matlab">function [peak] = JF_findpeaks(signatures, offset, startband, endband)
</pre><pre class="language-matlab">% how many spectra
numspectra = size(signatures(:,1));
</pre><pre class="language-matlab">% calculate the second derivative of the signatures
% Set window 5, fit second order spline, return second order derivatives
secondderivatives = JF_savitzky_derivative(signatures, 2, 5, 2);
</pre><pre class="language-matlab">% Subset to the range where we know the peaks are
data = secondderivatives(:,startband-offset:endband-offset);
</pre><pre class="language-matlab">% create the X-values
waves = startband:endband;
</pre><pre class="language-matlab">% now find the position of the two peaks in each signature that occurs in the data
for n=1:numspectra
[pksw,locsw] = findpeaks(data(n,:), waves, 'MinPeakProminence',0.00001);
end
</pre><pre class="language-matlab">end
</pre>Jellehttps://au.mathworks.com/matlabcentral/profile/authors/586239-jelletag:au.mathworks.com,2005:Question/3784622018-01-23T00:48:46Z2018-01-23T03:38:58ZIs there a search algorithm I can apply to a dataset that I do not have a specific F(x,y) function for?<p>Hello,</p><p>I am looking for the best search algorithm for the following set of data:</p><p>I have a set of temperature values T(x,y) which I want to find a minimum of; it is important to note that I do not have a specific function (such as T(x,y)= x^2+y^2), just the points. I haven't found a search function that works on raw data (without a function handle), but I'm a little out of my element so I may have misunderstood the documentation.</p><p>What I would like to do is to have the algorithm start at the maximum T value, then show the path it takes to the minimum T value. I want to be able to overlay the path on data for presentation. For what it's worth, the data is relatively well behaved, so there is a well defined global maximum and few peaks between the maximum and minimum.</p><p>Thank you for any direction you can offer,</p><p>Matt</p><p>Edit1: This does take place on a square grid.</p>Matthewhttps://au.mathworks.com/matlabcentral/profile/authors/2248265-matthewtag:au.mathworks.com,2005:Question/3784782018-01-23T03:32:43Z2018-01-23T03:32:43ZUndefined function or variable 'hObject' in app designer<pre> [filename, pathname] = uigetfile('*.mp3', 'Select audiofile');
[a,fs]=audioread([pathname filename]);
handles.B1 = audioplayer(a,fs);
play(handles.B1);
guiData(hObject,handles);</pre><p>I have this code and it keep telling me that the hObject is undefined. I want to use it for a push button, so that when I click the button, it will let me to select a sound file and play it. I know I need to use guidata function to save it in order to play it. However, I don't really know how to use it, like how to create an hObject in order to make it work properly.</p>Chunhui Guohttps://au.mathworks.com/matlabcentral/profile/authors/10911264-chunhui-guotag:au.mathworks.com,2005:Question/3783742018-01-22T15:42:35Z2018-01-23T03:30:28Zi have divided the image into blocks now, i want to access each block individually and i compute histogram how do i access each block <pre class="language-matlab">a=imread(img);
subplot(4,3,2)
imshow(img)
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
[r, c, numOfBands] = size(a);
%dividing image into 8x8 subblocks
bs=8;%block size
nob=(r/bs)*(c/bs);%Total no of blocks
k=0;
for i=1:(r/bs)
for j=1:(c/bs)
Block(:,:,k+j)=a((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs));
end
k=k+(r/bs);
end
</pre>teja jayavarapuhttps://au.mathworks.com/matlabcentral/profile/authors/11914075-teja-jayavaraputag:au.mathworks.com,2005:Question/3784772018-01-23T03:28:30Z2018-01-23T03:29:34ZI have a power density plot with the below matlab code. I want to find the 3dB bandwidth of it. Can someone help me to solve this matter<pre class="language-matlab">%%PARAMETERS
D = 1*10^6;
vi = 10^6;
r = 10^4;
</pre><pre class="language-matlab">%%RANGE
w = linspace(0.9*10^6,1.1*10^6,211);
</pre><pre class="language-matlab">%%EQUATION
b = 0.7;
syms m n;
Y1 = (((D/(4.*b))^m)*((2*m.*b)+(r/2)))./(factorial(m)*(((2*m.*b)+(r/2))^2+(w-vi).^2));
Y = symsum(Y1, m, 0, 10);
</pre><pre class="language-matlab">%%PLOT
plot(w-vi,Y,'blue');
xlabel('Frequency Detuning (Hz)');
ylabel ('Relative Power Density');
</pre>SriMiGSShttps://au.mathworks.com/matlabcentral/profile/authors/8806197-srimigsstag:au.mathworks.com,2005:Question/3781942018-01-21T12:03:45Z2018-01-23T03:28:27ZHow can I remove big rectangle , which contains small rectangle?<p>I want to remove the rectangles, which contain small rectangles with specific sizes. The big rectangle marked by arrow..</p><img src = "/matlabcentral/answers/uploaded_files/101906/dddd.png">K M Ibrahim Khalilullahhttps://au.mathworks.com/matlabcentral/profile/authors/7463294-k-m-ibrahim-khalilullahtag:au.mathworks.com,2005:Question/3784112018-01-22T18:12:50Z2018-01-23T03:27:04ZPlotting the case of iteration<p>in the code below I want to see the plot has the names of all the cases of "0.1 to 1" each line indicates case; feature (0.1), feature (0.2) and so on till feature (1.0).</p><pre class="language-matlab">L =0.1:0.1:1.0;
tot=numel(L);
for i=1:tot
plot(x+i,y+i,'Color');
</pre><pre> nam{i} = sprintf('feaures (%d)',i);</pre>Najiya Omarhttps://au.mathworks.com/matlabcentral/profile/authors/6880491-najiya-omartag:au.mathworks.com,2005:Question/3388092017-05-05T01:18:02Z2018-01-23T03:25:19ZFinding x,y coordinates of pixel by RGB color value<p>Hi,
Is there a reverse impixel function? I want to find the x and y coordinates of pixels in a color image by searching for them only with a RGB color value.
I have tried converting into a binary image and searching for the '1' values by using</p><p>BW = im2bw(RGB, level)</p><p>and then [rows,cols] = find(BW==1);</p><p>but I am confused on how to set a level to implement an RGB value so that only my specific color pixels will show up as white in the binary image.</p><p>Is there a better way to find the coordinates of pixels only by using RGB value?</p><p>thanks!</p>Aa Mhttps://au.mathworks.com/matlabcentral/profile/authors/10264504-aa-mtag:au.mathworks.com,2005:Question/3784762018-01-23T03:23:13Z2018-01-23T03:23:13ZLSTM for data prediction <p>Hi, I am doing a program for prediction using lstmLayer. For example,</p><p>input = [2.49810000000000;1];[2.10350000000000;0];[3.09650000000000;0];[3.81500000000000;0];[13.1828000000000;0];19.4358000000000;0];[15.8167000000000;0];[13.8152000000000;0];[11.6463000000000;0];[13.8282000000000;0];[12.9633000000000;0];[18.1005000000000;1];[22.5192000000000;0];[15.7932000000000;1];[11.6019000000000;1];[6.75210000000000;1];[11.9233000000000;0];[15.1086000000000;0];[34.5000000000000;0];[29.8018000000000;0];[21.7118000000000;0];[16.1591000000000;1];[7.30350000000000;1];[5.43510000000000;1]</p><p>expectedOutput = [-4.64682000000000e-15;0;0;0;3.84368400000000;1.09669700000000;6.47763100000000;4.43292000000000;2.04262700000000;3.81629800000000;3.53217500000000;-0.290735500000000;3.25944900000000;-3.41447200000000;-7.10655400000000;-11.7593800000000;2.06697600000000;5.41984200000000;14.1654800000000;11.4626400000000;3.37265600000000;-2.18005900000000;-11.0356600000000;-12.9039900000000]</p><p>Command:
layers = [ ...
sequenceInputLayer(2)
lstmLayer(100,'OutputMode','last')
fullyConnectedLayer(1)
softmaxLayer
classificationLayer]</p><p>option = trainingOptions('sgdm','MaxEpochs',100);</p><p>net = trainNetwork(input,expectedOutput,layers,option);</p><p>MATLAB message: Error using trainNetwork (line 140)
Invalid training data. Responses must be a vector of categorical responses, or a cell array of categorical
response sequences.</p><p>Caused by:
Error using nnet.internal.cnn.util.TrainNetworkDataValidator/assertValidSequenceResponse (line 279)
Invalid training data. Responses must be a vector of categorical responses, or a cell array of categorical
response sequences.</p><p>The data type of the input is cell and the output is double. However, the error remain exist and the prediction of the program is failed. How can I do the prediction for my case?</p>Soon Kok Yewhttps://au.mathworks.com/matlabcentral/profile/authors/6305584-soon-kok-yewtag:au.mathworks.com,2005:Question/3766262018-01-11T08:38:49Z2018-01-23T03:19:30ZHow to use Genetic Algorithm (GA) for multi-objective function (Dynamic Optimization)?<p>I need to optimize this multiobjective function using GA:</p><pre class="language-matlab">Z=min(2X+Y);
X= sum (a1+b1+c1-d1+(N1/S))
Y= sum (a2+b2+c2-d2+(N2/S))
</pre><p>All other variables are known (however, dynamically changed), excepted (b1,b2) which needed to optimized to get the optimal value of (Z)</p>Sherif Shokryhttps://au.mathworks.com/matlabcentral/profile/authors/10265505-sherif-shokrytag:au.mathworks.com,2005:Question/3784752018-01-23T03:05:04Z2018-01-23T03:05:04ZI get a Solver not found (mosek) warning while trying to run in matlab parallel code. Any help is appreciated.<p>I am using MOSEK solver in my MATLAB code with YALMIP interface. I try to use MATLAB Parallel Cloud and it returns Solver not found (mosek) error. How to resolve this issue?</p>Madhushini Narayana Prasadhttps://au.mathworks.com/matlabcentral/profile/authors/8690825-madhushini-narayana-prasadtag:au.mathworks.com,2005:Question/3780372018-01-19T20:40:05Z2018-01-23T02:49:23ZHow can I combine fields for two different structures in two different .mat files?<p>Hello,
I am trying to combine two structures saved in two different .mat files into one structure/.mat file.
I would like to end up with a new 1x1 structure containing the same fields and all the values within the fields for both original files.</p><p>My two files contain the same six fields (x, y, z, a, b, c) containing either cell or double (x,y,z are cell and a,b,c are double) with different dimensions.</p><p>I think I need to combine the fields and then create another structure from them, but I cannot figure out how to do this.</p><p>I think I may need to combine some vertically and some horizontally (1 x value vs. value x 1 dimension), which may be an issue.</p><p>Appreciate any help
Thank you,
Megan</p>Megan Laddshttps://au.mathworks.com/matlabcentral/profile/authors/9779307-megan-laddstag:au.mathworks.com,2005:Question/3783702018-01-22T15:36:13Z2018-01-23T04:05:51ZLoading a set of data from a txt file, plotting the data onto a spherical 3D plot (astronomy)<p>Hi, I am trying to import some star data in the form of a .txt file (notepad) which has a column of Right Ascension, and a second column of Declination. Here is an example:</p><pre> RA DEC
00 08.2 +29 04
00 09.0 +59 08
00 13.1 +15 10
00 25.4 -77 17
00 26.2 -42 20</pre><p>Then I am to plot the coordinates onto a spherical 3D graph (celestial sphere), I am new to matlab and I need some assistance on this, any help is appreciated. Please be gentle on the comments. Thank you =)</p>Goh Jia Manhttps://au.mathworks.com/matlabcentral/profile/authors/11985725-goh-jia-mantag:au.mathworks.com,2005:Question/3782732018-01-22T06:24:46Z2018-01-23T02:34:14Z3D bar plot with patterns<p>Hi, I have got to know great work for on "applyhatch" a 2D bar plot. (https://blogs.mathworks.com/pick/2011/07/15/creating-hatched-patches/?s_tid=srchtitle)</p><p>However, this seems applicable when we use bar function instead of bar3. I was wondering if there is a way to draw different patterns for bar3. For example, the attached picture, instead of different colors, I want different patterns ('/','+','d' et al). How could I achieve that? Thanks for your help!</p><p>output = [0,0.497,0.487,0.677,0.418;1,0.234,0.295,0.168,0.312;2,0.089,0.102,0.071,0.128;3,0.064,0.061,0.038,0.065;...
4,0.039,0.026,0.018,0.03;5,0.028,0.01,0.007,0.02;6,0.049,0.019,0.021,0.027];</p><p>figure (1);</p><p>bar3(0:1:6,output(:,2:end)*100);</p><p>ylim([-0.5,6.5]);zlim([0,70]);</p><p>ylabel('Number of choices');zlabel('%Frequency');</p><p>set(gca,'YTickLabel',{'0','1','2','3','4','5','6+'});</p><p>set(gca,'XTickLabel',{'G(1)-informed','G(1)-uninformed','G(2)-informed','G(2)- uninformed'});</p>Yuanji Wenhttps://au.mathworks.com/matlabcentral/profile/authors/3166294-yuanji-wentag:au.mathworks.com,2005:Question/656862013-03-03T18:17:13Z2018-01-23T02:09:53Zdisplaying compound images acquired from multiple cameras on 1 figure/GUI<p>Hi
I am trying to preview a movie object that shows the difference image from 2 identical cameras. Eventually I want to create a GUI that shows either the sum image or the difference image. However, I can't seem to figure out if it's possible to create a video object from 2 video inputs. I tried using the setappdata command to create an UpdatePreviewWindowFcn that would take the difference between the 2 inputs, but the error message is not telling me what's wrong so I'm not sure how to fix. I am not sure if there is another way to modify the acquired data before previewing it other than updating the preview window function (via setappdata). Is there another way?</p><p>Alternatively, rather than previewing a video object I thought of reading the data and then just showing a movie. But here I am not sure how to order the commands such that each frame pair acquired by the 2 cameras becomes a frame in the movie that shows in real time.</p><p>Any tips on how to do this would be greatly appreciated. Please and Thank you. David</p>Davidhttps://au.mathworks.com/matlabcentral/profile/authors/4116918-davidtag:au.mathworks.com,2005:Question/3784692018-01-23T01:33:18Z2018-01-23T02:09:19ZDetermine whether a specific array element is already included in the large array<p>Dear all,</p><p>I want to check whether the specific array is already included in the target large array (for example, larger than > size(1e7, 5))</p><p>for example, if there is a target array 'arr' which is n*5 array which is quite large</p><pre class="language-matlab">arr = [0 0 0 0 0]
[0 0 0 0 1]
[0 0 0 1 0]
[0 0 1 1 0]
[0 1 0 0 1]
...
[19980 0 0 0 1]
[19980 0 1 0 1]
...
[30000 1 0 0 1]
</pre><p>I would like to check whether a new array element [19980 0 1 0 1] is in the target array.</p><p>Now I am iterating the rows of the arrays to check whether a new array element 'arr_temp' is equal to some line of target array,</p><pre> arr_temp = [k l m n e]; % our new array element 'arr_temp' with some specific value
tf = 0;
for m = 1:u % u is the row size of target array 'a'
tf = tf + isequal(arr(m,:), arr_temp); % check if arr_temp is in any [arr]
end
if (tf == 0) % if arr_temp is not in the [arr]
arr(u+1,:) = arr_temp;
u = u + 1; % increment u
end</pre><p>But it seems that this takes too long time (especially, if the size of target array is large,</p><p>Is there any other way which takes short time while checking whether a new array element 'arr_temp' is equal to some line of target array?</p><p>Thank you very much for your time.</p><p>Sincerely,
Lee.</p>Sang Hunhttps://au.mathworks.com/matlabcentral/profile/authors/3438951-sang-huntag:au.mathworks.com,2005:Question/3782582018-01-22T03:48:32Z2018-01-23T01:53:40ZDistortion with mfwdtran map projection<p>I'm plotting the footprints of buildings taken from the Open Street Maps data set. I've converted the lat and lon coordinates to Cartesian coordinates using mfwdtran. The buildings I'm plotting are in New York City so the UTM zone is set to 18T.</p><p>The building footprint is more distorted than I would like it to be. I assume the distortion is due to the large size of the UTM zone definition. Is there a way to refine the location of the map projection to reduce distortion?</p><p>Here is an example of the distorted building footprint. Note that the corners are not right angles:</p><img src = "/matlabcentral/answers/uploaded_files/101986/distorted.PNG">archlabhttps://au.mathworks.com/matlabcentral/profile/authors/9516783-archlabtag:au.mathworks.com,2005:Question/3784682018-01-23T01:28:17Z2018-01-23T01:49:31ZODE seemingly not starting at the initial conditions that I'm setting<p>Hi all,</p><p>So in this script I'm trying to solve an equation modelling how a particle is removed from a thin film. The equation is solving for y (the distance from a surface), where in turn diff(y,1) is the velocity of the particle.</p><p>For my model, I am making the assumption that the particle starts initially at rest. However, when plotting my graph the system seems to spike at t = 0 to a non-zero value. Any help as to why this is would be brilliant. Here is my script:</p><pre class="language-matlab">clc;
clear;
D0 = 22*10^-6; %Initial Separation
R = 3*10^-6; %Particle Radius
T = 15*10^-6; %Oil film thickness
CA = 60; %Contact Angle(Assumed Constant)
CAR = CA.*(pi/180); %Contact Angle in Radians
Zc = R/10; %Capillary Rise
rohp = 1400; %Particle Density
roha = 1.2;%Density of Air
roho = 900;%Density of Oil
g = 9.81; %Gravitational Acceleration
time = input('What length of time do you want to analyse?');
ttotal = time*60*60*24*30;
Cd = 0.1;
</pre><pre class="language-matlab">m = (4/3)*pi*(R.^3)*rohp; %Particle Mass
mew = 0.055;%Oil Viscosity
F0 = m*9.81; %Particle Weight
surf = 30*10^-3; %surface tension between oil and air
</pre><pre class="language-matlab">syms y(t)
eqn = m.*diff(y,2)== F0 - 6.*pi.*mew.*(R.^2).*(1./y).*diff(y,1);
</pre><pre class="language-matlab">V = odeToVectorField(eqn)%breaking down into first order ODE's
</pre><pre class="language-matlab">M = matlabFunction(V,'vars',{'t','Y'})
sol = ode15s(M,[0 time],[D0 0]);
figure
tValues = linspace(0,time,1000);
yValues = deval(sol,tValues,1);
vValues = deval(sol,tValues,2);
subplot(2,1,1)
plot(tValues,abs(yValues),'LineWidth',2);
title('Separation');
xlabel('Time (s)');
ylabel('Separation Distance (m)');
subplot(2,1,2);
plot(tValues,abs(vValues),'r','LineWidth',2);
title('Velocity');
xlabel('Time(s)');
ylabel('Velocity (m/s)');
</pre><p>So there you go, if you plot and assess the graph you should see what I mean. Any help would be much appreciated, cheers.</p>Peterhttps://au.mathworks.com/matlabcentral/profile/authors/9450644-petertag:au.mathworks.com,2005:Question/559302012-12-06T17:25:00Z2018-01-23T01:31:56Zhow to make communication between matlab and modbus-tcpip using Twido plc?<p>I used the command networkrole but I could not make placing matlab communication as server and as client plc</p>Julio Mendezhttps://au.mathworks.com/matlabcentral/profile/authors/3866241-julio-mendeztag:au.mathworks.com,2005:Question/3784372018-01-22T21:30:56Z2018-01-23T01:24:42ZUsing flipud Function?<p>Hi Everybody,</p><p>I am trying to save images but the outputs images were overturned (up down and down up). Therefor I used flipud but it isn't work.</p><p>Thank you in advance</p><p>Reyadh</p><pre class="language-matlab">if true
cd C:\Calculated_NDVI_Arcgis
dinfo = dir('*_B3*.tif');
nfile = length(dinfo);
filenames = {dinfo.name};
for K = 1 : nfile
b3_file{K} = filenames{K};
band_pos{K} = strfind(b3_file{K}, '_B3');
b4_file{K} = b3_file{K}; b4_file{K}(band_pos{K} + 2) = '4';
b3_data{K} = double( imread(b3_file{K}) );
b4_data{K} = double( imread(b4_file{K}) );
finalndvi{K} = (b4_data{K} - b3_data{K}) ./ (b4_data{K} + b3_data{K});
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R = georasterref('RasterSize',size(finalndvi{K}),'LatitudeLimits',[30.95115,31.76385],'LongitudeLimits',[46.58315,47.43285]);
R= flipud(R);
geotiffwrite(sprintf('%d.tif',K),finalndvi{K},R);
end
</pre>Reyadh Albarakathttps://au.mathworks.com/matlabcentral/profile/authors/8617663-reyadh-albarakattag:au.mathworks.com,2005:Question/3784652018-01-23T01:00:55Z2018-01-23T01:21:47ZHow to looking for min and max value of curve<p>First of all, im sorry for my bad English.</p><p>I want to ask, I have a lot of elevation data for tide and the type of that tide is semidiurnal.
like this picture</p><img src = "/matlabcentral/answers/uploaded_files/102124/tide07b.gif"><p>I have to know the value of high tides and low tides.
I cant use min and max because there are two times for high and low tides.
I hope someone can help me to solve this.</p>Jonathan Wijayahttps://au.mathworks.com/matlabcentral/profile/authors/11991171-jonathan-wijayatag:au.mathworks.com,2005:Question/3784632018-01-23T00:52:05Z2018-01-23T01:18:48ZHow do I find the range of a vector?<p>I entered "range(vector)" and it says there was an error and I was wondering how I find the range of this vector</p>Tyler Riggerthttps://au.mathworks.com/matlabcentral/profile/authors/11941380-tyler-riggerttag:au.mathworks.com,2005:Question/3784662018-01-23T01:03:20Z2018-01-23T01:14:35ZUsing a for loop to generate multiple arrays with variables<p>I am trying to use a for loop to generate multiple arrays using a linspace function. So the data I have imported looks like this.</p><pre class="language-matlab">Volume Mix Max
.25 .0015 5000
.50 . .0018 8000
</pre><p>I am trying to create a linspace for each of the volumes starting from zero and going the max with about 1000 points in between but I want to use a loop or another function to create them all. Then use those arrays and substitute them into different functions (Engineering equations).
The linspace should be linspace(0,max,100) for each volume (there are actually about 15 of them) but I don't know how to put it in a loop or store them.</p>Steven Mancinihttps://au.mathworks.com/matlabcentral/profile/authors/7310778-steven-mancinitag:au.mathworks.com,2005:Question/3783362018-01-22T12:43:26Z2018-01-23T01:13:27ZUndefined function or variable<p>that is the whole code which should get face detection with distance</p><pre> load('callast.mat');</pre><pre> double faceDetector();
vid = videoinput('macvideo', 1, 'YCbCr422_1280x960');%left
vid2 = videoinput('macvideo', 3, 'YCbCr422_1280x960');%right</pre><pre> triggerconfig([vid vid2],'manual');
vid2.FramesPerTrigger = 10;
vid.FramesPerTrigger = 10;</pre><pre class="language-matlab">start([vid vid2]);
pause(1)
</pre><pre> trigger([vid vid2]);</pre><pre> I1 = getsnapshot(vid);
I2 = getsnapshot(vid2);</pre><pre> % I1 = undistortImage(T1,stereoParams.CameraParameters1);
%I2 = undistortImage(T2,stereoParams.CameraParameters2);</pre><pre> faceDetector = vision.CascadeObjectDetector;</pre><pre> face1 = faceDetector(I1);
face2 = faceDetector(I2);</pre><pre> center1 = face1(1:2) + face1(3:4)/2;</pre><pre> center2 = face2(1:2) + face2(3:4)/2;</pre><pre> point3d = triangulate(center1, center2, stereoParams);
distanceInMeters = norm(point3d)/1000;</pre><pre> distanceAsString = sprintf('%0.2f meters', distanceInMeters);
I1 = insertObjectAnnotation(I1,'rectangle',face1,distanceAsString,'FontSize',18);
I2 = insertObjectAnnotation(I2,'rectangle',face2, distanceAsString,'FontSize',18);
I1 = insertShape(I1,'FilledRectangle',face1);
I2 = insertShape(I2,'FilledRectangle',face2);</pre><pre> imshowpair(I1, I2, 'montage');</pre><p>the error</p><pre> Undefined function or variable 'stereoParams'.</pre><pre> point3d = triangulate(center1, center2, stereoParams);</pre>ahmed nasrhttps://au.mathworks.com/matlabcentral/profile/authors/8930187-ahmed-nasrtag:au.mathworks.com,2005:Question/3382442017-05-01T04:00:00Z2018-01-23T01:12:08ZHow can I plot a confusion matrix for a multi-class or non-binary classification problem?<p>I want to make a plot similar to the confusion matrix created in the Classification Learner app. This can make a confusion matrix for a multi-class or non-binary classification problem. In addition, it can plot things such as a True Positive or False Negative rates.</p><p>How can I do this?</p>MathWorks Support Teamhttps://au.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:au.mathworks.com,2005:Question/3784642018-01-23T00:56:27Z2018-01-23T03:50:51Zhow to created and get data for use several action in pushbutton GUI?<pre class="language-matlab">%Sample code
</pre><pre class="language-matlab">function a_input_Callback(hObject, eventdata, handles)
</pre><pre class="language-matlab">input = str2num(get(hObject,'String'));
</pre><pre class="language-matlab">if (isempty(input))
</pre><pre class="language-matlab">set(hObject,'String','0')
</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">guidata(hObject, handles);
</pre><pre class="language-matlab">function a_input_Callback(hObject, eventdata, handles)
</pre><pre class="language-matlab">input = str2num(get(hObject,'String'));
</pre><pre class="language-matlab">if (isempty(input))
</pre><pre class="language-matlab">set(hObject,'String','0')
</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">guidata(hObject, handles);
</pre><pre class="language-matlab">%for example I have push button
</pre><pre class="language-matlab">function add_push_Callback(hObject, eventdata, handles)
</pre><pre class="language-matlab">a = get(handles.a_input,'String');
</pre><pre class="language-matlab">b = get(handles.b_input,'String');
</pre><pre class="language-matlab">total = str2num(a) + str2num(b);
</pre><pre class="language-matlab">c = num2str(total);
</pre><pre class="language-matlab">set(handles.answer,'String',c);
</pre><pre class="language-matlab">guidata(hObject, handles);
</pre><pre class="language-matlab">function div_push_Callback(hObject, eventdata, handles)
</pre><pre class="language-matlab">a = get(handles.a_input,'String');
</pre><pre class="language-matlab">b = get(handles.b_input,'String');
</pre><pre class="language-matlab">total = str2num(a) / str2num(b);
</pre><pre class="language-matlab">c = num2str(total);
</pre><pre class="language-matlab">set(handles.answer,'String',c);
</pre><pre class="language-matlab">guidata(hObject, handles);
</pre><pre class="language-matlab">% What I want to as is, I dont want to create a = get(handles.a_input,'String');
</pre><pre class="language-matlab">% and b = get(handles.b_input,'String'); again and again in each button action
</pre><pre class="language-matlab">%just want to create it only one time and than we can call it to do use in each button.
Thanks!
</pre>chanhttps://au.mathworks.com/matlabcentral/profile/authors/4359215-chantag:au.mathworks.com,2005:Question/3784582018-01-23T00:24:05Z2018-01-23T00:50:19Zi need a code to capture several images from two usb cameras at the same time to use them in stereo calibration app ?<p>i am using this code but there seems to be a problem with lines containing the word manual and so the images aren't good and this is supposed to give me 50 images but it doesn't and i can't control capturing them</p><pre class="language-matlab">leftCam=imaq.VideoDevice('winvideo',2);
</pre><pre class="language-matlab">rightCam=imaq.VideoDevice('winvideo',3);
</pre><pre class="language-matlab">leftCam.ReturnedDataType='uint8';
</pre><pre class="language-matlab">leftCam.DeviceProperties.FocusMode='manual';
</pre><pre class="language-matlab">leftCam.DeviceProperties.WhiteBalanceMode='manual';
</pre><pre class="language-matlab">rightCam.ReturnedDataType='uint8';
</pre><pre class="language-matlab">rightCam.DeviceProperties.FocusMode='manual';
</pre><pre class="language-matlab">rightCam.DeviceProperties.WhiteBalanceMode='manual';
</pre><pre class="language-matlab">leftImage=step(leftCam);
</pre><pre class="language-matlab">rightImage=step(rightCam);
</pre><pre class="language-matlab">dispImage=imfuse(leftImage,rightImage,'montage');
</pre><pre class="language-matlab">hFuse=imshow(dispImage);
</pre><pre class="language-matlab">count=1;
</pre><pre class="language-matlab">for i=1:1000
</pre><pre> leftImage=step(leftCam);</pre><pre> rightImage=step(rightCam);</pre><pre> dispImage=imfuse(leftImage,rightImage,'montage');</pre><pre> if mod(i,20)==0</pre><pre> imwrite(leftImage,sprintf('left/image%d.png',count));</pre><pre> imwrite(rightImage,sprintf('right/image%d.png',count));</pre><pre> dispImage= zeros (size (dispImage),'like',dispImage);</pre><pre> count= count +1;
end</pre><pre> hFuse.CData = dispImage;</pre><pre> drawnow;
end</pre><pre class="language-matlab">release(leftCam);
</pre><pre class="language-matlab">release(rightCam);
</pre><pre class="language-matlab">clear all;
</pre><pre class="language-matlab">close all;
</pre>Nouran Makhyounhttps://au.mathworks.com/matlabcentral/profile/authors/11529968-nouran-makhyountag:au.mathworks.com,2005:Question/3784592018-01-23T00:32:03Z2018-01-23T00:45:03ZInput a range of numbers into an expression<pre class="language-matlab">tan(x)=sin(x)/cos(x) for x=-π/2, -π/4, 0, π/4, π/2.
</pre><p>I inputted a range for x;</p><pre class="language-matlab">>> x=[-pi/2 -pi/4 0 pi/4 pi/2]
</pre><pre class="language-matlab">x =
</pre><pre> -1.5708 -0.7854 0 0.7854 1.5708</pre><p>I have the numbers in the workspace but I am trying to prove that when x is put into exquation it outputs the proof that tan(x) is equal to the sin(x)/cos(x).</p><p>Thanks</p>Brooks Nelsonhttps://au.mathworks.com/matlabcentral/profile/authors/9710704-brooks-nelsontag:au.mathworks.com,2005:Question/3783762018-01-22T15:48:49Z2018-01-23T00:37:48ZHow to fill the holes in 3D image reconstructed from binary images of CT slides<p>I have around 200 CT slides from patients and need to reconstruct them and segment out the eye orbit. I read the original DICOM image, use imbinarize(I,T) to change them to binary image, and then stack them up to form the 3D orbital image (see attached images below).</p><img src = "/matlabcentral/answers/uploaded_files/102071/img_dicom.png"><img src = "/matlabcentral/answers/uploaded_files/102072/img_binary.png"><img src = "/matlabcentral/answers/uploaded_files/102073/img_orbit.png"><p>However, as you can see, there are many holes inside the orbit. To cope with this, I use bwmorph() with 'thicken' and 'bridge', then use imclose() with the 'disk' parameter:</p><pre class="language-matlab">for i = 30 : 160
info = dicominfo(dirOutput(i).name,'UseDictionaryVR',true);
imgTemp = dicomread(info);
imgCropped = imcrop(imgTemp,bboxCrop);
imgCroppedBin = imbinarize(imgCropped,0.51728);
img_thick = bwmorph(imgCroppedBin,'thicken');
img_bridge = bwmorph(img_thick,'bridge',Inf);
se = strel('disk',1);
I(:,:,i) = imclose(img_bridge,se);
end;
</pre><p>I(:,:,i) is the resulting 3D array.
Then I use fv = isosurface(I,ISOVALUE) and patch() to reconstruct the 3D array to a 3D image (as attached above).</p><p>The resulting 3D image still has many holes unfilled. Increasing the STREL element size or decreasing the ISOVALUE will make the final model thick and coarse (e.g. with stair case inside).</p><p>May I ask how can I fill the resulting holes in the 3D model and still preserve the original smoothness of the image? Should I do this in the 3D image or do this in 2D binary image before the reconstruction?</p><p>Thanks!</p>Ringo Cheunghttps://au.mathworks.com/matlabcentral/profile/authors/9704883-ringo-cheungtag:au.mathworks.com,2005:Question/3784152018-01-22T18:35:06Z2018-01-23T00:35:58ZSearch for pdf with specific title and move to a different location on my PC with matlab<p>Hello,</p><p>I have a folder, let's say 'C:\directory', with a large number of PDF files in it. This folder also houses my matlab code that I am working on. Some of them have the same first few letters, let's say 'abcd' in their titles, while others don't. I want to locate the PDF files with the repeated text in their titles and move them to a new folder, let's say 'C:\directory2'. How can I do this easily, preferably using some combination of ifs and loops? Also, the repeated text will only be at the very beginning of the PDF's titles, not somewhere in the middle if that makes it any easier.</p>Nathaniel Wernerhttps://au.mathworks.com/matlabcentral/profile/authors/3668968-nathaniel-wernertag:au.mathworks.com,2005:Question/3784562018-01-22T23:45:21Z2018-01-23T00:17:45ZTime-space plot with meshgrid?<p>I am given a table with three columns</p><pre class="language-matlab">x t color
0 0 10
0.1 0 9
0.2 0 11
0.3 0 3
0 0.1 10
0.1 0.1 9
0.2 0.1 11
0.3 0.1 3
</pre><p>The table is given by a variable P. so that x=P(:,1), t=P(:,2), color=P(:,3).</p><p>I want to make a 2D plot in which the x axis is x, the y axis is t, and every point (x,t) is colored according to the values of P(:,3) (preferably in a grey scale).</p><p>I know that in order to make a plot, I need to use meshgrid for x and t. But how can I make the "color" in accordance with the values after using the meshgrid?</p><p>Hope I made myself clear</p><p>Thanks in advance !</p>Johnsonhttps://au.mathworks.com/matlabcentral/profile/authors/5550250-johnsontag:au.mathworks.com,2005:Question/3784572018-01-23T00:16:33Z2018-01-23T00:16:33ZHow to resume training a ClassificationBaggedEnsemble object with new data ??<p>I built Random forest for classification using fitcensemble and trained it with some data (data1) and got ClassificationBaggedEnsemble object (ens). Now I have some more data (data2) and so I want to resume (continue) training this ensemble (ens) with this NEW data.. Can I do so? if yes, then how please??
Thanks in advance..</p>Nada Sherifhttps://au.mathworks.com/matlabcentral/profile/authors/11527792-nada-sheriftag:au.mathworks.com,2005:Question/2318082015-07-30T18:07:23Z2018-01-23T00:00:32ZProblem with rectify StereoImages<p>I want to do a 3D reconstruction from two images from the same camera. I used the Stereo Camera Calibrator App on Matlab R2015a in order to calibrate the camera. The calibration seems to work fine :</p><img src = "/matlabcentral/answers/uploaded_files/34918/StereoCameraCalibration.jpg"><p>Then I used the example from the help to do the 3D reconstruction.</p><pre class="language-matlab">load('Param_test8.mat') % loads the camera parameters
% Read in the stereo pair of images.
I1 = imread('Cam1/Camera1_img1.tif');
I2 = imread('Cam2/Camera2_img1.tif');
% Rectify the images.
[J1, J2] = rectifyStereoImages(I1, I2, stereoParams,'cubic','OutputView','full');
</pre><p>However, there is a problem when I run the rectifyStereoImages, since the two images are then positioned very far from each other :</p><img src = "/matlabcentral/answers/uploaded_files/34919/BeforCalib.jpg"><img src = "/matlabcentral/answers/uploaded_files/34920/AfterCalib.jpg"><p>I don't understand where the problem is, since the stereo calibration manages to position the cameras and the checkerboards very well. I tried different positions for the camera, and different images to reconstruct, but I don't know where the problem is.</p>MJ MJhttps://au.mathworks.com/matlabcentral/profile/authors/6735394-mj-mjtag:au.mathworks.com,2005:Question/3782692018-01-22T06:12:48Z2018-01-23T00:00:04Zaxis command fails for log scale<pre class="language-matlab">figure
plot([1 2], [1 2])
axis([0 3 0 3])
axis(gca)
set(gca,'yscale','log')
%axis auto
axis(gca)
</pre><p>The second axis command does not return the correct value. It returns zero for the min Y axis limit, and does not reflect any of the changes from switching to the log scale. Including the axis auto function is a partial workaround for this example, but for some reason does not work the same way in my (very complicated) example.</p>Charleshttps://au.mathworks.com/matlabcentral/profile/authors/9260291-charlestag:au.mathworks.com,2005:Question/3277932017-03-02T20:43:12Z2018-01-22T23:57:26Zcmd+0 keyboard shortcut from Live Editor to Command Window<p>This shortcut works if I'm in a regular Editor window, but not when I'm in a Live Editor. Also, from the Command Window, shift+cmd+0 takes me back to the Live Editor just fine. I am using R2016b on a fully updated Mac.</p>Andrew Metcalfhttps://au.mathworks.com/matlabcentral/profile/authors/515846-andrew-metcalftag:au.mathworks.com,2005:Question/3783432018-01-22T13:27:03Z2018-01-22T23:47:47ZHow to get values from structure array<p>Hello. I wonder how to get values from structure array, in my case. I know that second line is: incorrect--possibly unbalanced (, {, or [.
Code:</p><pre class="language-matlab">Pose = rget( Kawasaki, 'pose');
getPoseValue =(Pose.x,Pose.y,Pose.z,Pose.o,Pose.t);
rset( Kawasaki, 'base', rpoint(getPoseValue) );
</pre><p>This is how it should be done with constant values. I want to get fresh values from pose of my robot.</p><p>Code2:</p><pre class="language-matlab">%rset( Kawasaki, 'base',
%rpoint(177.957,349.963,-229.418,15.983,179.610,-162.582) );
</pre><img src = "/matlabcentral/answers/uploaded_files/102060/2.PNG">Damianhttps://au.mathworks.com/matlabcentral/profile/authors/9070949-damiantag:au.mathworks.com,2005:Question/3784552018-01-22T23:31:19Z2018-01-22T23:44:24ZI want to understand the meaning(Syntax) of this line. Someone please explaiin what conditions are being used and what does it exactly mean in terms of variables used<pre> Kf(fmag<=1) = ((1-(nimage*magnification*fth(fmag<=1)).^2)</pre>Sagar Saxenahttps://au.mathworks.com/matlabcentral/profile/authors/7588931-sagar-saxena