how to divide three element array string and assign independent variable matlab?
显示 更早的评论
hello recently I have a network analyzer equipment and I have connected it to be able to make an application in matlab, currently I have a problem when I request the values of the frequency marker that I assign in the equipment it returns a three-element string vector, I want to separate each element and assign it an independent variable to be able to manipulate that data.
fprintf(obj1,'MARKOFF');
fprintf(obj1,'MARKUNCO');
pause(5);
fprintf(obj1,'MARKDISC');
%%fprintf(obj1, "MARK1;1.5 GHZ" );
fprintf(obj1, "MARK1;" );
fprintf(obj1, "SEAMAX;" );
fprintf(obj1, "OUTPMARK;" );
%data2=scanstr(obj1,'%f');
%disp(data2);
%mkr =fscanf(obj1,'%s');
%disp(mkr);
data2=scanstr(obj1);
disp(data2);
the output display is :
[ -0.4198]
[3.9630e+18]
[ 323687500]
4 个评论
John D'Errico
2020-3-20
There is a simple way to do exactly what you want.
data2(1)
data2(2)
data2(3)
As you see, you can simply access any element of that vector. Creating new variables on the fly is a really bad idea though.
Gerbin Gaytan Rivera
2020-3-20
John D'Errico
2020-3-20
Yes, but that is c, not MATLAB. Do you really expect that what makes sense in one language will apply in another? By your logic, merely by my understanding English, I should also be able to speak and write flawless Chinese, French, Latin and Farsi, not to mention any of hundreds of other languages.
Gerbin Gaytan Rivera
2020-3-20
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!