How can I make a variable defined in one script make change also in a second script?

조회 수: 1 (최근 30일)
MOTIVATION: I wrote the following lines to obtain the distance of a give moving point between two images:
open cpcorr.m;
P2=4;
base_points_0 = [ 75 24 ];
input_points_0 =[ 75 24 ];
imagea = imread('0.bmp');
imageb = imread('1.bmp');
image1 = rgb2gray(imagea);
image2 = rgb2gray(imageb);
y = zeros(1,2,4);
[input_points, base_points] = cpselect(image2,image1, input_points_0, base_points_0, 'wait', true);
y(:,:,1) = base_points;
corrected_inputs = cpcorr(input_points, base_points, image2, image1);
y(:,:,2) = corrected_inputs;
input_points = corrected_inputs;
base_points = corrected_inputs;
filename1 = '1.bmp';
PROBLEM: The value 4 of variable P2 should be assigned to the correlation size (CORRSIZE = P2) in cpcorr.m but unfortunately I obtain the following error:
??? Undefined function or variable 'P2'.
Error in ==> cpcorr at 76
CORRSIZE = P2;
QUESTION: How can I write a value in the calculation script that makes a change in cpcorr.m without needing to change that number manually?
Thank you for your help
Emerson

채택된 답변

Junaid
Junaid 2012년 2월 5일
Hi,
use global variables.
declare p2 as global.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by