2018-10-21 Allen

## Smoothing 2D curves

I am trying to get a curve from the extracted boundary of the 3D mesh. I do the following to extract the boundary:1- segment the 3d mesh into regions.2- extract the boundary of each region3- Transform 3D boundary into X-Y plane4- segment the boundaryThe following image shows the resulted boundary example of coordinate pointsX Y0.24628 1.491850.26724 1.498860.26145 1.497091.09528 1.211060.24628 1.491850.26724 1.498860.26854 1.498430.26145 1.497090.27626 1.500010.28379 1.501170.28052 1.499950.29360 1.502990.30082 1.504350.31017 1.506280.31869 1.508400.31892 1.50806... 2018-10-21 Darcy

## ROI transparent background (MATLAB)

I'm trying to use imfreehand and save the coordinates of my ROI so when I overlay the image onto another, that ROI is transparent (or set to NAN). Basically is there a way to set inside the imfreehand region as 'NaN' when I overlay onto another image? Reference attached image. Here is my code: %% output arrival_time parametric heatmap %%figure;imagesc(at);colorbar;title('arrival time');colormap('jet');caxis([2.5 5]);%savefig(['Acute_1e13_draft_DRAFT_ignore' '.fig']);%% code to blend heatmap %%minv = 2.5;%min(min(R1_perf(:,:,29)));maxv = 5;%max(max(R1_perf(:,:,2 t9)));map=co... 2018-10-21 Katherine

## How can I obtain only word without All Punctuation Marks when I read text file?

The text file abc.txt is an arbitrary article that has been scraped from the web. For example, it is as follows: His name is "Donald" and he likes burger. On December 11, he married.I want to extract only words in lower case and numbers except for all kinds of periods and quotes in the above article. In the case of the above example: {his, name, is, Donald, and, he, likes, burger, on, December, 11, he, married}My code is as follows:filename = 'abc.txt';fileID = fopen(filename,'r');C = textscan(fileID,'%s','delimiter',{',','.',':',';','"','''});fclose(fileID);Cstr = C{:};C... 2018-10-21 Sandra

## Not getting expected result when converting numeric value to character vector

I am trying to convert the numeric value as string or character using num2str or sprintf. I don't understand why the output is different than my input? I expect the output to be the same as the input.s=num2str(180814132242864695,'%18d')s = 180814132242864704 % this is the outputs = sprintf('%18d',180814132242864695)s = 180814132242864704 MATLAB interprets all numeric literals as double precision floating point. The problem isn't with the conversion to a string but rather with the fact that when converted into memory the value 180814132242864695 becomes the nearest value... 2018-10-21 Bernard

## Declaring a vector in matlab whose size we don't know

Suppose we are running an infinite for loop in MATLAB, and we want to store the iterative values in a vector. How can we declare the vector without knowing the size of it?z=??for i=1:inf z(i,1)=i; if(condition)%%condition is met then break out of the loop break; end;end; Please note first that this is bad practise, and you should preallocate where possible.That being said, using the end keyword is the best option for extending arrays by a single element:z = [];for ii = 1:x z(end+1, 1) = ii; % Index to the (end+1)th position, extending the arrayendYou c... 2018-10-21 Sandy

## How to read a ".wav" file into MATLAB?

I wanted to input a wave file in the MATLAB so that I could process it using filters, when I come to input the wave file called wave.wav, this file is located on my desktop, and then I used [y, fs, nb] = wavread('wave.wav');to read the wave file but always gives me an error cannot open file, the only thing I can think of is that the function doesnt know the path of the wave.wav, any help?And how can I play the file also using MATLAB after read, sound()? Yes, you are correct on both counts. Use the full path to the file, and use the sound function to play it back. See t... 2018-10-21 Bertram

## Plotting Eye Diagram from ADS Data in MATLAB

I have a data file (Sample_Eye_1.txt) which I obtained from the simulation plot of ADS Keysight. It has 3 fields - "Index", "Time" and "Voltage". Now the eye diagram plot will be voltage vs time. There can be different voltages at the same time at only different index. So index can be seen as a data filter field or similar like that. The plot in ADS simulation is the followingYou can see that the line plot is plotted like it is superimposed on different lines.Now when I plot data in MATLAB voltage vs time, it is not superimposed somehow. This is the plot generated plot of ... 2018-10-21 Rex

## How to use the same variable in different functions in GUI MATLAB

I have a popup menu with the following code. There are two options as C1 and C2. If the user selects C1, I want to set the value as 10 and if the user selcts C2, I want to set the value as 20. function pop_Callback(hObject, eventdata, handles)contents = cellstr(get(hobject,'String'));A = contents{get(hObject,'Value')};if (strcmp(A,'C1')) X = 10;elseif (strcmp(A,'C2')) X = 20;endset(handles.pop,X)I want to use another function with a pushbutton and static text to display the answer, where the output is, Whatever the set value + 12. function push_Callback(hObject, event... 2018-10-21 Tina

## MATLAB symengine fails on a logical statement

I want to make matlab agree with the following simple statement:(x-a)^b>=0 when x>0, a>0, b<0, x>aIn order to do so I write:syms x a bassume(x>0 & a>0 & b<0 & x>a);isAlways((x-a)^b>=0,'Unknown','error')And get the following error message:Error using symengineCannot prove '0 <= (x - a)^b'.Error in sym/isAlways (line 38)Y = mupadmex('symobj::isAlways',X.s,isMath,['"Unknown' p.Unknown '"'],9);Why does MATLAB fail to agree with such an evident statement? I don't know why but instead of using as assumption x>a, use x-a > 0. I... 2018-10-22 Madge

## One node decision tree in matlab

Im using matlab 2014a and I cant find how to do 1 node decision tree (and 2 nodes, 3 nodes ext.) Itried to use: "MaxNumSplits",and "MaxDepth" but I got MaxNumSplits is not a valid parameter name.thanks ahead Your version of Matlab is too old for manipulating the MaxNumSplits parameter.Matlab's way of implementing algorithms changes along time. This is the case here for fitctree (fit classification tree) when the R2015a version was released. See the following 'new features' page introducing 2 new parameters for the fitctree function Additional option to control ... 2018-10-22 Gabriel

## SVM Matlab classification

I'm approaching a 4 class classification problem, it's not particularly unbalanced, no missing features a lot of observation.. It seems everything good but when I approach the classification with fitcecoc it classifies everything as part of the first class. I try. to use fitclinear and fitcsvm on one vs all decomposed data but gaining the same results. Do you have any clue about the reason of that problem ? Here are a few recommendations:Have you normalized your data? SVM is sensitive to the features beingfrom different scales. Save the mean and std you obtain during th... 2018-10-22 Perry

## Plot confidence boundary from 2 signals

I have a plot from two signals. On x axis time and on y axis yaw rate. Now I need to plot confidence boundaries (upper and lower) of graph according to confidence interval 95%. It should be like this:but how should I start?I loaded my yawrate and size. They have (1080 1) as size and just vectors, and if call yawrate it looks like in photo. N = size(yawrate,1); yMean = mean(yawrate); ySEM = std(yawrate)/sqrt(N); CI95 = tinv([0.025 0.975], N-1); yCI95 = bsxfun(@times, ySEM, CI95(:)); f... 2018-10-22 Ella

## Switch between two opened tabs in the MATLAB editor

I have opened several files in the MATLAB editor. If I want to go to the previously used file, it is relatively difficult to have to look for (and click on) the name of the file. Instead, can we use a MATLAB shortcut to directly go to the previously used file within the opened files? I am not asking about using ctrl+page up or ctrl+page down to move to the neighbouring files in the editor, but instead want to go to the one which was previously in focus. You can always use Notepad++ and use 'Ctrl+Tab' there. Any changes you make will be reflected in the MATLAB editor as w... 2018-10-22 Verne

## Matlab optimization toolbox, optimizing hessian

Never used this toolbox before, I have a very large problem (i.e. number of variables) to be optimzed. I'm aware it's possible to optimize the hessian computation, which is my issue given the error:Error using eyeRequested 254016x254016 (480.7GB) array exceeds maximum array size preference. Creation of arrays greater than this limit maytake a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.But according to this quote (from a forum) it must be possible to optimize the hessian computation: If you are going to u... 2018-10-22 Benjamin

## Matlab computing the sampling frequency to produce a specific sound from a pure sine wave

I have a rather strange but i thin interesting question. The idea is to gain a better understanding of sampling rate vs frequency shifting when playing audio. The idea is a little experiment: clc;clear all;%synthetic example%in practice it seems that a period T = 2*maxFreq is not enough -> i choose%10T=1/(10*10^6);%period should be at least 1/(2*10^6Hz) => Nyquist freq if we want to be able to reproduce 10^5Hz max freqx=0:T:1-T;f=10^6;%frequencyy=sin(2*pi*f*x);%i see visually that there is 11 samples constituting 1 period%plot(y(1:11))%plot(y(100:111))%etcnbPeriods=le... 2018-10-22 Jeff