How to change the line color in a plot using geoplot? [closed] - matlab

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 3 years ago.
Improve this question
I want to use geoplot command to show latitude and longitude and change the line color using a third variable speed. Speed is a array of size (120,3). How can I do this considering that I want to represent my data on a map (using geoplot)? The colour and corresponding value can be checked with colourbar.
I am using MATLAB.

Have a look at the documentation of geoplot. Use the name-value pair 'Color','r' to configure red lines in this case (r:red, k:black, b:blue, g:green,... or use a 3x1 RGB array (normalized), see here). You can also use the keyword 'LineStyle' to set e.g. dashed lines.
c = [1 0 0]; % RGB | [255 0 0]/255
geoplot(...,'Color',c);

Related

Creating an axis of months [closed]

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 5 years ago.
Improve this question
I would like to create an axis from the dates 03-01-2014 to 2-28-2015 with (289*12) individual data points. So for each month the X-axis will have the month shown for every 288 data points I have in my array.
Does someone know how I can achieve this?
You can do this by three function which already available in Matlab toolbox
first plot your data(it would be better if you say how we can regenerate your data because of that i try my own )
x = [1 2 3 4 5 6];
data = sin(x);
plot(x,data)
this 3 lines code gave me below plot for instance.
so how we could add month to axis ?! we can do it with set and gca like below
set(gca,'xtick',1:6); % this xtick is very important(i said in this line i want to have x axis ticks in 1,2,3,..,6 so if your x axis is different you must change this line)
set(gca,'xticklabel',{'03-01-2011','03-01-2012','03-01-2013','03-01-2014','03-01-2015','03-01-2016'})
set(gca,'XTickLabelRotation',30)
the output will be

How can I trace the highest value in a matrix until I go to a cell in the matrix with zero value? [closed]

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 6 years ago.
Improve this question
I need to start with the highest value in the matrix (i,j). Then, go backwards to one of positions (i-1,j), (i, j-1), and (i-1, j-1) depending on the direction of movement used to construct the matrix. This method is used throughout until a matrix cell with zero value is reached.The above image shows what I want, I need to trace those marked in blue. I know there is a max function in matlab.
If I understand what you try to do...
Suppose M is your matrix:
result=[];
[~,ind]=max(M(:));
[r,c]=ind2sub(size(M),ind);
result=[result; r c];
while M(r,c)~=0
[~,f]=max([M(r-1,c),M(r,c-1),M(r-1,c-1)]);
switch f
case 1
r=r-1;
case 2
c=c-1;
case 3
r=r-1;
c=c-1;
end
result=[result; r c];
end
Then, result is a 2 x n matrix, where each row is the indexes of one step- from the upper to lower.

how to find indices in cell array [closed]

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 7 years ago.
Improve this question
I have a vector, size: normal(494020);
normal={ 'back.' 'buffer_overflow.' 'ftp_write.' 'guess_passwd.' 'imap.'};
The strings in this vector are randomly distributed. I want to know what is the index of 'back.' , and how many indices it covers. Same way for other strings. Please help.
Use strcmp to compare a cell array of strings with a string:
>> normal={ 'back.' 'buffer_overflow.' 'ftp_write.' 'guess_passwd.' 'imap.'};
>> strcmp('back.',normal)
ans =
1 0 0 0 0
So what you're after is
string='back.';
index_of_string=find(strcmp(string,normal),1);
this will return the first index k for which normal{k} is the same as string. So it will discard multiplicities.
If by "how many indices it cover" you mean that you need multiplicities, then just remove the ,1 from the call to find, then you'll get an index vector containing every index k for which normal{k} is equal to string.

Returning specific regions [closed]

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 9 years ago.
Improve this question
Say that I have a labeled image, where I have calculated the area of each region. How can I return specific regions? That is, say I want to return the regions that have >=300 and <500?
Thanks.
You can group the results of regionprops into a vector and use it for indexing:
rg = regionprops( L, 'Area' );
allArea = [rg(:).Area]; % grouping all area values into a single vecotr
labels = find( allArea >= 300 & allArea < 500); % select relevant regions

How can I apply a ring-shaped median filter to an image in matlab? [closed]

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 9 years ago.
Improve this question
The default matlab function medfilt2 uses a rectangular mask.
Thanks guys
you can use ordfilt2 .
For example, if your "ring" is just defined by:
ring= fspecial('gaussian',21,1)
ring = ring>eps & ring<1e-9
then:
order=sum(ring(:))/2;
B = ordfilt2(A,order,ring);
replaces each element in A by the order-th element in the sorted set of neighbors specified by the nonzero elements in the ring domain.
Here I chose 'order' to be half the total # of the pixels in the ring.