how to convert a wave form into 2D matrix form using for loop?

1 回表示 (過去 30 日間)
ajeet verma
ajeet verma 2017 年 8 月 7 日
コメント済み: ajeet verma 2017 年 8 月 7 日
my code is here
%%STEP FIRST (wave form)
clc;
clear all;
Imax=0.8;
Imin=0.2;
Im=Imax-Imin;
T = 20;
s1= @(x) ((2*Im*x/T)+Imin+Im/2).*(0<=x & x<=T/4) +((-2*Im*x/T)+Imin+3*Im/2).*(T/4<=x & x<=3*T/4)+((2*Im*x/T)+Imin-3*Im/2).*(3*T/4<=x & x<=T);
x = linspace(0, 20);
I1 = s1(x);
figure(1),plot(x,I1)
% second step (2D matrix image)
m=1000;
n=1000;
for i=1:m
for j=1:n
s1= @(x) ((2*Im*x/T)+Imin+Im/2).*(0<=x & x<=T/4) +((-2*Im*x/T)+Imin+3*Im/2).*(T/4<=x & x<=3*T/4)+((2*Im*x/T)+Imin-3*Im/2).*(3*T/4<=x & x<=T);
I(i,j)=s1*(j/n+i/m);
end
end
imshow(I,[]);
second step is not working, where is wrong? please help please find attachment

採用された回答

KSSV
KSSV 2017 年 8 月 7 日
clc;
clear all;
Imax=0.8;
Imin=0.2;
Im=Imax-Imin;
T = 20;
s1= @(x) ((2*Im*x/T)+Imin+Im/2).*(0<=x & x<=T/4) +((-2*Im*x/T)+Imin+3*Im/2).*(T/4<=x & x<=3*T/4)+((2*Im*x/T)+Imin-3*Im/2).*(3*T/4<=x & x<=T);
x = linspace(0, 20);
I1 = s1(x);
figure(1),plot(x,I1)
% second step (2D matrix image)
m=1000;
n=1000;
I = zeros(m,n) ;
for i=1:m
for j=1:n
s1= @(x) ((2*Im*x/T)+Imin+Im/2).*(0<=x & x<=T/4) +((-2*Im*x/T)+Imin+3*Im/2).*(T/4<=x & x<=3*T/4)+((2*Im*x/T)+Imin-3*Im/2).*(3*T/4<=x & x<=T);
I(i,j)=s1(j/n+i/m);
end
end
imshow(I,[]);
  4 件のコメント
ajeet verma
ajeet verma 2017 年 8 月 7 日
if we reduce the value of image size (1000,1000) to (100,100) it works properly,
ajeet verma
ajeet verma 2017 年 8 月 7 日
but desired result is not coming

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by