How to let a script use a variable from the workspace.
Mostra commenti meno recenti
Hello, I've written a code which gives a color based on a certain frequency input. Now how do I get this code to take the frequency input from the workspace rather than having to insert it into the code itself all the time. The code works like this but you can see in the first line that i have to give a frequency input within the code for it to work. MyImshow is a function that shows the image.
freq = 470;
% Load the image
X = imread('Solid_white.png');
R = uint8(zeros(size(X)));
R(:,:,1) = X(:,:,1);
G = uint8(zeros(size(X)));
G(:,:,2) = X(:,:,2);
B = uint8(zeros(size(X)));
B(:,:,3) = X(:,:,3);
Y = uint8(zeros(size(X)));
Y(:,:,1:2) = X(:,:,1:2);
P = uint8(zeros(size(X)));
P(:,:,1:2:3) = X(:,:,1:2:3);
T = uint8(zeros(size(X)));
T(:,:,2:3) = X(:,:,2:3);
% Show components
if (0 <= freq) && (freq <= 100)
myimshow(R)
figure(2)
elseif (100 <= freq) && (freq <= 200)
figure(3)
myimshow(G)
elseif (200 <= freq) && (freq <= 300)
figure(4)
myimshow(B)
elseif (300 <= freq) && (freq <= 400)
figure(5)
myimshow(Y)
elseif (200 <= freq) && (freq <= 500)
figure(6)
myimshow(P)
elseif (200 <= freq) && (freq <= 600)
Figure(7)
myimshow(T)
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Images in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!