Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How would I do to plot an excel file which consist of a set of data in two columns. Would like to make my first column data representing the y-axis and second column data in x-axis.
Its really easy if you use the function xlsread(). Your code should look like
A = xlsread('Data.xlsx');
x = A(:,2);
y = A(:,1);
plot(x, y);
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
distance = [10:.1:30];
norm_dist = normpdf(distance,20,2);
I am trying to generate x,y,z coordinates from the above range of normally distributed values but don't know how to do. Please help.
The normal_dist variable generates values in a normally distributed fashion. I want to use these values to randomly generate the x,y,z, coordinates values. The separate x,y,z values need to be generated not a 3-D array
If I understand your question correctly, you need to use meshgrid function as well
distance = [10:.1:30];
[X,Y,Z] = meshgrid(distance);
F = normpdf(X,20,2);
As a result you'll get 3d grid with those numbers
meshgrid() creates a matrix you can use for further calculations. Probably you will need to make normpdf dependent on X, Y, Z at the same time, e.g.
F = normpdf(X.^2+Y.^2+Z.^2,20,2)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have the following query. I want to plot in MATLAB the following equation :
i + s - ln(s)/sigma = constant (i and s are variables)
for a given value of constant and sigma. The equation is between s and i. the value of sigma is 0.5 and value of constant can be assumed to be 1.
I want to plot the above equation. i and s both are function of time but in graph we need graph of s & i only. i on y axis and s on x axis.
try fimplicit
https://www.mathworks.com/help/matlab/ref/fimplicit.html
f=#(s,i) i + s - log(s)/2 - 5;
fimplicit(f,[1 5 2 10])
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I don't understand when to use the semilogx or semilogy function in Matlab and when to use the plot function,for example for displaying the spectrum of a signal
semilogx will scale the x-axis logarthmically, the same applies for semilogy on the y-axis. The data is exactly the same but sometimes it can be easier to view data where your axes are scaled like this. For example compare the two plots below.
x = [0.01 0.1 1 10 100 1e3 10e3];
subplot(121);
plot(x, '-o');
grid on;
subplot(122);
semilogy(x, '-o');
grid on;
You can access the documentation for any MATLAB function using help or doc as follows doc semilogx
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm creating a matrix in matlab of size n that contains only ones and zeros. The easiest way to do that is round(rand(m,n)) for a matrix of size mxn, but it creates in some cases rows that have all zeros or all ones. I want to put a lower and upper bound in the number of ones that each row has. Is there an easy way to do that?
Thanks
This is just for one column, but can easily be extended to a matrix:
v = zeros(m,1); % column
Fill the beginning of the column with at least 40% and at most 60% ones:
v(1: floor((0.4+(0.6-0.4)*rand())*(m+1))) = 1;
Shuffle the column:
v = v(randperm(numel(v)));
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have two data set in my hand, they are 720*1 size column matrices , how can ı calculate the error and draw the error ditribution diagram? One of them are actual data and the other is the predicted one.
In matlab,
true = rand(720, 1); % or wherever else you get your data
pred = rand(720, 1); % or wherever else you get your data
errs = pred - true; % the error in each predicted value
nbins = 50; % number of bins for histogram
hist(errs, nbins); % plot the histogram