Stack All Flow » Matlab

131 FOLLOWERS

The following section of Stack All Flow is dedicated to articles on Matlab. Other major categories to explore are Dev, MySQL, Php, Ubuntu, Unix Linux, and more. Find tutorial and helpful tips to clear your doubts on the above-mentioned topics as well more.

Stack All Flow » Matlab

2y ago

I am using neural network module in matlab. I have 8 independent variable e.g X1, X2, X3,…X8 with 1 dependent variable e.g Y. As i used neural network and got a equation like– Output = a*(target)+b, but I want a regression equation like — Y(predicted) = f(X1, X2, X3,…X8). Is this provision available in neural network.
Accepted Answer:
y = repmat(b2,O,N) + LW*tanh( repmat(b1,I,N) + IW*x );
Hope this helps.
Thank you for formally accepting my answer
Greg
#MATLAB #Regression #equation #neural #network
The post Regression equation in neural network? appeared first on Stack All Flow ..read more

Stack All Flow » Matlab

2y ago

I want to make new vector based on the values of a different one and taking the sixth value from the end (that would be the new last value) and so on every 6 values. Example: Original vector=( a b c d e f g h i j k l m n o p q r s t) New one (t-6) = (c i o) Thanks!
Accepted Answer:
>> V = 'a':'t'
V =
abcdefghijklmnopqrst
>> fliplr(V(end-5:-6:1))
ans =
cio
#MATLAB #Create #vector #specific #values #vector
The post Create a new vector with specific values from other vector? appeared first on Stack All Flow ..read more

Stack All Flow » Matlab

2y ago

Hello,
the following function computes the number of binary words of length m and certain weight r (number of ones), which do not contain l consecutive zeros:
if (r==0)
if (m<=l-1)
numberOfStrings = 1;
return
else
numberOfStrings = 0;
return
end
else
tmp = 0;
for j=0:min(m,l-1)
for s=0:r-1
bin1=0;
bin2=0;
if ((m-j)-1-s*l < r-1)
bin1 = 0;
else
bin1 = nchoosek((m-j)-1-s*l,r-1);
end
if ((m-j)-1-(1+s)*l < r-1)
bin2 = 0;
else
bin2 = nchoosek((m-j)-1-(1+s)*l,r-1);
end
tmp = tmp + (-1)^s * nchoosek(r-1,s) * (bin1-bin2);
end
end
numBin = tmp;
end
In the first If-case we consider r=0 (also ..read more

Stack All Flow » Matlab

2y ago

I know that I can easily plot a sphere using the sphere function, but I am trying to do it with the cylinder function. This is what I have so far, but I can’t seem to get the function right.
clc;
x1 = linspace(0,pi,100);
y1 = linspace(0,1,100);
z1 = linspace(0,2,100);
[x2, y2,z2]=cylinder(x.^2+y.^2),200);
figure(2);
surf(x2, y2,z2);
xlabel('X');
ylabel('Y');
zlabel('Z');
colormap(jet)
Accepted Answer:
x = linspace(0, 1, 20);
[X, Y, Z] = cylinder(sqrt(x .* (1 - x)));
surf(X, Y, Z);
axis equal
The first input determines the radius. Then h^2 = p*q helps.
#MATLAB #plot #sphere #cylinder #f ..read more

Stack All Flow » Matlab

2y ago

Is there a way of selecting a specific sheet from a csv file please? I’ve got each sheet saved as a date (eg, 19.07) and using strcat, the program finds the sheet I want (like 19.07 for example) but then is there a way of selecting just that sheet from the whole csv file? Thanks
Accepted Answer:
Using xlsread you can select any sheet
#MATLAB #Select #specific #sheet #csv #file
The post Select specific sheet in csv file? appeared first on Stack All Flow ..read more

Stack All Flow » Matlab

2y ago

As is shown in the image,a new point D(0.5,0.5,0) is interpolated on edge OB.As result,the 2 original triangles are divided into 4 triangles.I have two matrix about the original triangls:p[0 0 0;0 0 1;0 1 0;1 0 0]which represents the coordinates of all the vertexes,t[1 2 3;1 3 4]represents the indexes of the vertexes composing each triangle.How to create a new t matrix ?
Accepted Answer:
Perhaps this post on Loren’s blog will help.
#MATLAB #triangulation #insert #point
The post How to do triangulation after insert a new point? appeared first on Stack All Flow ..read more

Stack All Flow » Matlab

2y ago

I have a program which creates a C structure which contains large arrays of various basic data types (ints doubles etc.). What is the most memory efficient way for me to return this data to Matlab from a C mexfunction, while also ensuring all of the memory deallocation is carefully taken care of? I would ideally like to return the whole structure, but methods for returning each array individually are also acceptable.
You may also assume I understand the basics of writing mexfunctions and returning arguments using the basic method of copying the data to an array pointed to by the plhs pointer ..read more

Stack All Flow » Matlab

2y ago

Hi,
I would like to filter a signal using filtfilt in order to have:
– zero phase – to have the initial and final sample of the filtered data the same as the raw data
Following this link: http://www.mechanicalvibration.com/filtfilt_Casual_versus_non_.html#foot60 the initial and final point are maintained using filtfilt. However when I do this, they are not.
The commands I use are: b = [0.0675, 0.1349, 0.0675]; % Low pass Butterworth filter a = [1.0, -1.1430, 0.4128]; Sig_filtered=filtfilt(b, a, Sig_raw);
Can anyone explain this to me or point me towards a filter function that can do this?
Tha ..read more

Stack All Flow » Matlab

2y ago

I used GraphPlot to create a graph but some node labels are on top of edges. Is it possible to change the label positions? If not, are there any alternatives to create visually appealing graphs?
Accepted Answer:
I don’t think there are documented properties of a GraphPlot that allow you to change the placement of the labels relative to the nodes. However, you could remove the labels and replace them with your own matching text labels. That way you have complete control over the placement of each label.
Here’s a demo.
% Creat a graphplot
s = [1 1 1 1 1 1 1 9 9 9 9 9 9 9];
t = [2 3 4 5 6 7 ..read more

Stack All Flow » Matlab

2y ago

I am writing a GUI in GUIDE which contains a popup menu. In the Property Inspector the String property is empty. The contents of the menu must be filled during execution and are assigned values from a structure as such:
a = {AlertFD.name};
set(handles.popupmenu1, 'String', a);
and the user input is assigned to b:
b = get(handles.popupmenu1, 'Value');
The problem occurs when I run the GUI: when I first click on the menu, I see an empty cell. I click on the empty cell and then the first element of cell a is shown and automatically passed as user input to b , even though I do not wish to selec ..read more