https://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-05-26T18:56:02Ztag:de.mathworks.com,2005:Question/3416862017-05-24T09:09:52Z2017-05-26T18:56:02ZScalability Simulink 3D animation<p>I'm currently visualizing a light show with about 300 LEDs using the Simulink 3D animation package and it seems I have to handle every LED separately.</p><p>In the VR Sink, I have to enable the emissiveColor of each LED seperately and connect each LED to a separate signal in Simulink. If I now want to change the diffusive color of all my LEDs, does that mean I have to change it by hand for each of the 300 LEDs I have?!</p><p>Any help is much appreciated.</p>Luuk Poorthttps://de.mathworks.com/matlabcentral/profile/authors/5564181-luuk-poorttag:de.mathworks.com,2005:Question/3421132017-05-26T18:56:00Z2017-05-26T18:56:00Zquiver: DOUBLE cannot convert the input expression into a double array.<p>Below is the matlab code I used to graph the direction field of Infected(t) vs Susceptible(t) of a modified epidemics SIR model.
The numbers I input are:
infected = 5; recover = 10; dRate = 8; bRate = 20; inject = 100; Vefficiency = 0.5;</p><p>When I run the code I will get the error message:
Error using quiver (line 44)
DOUBLE cannot convert the input expression into a double array.
Error in vaccine (line 15)
quiver(S,I,dSu,dIu);</p><p>Any idea what I need to do to fix this issue? Vefficiency has to between 0 and 1</p><p>syms S I V recover infected dRate bRate inject Vefficiency;</p><p>infected = input('Enter infected rate : ');</p><p>recover = input('Enter recovery rate : ');</p><p>dRate = input('Enter death rate : ');</p><p>bRate = input('Enter birth rate : ');</p><p>inject = input('Enter vaccination rate : ');</p><p>Vefficiency = input('Enter efficiency of Vaccine : ');</p><p>[S,I]= meshgrid(0:5:100,0:5:100);</p><p>dI = infected.*I.*S - recover.*I - dRate.*I + (1-Vefficiency).*infected.*V.*I;</p><p>dS = bRate - infected.*I.*S - dRate.*S - inject.*S;</p><p>dV = inject.*S - (1-Vefficiency).*infected.*V.*I - dRate.*V;</p><p>dSu = dS./sqrt(dS.^2+dI.^2);</p><p>dIu = dI./sqrt(dS.^2+dI.^2);</p><p>quiver(S,I,dSu,dIu);</p><p>xlabel('S(t)');</p><p>ylabel('I(t)');</p>Fan Yanghttps://de.mathworks.com/matlabcentral/profile/authors/7926832-fan-yangtag:de.mathworks.com,2005:Question/3410202017-05-19T16:22:04Z2017-05-26T18:54:09ZAnyone could help me solving this problem or could you refer me to any video or link that can help. I have been trying to solve it for couple of hours. Your help will be appreciated.<img src = "/matlabcentral/answers/uploaded_files/78247/PROBLEM%208.jpg">Wasi von Deutschlandhttps://de.mathworks.com/matlabcentral/profile/authors/10267023-wasi-von-deutschlandtag:de.mathworks.com,2005:Question/3408932017-05-18T16:35:07Z2017-05-26T18:52:41ZHow to plot test and validation accuracy every epoch using Computer vision system toolbox? And what about overfitting?<p>I am finding many blogs of CNN and its related classification strategy in Matlab but I couldn't find how I could actually plot the validation set accuracy for every epoch along with the training set accuracy.</p><p><a href = "https://www.mathworks.com/help/nnet/ref/trainingoptions.html#namevaluepairarguments">https://www.mathworks.com/help/nnet/ref/trainingoptions.html#namevaluepairarguments</a></p><p>above documentation shows that I could plot training accuracy every epoch but not the validation set accuracy.</p><p>If that is not possible how to make sure that my network is not overfitting?</p>Jayhttps://de.mathworks.com/matlabcentral/profile/authors/6715736-jaytag:de.mathworks.com,2005:Question/1321192014-06-02T16:34:18Z2017-05-26T18:49:54ZKeyboard shortcut to evaluate current line? <p>I often use a keyboard shortcut to evaluate highlighted selections of a script I'm working on. But often, I will add a single line to a script and want to evaluate it right away. To do this I highlight the line and hit F9, but it would be a smoother process if I could simply hit F10 to evaluate the line my cursor is on without needing to highlight the line. I've checked the Preferences and I don't see this option available. Are there any clever hacks to allow this?</p><p>I'm using R2012b on a Mac.</p>Chad Greenehttps://de.mathworks.com/matlabcentral/profile/authors/1062128-chad-greenetag:de.mathworks.com,2005:Question/3421122017-05-26T18:48:42Z2017-05-26T18:48:42ZRemove gray lines from Boxplot Extrememode<p>I'm trying to remove the gray lines from the boxplot when using ('extrememode', 'compress') settings. I would rather it look more like just an axis break. Anyone know how to do this? Thanks! (I'm using Matlab 2013a)</p>Kirstenhttps://de.mathworks.com/matlabcentral/profile/authors/4512982-kirstentag:de.mathworks.com,2005:Question/3328982017-03-31T05:15:05Z2017-05-26T18:47:23ZIs it possible to multiply a 3D matrix with a coumn vector?<p>I have a 3D matrix with three rows and three columns. I want to multiply this matrix with a column vector of 3 rows. How can it be done?</p>Vipin Padinjarathhttps://de.mathworks.com/matlabcentral/profile/authors/8912882-vipin-padinjarathtag:de.mathworks.com,2005:Question/3421112017-05-26T18:45:15Z2017-05-26T18:45:15ZI already saved two data into my .xls file but when everytime i try to save new data, it replace the second data. Meaning that i have two data only in my .xls file. How to solve this? Help me. Here's the code: Thanks!<p>c = xlsread('Ikan', 'Sheet1');
nrows=size(c,1);
position = ['a' num2str(nrows+2)];
[status, message] = xlswrite('Ikan', d, 1, position);</p>Hanani Hamdanhttps://de.mathworks.com/matlabcentral/profile/authors/9354946-hanani-hamdantag:de.mathworks.com,2005:Question/3419862017-05-25T23:05:16Z2017-05-26T18:44:23Zwhy does the anonymous calculate incorrectly<p>in my code below, i am calculating a result two different ways. When I embed more into the anonymous function, it calculates an incorrect answer. Note y_A does not equal y_B. Does anyone have an idea why?</p><pre class="language-matlab">g=1.4;
M1=2;
theta=-15*pi/180;
M=M1;
vM1= sqrt((g+1)/(g-1))*atan(sqrt(((g-1)/(g+1))*(M^2-1)))-atan(sqrt((M^2)-1))
</pre><pre class="language-matlab">fx = @(M) vM1 - theta - sqrt((g+1)/(g-1))*atan(sqrt(((g-1)/(g+1))*(M^2-1)))-tan(sqrt((M^2)-1));
</pre><pre class="language-matlab">fx2= @(M)(sqrt((g+1)/(g-1))*atan(sqrt(((g-1)/(g+1))*(M^2-1)))-atan(sqrt((M^2)-1)));
</pre><pre class="language-matlab">y2=fx2(2.595)%second anonymous function works works for this one
</pre><pre class="language-matlab">y_A=fx(2.595)%trying to figure out why anonymous function is not working
</pre><pre class="language-matlab">y_B=vM1-theta-y2%checks out close to zero
</pre>Lou Jacksonhttps://de.mathworks.com/matlabcentral/profile/authors/50491-lou-jacksontag:de.mathworks.com,2005:Question/3420972017-05-26T17:13:09Z2017-05-26T18:40:57Zusing Matlab student version as free student<p>If I will be enrolled as a free student at the university , can I buy a Matlab student version and use it ?</p>abdel-illah dekkiche, M.Eng.https://de.mathworks.com/matlabcentral/profile/authors/10385227-abdel-illah-dekkiche-m-engtag:de.mathworks.com,2005:Question/3016532016-09-01T19:49:02Z2017-05-26T18:39:41ZNeed help with image registration<p>Hi everyone, Could you please help me in validating image registration. I have used control point based registration technique but unsure how to validate my resultant image. Please help</p>sharikahttps://de.mathworks.com/matlabcentral/profile/authors/7022164-sharikatag:de.mathworks.com,2005:Question/3402402017-05-14T18:36:24Z2017-05-26T18:38:45ZChange image contrast and brightness - GUI and sliders<p>I am building a simple GUI in Matlab that I aim to use in order to change image brightness and contrast using sliders (similar to Brightness / Contrast in paint.net).</p><p>I was calculating the the brightness via mean2 and set it as the slider value. Unfortunately, when I move the slider (set 0...255) the I = I + BrightSliderValue does not seems to be the right operation. Any idea how to solve it?
Furthermore, how do I proceed with the contrast issue? How do I calculate it and how do I change it?</p><p>Code:</p><pre> % --- Executes on button press in convertGSbutton.
function convertGSbutton_Callback(hObject, eventdata, handles)
% hObject handle to convertGSbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</pre><pre> I = getappdata(handles.imageAxes , 'yourVariable');
disp(size(I, 3));
if size(I, 3)>1
I = rgb2gray(I);
else
h = msgbox('A none color image');
end</pre><pre> axes(handles.imageAxes);
imshow(I);
brightness = mean2(I)
set(handles.BrightSlider, 'value', brightness);
%contrast = (I) % to be calculated
%set(handles.ContrastSlider, 'value', contrast);
setappdata(handles.imageAxes, 'yourVariable', I);</pre><pre> % --- Executes on slider movement.
function BrightSlider_Callback(hObject, eventdata, handles)
% hObject handle to BrightSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</pre><pre> % Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
I = getappdata(handles.imageAxes , 'yourVariable');
BrightSliderValue = get(handles.BrightSlider, 'Value');
I = I + BrightSliderValue ; % to be change
axes(handles.imageAxes);
imshow(I);
setappdata(handles.imageAxes, 'yourVariable', I);</pre><pre> % --- Executes on slider movement.
function ContrastSlider_Callback(hObject, eventdata, handles)
% hObject handle to ContrastSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</pre><pre> % Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
I = getappdata(handles.imageAxes , 'yourVariable');
ContrastSliderValue = get(handles.ContrastSlider, 'Value');
I = I + ContrastSliderValue; % to be change
I = getappdata(handles.imageAxes , 'yourVariable');
% I = %change contrast
axes(handles.imageAxes);
imshow(I);
setappdata(handles.imageAxes, 'yourVariable', I);</pre>huhttps://de.mathworks.com/matlabcentral/profile/authors/4719628-hutag:de.mathworks.com,2005:Question/3421102017-05-26T18:27:14Z2017-05-26T18:27:14ZPole-zero plot with blackman window, FIR filter - GUI<p>Hi everyone,</p><p>I'm working on a GUI and I want to make pole-zero plot with blackman window (together with fir1 function) but it doesn't work. Other windows works good, however blackman plot not. I used pzplot, pzmap and zplane functions. What should I do?</p><pre> b = fir1(rzad,Wn,blackman(rzad+1));
Hz=tf(b,1);
axes(handles.axes6)
h = pzplot(Hz);
%pzmap(Hz)
%zplane(b,1)
grid on</pre>Aleksandra Jankowskahttps://de.mathworks.com/matlabcentral/profile/authors/9937308-aleksandra-jankowskatag:de.mathworks.com,2005:Question/3421092017-05-26T18:26:25Z2017-05-26T18:26:25Zplotxx scattered plot with smooth line and marker<p>I am using plotxx, i want to replicate the scattered chart with smooth lines and markers from excel in matlab.
Any help?</p>Kathyhttps://de.mathworks.com/matlabcentral/profile/authors/10376926-kathytag:de.mathworks.com,2005:Question/3419072017-05-25T13:12:19Z2017-05-26T18:25:44ZMatlab older version trial<p>Hello I am using Vivado 2015.4 System Generator and I need Matlab communication toolbox for some features I want to get the free trial of matlab that is supported by the Vivado 2015.4 but only I can get is version 2017a How can I get the 2015b version of Matlab as free trial I know that is possible for purchased products but I want to get free and legally</p>nisanur bakirhttps://de.mathworks.com/matlabcentral/profile/authors/7993985-nisanur-bakirtag:de.mathworks.com,2005:Question/3404222017-05-15T21:59:39Z2017-05-26T18:23:16ZHow do I calculate a sum associated with text from an Excel file?<p>I'm trying to calculate hit rate and false alarm rate with two conditions (match and mismatch). The data is in an Excel Spreadsheet, with the condition in one column, and the response (either 1 or blank) in another. What kind of script can I use to get MATLAB to add up the responses to each condition? I tried using strcmp, but since the second value is a number, it doesn't seem to be working.</p>Kacie Dunhamhttps://de.mathworks.com/matlabcentral/profile/authors/9079363-kacie-dunhamtag:de.mathworks.com,2005:Question/3420712017-05-26T13:56:32Z2017-05-26T18:22:54ZSave object's boundary as coordinate arrays.<p>I have traced an image boundary and I need to save it as coordinate arrays. Actually I'm working on thermal image where I first extracted only the red component of the RGB image and then to black and white image then I have done morphological closing on it and obtained object's boundary.Actually I'm confused abt how to get boundary then I found it here and I have to save it in coordinate arrays.Thanks for your help in advance.
My code looks like this</p><pre class="language-matlab">a = imread('D:\New folder (5)\New folder (5)\VID-20170522-WA0021 (5-23-2017 3-45-10 PM)\yash.jpg');
a_red=a;
a_green=a;
a_blue=a;
a_red(:,:,2)=0;
a_red(:,:,3)=0;
BW = im2bw(a_red, 0.2);
se=strel('disk',10);
closeBW=imclose(BW,se);
[B,L] = bwboundaries(closeBW,'noholes');
c=label2rgb(L, @jet, [.5 .5 .5]);
imshow(c);
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
</pre>yaswanth pushpakhttps://de.mathworks.com/matlabcentral/profile/authors/10381878-yaswanth-pushpaktag:de.mathworks.com,2005:Question/3417782017-05-24T17:13:29Z2017-05-26T18:20:38ZHow MATLAB divide the number of iterations of "parfor" on the workers of one computer?<p>Dear all,</p><p>Please, I have a question, how MATLAB divide the number of iterations of "parfor" on the workers of the computer?</p><p>In the following example of Mathworks in the picture, as I understood, they mentioned when the number of iteration is 10 and the number of workers is 4, the first three workers take the 2 iterations equally then the remaining four iterations divide into the four. That is mean the first three workers take 3 iterations and the last worker take just one iteration.</p><p>Please, could anyone correct me if I am wrong ! And please, explain to me how MATLAB divide the number of iterations, i.e. even or odd ?</p><p>Lease, if I have this case how MATLAB divide the iterations ?
1. If the number of iteration is 40 and we have 4 workers.
2. If the number of iteration is 40 and we have 5 workers.
3. If the number of iteration is 40 and we have 8 workers.
4. If the number of iteration is 40 and we have 12 workers.</p><p>Kind regards
Ammar</p><img src = "/matlabcentral/answers/uploaded_files/78660/ParFor.bmp">Ammar https://de.mathworks.com/matlabcentral/profile/authors/6713588-ammartag:de.mathworks.com,2005:Question/3421082017-05-26T18:20:29Z2017-05-26T18:20:29ZI need help with my first assignment in matlab.<p>% Section: Understanding variables (double) and writing an equation.
% In MATLAB you can describe a variable as an equation. You can set the
% variable x to be equal to two times <i>pi</i> by writing the following:
% x = 2*pi;
%
% In this problem you are given the radius of a circle in the variable
% called <i>r</i> and you are asked to return the area of the circle in the
% variable <i>area</i>.</p><p>Above is the question they are asking. Below is what I have come up with.
function area = problem3(r)
r=3;
area=pi*r^2;</p><p>It says that I still have a syntax problem as well as my return problem should be empty and 0. I do not understand what this means.</p>Gregory Smithhttps://de.mathworks.com/matlabcentral/profile/authors/10353244-gregory-smithtag:de.mathworks.com,2005:Question/3421072017-05-26T18:19:10Z2017-05-26T18:19:10ZHow to identify signal spikes <p>I'm trying to analyse some electric signal data. I have electrical pulse data signal and the first thing which i need to start the analysis is to extract the repetition rate of the signal (the number of spikes per second). For me the most difficult is: i have two signals together in the same file (One being always smaller than the other, a example in the figure). It's possible to calculate the repetition rate for each signal? In the data are the variables of the signal amplitude (signal), time (timescale) and sample rate (fs).
Thanks!</p>Vanessa Carvalhohttps://de.mathworks.com/matlabcentral/profile/authors/10389753-vanessa-carvalhotag:de.mathworks.com,2005:Question/3418262017-05-24T23:23:46Z2017-05-26T18:18:53ZAdd contents of two columns to new columns with a delimiter between them<p>I have a matrix of 11693682x3 uint8.
I would like to create so called 'keys' for my data in a new column.
For example:</p><pre class="language-matlab">1, 2, 3
2, 5, 7
3, 3, 6,
4, 29, 0
Output:
1, 2, 3, 1|2
2, 5, 7, 2|5
3, 3, 6, 3|3
4, 29, 0, 4|29
</pre><p>Could anyone point me at the best way to solve this?</p>Rogier Busscherhttps://de.mathworks.com/matlabcentral/profile/authors/4539647-rogier-busschertag:de.mathworks.com,2005:Question/3421062017-05-26T18:13:28Z2017-05-26T18:31:26ZAlexnet problem using Neural Network Toolbox<p>[merchImagesTrain,merchImagesTest]=merchData;</p><p>Result is "merchData" is an undefined function or variable.</p><p>To clarify, Alexnet was loaded and the examples in MATLAB's document were tried (see link below):</p><p>www.mathworks.com/help/nnet/ref/alexnet.html</p><p>They worked up to the one cited above.</p>Howard Silverhttps://de.mathworks.com/matlabcentral/profile/authors/57173-howard-silvertag:de.mathworks.com,2005:Question/3414152017-05-22T18:50:19Z2017-05-26T18:13:23ZIs there any automatic code/way to choose/optimize the neural networks parameters on MATLAB?<p>Dear experts,</p><p>I am an undergraduate student and i am doing my bachelor thesis in classification using neural networks.</p><p>I am struggling in optimizing neural networks hyper parameters (example: learning rate, regularization parameter, number of hidden neurons, mini-batch sizes, which training algorithm, weights/biases, mu(for Jacobin methods)....etc.). I read different books, where they provide some rules of thumb to choose the parameters.</p><p>However, my supervisor mentioned that there is an automatic way/code to choose the hyper parameters on matlab and then matlab runs with the parameters which fits the most and then it trains the data.</p><p>Is there any possibility to mention where can i find such an automated way or mention it in the answer? (i have looked everywhere in the Q&A asked about neural networks, and the documentation it is really hard to find such method so i decided to ask the experts themselves) Thanks in advance</p>Yehia Elbahrawyhttps://de.mathworks.com/matlabcentral/profile/authors/6507097-yehia-elbahrawytag:de.mathworks.com,2005:Question/3420722017-05-26T14:05:27Z2017-05-26T18:11:44ZHow to create an RGB image?<p>What I have done thus far to create RGB images is to just load a white image and seperate the red green and blue components from this image and combine them in different ways to get different colors. No this feels kind of redundant because I keep thinking that MatLab must have a built-in RGB system in which you can just write a one line code from which the output will be any of the colors within RGB. Is there a simple function for this?</p>Zeff020https://de.mathworks.com/matlabcentral/profile/authors/10353572-zeff020tag:de.mathworks.com,2005:Question/3407732017-05-18T03:35:05Z2017-05-26T18:11:37ZImprovement of speed for code for hex serial command list<p>Hi</p><p>First of all, sorry for my bad english writing.</p><p>My matlab versions are 2015b and 2016a.</p><p>Followed by my previous question <a href = "https://www.mathworks.com/matlabcentral/answers/340723-serial-communication-with-hex-code">https://www.mathworks.com/matlabcentral/answers/340723-serial-communication-with-hex-code</a>, I am writing to ask another questions regarding my code as attached file.</p><p>Also, I am sorry that I cannot clarify company/model of my device and cannot show a document including details for serial command list and explanation, because the manufacturer indicated that this document is confidential document.</p><p>Now, anyway, communication between computer and my sensor device is good.</p><p>The variable 'data' is usually 41*2 or 40*2 depending on existence of escape octet, 7D, when I send the command list in the variable 'Str' (so variable 'D').</p><p>The part of the command list ('Str'), '2B', '01', '01', is for auto-output from the device to the computer.</p><p>So, principly, I do not need to send the command list again everytime, because the device send (or I can use fread() I think) every 1 second once I send the command list at a very first time.</p><p>However, when I did not send it again, 'data' length is very weird. (It goes up to 512*2 and varies a lot from 40*2 to 512*2)</p><p>This is first question. Why it is?. Did I make any mistake you think?</p><p>Another question is that this code might be in-effective. So, please suggest any solution to improve running speed for this code.</p><p>Last question is...... if you can convert this code into C or C++, please help me.</p><p>I think I can improve running speed by compiling C code into mex file.</p><p>Thanks</p>Deohttps://de.mathworks.com/matlabcentral/profile/authors/8363057-deotag:de.mathworks.com,2005:Question/3417792017-05-24T17:20:34Z2017-05-26T18:11:06ZHow to plot the symbolic expression given by "root"<p>Hello.</p><p>I want to solve the 3rd degree symbolic equation. I chose "solve" for this purpose. It gives the answer with "root(...)";
For example,</p><pre class="language-matlab">root(z^3 - (9*z^2)/10 + (17*z)/40 - 9/40, z, 1)
root(z^3 - (9*z^2)/10 + (17*z)/40 - 9/40, z, 2)
root(z^3 - (9*z^2)/10 + (17*z)/40 - 9/40, z, 3)
</pre><p>Now I want to plot this function, I mean, z^3 - (9*z^2)/10 + (17*z)/40.
The problem is that this expression depends on the coefficients I give to the function. I could copy and paste this equation myself but then I need to do it everytime I change the coefficients which is pretty uncomfortable.</p><p>Is it possible to get the symbolic expression or just to make MATLAB plot the function somehow without doing it manually?</p><p>The code is here:</p><pre class="language-matlab">function draft14
clc;
fsys = @(x,y,z,c,mu1,s1,r2,b,s2) [c*y - mu1*x + x*z + s1; ...
r2*y*(1 - b*y) - x*y; ...
z - x*y + s2];
c = 0.2;
mu1 = 0.5;
s1 = 0.1;
r2 = 0.9;
b = 0.5;
s2 = 0;
par = [c mu1 s1 r2 b s2];
f = @(t,x) fsys(x(1),x(2),x(3),par(1),par(2),par(3),par(4),par(5),par(6));
tspan = 0:0.01:2;
y0 = [0.1 0.9 0.1];
[~,Y] = ode45(f,tspan,y0);
plot3(Y(:,1),Y(:,2),Y(:,3)); hold on;
plot3(y0(1),y0(2),y0(3), 'o','LineWidth',3);
xlabel('X'); ylabel('Y'); zlabel('Z');
figure;
plot(Y(:,1),Y(:,2));
xlabel('X'); ylabel('Y');
cubeq(par);
end
function cubeq(par) %Решает численно кубическое уравнение
c = par(1);
mu1 = par(2);
s1 = par(3);
r2 = par(4);
b = par(5);
s2 = par(6);
syms x
f = x^3 - r2*x^2 + (c + mu1*r2*b)*x - r2*(b*s1 + c);
s = solve(f,x);
disp('Решение кубического уравнения:');
disp(s);
clear x;
end
</pre><p>P.S. In the code above you can see than I set the parameters in the first function and then give it to the "cubeq" function. In the "cubeq" function I need to plot the cubic parabola, on which the roots depend.</p>MGMKLMLhttps://de.mathworks.com/matlabcentral/profile/authors/6400310-mgmklmltag:de.mathworks.com,2005:Question/3375872017-04-27T08:54:38Z2017-05-26T18:09:26ZHow to avoid NaN in the Mini-batch-loss from traning convolutional neural network?<p>Hello,</p><p>I´m working on training a convolutional neural network following the example from https://de.mathworks.com/help/nnet/examples/create-simple-deep-learning-network-for-classification.html. I have 2000 images in each of 8 label categories and use 90% for training and 10% for testing. The images are in .jpg format and have a size 512x512x1. The arciture of the CNN is currently as follows:</p><pre> layers = [imageInputLayer([512 512 1])
convolution2dLayer(5,15)
reluLayer
maxPooling2dLayer(2,'Stride',2)
fullyConnectedLayer(8)
softmaxLayer
classificationLayer()];</pre><pre> options = traningOptions('sgdm','MaxEpochs',15,'InitialLearnRate',0.001, 'ExecutionEnvironment', 'parallel' );</pre><p>After training the first epoch the mini-batch loss is going to be NaN and the accuracy is around the chance level. The reason for this is probably that the back probagating generates NaN weights.</p><img src = "/matlabcentral/answers/uploaded_files/76297/170427_Leu_MiniBatchLoss%20NaN.png"><p>How can I avoid this problem?
Thanks for the answers!</p>AlexanderTUEhttps://de.mathworks.com/matlabcentral/profile/authors/5854024-alexandertuetag:de.mathworks.com,2005:Question/3408982017-05-18T17:18:37Z2017-05-26T18:08:22ZTracking boxplot x axis labels<p>I am using the boxplot function to visualize data in a hierarchical way. Since the function allows me to define the order and hierarchy of the boxes, is there a way I can retrieve the organized tick labels in a string (cell) array?</p><p>Example:
By changing the order of the strings a,b,c,d (which are the different values associated to the vector_data) the tick labels on the X axis will change. How can I track that change? Can I get a table showing how the x axis tick labels are organized? What is the figure object that has that info?</p><pre class="language-matlab">comp=[a,b,c,d];
boxplot(vector_data(:,1),comp,'FactorGap',[3,1],'PlotStyle','compact','MedianStyle','line','BoxStyle','outline');
</pre><p>Thank you!</p>Eugenio Davisohttps://de.mathworks.com/matlabcentral/profile/authors/9494870-eugenio-davisotag:de.mathworks.com,2005:Question/3411702017-05-21T05:12:40Z2017-05-26T18:06:22Zhow to do beam steering in elevation plane in edit ScanRadarExample?? <p>%% Scan Radar Using a Uniform Rectangular Array
% This example simulates a phased array radar that periodically scans a
% predefined surveillance region. A 900-element rectangular array is used
% in this monostatic radar. Steps are introduced to derive the radar
% parameters according to specifications. After synthesizing the received
% pulses, detection and range estimation are performed. Finally, Doppler
% estimation is used to obtain the speed of each target.</p><p>% Copyright 2010-2016 The MathWorks, Inc.</p><p>%% Radar Definition
% First we create a phased array radar. We reuse most of the subsystems
% built in the example <a href = "BasicMonostaticRadarExample.html">Designing a Basic
% Monostatic Pulse Radar</a>. Readers are encouraged to explore the details of
% <a href = "http://www.mathworks.com/discovery/radar-system-design.html">radar system
% design</a> through that example. A major difference is that we use a
% 30-by-30 uniform rectangular array (URA) in place of the original single
% antenna.</p><p>%%
% The existing radar design meets the following specifications.
pd = 0.9; % Probability of detection
pfa = 1e-6; % Probability of false alarm
max_range = 5000; % Maximum unambiguous range
tgt_rcs = 1; % Required target radar cross section
int_pulsenum = 10; % Number of pulses to integrate</p><p>%%
% Load the radar system and retrieve system parameters.</p><p>load BasicMonostaticRadarExampleData;</p><p>fc = radiator.OperatingFrequency; % Operating frequency (Hz)
v = radiator.PropagationSpeed; % Wave propagation speed (m/s)
lambda = v/fc; % Wavelength (m)
fs = waveform.SampleRate; % Sampling frequency (Hz)
prf = waveform.PRF; % Pulse repetition frequency (Hz)</p><p>%%
% Next, we define a 30-by-30 uniform rectangular array.</p><p>ura = phased.URA('Element',antenna,...
'Size',[30 30],'ElementSpacing',[lambda/2, lambda/2]);
% Configure the antenna elements such that they only transmit forward
ura.Element.BackBaffled = true;</p><p>% Visualize the response pattern.
pattern(ura,fc,'PropagationSpeed',physconst('LightSpeed'),...
'Type','powerdb');</p><p>%%
% Associate the array with the radiator and collector.</p><p>radiator.Sensor = ura;
collector.Sensor = ura;</p><p>% We need to set the WeightsInputPort property to true to enable it to
% accept transmit beamforming weights
radiator.WeightsInputPort = true;</p><p>%%
% Now we need to recalculate the transmit power. The original transmit
% power was calculated based on a single antenna. For a 900-element array,
% the power required for each element is much less.</p><p>% Calculate the array gain
arraygain = phased.ArrayGain('SensorArray',ura,'PropagationSpeed',v);
ag = arraygain(fc,[0;0]);</p><p>% Use the radar equation to calculate the peak power
snr_min = albersheim(pd, pfa, int_pulsenum);
peak_power = radareqpow(lambda,max_range,snr_min,waveform.PulseWidth,...
'RCS',tgt_rcs,'Gain',transmitter.Gain + ag)</p><p>%%
% The new peak power is 0.0065 Watts.</p><p>% Set the peak power of the transmitter
transmitter.PeakPower = peak_power;</p><p>%%
% We also need to design the scanning schedule of the phased array. To
% simplify the example, we only search in the azimuth dimension. We require
% the radar to search from 45 degrees to -45 degrees in azimuth. The
% revisit time should be less than 1 second, meaning that the radar should
% revisit the same azimuth angle within 1 second.</p><p>initialAz = 45; endAz = -45;
volumnAz = initialAz - endAz;</p><p>%%
% To determine the required number of scans, we need to know the beamwidth
% of the array response. We use an empirical formula to estimate the 3-dB
% beamwidth.
%
% $$G=\frac{4\pi}{\theta^2}$$
%
% where $G$ is the array gain and $\theta$ is the 3-dB beamwidth.</p><p>% Calculate 3-dB beamwidth
theta = radtodeg(sqrt(4*pi/db2pow(ag)))</p><p>%%
% The 3-dB beamwidth is 6.77 degrees. To allow for some beam overlap in
% space, we choose the scan step to be 6 degrees.</p><p>scanstep = -6;
scangrid = initialAz+scanstep/2:scanstep:endAz;
numscans = length(scangrid);
pulsenum = int_pulsenum*numscans;</p><p>% Calculate revisit time
revisitTime = pulsenum/prf</p><p>%%
% The resulting revisit time is 0.005 second, well below the prescribed
% upper limit of 1 second.</p><p>%% Target Definition
% We want to simulate the pulse returns from two non-fluctuating targets,
% both at 0 degrees elevation. The first target is approaching to the
% radar, while the second target is moving away from the radar.</p><p>tgtpos = [[3532.63; 0; 800],[2020.66; 0; 0]];
tgtvel = [[1; 50; 0],[160; 80; 0]];
tgtmotion = phased.Platform('InitialPosition',tgtpos,'Velocity',tgtvel);</p><p>tgtrcs = [1.6 2.2];
target = phased.RadarTarget('MeanRCS',tgtrcs,'OperatingFrequency',fc);</p><p>% Calculate the range, angle, and speed of the targets
[tgtrng,tgtang] = rangeangle(tgtmotion.InitialPosition,...
sensormotion.InitialPosition);</p><p>numtargets = length(target.MeanRCS);</p><p>%% Pulse Synthesis
% Now that all subsystems are defined, we can proceed to simulate the
% received signals. The total simulation time corresponds to one pass
% through the surveillance region. Because the reflected signals are
% received by an array, we use a beamformer pointing to the steering
% direction to obtain the combined signal.</p><p>% Create the steering vector for transmit beamforming
steeringvec = phased.SteeringVector('SensorArray',ura,...
'PropagationSpeed',v);</p><p>% Create the receiving beamformer
beamformer = phased.PhaseShiftBeamformer('SensorArray',ura,...
'OperatingFrequency',fc,'PropagationSpeed',v,...
'DirectionSource','Input port');</p><p>% Define propagation channel for each target
channel = phased.FreeSpace(...
'SampleRate',fs,...
'TwoWayPropagation',true,...
'OperatingFrequency',fc);</p><p>fast_time_grid = unigrid(0, 1/fs, 1/prf, '[)');</p><p>% Pre-allocate array for improved processing speed
rxpulses = zeros(numel(fast_time_grid),pulsenum);</p><p>for m = 1:pulsenum</p><pre> % Update sensor and target positions
[sensorpos,sensorvel] = sensormotion(1/prf);
[tgtpos,tgtvel] = tgtmotion(1/prf);</pre><pre> % Calculate the target angles as seen by the sensor
[tgtrng,tgtang] = rangeangle(tgtpos,sensorpos);</pre><pre> % Calculate steering vector for current scan angle
scanid = floor((m-1)/int_pulsenum) + 1;
sv = steeringvec(fc,scangrid(scanid));
w = conj(sv);</pre><pre> % Form transmit beam for this scan angle and simulate propagation
pulse = waveform();
[txsig,txstatus] = transmitter(pulse);
txsig = radiator(txsig,tgtang,w);
txsig = channel(txsig,sensorpos,tgtpos,sensorvel,tgtvel);</pre><pre> % Reflect pulse off of targets
tgtsig = target(txsig);</pre><pre> % Beamform the target returns received at the sensor
rxsig = collector(tgtsig,tgtang);
rxsig = receiver(rxsig,~(txstatus>0));
rxpulses(:,m) = beamformer(rxsig,[scangrid(scanid);0]);
end</pre><p>%% Matched Filter
% To process the received signal, we first pass it through a matched
% filter, then integrate all pulses for each scan angle.</p><p>% Matched filtering
matchingcoeff = getMatchedFilter(waveform);
matchedfilter = phased.MatchedFilter(...
'Coefficients',matchingcoeff,...
'GainOutputPort',true);
[mf_pulses, mfgain] = matchedfilter(rxpulses);
mf_pulses = reshape(mf_pulses,[],int_pulsenum,numscans);</p><p>matchingdelay = size(matchingcoeff,1)-1;
sz_mfpulses = size(mf_pulses);
mf_pulses = [mf_pulses(matchingdelay+1:end) zeros(1,matchingdelay)];
mf_pulses = reshape(mf_pulses,sz_mfpulses);</p><p>% Pulse integration
int_pulses = pulsint(mf_pulses,'noncoherent');
int_pulses = squeeze(int_pulses);</p><p>% Visualize
r = v*fast_time_grid/2;
X = r'*cosd(scangrid); Y = r'*sind(scangrid);
clf;
pcolor(X,Y,pow2db(abs(int_pulses).^2));
axis equal tight
shading interp
axis off
text(-800,0,'Array');
text((max(r)+10)*cosd(initialAz),(max(r)+10)*sind(initialAz),...
[num2str(initialAz) '^o']);
text((max(r)+10)*cosd(endAz),(max(r)+10)*sind(endAz),...
[num2str(endAz) '^o']);
text((max(r)+10)*cosd(0),(max(r)+10)*sind(0),[num2str(0) '^o']);
colorbar;</p><p>%%
% From the scan map, we can clearly see two peaks. The close one is at
% around 0 degrees azimuth, the remote one at around 10 degrees in azimuth.</p><p>%% Detection and Range Estimation
% To obtain an accurate estimation of the target parameters, we apply
% threshold detection on the scan map. First we need to compensate for
% signal power loss due to range by applying time varying gains to the
% received signal.</p><p>range_gates = v*fast_time_grid/2;
tvg = phased.TimeVaryingGain(...
'RangeLoss',2*fspl(range_gates,lambda),...
'ReferenceLoss',2*fspl(max(range_gates),lambda));
tvg_pulses = tvg(mf_pulses);</p><p>% Pulse integration
int_pulses = pulsint(tvg_pulses,'noncoherent');
int_pulses = squeeze(int_pulses);</p><p>% Calculate the detection threshold</p><p>% sample rate is twice the noise bandwidth in the design system
noise_bw = receiver.SampleRate/2;
npower = noisepow(noise_bw,...
receiver.NoiseFigure,receiver.ReferenceTemperature);
threshold = npower * db2pow(npwgnthresh(pfa,int_pulsenum,'noncoherent'));
% Increase the threshold by the matched filter processing gain
threshold = threshold * db2pow(mfgain);</p><p>%%
% We now visualize the detection process. To better represent the data, we
% only plot range samples beyond 50.</p><p>N = 51;
clf;
surf(X(N:end,:),Y(N:end,:),...
pow2db(abs(int_pulses(N:end,:)).^2));
hold on;
mesh(X(N:end,:),Y(N:end,:),...
pow2db(threshold*ones(size(X(N:end,:)))),'FaceAlpha',0.8);
view(0,56);
axis off</p><p>%%
% There are two peaks visible above the detection threshold, corresponding
% to the two targets we defined earlier. We can find the locations of these
% peaks and estimate the range and angle of each target.</p><p>[~,peakInd] = findpeaks(int_pulses(:),'MinPeakHeight',sqrt(threshold));
[rngInd,angInd] = ind2sub(size(int_pulses),peakInd);
est_range = range_gates(rngInd); % Estimated range
est_angle = scangrid(angInd); % Estimated direction</p><p>%% Doppler Estimation
% Next, we want to estimate the Doppler speed of each target. For details
% on Doppler estimation, refer to the example
% <a href = "DopplerEstimationExample.html">Doppler Estimation</a>.
%
for m = numtargets:-1:1
[p, f] = periodogram(mf_pulses(rngInd(m),:,angInd(m)),[],256,prf, ...
'power','centered');
speed_vec = dop2speed(f,lambda)/2;</p><pre> spectrum_data = p/max(p);
[~,dop_detect1] = findpeaks(pow2db(spectrum_data),'MinPeakHeight',-5);
sp(m) = speed_vec(dop_detect1) % Estimated Doppler speed
end</pre><p>%%
% Finally, we have estimated all the parameters of both detected targets.
% Below is a comparison of the estimated and true parameter values.</p><p>%%
% ------------------------------------------------------------------------
% Estimated (true) target parameters
% ------------------------------------------------------------------------
% Range (m) Azimuth (deg) Speed (m/s)
% Target 1: 3625.00 (3622.08) 12.00 (12.76) 86.01 (86.49)
% Target 2: 2025.00 (2020.66) 0.00 (0.00) -59.68 (-60.00)</p><p>%% Summary
% In this example, we showed how to simulate a phased array radar to scan a
% predefined surveillance region. We illustrated how to design the
% scanning schedule. A conventional beamformer was used to process the
% received multi-channel signal. The range, angle, and Doppler information
% of each target are extracted from the reflected pulses. This information
% can be used in further tasks such as high resolution direction-of-arrival
% estimation, or target tracking.</p><p>displayEndOfDemoMessage(mfilename)</p>Ali Mehdihttps://de.mathworks.com/matlabcentral/profile/authors/9692325-ali-mehditag:de.mathworks.com,2005:Question/3411442017-05-20T20:18:14Z2017-05-26T18:05:52ZCan I rotate a background node in the 3D World Editor<p>I want the z-axis to be the upwards-pointing axis in a 3D world. Is it possible to rotate a background-node such that the ground is parallel to the xy-plane rather than the xz-plane ?</p>Ronny Landsverkhttps://de.mathworks.com/matlabcentral/profile/authors/10027440-ronny-landsverktag:de.mathworks.com,2005:Question/3420932017-05-26T16:45:18Z2017-05-26T18:04:03Zx2 and y2 not plotting as expected <p>Code is following</p><pre class="language-matlab">clear all; close all; clc;
% Arbitrary x's and y's
x1 = [10 20 30 40];
y1 = [1 2 3 4];
x2 = [100 200 300 400];
y2 = [105 95 85 75];
figure
plot(x1,y1,'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r')
ax2 = axes('Color','none'); % Create secondary axis
plot(ax2, x2,y2,'o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b')
% Now set the secondary axis attributes
ax2.Color = 'none'; % Make the chart area transparent
ax2.XAxisLocation = 'top'; % Move the secondary x axis to the top
ax2.YAxisLocation = 'right'; % Move
</pre><p>i get the output</p><img src = "/matlabcentral/answers/uploaded_files/78873/Capture.PNG"><p>but i am looking for this output</p><img src = "/matlabcentral/answers/uploaded_files/78874/Capture1.PNG"><p>x2 and y2 are not plotting properly.where am i going wrong?</p>Kathyhttps://de.mathworks.com/matlabcentral/profile/authors/10376926-kathytag:de.mathworks.com,2005:Question/3421052017-05-26T18:00:18Z2017-05-26T18:54:28Z How can I determine the sampling frequency for FFT or IFFT to use in Matlab?<p>I have the following data from measurements:
Number of points =1000
frequency span =80 MHz</p><p>start frequency= 2.38 GHz</p><p>stop frequency= 2.46 GHz</p><p>sweep time/measurement duration= 90.09 ms</p><p>I heard the sampling frequency must be at least 2 times higher than the highest frequency?</p>shivikhttps://de.mathworks.com/matlabcentral/profile/authors/7347095-shiviktag:de.mathworks.com,2005:Question/1299632014-05-17T07:48:06Z2017-05-26T17:58:34ZGenerating 50 Random locations inside geo map data<p>I have a function called map() which takes a string input and uses it to generate a particulare map</p><pre class="language-matlab">function map(Name)
worldmap({Name})
land = shaperead('landareas.shp', 'UseGeoCoords', true);
geoshow(land, 'FaceColor', [0.15 0.5 0.15])
</pre><p>what I would like to do is randomly generate from a seed 50 locations and place them on land or within the regions border,</p><p>such as i run map('Australia') and i get 50 randomly generated locations in australia.</p>matthewhttps://de.mathworks.com/matlabcentral/profile/authors/5339661-matthewtag:de.mathworks.com,2005:Question/3419482017-05-25T17:02:57Z2017-05-26T17:57:24Zcompare date and time <p>I need to check of the date is after specific date and time. for example</p><p>if (datestr(datenum(datetime))) > (datestr([2017 05 21 12 00 00]</p><p>datetime is array of date in the format 22-May-2017 12:00:00</p>Kathyhttps://de.mathworks.com/matlabcentral/profile/authors/10376926-kathytag:de.mathworks.com,2005:Question/3416252017-05-23T22:26:38Z2017-05-26T17:56:45ZConfidence intervals estimates for cubic smoothing spline (csaps)<p>Is there a built in function that will return the confidence bands for csaps (or the output from ppval)? Extra information that might be useful:</p><ol><li>I have data that is smoothed both with and without weights.</li><li>I estimated the smoothing parameter using cross-validation using both k-fold and leave-one-out. <i>Aside: why doesn't MATLAB do this automatically?</i></li></ol><p>I found a paper, <i>Bayesian "confidence intervals" for the cross-validated smoothing spline</i> by G. Wahba that describes a method for estimating the confidence intervals, but I'd rather not code it myself if a script already exists.</p><p>Edit: The title was poorly worded and it doesn't seem I can change it now. I meant confidence bands, not confidence interval.</p>Matthew Taliaferrohttps://de.mathworks.com/matlabcentral/profile/authors/3369786-matthew-taliaferrotag:de.mathworks.com,2005:Question/3421042017-05-26T17:55:27Z2017-05-26T17:55:27Zhow to retrieve the data from simulink during simulation<p>I have read many posts and comments on this regard but still, coudn't figure out How can have access to block data during simulation.I have followed <a href = "https://www.mathworks.com/help/simulink/ug/accessing-block-data-during-simulation.html">this instruction</a> but something is still wrong. Can anybody help me on this?</p><p>Here is my code: ( in this code I ma simply trying to get the Clock block data from simulation)
load_system('Engine1')
set_param('Engine1','SimulationCommand','Start');
block = 'Engine1/Clock';
rto = get_param(block, 'RuntimeObject');
time = rto.OutputPort(1).Data
plot(time,'or','MarkerSize',5,'MarkerFaceColor','r')</p><p>The plot is just showing the last output equal to zero!!</p>Babakhttps://de.mathworks.com/matlabcentral/profile/authors/5362071-babaktag:de.mathworks.com,2005:Question/3420602017-05-26T11:58:14Z2017-05-26T17:55:05ZHow to do simultaneous curve fitting for two model equations having common constants ??<p>I am having two different model equations and also experimental data respectively. Both model equations are having common constants. Is there any way to do curve fitting for both the models simultaneously. So that final values constants can satisfy both the model equations ??</p>yugal guptahttps://de.mathworks.com/matlabcentral/profile/authors/7042557-yugal-guptatag:de.mathworks.com,2005:Question/3407342017-05-17T18:47:29Z2017-05-26T17:51:49ZCan one call nlinfit using bootstrp? <p>I would like to compute nonlinear regression parameter confidence intervals using bootstrp; however, I am having difficulty passing 'nlinfit' to the function 'bootstrp'. Below is an example code:</p><p>fun = @(b,x) b(1).*x.^b(2) + b(3);
beta = bootstrp(iterations,'nlinfit',x,y,fun,rand(3,1));</p><p>% with x and y vectors of equal length and
% beta a matrices of regression parameter estimates
% of length iterations and width width equal to length of b.
% 'rand' is called for random starting point for beta in nlinfit.</p><p>I have passed 'polyfit' to 'bootstrp' successfully but not 'nlinfit'. Any suggestions would be greatly appreciated.</p><p>Please note I am familiar with 'nlparci' but prefer bootstrap regression parameter confidence intervals. Also, I have written code to compute nonlinear regression parameter confidence intervals but would prefer to use 'bootstrp' for a cleaner code. I do not have access to the optimization toolbox.</p><p>% The above code produces this error code:
Error using bootstrp>bootEvalCommand (line 289)
Nonscalar arguments to BOOTFUN must have the same number of rows.</p>Daniel Livseyhttps://de.mathworks.com/matlabcentral/profile/authors/8423420-daniel-livseytag:de.mathworks.com,2005:Question/3421032017-05-26T17:50:11Z2017-05-26T17:51:33ZDefining a notch filter <p>Hi, I'm new to Matlab. I'm trying to define a notch filter in matlab and implement it. The steps I've read for manually defining a notch filter so far are:</p><p>1- Taking the fft</p><p>2-Taking fftshift of the image</p><p>3- Defining the noise frequences in the fftshift image as notch centers</p><p>4-Implementing notch filter</p><p>I've done steps 1 and 2</p><p>I=imread('cameraman.tif');</p><p>F=fft2(I);</p><p>F = fftshift(F); % Center FFT</p><p>F = abs(F); % Get the magnitude</p><p>F = log(F+1); % Use log, for perceptual scaling, and +1 since log(0) is undefined</p><p>F = mat2gray(F); % Use mat2gray to scale the image between 0 and 1</p><p>imshow(F,[]);</p><img src = "/matlabcentral/answers/uploaded_files/78881/Capture.JPG"><p>Now I don't know how to get the frequencies to set as the notch centers. Kindly help!</p>Ayesha chhttps://de.mathworks.com/matlabcentral/profile/authors/6315937-ayesha-chtag:de.mathworks.com,2005:Question/3421022017-05-26T17:40:26Z2017-05-26T17:49:05ZHow can i correctly write an if "yes or no" statement?<p>For Example, x=input('Do you know the area of your building?(yes/no)' ,'s')
if (x=='yes')
area=input('What is the area of your building?')
elseif (x=='no')
shape=input('is your building circular or rectangular?')
end
How could i make it so that if the input is "yes" or "no" that it would do one of the following commands?</p>Kelvin Luohttps://de.mathworks.com/matlabcentral/profile/authors/9704495-kelvin-luotag:de.mathworks.com,2005:Question/3420982017-05-26T17:23:21Z2017-05-26T17:47:44ZHow do i find the yearly mean and maximum of Discharge data from a 50 years data? <p>Hi
I am a new learner of MATLAB. Therefore i request the kind members to please respond to my query.</p>Farooq Ziahttps://de.mathworks.com/matlabcentral/profile/authors/7126623-farooq-ziatag:de.mathworks.com,2005:Question/3420782017-05-26T14:40:45Z2017-05-26T17:46:21Zhow can i convert decimal to hex or another basis without use dec2hex ?<p>I need to make a function about convert basis to another (decimal to oktal or another) but i dont know the prinsip , i hope some one give me tips for that</p>Mohammad Imam Malikhttps://de.mathworks.com/matlabcentral/profile/authors/9865796-mohammad-imam-maliktag:de.mathworks.com,2005:Question/1784882015-02-15T01:16:59Z2017-05-26T17:44:55Zintersection of 3 cercles (intersect problem)<pre> I am trying to find the intersection between 3 cercles.
I started with intersection between each 2 cercles with "circcirc" function
then, to find the common point between [x1,y1] and [x2,y2] i used the intersect function but i got "Empty matrix: 1-by-0"</pre><p>Can someone help me with this</p><pre class="language-matlab">%% Données pour configuation des transcepteurs
% Triangle equilateral inscrit dans un cercle de rayon R
R=50;
D=2*R;
a=D*sin(degtorad(60));
b=a; c=a;
h=sqrt(3)/2*a;
</pre><pre class="language-matlab">B=h*2/3*(cos(degtorad(30))-sin(degtorad(30))*i);
A=-h*2/3*(cos(degtorad(30))+sin(degtorad(30))*i);
C=i*2*h/3;
figure;
plot(A,'o');
grid on
hold on
plot(B,'o');
plot(C,'o');
</pre><pre class="language-matlab">ang=0:0.01:2*pi;
xp=R*cos(ang);
yp=R*sin(ang);
plot(xp,yp,'k');
axis('equal');
</pre><pre class="language-matlab">Tag=20+30i;
plot(Tag,'vk');
d1=sqrt((real(Tag)-real(A))^2+(imag(Tag)-imag(A))^2);
d2=sqrt((real(Tag)-real(B))^2+(imag(Tag)-imag(B))^2);
d3=sqrt((real(Tag)-real(C))^2+(imag(Tag)-imag(C))^2);
</pre><pre class="language-matlab">ang=0:0.01:2*pi;
xp1=d1*cos(ang);
yp1=d1*sin(ang);
C1=real(A)+xp1+i*(imag(A)+yp1);
plot(C1,'b');
</pre><pre class="language-matlab">ang=0:0.01:2*pi;
xp2=d2*cos(ang);
yp2=d2*sin(ang);
C2=real(B)+xp2+i*(imag(B)+yp2);
plot(C2,'g');
</pre><pre class="language-matlab">ang=0:0.01:2*pi;
xp3=d3*cos(ang);
yp3=d3*sin(ang);
C3=real(C)+xp3+i*(imag(C)+yp3);
plot(C3,'r');
</pre><pre> [x1,y1]=circcirc(real(C),imag(C),d3,real(B),imag(B),d2);
[x2,y2]=circcirc(real(C),imag(C),d3,real(A),imag(A),d1);
TagExp= intersect(x1,x2)+i*intersect(y1,y2);</pre>Mohammed Ghedamsihttps://de.mathworks.com/matlabcentral/profile/authors/4094509-mohammed-ghedamsitag:de.mathworks.com,2005:Question/3420992017-05-26T17:26:35Z2017-05-26T17:44:41ZI have a matrix and I am actually interested in obtaining a vector that will consist of the first column in each row that has values lower certain value.<p>I have a matrix and I am actually interested in obtaining a vector that will consist of the first column in each row that has values lower 3. e.g if I have A=[ 5 7 8 3 2 ;6 2 1 4 4;1 2 3 4 5; 4 5 2 1 3].
I expect an Ans: [5;2;1;4]</p>Sainthttps://de.mathworks.com/matlabcentral/profile/authors/7734966-sainttag:de.mathworks.com,2005:Question/3391072017-05-07T05:54:02Z2017-05-26T17:43:59ZMatlab + Hadoop Integration ??<p>We Followed standard doc for integrating Hadoop-2.7.2 with Matlab-R2016b.
* <b>Link for document*</b> : <a href = "http://in.mathworks.com/help/mdce/configure-a-hadoop-cluster.html">http://in.mathworks.com/help/mdce/configure-a-hadoop-cluster.html</a></p><p>We Completed up to this stage but we are confuse with the rest part....</p><p>The requirements are:</p><ol><li>MATLAB® Distributed Computing Server™ must be installed or available on the cluster nodes. See Install Products and Choose Cluster Configuration.</li><li>If the cluster is running in Kerberos authentication that requires the Java Cryptography Extension, you must download and install the Oracle version of this extension to each MATLAB Distributed Computing Server installation. You must also perform this step for the MATLAB client installation. To install the extension, place the Java Cryptography Extension jar files into the folder ${MATLABROOT}/sys/jre/${ARCH}/jre/lib/security.</li><li>You must have a Hadoop installation on the MATLAB client machine, that can submit normal (non-MATLAB) jobs to the cluster.</li><li>The cluster must identify its user home directory as a valid location that the nodes can access. You must choose a local filesystem path and typically use a local folder such as /tmp/hduserhome or /home/${USER}. Set yarn.nodemanager.user-home-dir for Hadoop version 2.X.</li><li>There is one Hadoop property that must not be "final." (If properties are "final", they are locked to a fixed predefined value, and jobs cannot alter them.)</li><li>The software needs to append a value to this property so that task processes are able to correctly run MATLAB. This property is passed as part of the job metadata given to Hadoop during job submission.</li></ol><p>This property is mapred.child.env, which controls environment variables for the job's task processes.</p><p>You must provide necessary information to the parallel.cluster.Hadoop object in the MATLAB client session. For example, see Run mapreduce on a Hadoop Cluster (Parallel Computing Toolbox) and Use Tall Arrays on a Spark Enabled Hadoop Cluster (Parallel Computing Toolbox).</p><p>*MAIN QUESTION IS .....</p><p>1. We are not able to see any Cluster Configuration in <b>Home->Parallel->Manage_Cluster_Profile</b> ???</p><p><b>2.what is Role of MJS in this and how to configure it.</b></p><p><b>3.we are not understanding what we have to export and import for rest of the worker (slave )and master node*</b> ??</p><p>Thanks</p>Pulkesh Haranhttps://de.mathworks.com/matlabcentral/profile/authors/9189565-pulkesh-harantag:de.mathworks.com,2005:Question/2235922015-06-12T16:27:43Z2017-05-26T17:42:20ZR2105a crashing after sleep/display unplug on Yosemite<p>Hi,</p><p>after my Macbook Pro running OS X 10.10 Yosemite returns from sleep mode or after unplugging and plugging back in an external display, R2015a crashes completely, doesn't show any windows at all, only says "Application not responding" in the dock. I'm not quite sure yet whether this has to do with the sleep mode and/or the display thing, since it only happens randomly. I'll support more information once I'm sure about the event causing this issue and would like to hear in the meantime if anybody else has this problem.</p>Florian Glaserhttps://de.mathworks.com/matlabcentral/profile/authors/6201728-florian-glasertag:de.mathworks.com,2005:Question/3421012017-05-26T17:34:10Z2017-05-26T17:34:35ZHow do you get an arbitrary 1 dimensional line scan from a 2D Matrix<p>Hello,</p><p>say I had a NxN Matrix</p><p>Is there any easy way to plot a line scan from any arbitrary points (x1,y1) to (x2,y2)?</p><p>Example, attached is a 256x256 variable tdelt</p><p>I want a line profile of the data between the points (81,96) and (188,40)</p><p>Not sure How I can do this</p><p>Thanks!</p>mattyicehttps://de.mathworks.com/matlabcentral/profile/authors/7041625-mattyicetag:de.mathworks.com,2005:Question/3420552017-05-26T11:08:12Z2017-05-26T17:33:40ZI have seven different graphs in one script and I want to see all seven graphs in one screen what matlab command I can Use.<p>f1=m1(:,1);
r1=m1(:,2);
i1=m1(:,3);
mag1=sqrt(r1.^2+i1.^2);
plot(f1,mag1);
figure(1);</p><p>f2=m2(:,1);
r2=m2(:,2);
i2=m2(:,3);
abs2=sqrt(r2.^2+i2.^2);
figure(2);
plot(f2,abs2);</p><p>f3=m3(:,1);
r3=m3(:,2);
i3=m3(:,3);
abs3=sqrt(r3.^2+i3.^2);
figure(3);
plot(f3,abs3);</p><p>f4=m4(:,1);
r4=m4(:,2);
i4=m4(:,3);
abs4=sqrt(r4.^2+i4.^2);
figure(4);
plot(f4,abs4);</p><p>f5=m5(:,1);
r5=m5(:,2);
i5=m5(:,3);
abs5=sqrt(r5.^2+i5.^2);
figure(5);
plot(f5,abs5);</p><p>f6=m6(:,1);
r6=m6(:,2);
i6=m6(:,3);
abs6=sqrt(r6.^2+i6.^2);
figure(6);
plot(f6,abs6);</p><p>f7=m7(:,1);
r7=m7(:,2);
i7=m7(:,3);
abs7=sqrt(r7.^2+i7.^2);
figure(7);
plot(f7,abs7);</p>Prateek Srivastavahttps://de.mathworks.com/matlabcentral/profile/authors/10070950-prateek-srivastavatag:de.mathworks.com,2005:Question/569072012-12-18T16:32:17Z2017-05-26T17:32:35Zhow can I use Path-Opening Filters in Matlab ?<p>actually I am doing my FYP in blood vessel segmentation and I am stuck in * how can I use Path-Opening Filters in Matlab *?</p>Ahmedhttps://de.mathworks.com/matlabcentral/profile/authors/3814359-ahmedtag:de.mathworks.com,2005:Question/3421002017-05-26T17:30:02Z2017-05-26T17:31:38ZHOW TO LEGEND A VOXEL<p>I used this code to legend a voxel. Can anyone tell me how to legend this voxel with different colours?</p><p>for x = 1:GridSize(1)</p><p>for y = 1:GridSize(2)</p><p>for z = 1:GridSize(3)</p><p>if (~isnan(VoxelGrid(x, y, z)))
cubeLength = 1;</p><p>f = VoxelGrid(x,y,z)/max(max(max(VoxelGrid)));</p><p>cm = colormap; % returns the current color map</p><p>colorID = max(1, sum(f > [0:1/length(cm(:,1)):1]));</p><p>colour = cm(colorID, :); % returns your color</p><p>plotcube([cubeLength cubeLength cubeLength],[x, y, z],0.9,[colour]);</p><p>end</p><p>end</p><p>end</p><p>end</p>trong vuhttps://de.mathworks.com/matlabcentral/profile/authors/10337552-trong-vu