フィルターのクリア

Printing Colon Values in a Vector

1 回表示 (過去 30 日間)
Jake Bolanski
Jake Bolanski 2011 年 10 月 20 日
Hello,
I am having a little trouble printing out colon values in a vector. For example:
for x = 1:10
y(x) = x
end
This seems to work for me. However, what if the values for x do not start with 1?
For example what I have right now is this:
for x= 23:78
y(x) = x
end
This produces a result like [0 0 0 ... 23 24 25 ... 78]. What I want to be able to do is start with 23 and end at 78 without the 0's; hence: [23 24 25 ... 77 78]. Any advice?
Thanks.
Also,
I am having a little trouble obtaining the mean values for y_coordinates in a rectangle. Currently, I am able to plot a rectangle about the centroid of a flower. What I want to do is use the impixel() command to obtain the RGB values - such that I can know the color. Since the x_values in the rectangle are same as the y_values change, mean(x_cood:x_cood + width) seems to work for me. However, I am unable to present the same for the y_cood. In other words, I want to be able to take the mean of all the y_coordindates at the x_coordinates such that I have an average of all the values within the rectangle. Then, I want to run the impixel() command. Here is what I have:
for U = 1:5:height
% plot(x_cood:x_cood + width,y_cood + U,...
% '--rs','LineWidth',2,...
% 'MarkerEdgeColor','k',...
% 'MarkerFaceColor','r',...
% 'MarkerSize',2)
% hold on;
x_mean = mean(x_cood:x_cood + width);
y_mean = mean(y_cood + U);
plot(x_mean,y_mean,...
'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','r',...
'MarkerSize',2)
hold on;
rect_pixel = impixel(cam_image_rgb,x_mean,y_mean);
r = rect_pixel(1);
g = rect_pixel(2);
b = rect_pixel(3);
fprintf('Red = %0.2f, Green = %0.2f, Blue = %0.2f\n',r,g,b)
end
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 10 月 20 日
Please ask one question at a time. After all, somebody else might search for a topic for answers.

サインインしてコメントする。

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 10 月 20 日
It is a matter of an offset, right?
Original:
for x= 23:78
y(x) = x
end
Can be done as:
for x= 23:78
y(x-22) = x
end
Or: y=23:78
  1 件のコメント
Jake Bolanski
Jake Bolanski 2011 年 10 月 20 日
Thanks! On a separate note, do you know if it is possible for me to tell the color using RGB values in MatLab? Currently I have r = 243, g = 246, b = 77. Is it possible to say this falls in the yellow category?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxes Appearance についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by