a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]

3 Kommentare

Azzi Abdelmalek
Azzi Abdelmalek am 17 Mai 2016
What space?
Bella
Bella am 17 Mai 2016
what?
Kelvin
Kelvin am 7 Feb. 2023
1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 7 It’s a matrix

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Todd Leonhardt
Todd Leonhardt am 17 Mai 2016
Bearbeitet: Todd Leonhardt am 17 Mai 2016

1 Stimme

a(:,2:3) is saying "give me the submatrix of a which consists of all rows and the 2nd and 3rd columns".
If you don't have MATLAB you can get a free evaluation, at least for academic purposes. You can also do many of the things MATLAB can do using open-source Octave (though there are significant limitations). Get one of those and then try to do this stuff yourself so you actually learn something ;-)

4 Kommentare

Bella
Bella am 17 Mai 2016
I did try it and I got [3 4; 4 5; 5 6] but it said it was wrong
Todd Leonhardt
Todd Leonhardt am 17 Mai 2016
Bearbeitet: Todd Leonhardt am 17 Mai 2016
Then I believe you entered something wrong. It should be [2 3; 3 4; 4 5; 5 6].
Bella
Bella am 17 Mai 2016
hmm, well thank you!
Image Analyst
Image Analyst am 17 Mai 2016
What do you mean "it said it was wrong"? +*What*_ said that? MATLAB? If so, post the error message here. If you got that you must have left off the top row and done this:
a = [
2 3 4 5 6;
3 4 5 6 7;
4 5 6 7 8]
a(:,2:3)
However there is nothing in MATLAB that says anything is wrong about that - no error message or anything.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Greg Biyu
Greg Biyu am 12 Mär. 2019

0 Stimmen

what is (:,:,3)?

5 Kommentare

Steven Lord
Steven Lord am 12 Mär. 2019
You may find this documentation page informative.
Ghislain Rutayisire
Ghislain Rutayisire am 22 Feb. 2021
exactly what i was looking for!
Anu Sebastian
Anu Sebastian am 9 Mär. 2021
What you mean by G=he(:,:,2); Especially (:,:,2)
Walter Roberson
Walter Roberson am 10 Mär. 2021
You were dealing with
he = imread('1.jpg');
which reads the image file and stores the result as an array.
If 1.jpg had been a color image, then the resulting array he would have been a 3D array, with the first index being for rows (vertical height), and the second index being for columns (horizontal distance), and for the third index being for color panes. The first color pane for an RGB image holds the Red component. The second color pane for an RGB image holds the Green component. The third color pane for an RGB image holds the Blue component.
Thus, if 1.jpg had been an RGB image, then he(:,:,2) would be a 2D array containing just the green component of the color information for each pixel.
However, your 1.jpg was not an RGB image; it was a grayscale image, and there is no red or green or blue component. If you needed specifically the green information (for example you were examining leaves) then you would not be able to proceed using that image. If, though, the green component was being used to approximate brightness (eyes are more sensitive to green), then you could just use the data you received instead. For example,
if ndims(he) > 2
G = he(:,:,2);
else
G = he;
end
end
Anu Sebastian
Anu Sebastian am 10 Mär. 2021
Thank you sir

Melden Sie sich an, um zu kommentieren.

Maria Celeste
Maria Celeste am 2 Nov. 2022

0 Stimmen

What are the answers to these? >> B(2:5) 20. >> A(4:8) 21. >> A(:,3) 22. >> B(:,3:4) 23. >> A(2:3,:) 24. >> B(2:3, 2:4) 25. >> length (A)

1 Kommentar

Walter Roberson
Walter Roberson am 2 Nov. 2022
B(2:5) is 'TAIF'
A(4:8) is [81 84 83 72 76]
A(:,3) is [84; 83]
B(:,3:4) is ['II'; 'XN'; 'YX']
A(2:3,:) is an error because A does not have 3 or more rows.
B(2:3, 2:4) is ['FXN'; 'KYX']

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by