Hi pro's,
I'm creating a MATLAB user interface to interpret and plot certain data earlier obtained by the MATLAB instrument toolbox. This data is stored in a 4x4 Cell each containing a 2x1 table with complex data inserted. I need to display the complex data in two plots. From the command window i can already do this with the following code:
function plot(S)
figure('Name', 'Patch cable');
subplot(2,1,1)
plot(S{1,1}(:,1)*1e-6, 20*log10(abs([S{1,1}(:,2) S{2,2}(:,2) S{3,3}(:,2) S{4,4}(:,2)])), 'linewidth', 2);
hold on; grid on
xlabel('Frequency [MHz]'); ylabel('Return loss [dB]');
legend('Pair 12', 'Pair 36', 'Pair 78', 'Pair 45', 'Location', 'southeast');
subplot(2,1,2)
plot(S{1,2}(:,1)*1e-6, 20*log10(abs([S{1,2}(:,2) S{1,3}(:,2) S{1,4}(:,2) S{2,3}(:,2) S{2,4}(:,2) S{3,4}(:,2)])), 'linewidth', 2);
hold on; grid on
xlabel('Frequency [MHz]'); ylabel('NEXT [dB]');
legend('Pair 12-36', 'Pair 12-78', 'Pair 12-45', 'Pair 36-78', 'Pair 36-45', 'Pair 45-78', 'Location', 'southeast');
end
When I use a MATLAB GUI I use a text edit box which returns a string with the name of the cell in the workspace. The question is how can i use this string to handle the Cell and its values as in the code shown above?
Thanks in advance for your help!
BR, Wouter

댓글 수: 3

Geoff Hayes
Geoff Hayes 2016년 7월 21일
How is the 4x4 cell related to the string in the text edit control? You mention how it is the name of the cell, but I don't understand how that would be used given the code that you have posted.
W. Hebben
W. Hebben 2016년 7월 25일
Hi Geoff,
True. However this is the original code without a gui where one of the functions inputs is the 4x4 cell. The relation to the edit text box is that i want to be able to enter a given 4x4 cell name (or other property available) in my text box and then run the code.
Geoff Hayes
Geoff Hayes 2016년 7월 25일
So how does the cell name or other property relate to the code above? Please clarify with an example.

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

답변 (1개)

Image Analyst
Image Analyst 2016년 7월 25일

0 개 추천

Get the variable name from the edit field like this
ca = handles.edit1.String;
Then you can use exist() or whos to check if that is a valid variable name, and if it is, do something. Or you can just go into a switch case statement where you check the user's entry for all valid cell array names that you know in advance exist, and then do something with that knowledge. Like
switch ca
case 'word1'
S = word1; % Assign cell array called word1 to S.
case 'someOtherName'
S = someOtherName; % Assign cell array called someOtherName to S.
case 'thingNumber3'
S = thingNumber3; % Assign cell array called thingNumber3 to S.
end
% Now we have S and can plot it
plot(S................... whatever....

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2016년 7월 20일

답변:

2016년 7월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by