How to make array in matlab ( how to inisialisasi array )
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
채택된 답변
Oleg Komarov
2011년 8월 4일
B = zeros(n)
B = zeros(m,n)
B = zeros([m n])
B = zeros(m,n,p,...)
B = zeros([m n p ...])
where m,n,p,... express the size for the 1st,2nd,3rd,...nth dimension.
If you're not looking for preallocation then your answer is too generic.
Something else I can think of is a generation of a random matrix, see rand and related functions.
EDIT
obj=VideoReader(video);
% (start)
%akhir deklarasi gambar yang ada di axes
numFrames = obj.NumberOfFrames;
waktu = obj.Duration;
iterasi = numFrames/waktu;
vidHeight = obj.Height;
vidWidth = obj.Width;
disp(numFrames);
a = length(numFrames);
frames = zeros(vidHeight,vidWidth,iterasi);
c = 0;
if(~isempty(get(handles.nmvideo,'String')))
try
for n = 1:iterasi:numFrames
c = c+1;
frames(:,:,c) = read(obj,n);
h = axes(handles.axes1);
imshow(frames(:,:,c));
end
catch
msgbox('Codec AVI tidak didukung atau Corupted file AVI','Error','error');
return
end
else
msgbox('Anda harus memilih video terlebih dahulu','Error','error');
end
댓글 수: 10
thx oleg komarov, i have problem about my program... maybe can you help me, i want to make array for inisialisasi frame 1 until frame 32 .... this is my code, maybe you can fix it ... :
obj=VideoReader(video);
% (start)
global frame1;global frame2;global frame3;global frame4;global frame5;
global frame6;global frame7;global frame8;global frame9;global frame10;
global frame11;global frame12;global frame13;global frame14;global frame15;
global frame16;global frame17;global frame18;global frame19;global frame20;
global frame21;global frame22;global frame23;global frame24;global frame25;
global frame26;global frame27;global frame28;global frame29;global frame30;
global frame31;global frame32;
%akhir deklarasi gambar yang ada di axes
numFrames=obj.NumberOfFrames;
waktu=obj.Duration;
iterasi=numFrames/waktu;
vidHeight = obj.Height;
vidWidth = obj.Width;
disp(numFrames);
a=length(numFrames);
disp(a);
if(~isempty(get(handles.nmvideo,'String')))
try
for n = 1:iterasi:numFrames
frame1=read(obj,n);
axes(handles.axes1);
imshow(frame1);
end
,enam);
catch
msgbox('Codec AVI tidak didukung atau Corupted file AVI','Error','error');
return;
end
else
msgbox('Anda harus memilih video terlebih dahulu','Error','error');
end
Please post the correct code in your original message and format it with the {} button.
,enam);
Is definitely an uncomplete line.
Drop the global part, then preallocate:
frames = zeros(vidHeight,vidWidth,iterasi);
c = 0;
Inside the loop
c = c+1;
frame(:,:,c) = read(...)
oleg komarov, i have question , in "frames = zeros(vidHeight,vidWidth,iterasi); " ... is it frames or frame? why in the behind oh your code is frame not frames? ( "frame(:,:,c) = read(...)")... and if i want to display the object, " imshow () " what? imshow (frame) ? or imshow (frames) ?
Sorry just a typo. Call it however you like it, it's the same array.
To display:
imshow(frames(:,:,c))
hhhmmm oleg komarov... i had try it,,, but i can't ... :( ... maybe i must study hard for understand it ...
frames its a variable, oleg ?
See my edit, post error messages and|or unexpected behaviour.
hhhhhmmmmmmmmmmmm...............
Yes, frames is a variable.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
참고 항목
2011년 8월 4일
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
