How to name and save multiple variable files in .png format.
Show older comments
I have the following code, which imports data from a .txt file and converts it into variables. Currently, I am naming these variables based on angles P and N and visualizing them using the 'image' command. If I wish to save all of this information, what steps should I take?
function required for the below code are attached with the question.
.txt files are too large to attach, please use any of your chice to show me this use case.
Any help is much appreciated, regards
clc;
clear;
close all;
% Import the data
AngleN2N4 = importfile();
AngleP2N4 = importfile();
AngleP2P4 = importfile();
AngleN2P4 = importfile();
TAngle42 = AngleN2P4 + AngleP2P4 + AngleN2N4 + AngleP2N4;
figure(1)
image1 = image(TAngle42,'CDataMapping','scaled');
title('X = +/-2 and Y = +/-4');
colorbar;
% colormap("winter")
AngleN2N5 = importfile();
AngleP2N5 = importfile();
AngleP2P5 = importfile();
AngleN2P5 = importfile();
TAngle52 = AngleN2P5 + AngleP2P5 + AngleN2N5 + AngleP2N5;
figure(2)
image2 = image(TAngle52,'CDataMapping','scaled');
title('X = +/-2 and Y = +/-5');
colorbar;
diff = TAngle52 - TAngle42;
figure(3)
image3 = image(diff,'CDataMapping','scaled');
for k = 1:5
for m = 2
for n = [4,5]
figure(k)
image('AngleN%dP%d',m, n,'CDataMapping','scaled')
title('X = +/-m and Y = +/-n');
colorbar;
image('AngleP%dN%d',m, n,'CDataMapping','scaled')
title('X = +/-m and Y = +/-n');
colorbar;
end
end
end
1 Comment
"Currently, I am naming these variables based on angles P and N ..."
And that is the problem right there.
"If I wish to save all of this information, what steps should I take?"
Do not use meta-data in variable names (unless you want to force yourself into writing slow, complex, inefficient, obfuscated code).
Learn to use arrays and indexing. Then your task is easy.
Accepted Answer
More Answers (0)
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!