显示 更早的评论
does anyone know how can a variable parameter convert to string? for example in under case, i parameter, (that, is a variable parameter) needs to be a variable string:
for i=1:10
lable=['input'''' i ''' ];
[r,'''i''']=xlsread(lable);
end
that i want to read input1 , input2,....,input10 and put them respectively r1,r2,..,r10
采纳的回答
10 个评论
thanks let me check now
i studied sprintf and eval, sorry i am beginner in Matlab, why matlab errores for :sprintf('A%d', i)=sprintf('xlsread(lableinput%d)', i)
this is for
A1=(input1.xls)
A2=(input2.xls)
.
.
.
.
.
Don't Do That!
basename = 'labelinput';
for i = 1:10
A{i} = xlsread(sprintf('%s%d.xls', basename, i));
end
Then use A{1} instead of A1, A{2} instead of A2, and so on.
What you are trying to do in making A1, A2, and so on, almost always runs in to problems.
so nice, perfect
now i need in every loop it shows : fprintf(' finished checking of input' 'i')
for example after A1=input1.xls shows:finished checking of input1
and after A2=input2.xls shows:finished checking of input2
but i dont know how putting variable (i), in fprintf
i mean this:
for i = 1:10
A{i} = xlsread(sprintf('%s%d.xls', basename, i));
fprintf(' finished checking of input' 'i')
end
and you are right Walter i dont need trying to make A1, A2
fprintf('finished checking of input %d\n', i);
so thanks Walter
you really give a lot helps
for last question:
how can put variable in this speech:
NET.addAssembly('System.Speech');
speaker = System.Speech.Synthesis.SpeechSynthesizer();
speaker.Rate = 1;
speaker.Volume = 100;
speaker.Speak(['finished checking input'''i'''']);
speaker.Speak(sprintf('finished checking input %d', i));
great, perfect!
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 String Parsing 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
