I want to plot mat file with command s=load('signal.mat'); plot(s) but there is error in that command how to plot the signal

댓글 수: 4

madhan ravi
madhan ravi 2018년 8월 20일
Upload .mat file
sandhya sandhya
sandhya sandhya 2018년 8월 20일
Thank you for reply . I uploaded mat file .please give me any other command.
madhan ravi
madhan ravi 2018년 8월 20일
편집: madhan ravi 2018년 8월 20일
FYI there is no file attached , please click the paper clip button and then upload it.
sandhya sandhya
sandhya sandhya 2018년 8월 20일
Thank you for reply .I attached my file

댓글을 달려면 로그인하십시오.

 채택된 답변

Stephan
Stephan 2018년 8월 20일
편집: Stephan 2018년 8월 20일

1 개 추천

Hi,
s = load('signal.mat');
will give you a struct s containing fields with your variable(s) in it. Access this data fields with the dot-Notation:
plot(s.your_variable_name_to_plot)
should work.
EDIT:
Your file contains a numeric Matrix of size 10x20480 which appears like 10 data sets - which shall be plotted?
s = load('signal.mat');
plot(transpose(s.val))
will plot all the data in one plot:
Best regards
Stephan

댓글 수: 6

sandhya sandhya
sandhya sandhya 2018년 8월 20일
편집: sandhya sandhya 2018년 8월 20일
Thank you for reply plot(s.your_variable_name_to_plot),please explain in detail . my variable is 's' here and i tried to plot with commands s=load('s2.mat'); plot(s) but its not working .please give me another command.
Stephan
Stephan 2018년 8월 20일
편집: Stephan 2018년 8월 20일
If you load a mat-file this way you will see, that s is a variable of the type struct . A struct is like a container for variables and it contains fields in which the values are saved. See this example:
s = load('DataForForumQuestion.mat')
s =
struct with fields:
XData1: [8688×1 double]
XData2: [8832×1 double]
YData1: [8688×1 double]
YData2: [8832×1 double]
In this case here are 4 variables in 4 fields of the struct s. if i want to plot YData2 for example i have to use:
plot(s.YData2)
If you want to avoid saving the data in a struct, you should use:
load('signal.mat');
without declaring a new variable s. In this case the data will directly be loaded into workspace and can be accessed directly.
Best regards
Stephan
sandhya sandhya
sandhya sandhya 2018년 8월 20일
Thank you for reply sir
Stephan
Stephan 2018년 8월 20일
편집: Stephan 2018년 8월 20일
See my edited answer
sandhya sandhya
sandhya sandhya 2018년 8월 21일
Thank you sir its working.
sandhya sandhya
sandhya sandhya 2018년 9월 5일
편집: sandhya sandhya 2018년 9월 5일
My signal variable value is 1*2560 double and i tried this code to plot the signal s = load('test.mat'); val = (val - 1024)/200; signal = val(1,1:1000); Fs = 360; t = (0:length(signal)-1)/360; plot(t,signal ),grid on we can plot the signal with the above command lines.But can anybody explain about this code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

질문:

2018년 8월 20일

편집:

2018년 9월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by