Asked by divya bhandari
on 14 Jun 2018

I want a correct logic of my code.

Also, I want the operations on my two plots i.e.

- error of two plots
- difference curve
- correlation.

true=multibandread('paris.lan',[512,512,7],'uint8=>uint8',128,... 'bil','ieee-le');

i1=true( :, :,1); i2=true( :, :,2); i3=true( :, :,3); i4=true( :, :,4); i5=true( :, :,5); i6=true( :, :,6); i7=true( :, :,7);

x(1)=double(i1(38,333)); x(2)=double(i1(38,334)); x(3)=double(i1(38,333)); x(1)=double(i1(38,333)); x(2)=double(i1(38,334)); x(3)=double(i1(39,333)); x(4)=double(i1(39,334)); y(1)=double(i1(486,115)); y(2)=double(i1(486,116)); y(3)=double(i1(487,115)); y(4)=double(i1(487,116)); avg1=((x(1)+x(2)+x(3)+x(4))/4); avg2=((y(1)+y(2)+y(3)+y(4))/4);

a(1)=double(i2(38,333)); a(2)=double(i2(38,334)); a(3)=double(i2(39,333)); a(4)=double(i2(39,334)); b(1)=double(i2(486,115)); b(2)=double(i2(486,116)); b(3)=double(i2(487,115)); b(4)=double(i2(487,116)); avg3=((a(1)+a(2)+a(3)+a(4))/4); avg4=((b(1)+b(2)+b(3)+b(4))/4);

m(1)=double(i3(38,333)); m(2)=double(i3(38,334)); m(3)=double(i3(39,333)); m(4)=double(i3(39,334)); n(1)=double(i3(486,115)); n(2)=double(i3(486,116)); n(3)=double(i3(487,115)); n(4)=double(i3(487,116)); avg5=((m(1)+m(2)+m(3)+m(4))/4); avg6=((n(1)+n(2)+n(3)+n(4))/4);

p(1)=double(i4(38,333)); p(2)=double(i4(38,334)); p(3)=double(i4(39,333)); p(4)=double(i4(39,334)); q(1)=double(i4(486,115)); q(2)=double(i4(486,116)); q(3)=double(i4(487,115)); q(4)=double(i4(487,116)); avg7=((p(1)+p(2)+p(3)+p(4))/4); avg8=((q(1)+q(2)+q(3)+q(4))/4);

r(1)=double(i5(38,333)); r(2)=double(i5(38,334)); r(3)=double(i5(39,333)); r(4)=double(i5(39,334)); s(1)=double(i5(486,115)); s(2)=double(i5(486,116)); s(3)=double(i5(487,115)); s(4)=double(i5(487,116)); avg10=((s(1)+s(2)+s(3)+s(4))/4); avg9=((r(1)+r(2)+r(3)+r(4))/4);

h(1)=double(i6(38,333)); h(2)=double(i6(38,334)); h(3)=double(i6(39,333)); h(4)=double(i6(39,334)); j(1)=double(i6(486,115)); j(2)=double(i6(486,116)); j(3)=double(i6(487,115)); j(4)=double(i6(487,116)); avg12=((j(1)+j(2)+j(3)+j(4))/4); avg11=((h(1)+h(2)+h(3)+h(4))/4);

f(1)=double(i7(38,333)); f(2)=double(i7(38,334)); f(3)=double(i7(39,333)); f(4)=double(i7(39,334)); g(1)=double(i7(486,115)); g(2)=double(i7(486,116)); g(3)=double(i7(487,115)); g(4)=double(i7(487,116)); avg13=((f(1)+f(2)+f(3)+f(4))/4); avg14=((g(1)+g(2)+g(3)+g(4))/4);

% d=[300,400,500]; % r=[avg1,avg3,avg5]; % plot(d,r) % hold on % c=[avg2,avg4,avg6]; % plot(d,c) % plot(d,c) % d=[100,200,300,400,500,600,700]; % r=[avg1,avg3,avg5,avg7,avg9,avg11,avg13]; % plot(d,r) % hold on % c=[avg2,avg4,avg6,avg8,avg10,avg12,avg14]; % plot(d,c) d=[100,200,300,400,500,600,700]; r=[avg1,avg3,avg5,avg7,avg9,avg11,avg13]; % plot(d,r) %hold on c=[avg2,avg4,avg6,avg8,avg10,avg12,avg14]; % plot(d,c) figure, plot(d,r,'r',d,c,'g') title('actual signals');

z=corr2(r,c); figure, plot(d,z) title('correlation of 2 signals'); %correlation

mm=r-c; SSE=dot(mm,mm); figure, plot(d,mm) title('error of 2 signals'); % error

deltaSignal = double(abs(c - r)); percentageDifference = double(deltaSignal ./ r); % Percent by element. meanPctDiff = mean(percentageDifference); % Average percentage over all elements. figure, plot(deltaSignal,percentageDifference,'r',deltaSignal,meanPctDiff,'g') title('% difference of 2 signals');

Opportunities for recent engineering grads.

Apply Today
## 10 Comments

## per isakson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578599

Is

the name of a variable?true## divya bhandari (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578603

yes,true is a variable name. Actually I just want to convert this long code of lines into a sjort one. and to make operations on the two plots obtained.

## divya bhandari (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578605

I tried but errors..

## per isakson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578655

In Matlab,

is the name of a function. Try to avoid using names of Matlab functions as names of variables (or your own functions). Matlab lets you do it, but it may cause bugs, which are difficult to spot.trueI modified your code so that it doesn't throw errors. However, it doesn't produce the expected result.

doesn't depend onfor k=1:7, ..., end.k## divya bhandari (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578779

Exactly,I am also not getting the expected output of this code.Help me a s soon as possible.

## divya bhandari (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578784

Please let me know about the 3 operations,which I asked above.

## per isakson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578926

"I tried but errors."I tried to help you in that effort.However, I'm not clear about your three items and I'm not prepared to analyze the 100+ lines of code in your question.

## divya bhandari (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_578938

3 operations are

## Aarti Dwivedi (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_585958

Why can't you get the difference by just subtracting the variables from each other? I am assuming they are of the same size

## divya bhandari (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405576-i-want-a-correct-logic-of-my-code-also-i-want-the-operations-on-my-two-plots-i-e-1-error-of-two-p#comment_585972

Thank you so much.

Sign in to comment.