How to plot plot from differnet location in a single figure?

%% I have differnt date from differnt folder in differnt location, as D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_dd/taudrag.mat having data T(1*25) %%and output (3*25*) and in another folder in another location D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_nn/taudrag.mat again have T(1*25) %%and output (2*25). I wants to plot one figure where i wants figure with respect to T(1*25) and output(5*25).
%% please tell me how could i do this.

Respuestas (1)

TADA
TADA el 25 de Jun. de 2019
If i understand your question corectly, and you have several .mat files each one with a varriable T and a varriable output,
you can load them like that:
data(1) = load('D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_dd/taudrag.mat');
data(2) = load('D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_nn/taudrag.mat');
that syntax returns a struct with fields for each varriable saved in that .mat file.
that would only work if you have the exact same varriable names saved in both files, otherwise you can simply load them into two different varriables
for i = 1:numel(data)
dataStruct = data(i);
plot(dataStruct.T, dataStruct.output);
hold on;
end

6 comentarios

Thanks for this, it is helpful for me.
Cheers You're welcome
%% How can I give legend here, as D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_dd/taudrag.mat
%% have output for d (1*3) for n=5 and D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_nn/taudrag.mat
%% have output for d (1*3) for n=10
TADA
TADA el 28 de Jun. de 2019
Editada: TADA el 28 de Jun. de 2019
I would try to make a shorter legend name which is easier to read, but probably the easiest way would be add the file paths to a cell array and send that to legend function:
legendEntries = {};
data(1) = load('D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_dd/taudrag.mat');
legendEntries{1} = 'D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_dd/taudrag.mat';
data(2) = load('D:/pendrive/coulomb_drag/Temperature/matlab_program/drag_Copy_nn/taudrag.mat');
legendEntries{2} = ... % and so on
Then you can simply send it to legend:
legend(legendEntries);
If you load your files in a loop, you can just as easily do the same thing and add the path to the legendEntries cell array, or use the original list of file paths you are using
%%It is not a good answer, as these command give same results as i use command
legend('a','b')
True.
I don't know the specifics of your particular problem.
Without more details, that's the best I can offer at the moment

La pregunta está cerrada.

Etiquetas

Preguntada:

el 25 de Jun. de 2019

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by